Package it.eng.spagobi.kpi.threshold.metadata

Examples of it.eng.spagobi.kpi.threshold.metadata.SbiThreshold


        Integer ds_id = kpi.getKpiDsId();
        ds = (SbiDataSetConfig) aSession.load(SbiDataSetConfig.class,
            ds_id);
      }

      SbiThreshold sbiThreshold = null;
      if (kpi.getThreshold() != null) {
        Integer thresholdId = kpi.getThreshold().getId();
        sbiThreshold = (SbiThreshold) aSession.load(SbiThreshold.class, thresholdId);
      }
View Full Code Here


          + (scaleCode != null ? scaleCode : "scaleCode null"));
      scaleName = kpiInst.getSbiMeasureUnit().getScaleNm();
      logger.debug("SbiKpiValue scaleName: "
          + (scaleName != null ? scaleName : "scaleName null"));
    }
    SbiThreshold t = kpiInst.getSbiThreshold();
    if(t!=null){

      Set ts = t.getSbiThresholdValues();
      Iterator i = ts.iterator();
      while (i.hasNext()) {
        SbiThresholdValue tls = (SbiThresholdValue) i.next();

        IThresholdValueDAO thDao=(IThresholdValueDAO)DAOFactory.getThresholdValueDAO();
View Full Code Here

   *
   * @throws EMFUserError
   */
  private void importThreshold(boolean overwrite) throws EMFUserError {
    logger.debug("IN");
    SbiThreshold exportedTh = null;
    try {
      List exportedThresholds = importer.getAllExportedSbiObjects(sessionExpDB, "SbiThreshold", null);
      Iterator iterSbiTh= exportedThresholds.iterator();
      while (iterSbiTh.hasNext()) {
        exportedTh = (SbiThreshold) iterSbiTh.next();
        Integer oldId = exportedTh.getThresholdId();
        Integer existingThId = null;
        Map thIdAss = metaAss.getTresholdIDAssociation();
        Set thIdAssSet = thIdAss.keySet();
        if (thIdAssSet.contains(oldId) && !overwrite) {
          metaLog.log("Exported threshold " + exportedTh.getCode() + " not inserted"
              + " because it has the same label of an existing threshold ");
          continue;
        } else {
          existingThId = (Integer) thIdAss.get(oldId);
        }
        if (existingThId != null) {
          logger.info("The threshold with id:[" + exportedTh.getThresholdId() + "] is just present. It will be updated.");
          metaLog.log("The threshold with code = [" + exportedTh.getCode() + "] will be updated.");
          SbiThreshold existingTh = ImportUtilities.modifyExistingSbiThreshold(exportedTh, sessionCurrDB, existingThId, metaAss);
          sessionCurrDB.update(existingTh);
        } else {
          SbiThreshold newThreshold = ImportUtilities.makeNewSbiThreshold(exportedTh, sessionCurrDB, metaAss);
          sessionCurrDB.save(newThreshold);
          metaLog.log("Inserted new Threshold " + newThreshold.getCode());
          Integer newId = newThreshold.getThresholdId();
          metaAss.insertCoupleThreshold(oldId, newId);
        }
      }
    } catch (Exception e) {
      if (exportedTh != null) {
View Full Code Here

      String name = threshold.getName();
      String description = threshold.getDescription();
      String code = threshold.getCode();
      Integer thresholdTypeId = threshold.getThresholdTypeId();

      SbiThreshold sbiThreshold = (SbiThreshold) aSession.load(
          SbiThreshold.class, threshold.getId());

      SbiDomains newThresholdType = null;
      if (thresholdTypeId != null) {
        newThresholdType = (SbiDomains) aSession.load(SbiDomains.class,
            thresholdTypeId);
      }
      SbiDomains oldThrType = sbiThreshold.getThresholdType();
      if(!oldThrType.getValueCd().equalsIgnoreCase(newThresholdType.getValueCd())){
        //If the type of threshold is changed all old threshold need to be deleted
        Set set = sbiThreshold.getSbiThresholdValues();
        ArrayList thValues=new ArrayList();
        for (Iterator iterator = set.iterator(); iterator.hasNext();) {
          SbiThresholdValue sbiThValue = (SbiThresholdValue) iterator.next();
          //look up for alarms
          String hql = "from SbiAlarm a where a.sbiThresholdValue.idThresholdValue = :id";
          Query hqlQuery = aSession.createQuery(hql);
          hqlQuery.setInteger("id", sbiThValue.getIdThresholdValue());
          List <SbiAlarm> alarms = hqlQuery.list();
          if(alarms != null && !alarms.isEmpty()){
            throw new EMFUserError(EMFErrorSeverity.ERROR, 10119);
          }
          aSession.delete(sbiThValue);
          aSession.flush();
        }
      }

      sbiThreshold.setName(name);
      sbiThreshold.setDescription(description);
      sbiThreshold.setCode(code);
      sbiThreshold.setThresholdType(newThresholdType);
      updateSbiCommonInfo4Update(sbiThreshold);
      aSession.saveOrUpdate(sbiThreshold);
     
      Integer thrId = threshold.getId();
View Full Code Here

      String name = threshold.getName();
      String description = threshold.getDescription();
      String code = threshold.getCode();
      Integer thresholdTypeId = threshold.getThresholdTypeId();

      SbiThreshold sbiThreshold = new SbiThreshold();

      SbiDomains thresholdType = null;
      if (thresholdTypeId != null) {
        thresholdType = (SbiDomains) aSession.load(SbiDomains.class,
            thresholdTypeId);
      }

      sbiThreshold.setName(name);
      sbiThreshold.setDescription(description);
      sbiThreshold.setCode(code);
      sbiThreshold.setThresholdType(thresholdType);
      updateSbiCommonInfo4Insert(sbiThreshold);
      idToReturn = (Integer) aSession.save(sbiThreshold);

      tx.commit();
View Full Code Here

  public boolean deleteThreshold(Integer thresholdId) throws EMFUserError {
    Session aSession = getSession();
    Transaction tx = null;
    try {
      tx = aSession.beginTransaction();
      SbiThreshold aThreshold = (SbiThreshold) aSession.load(
          SbiThreshold.class, thresholdId);
      aSession.delete(aThreshold);

      tx.commit();
View Full Code Here

      if(fetchSize > 0) hibernateQuery.setMaxResults(fetchSize);     

      toTransform = hibernateQuery.list();     

      for (Iterator iterator = toTransform.iterator(); iterator.hasNext();) {
        SbiThreshold hibThreshold = (SbiThreshold) iterator.next();
        Threshold threshold = toThreshold(hibThreshold);
        toReturn.add(threshold);
      }

    } catch (HibernateException he) {
View Full Code Here

      if(fetchSize > 0) hibernateQuery.setMaxResults(fetchSize);     

      toTransform = hibernateQuery.list();     

      for (Iterator iterator = toTransform.iterator(); iterator.hasNext();) {
        SbiThreshold hibThreshold = (SbiThreshold) iterator.next();
        Threshold threshold = toThreshold(hibThreshold);
        toReturn.add(threshold);
      }

    } catch (HibernateException he) {
View Full Code Here

          if(kpiInst.getKpi() != null){

            SbiKpi sbiKpi =  (SbiKpi) aSession.load(SbiKpi.class, kpiInst.getKpi());           
            sbiKpiInstance.setSbiKpi(sbiKpi);
            if(kpiInst.getThresholdId() != null){
              SbiThreshold sbiThr =  (SbiThreshold) aSession.load(SbiThreshold.class, kpiInst.getThresholdId());           
              sbiKpiInstance.setSbiThreshold(sbiThr);
            }
            sbiKpiInstance.setWeight(kpiInst.getWeight());

            sbiKpiInstance.setTarget(kpiInst.getTarget());           
View Full Code Here

    Session aSession = null;
    Transaction tx = null;
    try {
      aSession = getSession();
      tx = aSession.beginTransaction();
      SbiThreshold hibThreshold = (SbiThreshold) aSession.load(
          SbiThreshold.class, id);
      toReturn = new Threshold();
      toReturn = toThreshold(hibThreshold);

    } catch (HibernateException he) {
View Full Code Here

TOP

Related Classes of it.eng.spagobi.kpi.threshold.metadata.SbiThreshold

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.