Examples of KpiInstance


Examples of it.eng.spagobi.kpi.config.bo.KpiInstance

        return;
      }

      // recover kpi instance from Id
      IKpiInstanceDAO kpiInstDAO=DAOFactory.getKpiInstanceDAO();
      KpiInstance kpiInst=kpiInstDAO.loadKpiInstanceById(kpiInstId);

      // main attributes     
      SbiKpiInstance hibKpiInst = new SbiKpiInstance();
      hibKpiInst.setIdKpiInstance(kpiInst.getKpiInstanceId());
      hibKpiInst.setBeginDt(kpiInst.getD());
      hibKpiInst.setWeight(kpiInst.getWeight());
      hibKpiInst.setTarget(kpiInst.getTarget());

      if(kpiInst.getChartTypeId()!=null){
        SbiDomains chartType=(SbiDomains)session.load(SbiDomains.class, kpiInst.getChartTypeId());     
        hibKpiInst.setChartType(chartType);
      }

      // Kpi
      if (kpiInst.getKpi()!=null) {   
        insertKpi(kpiInst.getKpi(), session);
        SbiKpi sbiKpi= (SbiKpi) session.load(SbiKpi.class, kpiInst.getKpi());
        hibKpiInst.setSbiKpi(sbiKpi);
      }

      // load threshold
      if (kpiInst.getThresholdId() != null) {
        IThresholdDAO thresholdDAO=DAOFactory.getThresholdDAO();
        Threshold th=thresholdDAO.loadThresholdById(kpiInst.getThresholdId());
        insertThreshold(th, session);
        SbiThreshold sbiTh= (SbiThreshold) session.load(SbiThreshold.class, th.getId());
        hibKpiInst.setSbiThreshold(sbiTh);
      }

      // load measureUnit!
      if(kpiInst.getScaleCode()!=null){
        IMeasureUnitDAO muDao=DAOFactory.getMeasureUnitDAO();
        MeasureUnit mu=muDao.loadMeasureUnitByCd(kpiInst.getScaleCode());
        insertMeasureUnit(mu, session);
        SbiMeasureUnit sbiMu= (SbiMeasureUnit) session.load(SbiMeasureUnit.class, mu.getId());
        hibKpiInst.setSbiMeasureUnit(sbiMu);
      }

      // Insert KPI Instance

      Transaction tx = session.beginTransaction();
      session.save(hibKpiInst);
      tx.commit();



      // after inserted Kpi Instance insert periods   
      // load all alarms
      ISbiAlarmDAO sbiAlarmDAO=DAOFactory.getAlarmDAO();
      List<Alarm> alarmsToLoad=sbiAlarmDAO.loadAllByKpiInstId(kpiInstId);
      for (Iterator iterator = alarmsToLoad.iterator(); iterator.hasNext();) {
        Alarm alarm = (Alarm) iterator.next();
        insertAlarm(alarm, session);       

      }


      // after inserted Kpi Instance insert periods
      // Load all the kpi inst period and the periodicity s well
      IKpiInstPeriodDAO kpiInstPeriodDao=DAOFactory.getKpiInstPeriodDAO();     
      List kpiInstPeriodList=kpiInstPeriodDao.loadKpiInstPeriodId(kpiInst.getKpiInstanceId());
      for (Iterator iterator = kpiInstPeriodList.iterator(); iterator.hasNext();) {
        KpiInstPeriod modKpiInst = (KpiInstPeriod) iterator.next();
        insertKpiInstancePeriod(modKpiInst, session);
      }
View Full Code Here

Examples of it.eng.spagobi.kpi.config.bo.KpiInstance

     
      //if no kpi instance --> fill data with kpi properties           
      //else with kpi instance properties
      if(res.getKpiInstance() != null){
        result.put(KPI_INST_ID, res.getKpiInstance().getKpiInstanceId() );
        KpiInstance kpiInst = DAOFactory.getKpiInstanceDAO().loadKpiInstanceById(res.getKpiInstance().getKpiInstanceId());

        if(kpiInst != null){
          result.put(KPI_ID, kpiInst.getKpi());
          if(kpiInst.getKpi() != null){
            Kpi kpi = DAOFactory.getKpiDAO().loadKpiById(kpiInst.getKpi());
            result.put(KPI_NAME, kpi.getKpiName());
            result.put(KPI_CODE, kpi.getCode());
          }
          result.put(KPI_INST_CHART, kpiInst.getChartTypeId());
          result.put(KPI_INST_PERIODICITY, kpiInst.getPeriodicityId());
          result.put(KPI_INST_TARGET, kpiInst.getTarget());
          result.put(KPI_INST_THR_ID, kpiInst.getThresholdId());
          if(kpiInst.getThresholdId() != null){
            Threshold thr = DAOFactory.getThresholdDAO().loadThresholdById(kpiInst.getThresholdId());
            result.put(KPI_INST_THR_NAME, thr.getName());
          }
          result.put(KPI_INST_WEIGHT, kpiInst.getWeight());
          result.put(KPI_INST_SAVE_HISTORY, kpiInst.isSaveKpiHistory());

        }
      }
      result.put(NAME, res.getName() );
      String text = res.getName() ;
