Package it.eng.spagobi.kpi.alarm.metadata

Examples of it.eng.spagobi.kpi.alarm.metadata.SbiAlarm


 
      toReturn = (List<SbiAlarm>)hibernateQuery.list()
      if(toReturn!=null && !toReturn.isEmpty()){
        Iterator it = toReturn.iterator();
        while(it.hasNext()){
          SbiAlarm alarm = (SbiAlarm)it.next();
          Hibernate.initialize(alarm);
          Hibernate.initialize(alarm.getModality());
          Hibernate.initialize(alarm.getSbiAlarmContacts());
          Iterator it2 = alarm.getSbiAlarmContacts().iterator();
          while(it2.hasNext()){
            Hibernate.initialize(it2.next());
          }
        }
      }
View Full Code Here


      String url = getAttributeAsString(URL);
      Integer kpiInstId = getAttributeAsInteger(KPI);
      Integer thresholdId = getAttributeAsInteger(THRESHOLD);
      JSONArray contactsJSON = getAttributeAsJSONArray(CONTACTS);

      SbiAlarm alarm = new SbiAlarm();
      alarm.setAutoDisabled(autoDisabled);
      alarm.setDescr(descr);     
      alarm.setLabel(label);
      alarm.setName(name);
      alarm.setSingleEvent(singleEvent);
      alarm.setText(text);
      alarm.setUrl(url)

      try {
      if(modality!=null){
        SbiDomains dModality = DAOFactory.getDomainDAO().loadSbiDomainByCodeAndValue(DOMAIN_CD, modality);
       
        alarm.setModality(dModality);
      }
      if(kpiInstId != null){
        SbiKpiInstance sbiKpiInstance = DAOFactory.getKpiInstanceDAO().loadSbiKpiInstanceById(kpiInstId);
        alarm.setSbiKpiInstance(sbiKpiInstance);
      }
      if(thresholdId != null){
        SbiThresholdValue sbiThresholdValue = DAOFactory.getThresholdValueDAO().loadSbiThresholdValueById(thresholdId);
        alarm.setSbiThresholdValue(sbiThresholdValue);
      }
     
      if(id != null && !id.equals("") && !id.equals("0")){ 
        alarm.setId(Integer.valueOf(id));
      }
     
        Set<SbiAlarmContact> contactsList = null;
        if(contactsJSON != null){
          contactsList = deserializeContactsJSONArray(contactsJSON);
          alarm.setSbiAlarmContacts(contactsList);
        }
        Integer idToReturn = alarmDao.update(alarm);
        logger.debug("Alarm updated or Inserted");
       
        JSONObject attributesResponseSuccessJSON = new JSONObject();
View Full Code Here

  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);
        }
    }
   
View Full Code Here

                                            if(logger.isDebugEnabled())
                                            logger.debug("Found contact '"+sbiAlarmContact.getName()+"'.");
   
    List<AlertSendingItem> alertSendingList = alertSendingSessionMap.get(sbiAlarmContact);
   
    SbiAlarm sbiAlarm = null;
    SbiAlarmEvent sbiAlarmEvent = null;
   
    StringBuffer subject = new StringBuffer();
    StringBuffer text = new StringBuffer();
    for(AlertSendingItem alertSendingItem : alertSendingList)
    {
        sbiAlarm = alertSendingItem.getSbiAlarm();
        sbiAlarmEvent = alertSendingItem.getSbiAlarmEvent();
       
                                            if(logger.isDebugEnabled())
                                            logger.debug("Found alarm "+sbiAlarm.getName()+".");       
                   
                    subject.append(sbiAlarm.getLabel());
                   
        text.append("<font size=\"4\">Allarme </font><font color=\"red\" size=\"4\"><b>");
        text.append(sbiAlarm.getName());
        text.append("</b></font><ul>");
       
                    text.append("<li><font size=\"2\">Lable: ");
                    text.append(sbiAlarm.getLabel());
                    text.append("</font></li>");
                    text.append("<li><font size=\"2\">Text: ");
                    text.append(sbiAlarm.getText());
                    text.append("</font></li>");
                    text.append("<li><font size=\"2\">Description: ");
                    text.append(sbiAlarm.getDescr());
                    text.append("</font></li>");
        text.append("</ul><br>");
        text.append("<font size=\"3\">Dettaglio KPI:</font><ul>");
        text.append("<li><font size=\"2\">Name: ");
        text.append(sbiAlarmEvent.getKpiName());
                    text.append("</font></li>");
        text.append("<li><font size=\"2\">Date: ");
        text.append(sbiAlarmEvent.getEventTs());
                    text.append("</font></li>");
                    text.append("<li><font size=\"2\">Value: ");
                    text.append(sbiAlarmEvent.getKpiValue());
                    text.append("</font></li>");
                    text.append("<li><font size=\"2\">Threshold: ");
                    text.append(sbiAlarmEvent.getThresholdValue());
                    text.append("</font></li>");
       
        String res = sbiAlarmEvent.getResources();
        if(res!=null){
                        text.append("<li><font size=\"2\">resources:");
                        text.append(res);
                        text.append("</font></li>");
        }
       
        text.append("</ul><hr width=\"90%\">");
    }
   
    String link = sbiAlarm.getUrl();
   
    text.append(link);
   
    String email = sbiAlarmContact.getEmail();
    if(email!=null){
View Full Code Here

    if( !(o instanceof SbiAlarm) ) {
      throw new SerializationException("AlarmJSONSerializer is unable to serialize object of type: " + o.getClass().getName());
    }
   
    try {
      SbiAlarm sbiAlarm = (SbiAlarm)o;
      result = new JSONObject();
      result.put(ID, sbiAlarm.getId());
      result.put(NAME, sbiAlarm.getName());
      result.put(LABEL, sbiAlarm.getLabel());     
      result.put(SINGLE_EVENT, sbiAlarm.isSingleEvent());
      result.put(AUTO_DISABLED, sbiAlarm.getAutoDisabled());
      result.put(DESCRIPTION, sbiAlarm.getDescr())
      result.put(TEXT, sbiAlarm.getText())
      result.put(URL, sbiAlarm.getUrl())
      if(sbiAlarm.getSbiKpiInstance() != null){
        result.put(KPI, sbiAlarm.getSbiKpiInstance().getIdKpiInstance())
      }
      if(sbiAlarm.getSbiThresholdValue() != null){
        result.put(THRESHOLD, sbiAlarm.getSbiThresholdValue().getIdThresholdValue())
      }
      SbiDomains modalityDomain = sbiAlarm.getModality();
      if(modalityDomain != null)
        result.put(MODALITY, modalityDomain.getValueCd());
      else
        result.put(MODALITY, "");
     
      //contacts
      List<SbiAlarmContact> allContacts = DAOFactory.getAlarmContactDAO().findAll();
      Iterator itAllContacts = allContacts.iterator();
     
      Set<SbiAlarmContact> alarmContacts = sbiAlarm.getSbiAlarmContacts();     
      JSONArray contactsJSON = new JSONArray();
     
      while(itAllContacts.hasNext()){
        JSONObject jsonContact = new JSONObject();
        SbiAlarmContact contact = (SbiAlarmContact)itAllContacts.next();
View Full Code Here

TOP

Related Classes of it.eng.spagobi.kpi.alarm.metadata.SbiAlarm

Copyright © 2018 www.massapicom. 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.