public void execute(JobExecutionContext jex) throws JobExecutionException
{
logger.debug("IN");
org.hibernate.Session hsession = null;
List<SbiAlarmEvent> activeSbiAlarmEventList = null;
SbiAlarm sbiAlarm = null;
try
{
hsession = HibernateUtil.currentSession();
activeSbiAlarmEventList = sae.findActive(hsession);
for(SbiAlarmEvent sbiAlarmEvent : activeSbiAlarmEventList)
{
if(logger.isInfoEnabled())
logger.info("Found AlarmEvent: "+sbiAlarmEvent.getKpiName());
sbiAlarm = sbiAlarmEvent.getSbiAlarms();
String resource = sbiAlarmEvent.getResources();
//creo un item e gli imposto l'evento e l'allarme
alertSendingItem = new AlertSendingItem(sbiAlarm,sbiAlarmEvent);
if(logger.isDebugEnabled())
logger.debug("Created AlertSendingItem: "+alertSendingItem);
List<SbiAlarmContact> sbiAlarmContactList = new ArrayList<SbiAlarmContact>();
List<SbiAlarmContact> associatedContactList = new ArrayList<SbiAlarmContact>(sbiAlarm.getSbiAlarmContacts());
if(resource!=null){
if(logger.isDebugEnabled())
logger.debug("Resource enhanced: "+resource);
for(SbiAlarmContact associatedContact : associatedContactList){
if(resource.equals(associatedContact.getResources()) || associatedContact.getResources()==null){
sbiAlarmContactList.add(associatedContact);
if(logger.isDebugEnabled())
logger.debug("Contact '"+associatedContact+"' added.");
}
}
}else{
if(logger.isDebugEnabled())
logger.debug("Resource not enhanced.");
for(SbiAlarmContact associatedContact : associatedContactList){
if(associatedContact.getResources()==null){
sbiAlarmContactList.add(associatedContact);
if(logger.isDebugEnabled())
logger.debug("Contact '"+associatedContact+"' added.");
}
}
}
if(logger.isDebugEnabled())
logger.debug("Distribution list: "+sbiAlarmContactList+"\n");
for(SbiAlarmContact sbiAlarmContact : sbiAlarmContactList)
{
alertSendingSessionList = alertSendingSessionMap.get(sbiAlarmContact);
if(alertSendingSessionList==null){
if(logger.isDebugEnabled())
logger.debug("alertSendingSessionList null");
alertSendingSessionList = new ArrayList<AlertSendingItem>();
}
alertSendingSessionList.add(alertSendingItem);
if(logger.isDebugEnabled())
logger.debug("Contact '"+sbiAlarmContact.getName()+"' added to alertSendingSessionList.");
alertSendingSessionMap.put(sbiAlarmContact, alertSendingSessionList);
}
//Se l'event � autodisabilitante
if(sbiAlarm.isAutoDisabled()){
//if(sbiAlarm.isSingleEvent()){
if(logger.isDebugEnabled())
logger.debug("Single alarm '"+sbiAlarm.getLabel()+"' disabled.");
sbiAlarmEvent.setActive(false);
sae.update(sbiAlarmEvent);
}
}