Package com.evasion.client.secure

Source Code of com.evasion.client.secure.EventCtrl

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

import com.evasion.common.Utils;
import com.evasion.ejb.local.BookTravelManagerLocal;
import com.evasion.ejb.local.EventHandlerLocal;
import com.evasion.entity.booktravel.BookTravel;
import com.evasion.entity.booktravel.RoadMap;
import com.evasion.entity.booktravel.exception.BookTravelServiceException;
import com.evasion.entity.event.EventData;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
*
* @author sebastien
*/
@ManagedBean
@RequestScoped
public class EventCtrl implements Serializable {

    /***
     * serialVersionUID.
     */
    private static final long serialVersionUID = 1L;
    /**
     * LOGGER.
     */
    private static final Logger LOGGER = LoggerFactory.getLogger(
            EventCtrl.class);
    private Date since;
    @EJB
    private EventHandlerLocal eventEJB;
    @EJB
    private BookTravelManagerLocal bookEJB;
private Map eventMap = new HashMap();

    @PostConstruct
    private void init() {
        since = (Date) Utils.getSessionAttribut("lastLogin");
        initPluginTravelEvent();
    }

    private void initPluginTravelEvent() {
        Map<RoadMap, List<EventData>> roadMapEvent = new HashMap<RoadMap, List<EventData>>();
        List<EventData> events = eventEJB.getEventforPluginSince(since, null, "Plugin-Travel");
        for (EventData eventData : events) {
            if (eventData.getEntityName().equals(RoadMap.class.getSimpleName())) {
                try {
                    RoadMap roadMap = bookEJB.findRoadMapById(new Long(eventData.getEntityId()));
                    List listValue;
                    if (roadMapEvent.containsKey(roadMap)) {
                        listValue = roadMapEvent.get(roadMap);
                        listValue.add(eventData);
                    } else {
                        listValue = new ArrayList();
                        listValue.add(eventData);
                        roadMapEvent.put(roadMap, listValue);
                    }
                }
                catch (BookTravelServiceException ex) {
                    LOGGER.error("Erreur de récupération du bookTravel id " + eventData.getEntityId(), ex);
                }
            }
            eventMap.putAll(roadMapEvent);
        }

    }

    public Date getSince() {
        return since;
    }

    public Map getEventMap() {
        return eventMap;
    }

   
}
TOP

Related Classes of com.evasion.client.secure.EventCtrl

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.