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.entity.booktravel.RoadMap;
import com.evasion.entity.booktravel.exception.BookTravelServiceException;
import com.evasion.exception.EvasionException;
import com.evasion.module.common.ICommonModule;
import com.evasion.module.common.entity.IEventData;
import com.evasion.module.travel.ITravelModule;
import java.io.Serializable;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
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 = Utils.getUserLastLogin();
    @EJB
    private ICommonModule eventEJB;
    @EJB
    private ITravelModule bookEJB;
private Map eventMap = new ConcurrentHashMap();

    @SuppressWarnings("PMD.UnusedPrivateMethod")
    @edu.umd.cs.findbugs.annotations.SuppressWarnings("UPM_UNCALLED_PRIVATE_METHOD")
    @PostConstruct
    private void init() {
        initPluginTravelEvent();
    }

    private void initPluginTravelEvent() {
        Map<RoadMap, List<IEventData>> roadMapEvent = new HashMap<RoadMap, List<IEventData>>();
        List<? extends IEventData> events = eventEJB.getEventforPluginSince(since, null, "Plugin-Travel");
        for (IEventData 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 (EvasionException ex) {
                    LOGGER.error("Erreur de récupération du bookTravel id " + eventData.getEntityId(), ex);
                }
            }
            if (roadMapEvent.size()>0) {
            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.