View Full Code Here

Examples of it.eng.spagobi.kpi.config.bo.KpiInstance

    Double kpiVal = null;
    if (val != null) {
      kpiVal = new Double(val);
    }
    if (kpiVal != null) {
      KpiInstance kInst = null;
      Session aSession = null;
      Transaction tx = null;

      try {
        aSession = getSession();
View Full Code Here

Examples of it.eng.spagobi.kpi.config.bo.KpiInstance

    modelInstNode.setLabel(java.util.UUID.randomUUID().toString());

    Integer kpiId = model.getKpiId();
    if(kpiId != null){
      Kpi kpi = DAOFactory.getKpiDAO().loadKpiById(kpiId);
      KpiInstance kpiInst = new KpiInstance();
      kpiInst.setKpi(kpiId);
      Threshold thrSrc = kpi.getThreshold();
      if(thrSrc != null){
        kpiInst.setThresholdId(thrSrc.getId());
      }
      kpiInst.setWeight(kpi.getStandardWeight());
      modelInstNode.setKpiInstance(kpiInst);
    }

    return modelInstNode;
View Full Code Here

Examples of it.eng.spagobi.kpi.config.bo.KpiInstance

          kpiInIDStr = obj.getString("kpiInstId");
        }catch(Throwable t){
          kpiInIDStr = null;

        }
        KpiInstance kpiInstance = null;
        if(kpiInIDStr != null){
          //existing kpi instance means model instance exists
          kpiInstance = kpiInstDao.loadKpiInstanceById(obj.getInt("kpiInstId"));

        }else{
          //new kpi instance
          if(kpiIdStr != null){
            if(obj.get("kpiId")!= null && !obj.getString("kpiId").equalsIgnoreCase("")){
              kpiInstance = new KpiInstance();
              int idd = obj.getInt("kpiId");
              kpiInstDao.setKpiInstanceFromKPI(kpiInstance, idd);
            }
          } 
        }
        String kpiInstPeriodicity;
        try{
          kpiInstPeriodicity = obj.getString("kpiInstPeriodicity");
          kpiInstance.setPeriodicityId(Integer.valueOf(kpiInstPeriodicity));
        }catch(Throwable t){
          kpiInstPeriodicity = null;
          if(kpiInstance != nullkpiInstance.setPeriodicityId(null);
        }


        String kpiInstChartTypeId;
        try{
          kpiInstChartTypeId = obj.getString("kpiInstChartTypeId");
          kpiInstance.setChartTypeId(Integer.valueOf(kpiInstChartTypeId));
        }catch(Throwable t){
          kpiInstChartTypeId = null;
          if(kpiInstance != null) kpiInstance.setChartTypeId(null);
        }

        String kpiInstTarget;
        try{
          kpiInstTarget = obj.getString("kpiInstTarget");
          kpiInstance.setTarget(Double.valueOf(kpiInstTarget));
        }catch(Throwable t){
          kpiInstTarget = null;
          if(kpiInstance != null) kpiInstance.setTarget(null);
        }


        String kpiInstThrCode;
        try{
          kpiInstThrCode = obj.getString("kpiInstThrName");
          Threshold thr = DAOFactory.getThresholdDAO().loadThresholdByCode(kpiInstThrCode);
          if(thr != null){
            kpiInstance.setThresholdId(thr.getId());
          }
        }catch(Throwable t){
          kpiInstThrCode = null;
          if(kpiInstance != null) kpiInstance.setThresholdId(null);
        }

        String kpiInstWeight;
        try{
          kpiInstWeight = obj.getString("kpiInstWeight");
          kpiInstance.setWeight(Double.valueOf(kpiInstWeight));
        }catch(Throwable t){
          kpiInstWeight = null;
          if(kpiInstance != null)
            kpiInstance.setWeight(null);
        }
        String saveHistory;
        try{
          saveHistory = obj.getString("kpiInstSaveHistory");
          kpiInstance.setSaveKpiHistory(true);
        }catch(Throwable t){
          if(kpiInstance != null)
            kpiInstance.setSaveKpiHistory(false);

        }

        modelInst.setKpiInstance(kpiInstance);
View Full Code Here

Examples of it.eng.spagobi.kpi.config.bo.KpiInstance

        modelNodeL=new SourceBean(modelNodeLineS);
       
        modelNodeL.setAttribute("code",line.getModelInstanceCode()!=null?line.getModelInstanceCode():"");
        modelNodeL.setAttribute("name",line.getModelNodeName()!=null?line.getModelNodeName():"");
       
        KpiInstance k = null;
        if (line.getModelInstanceNodeId()!=null){
          Integer id = new Integer(line.getModelInstanceNodeId());
          Date d = new Date();
          IModelInstanceDAO modInstDAO=DAOFactory.getModelInstanceDAO();
          ModelInstanceNode n = modInstDAO.loadModelInstanceById(id, d);
View Full Code Here

Examples of it.eng.spagobi.kpi.config.bo.KpiInstance

  static private Logger logger = Logger.getLogger(KpiInstanceDAOImpl.class);

 
  public KpiInstance loadKpiInstanceById(Integer id) throws EMFUserError {
    logger.debug("IN");
    KpiInstance toReturn = null;
    Session aSession = null;
    Transaction tx = null;

    try {
      aSession = getSession();
View Full Code Here

Examples of it.eng.spagobi.kpi.config.bo.KpiInstance

  }

  public KpiInstance loadKpiInstanceByIdFromHistory(Integer id, Date d)
  throws EMFUserError {
    logger.debug("IN");
    KpiInstance toReturn = null;
    Session aSession = null;
    Transaction tx = null;

    try {
      aSession = getSession();
View Full Code Here

Examples of it.eng.spagobi.kpi.config.bo.KpiInstance

 
  public KpiInstance toKpiInstance(SbiKpiInstance kpiInst)
  throws EMFUserError {

    logger.debug("IN");
    KpiInstance toReturn = new KpiInstance();
    Integer kpiId = kpiInst.getIdKpiInstance();
    SbiKpi kpi = kpiInst.getSbiKpi();
    Integer k = kpi.getKpiId();
    Date d = new Date();
    d = kpiInst.getBeginDt();
    Integer thresholdId = null;
    if(kpiInst.getSbiThreshold()!=null){
      thresholdId = kpiInst.getSbiThreshold().getThresholdId();
    }
    Double weight = kpiInst.getWeight();
    Double target = kpiInst.getTarget();
    Integer idPeriodicity = null;
    Set periods = kpiInst.getSbiKpiInstPeriods();
    if (periods != null && !periods.isEmpty()) {
      Iterator s = periods.iterator();
      while (s.hasNext()) {
        SbiKpiInstPeriod p = (SbiKpiInstPeriod) s.next();
        if (p.isDefault_()!=null && p.isDefault_().booleanValue()==true) {
          SbiKpiPeriodicity periodicity = p.getSbiKpiPeriodicity();
          if (periodicity != null) {
            idPeriodicity = periodicity.getIdKpiPeriodicity();
          }
        }
      }
    }

    SbiMeasureUnit unit = kpiInst.getSbiMeasureUnit();
    String scaleCode = null;
    String scaleName = null;
    if (unit != null) {
      scaleCode = unit.getScaleCd();
      scaleName = unit.getScaleNm();
    }

    toReturn.setWeight(weight);
    logger.debug("KpiInstance weight setted");
    toReturn.setTarget(target);
    logger.debug("KpiInstance target setted");
    toReturn.setKpiInstanceId(kpiId);
    logger.debug("KpiInstance Id setted");
    toReturn.setKpi(k);
    logger.debug("KpiInstance kpi setted");
    toReturn.setThresholdId(thresholdId);
    logger.debug("KpiInstance thresholdId setted");
    toReturn.setD(d);
    logger.debug("KpiInstance date setted");
    toReturn.setPeriodicityId(idPeriodicity);
    logger.debug("KpiInstance periodicity ID setted");
    toReturn.setScaleCode(scaleCode);
    logger.debug("Kpi value scale Code setted");
    toReturn.setScaleName(scaleName);
    logger.debug("Kpi value scale Name setted");
   
    if(kpiInst.getChartType()!=null){
      toReturn.setChartTypeId(kpiInst.getChartType().getValueId());
    }

    logger.debug("OUT");
    return toReturn;
  }
View Full Code Here

Examples of it.eng.spagobi.kpi.config.bo.KpiInstance

      Integer id =  getAttributeAsInteger(ID);
      try {
        if(id != null){
          IThresholdValueDAO tresholdDao = DAOFactory.getThresholdValueDAO();
          IKpiInstanceDAO kpiDao = DAOFactory.getKpiInstanceDAO();
          KpiInstance k = kpiDao.loadKpiInstanceById(id);
          if(k!=null){
            List<ThresholdValue> tresholds = tresholdDao.loadThresholdValuesByThresholdId(k.getThresholdId());
            logger.debug("Threshold values loaded");
            JSONArray trshJSON = (JSONArray) SerializerFactory.getSerializer("application/json").serialize(tresholds,locale);
            JSONObject trashResponseJSON = createJSONResponseThresholds(trshJSON);
   
            writeBackToClient(new JSONSuccess(trashResponseJSON));
View Full Code Here
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.