Package com.evasion.plugin.common

Source Code of com.evasion.plugin.common.EventManager

/*
* To change this template, choose Tools | Templates and open the template in
* the editor.
*/
package com.evasion.plugin.common;

import com.evasion.entity.security.User;
import com.evasion.module.common.IEventManager;
import com.evasion.module.common.entity.IEventData;
import com.evasion.plugin.common.entity.EventData;
import com.evasion.plugin.common.dao.EventDataDaoImpl;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.EntityManager;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
*
* @author sebastien.glon
*/
public class EventManager implements IEventManager, Serializable {

    /**
     * LOGGER
     */
    private static final Logger LOGGER = LoggerFactory.getLogger(
            EventManager.class);

    private final EventDataDaoImpl eventDao;

    /**
     * Constructeur pour utilisation en test.
     * @param em entity manager.
     */
    protected EventManager(EntityManager em) {
        eventDao = new EventDataDaoImpl();
        eventDao.setEntityManager(em);
    }

    /**
     * Constructeur par défaut pour l'EJB.
     */
    public EventManager() {
        eventDao = new EventDataDaoImpl();
    }

    /** {@inheritDoc } */
    @Override
    public List<? extends IEventData> getEventSince(Date date, String code) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    /**
     * {@inheritDoc }
     */
    @Override
    public List<? extends IEventData> getEventforPluginSince(Date date, String code, String plugin) {
        return eventDao.selectEventSince(date, code, plugin);
    }

    /**
     * {@link com.evasion.module.common.IEventManager.addEvent}
     */
    public void addEvent(String plugin, String entityName, String entityId, String code, String auteur) {
        if (StringUtils.isWhitespace(plugin)
                || StringUtils.isWhitespace(entityName)
                || StringUtils.isWhitespace(entityId)
                || StringUtils.isWhitespace(code)) {
            throw new IllegalArgumentException("Au moin une propriété est vide ou null");
        }
        LOGGER.debug("Ajout d'évènement.");
        EventData eventData = new EventData(entityName, entityId, code, plugin, auteur);

        eventDao.persist(eventData);
    }

    /**
     * NOT IMPLEMENTED HERE: ONLY ON EJB.
     */
    @Override
    public void addEvent(String plugin, String entityName, String entityId, String code) {
        throw new UnsupportedOperationException("Not supported yet.");
    }
}
TOP

Related Classes of com.evasion.plugin.common.EventManager

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.