Package it.eng.spagobi.kpi.config.bo

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


      temp.put("ParKpiInstance", kpiInstanceID.toString());
      // If not, the dataset will be calculated without the parameter Resource
      // and the DataSet won't expect a parameter of type resource
      //if(dataSet.hasBehaviour( QuerableBehaviour.class.getName()) ) {
      if(dataSet!=null){
        Kpi kpi = DAOFactory.getKpiDAO().loadKpiById(kpiI.getKpi());
        //if parameter exists and OU is abilitaded for Model Instance, than calculate as dataset parameter
        String parKpiOuLabel = (String)this.parametersObject.get("ParKpiOU");
        logger.info("Got ParKpiOU: " + parKpiOuLabel);
       
        String paramLabelHierarchy = (String)this.parametersObject.get("ParKpiHierarchy");
View Full Code Here


      KpiValue value = null;
     
      line = retrieveKpiLine(line, value, kpiI, miId, r, alreadyExistent);
     
      Integer kpiId = kpiI.getKpi();
      Kpi k = DAOFactory.getKpiDAO().loadKpiById(kpiId);
      logger.debug("Retrieved the kpi with id: " + kpiId.toString());
           
      if (k != null) {
        List docs = k.getSbiKpiDocuments();

        Iterator it = docs.iterator();
        List documents = new ArrayList();
        while(it.hasNext()){
          KpiDocuments doc = (KpiDocuments)it.next();
View Full Code Here

   
    // If not, the dataset will be calculated without the parameter Resource
    // and the DataSet won't expect a parameter of type resource
    //if(dataSet.hasBehaviour( QuerableBehaviour.class.getName()) ) {
    if(dataSet!=null){
      Kpi kpi = DAOFactory.getKpiDAO().loadKpiById(kpiInst.getKpi());
     
      if(behaviour.equalsIgnoreCase("timeIntervalDefault") || behaviour.equalsIgnoreCase("timeIntervalForceRecalculation")){
        if(dateIntervalFrom!=null && dateIntervalTo!=null){
          kVal.setBeginDate(dateIntervalFrom);
          kVal.setEndDate(dateIntervalTo);
View Full Code Here

      ouLabel = ouGrant.getOuNode().getOu().getLabel();
    }
    logger.debug("kpi inst id= "+kVal.getKpiInstanceId()+" parent kpi is "+ kpiParent.getKpiName()+" and OU :"+ ouLabel);
    for(int i= 0; i< relations.size(); i++){
      KpiRel rel = relations.get(i);
      Kpi child = rel.getKpiChild();
      IDataSet chDataSet = kpiDao.getDsFromKpiId(child.getKpiId());
      HashMap chPars  = new HashMap();
      chPars.putAll(pars);
      //then the one in rel table
      String parameter = rel.getParameter();
      KpiValue kpiVal = recursiveGetKpiValueFromKpiRel(child, chDataSet, chPars, kVal, begD, endDate, modInstNodeId);
View Full Code Here

   */
  public void insertOrUpdateRelatedUdpValues(Object object, Object sbiObject, Session aSession, String family) throws EMFUserError{
    logger.debug("IN");

    SbiKpi sbiKpi = null;
    Kpi kpi = null;
    SbiKpiModel sbiKpiModel = null;
    Model modelNode = null;
    boolean isKpi = false;
    if(family.equalsIgnoreCase("KPI")){
      isKpi = true;
      sbiKpi = (SbiKpi)sbiObject;
      kpi = (Kpi)object;
      logger.debug("kpi udp attributes");
    }
    else if(family.equalsIgnoreCase("MODEL")){
      isKpi = false;
      sbiKpiModel = (SbiKpiModel)sbiObject;
      modelNode = (Model)object;
      logger.debug("model udp attributes");
    }
    else {
      logger.debug("family not recognied "+ family);
      return;
    }

    // if there are values associated
    List<UdpValue> udpValues = null;
    Integer idObject = null;
    if(isKpi){
      udpValues = kpi.getUdpValues();
      idObject = sbiKpi.getKpiId();
    }
    else{
      udpValues = modelNode.getUdpValues();     
      idObject = sbiKpiModel.getKpiModelId();
View Full Code Here

      Integer kpiTypeId = domainIds.get(kpiTypeCd);
      Integer metricScaleId = domainIds.get(metricScaleCd);
      Integer measureTypeId = domainIds.get(measureTypeCd);

      if (name != null && code != null) {
        Kpi k = new Kpi();

        try {

          k.setKpiName(name);
          k.setCode(code);

          if(description != null){
            k.setDescription(description);
          }
          if(weight != null && !weight.equalsIgnoreCase("")){
            k.setStandardWeight(Double.valueOf(weight));
         
          if(isAdditive != null && isAdditive.booleanValue()==true){
            k.setIsAdditive(new Boolean(true));
          }else{
            k.setIsAdditive(new Boolean(false));
          }
          if(dsLabel != null){
            k.setDsLabel(dsLabel);
            IDataSet ds = dsDao.loadActiveDataSetByLabel(dsLabel);

            if(ds!=null){
              int dsId = ds.getId();
              k.setKpiDsId(new Integer(dsId));
            }       
          }
          if(thresholdCode != null){
            Threshold t = thrDao.loadThresholdByCode(thresholdCode);
            k.setThreshold(t);
          }

          k.setKpiName(name);
          k.setCode(code);

          if(description != null){
            k.setDescription(description);
          }
          if(weight != null && !weight.equalsIgnoreCase("")){
            k.setStandardWeight(Double.valueOf(weight));
         
          if(dsLabel != null){
            k.setDsLabel(dsLabel);
            IDataSet ds = dsDao.loadActiveDataSetByLabel(dsLabel);

            if(ds!=null){
              int dsId = ds.getId();
              k.setKpiDsId(new Integer(dsId));
            }       
          }
          if(thresholdCode != null){
            Threshold t = thrDao.loadThresholdByCode(thresholdCode);
            k.setThreshold(t);
          }

          List docsList = null;
          if(docLabelsJSON != null){
            docsList = deserializeDocLabelsJSONArray(docLabelsJSON);
            k.setSbiKpiDocuments(docsList);
          }else if(docs!=null && !docs.equalsIgnoreCase("")){
            KpiDocuments d = new KpiDocuments();
            d.setBiObjLabel(docs);
            docsList = new ArrayList();
            docsList.add(d);
            k.setSbiKpiDocuments(docsList);
          }

          if(interpretation != null){
            k.setInterpretation(interpretation);
          }
          if(algdesc != null){
            k.setMetric(algdesc);
          }
          if(inputAttr != null){
            k.setInputAttribute(inputAttr);
          }
          if(modelReference != null){
            k.setModelReference(modelReference);
          }
          if(targetAudience != null){
            k.setTargetAudience(targetAudience);
          }
          if(kpiTypeCd != null){
            k.setKpiTypeCd(kpiTypeCd);
            k.setKpiTypeId(kpiTypeId);
          }
          if(metricScaleCd != null){
            k.setMetricScaleCd(metricScaleCd);
            k.setMetricScaleId(metricScaleId);
          }
          if(measureTypeCd != null){
            k.setMeasureTypeCd(measureTypeCd);
            k.setMeasureTypeId(measureTypeId);
          }   

          // add to Kpi Definition UDP Value list...
          //List udpValues = k.getUdpValues();
          List<UdpValue> udpValues = new ArrayList<UdpValue>()
          for(int i=0; i< udpValuesArrayJSon.length(); i++){
            JSONObject obj = (JSONObject)udpValuesArrayJSon.get(i);
            // only label and value information are retrieved by JSON object
            String label = obj.getString("name")
            String value = obj.getString("value")

            UdpValue udpValue = new UdpValue();

            // reference id is the kpi id
            Integer kpiId = k.getKpiId();

            //udpValue.setLabel(label);
            udpValue.setValue(value);
            udpValue.setReferenceId(kpiId);

            // get the UDP to get ID (otherwise could be taken in js page)
            Udp udp = DAOFactory.getUdpDAO().loadByLabelAndFamily(label, "KPI");
            Domain familyDomain = DAOFactory.getDomainDAO().loadDomainById(udp.getFamilyId());

            Integer idUdp = udp.getUdpId();

            udpValue.setLabel(udp.getLabel());
            udpValue.setName(udp.getName());
            udpValue.setFamily(familyDomain != null ? familyDomain.getValueCd() : null);
            udpValue.setUdpId(udp.getUdpId());

            udpValues.add(udpValue);
          }

          k.setUdpValues(udpValues);


          if(id != null && !id.equals("") && !id.equals("0")){             
            k.setKpiId(Integer.valueOf(id));
            kpiDao.modifyKpi(k);
            logger.debug("threshold "+id+" updated");
            JSONObject attributesResponseSuccessJSON = new JSONObject();
            attributesResponseSuccessJSON.put("success", true);
            attributesResponseSuccessJSON.put("responseText", "Operation succeded");
View Full Code Here

  private List cleanKpiListForRelation(ArrayList kpis, Integer id){
    List newList = null;
    if(kpis != null){
      newList = kpis;
      for(int i=0; i< kpis.size(); i++){
        Kpi kpi = (Kpi)kpis.get(i);
        if(kpi.getKpiId().intValue() == id.intValue()){
          //remove it
          newList.remove(kpi);
        }
      }
    }
View Full Code Here

    if (kpiInstanceID!=null){
      IKpiInstanceDAO kpiInstDAO=DAOFactory.getKpiInstanceDAO();
      KpiInstance kI = kpiInstDAO.loadKpiInstanceById(new Integer(kpiInstanceID));
      Integer kpiID = kI.getKpi();
      if (kpiID!=null){
        Kpi k = DAOFactory.getKpiDAO().loadKpiById(kpiID);
        String kpiCode = k.getCode();
        String kpiDescription = k.getDescription();
        String kpiInterpretation = k.getInterpretation();
        String kpiName = k.getKpiName();
        String thresholdName = "";
        List thresholdValues = null;
        if(kI.getThresholdId()!=null){
          thresholdValues=DAOFactory.getThresholdValueDAO().loadThresholdValuesByThresholdId(kI.getThresholdId());
          Threshold thres = DAOFactory.getThresholdDAO().loadThresholdById(kI.getThresholdId());
View Full Code Here

      if(!hibList.isEmpty()) {
        return null;
      }
      // get the Kpi BO from id
      IKpiDAO kpiDao=DAOFactory.getKpiDAO();
      Kpi kpi=kpiDao.loadKpiById(kpiId);

      // main attributes     
      hibKpi = new SbiKpi();
      hibKpi.setKpiId(kpi.getKpiId());
      hibKpi.setCode(kpi.getCode());
      hibKpi.setDescription(kpi.getDescription());
      hibKpi.setInterpretation(kpi.getInterpretation());
      hibKpi.setName(kpi.getKpiName());
      // Weight???  hibKpi.setWeight(kpi.get)
      hibKpi.setWeight(kpi.getStandardWeight());
      char isFather=kpi.getIsParent().equals(true)? 'T' : 'F';
      hibKpi.setFlgIsFather(new Character(isFather));
      hibKpi.setInterpretation(kpi.getInterpretation());
      hibKpi.setInputAttributes(kpi.getInputAttribute());
      hibKpi.setModelReference(kpi.getModelReference());
      hibKpi.setTargetAudience(kpi.getTargetAudience());
      hibKpi.setIsAdditive(kpi.getIsAdditive());

      if(kpi.getMeasureTypeId()!=null){
        SbiDomains measureType=(SbiDomains)session.load(SbiDomains.class, kpi.getMeasureTypeId());     
        hibKpi.setSbiDomainsByMeasureType(measureType);
      }
      if(kpi.getKpiTypeId()!=null){
        SbiDomains kpiType=(SbiDomains)session.load(SbiDomains.class, kpi.getKpiTypeId());     
        hibKpi.setSbiDomainsByKpiType(kpiType);
      }
      if(kpi.getMetricScaleId()!=null){
        SbiDomains metricScaleType=(SbiDomains)session.load(SbiDomains.class, kpi.getMetricScaleId());     
        hibKpi.setSbiDomainsByMetricScaleType(metricScaleType);
      }

      // load dataset
      if (kpi.getKpiDsId() != null) {   
        Integer dsID = kpi.getKpiDsId();       
        GuiGenericDataSet guiGenericDataSet = DAOFactory.getDataSetDAO().loadDataSetById(dsID);
        if(guiGenericDataSet!=null){
          insertDataSet(guiGenericDataSet, session);
          SbiDataSetConfig sbiDs= (SbiDataSetConfig) session.load(SbiDataSetConfig.class, guiGenericDataSet.getDsId());
          hibKpi.setSbiDataSet(sbiDs);
        }
      }

      // load threshold
      if (kpi.getThreshold() != null) {
        Threshold th=kpi.getThreshold();
        insertThreshold(th, session);
        SbiThreshold sbiTh= (SbiThreshold) session.load(SbiThreshold.class, th.getId());
        hibKpi.setSbiThreshold(sbiTh);
      }

      // Measure Unit   ???
      if(kpi.getScaleCode()!=null && !kpi.getScaleCode().equalsIgnoreCase("")){
        IMeasureUnitDAO muDao=DAOFactory.getMeasureUnitDAO();
        MeasureUnit mu=muDao.loadMeasureUnitByCd(kpi.getScaleCode());
        insertMeasureUnit(mu, session);
        SbiMeasureUnit sbiMu= (SbiMeasureUnit) session.load(SbiMeasureUnit.class, mu.getId());
        hibKpi.setSbiMeasureUnit(sbiMu);
      }

      Transaction tx = session.beginTransaction();
      Integer kpiIdReturned = (Integer)session.save(hibKpi);
      tx.commit();

      List kpiDocsList = kpi.getSbiKpiDocuments();
      Iterator i = kpiDocsList.iterator();
      while (i.hasNext()) {
        KpiDocuments doc = (KpiDocuments) i.next();
        String label = doc.getBiObjLabel();
View Full Code Here

      if(hibList!=null && !hibList.isEmpty()) {
        return;
      }
      // get the Kpi BO from id
      IKpiDAO kpiDao=DAOFactory.getKpiDAO();
      Kpi kpi=kpiDao.loadKpiById(kpiId);

      // main attributes     
      SbiKpi hibKpi = new SbiKpi();
      hibKpi.setKpiId(kpi.getKpiId());
      hibKpi.setCode(kpi.getCode());
      hibKpi.setDescription(kpi.getDescription());
      hibKpi.setInterpretation(kpi.getInterpretation());
      hibKpi.setName(kpi.getKpiName());
      hibKpi.setWeight(kpi.getStandardWeight());
      char isFather=kpi.getIsParent().equals(true)? 'T' : 'F';
      hibKpi.setFlgIsFather(new Character(isFather));
      hibKpi.setInterpretation(kpi.getInterpretation());
      hibKpi.setInputAttributes(kpi.getInputAttribute());
      hibKpi.setModelReference(kpi.getModelReference());
      hibKpi.setTargetAudience(kpi.getTargetAudience());
      hibKpi.setIsAdditive(kpi.getIsAdditive());

      if(kpi.getMeasureTypeId()!=null){
        SbiDomains measureType=(SbiDomains)session.load(SbiDomains.class, kpi.getMeasureTypeId());     
        hibKpi.setSbiDomainsByMeasureType(measureType);
      }
      if(kpi.getKpiTypeId()!=null){
        SbiDomains kpiType=(SbiDomains)session.load(SbiDomains.class, kpi.getKpiTypeId());     
        hibKpi.setSbiDomainsByKpiType(kpiType);
      }
      if(kpi.getMetricScaleId()!=null){
        SbiDomains metricScaleType=(SbiDomains)session.load(SbiDomains.class, kpi.getMetricScaleId());     
        hibKpi.setSbiDomainsByMetricScaleType(metricScaleType);
      }

      // load dataset
      if (kpi.getKpiDsId() != null) {   
        Integer dsID = kpi.getKpiDsId();       
        GuiGenericDataSet guiGenericDataSet = DAOFactory.getDataSetDAO().loadDataSetById(dsID);
        if(guiGenericDataSet!=null){
          insertDataSet(guiGenericDataSet, session);
          SbiDataSetConfig sbiDs= (SbiDataSetConfig) session.load(SbiDataSetConfig.class, guiGenericDataSet.getDsId());
          hibKpi.setSbiDataSet(sbiDs);
        }
      }

      // load threshold
      if (kpi.getThreshold() != null) {
        Threshold th=kpi.getThreshold();
        insertThreshold(th, session);
        SbiThreshold sbiTh= (SbiThreshold) session.load(SbiThreshold.class, th.getId());
        hibKpi.setSbiThreshold(sbiTh);
      }

      // Measure Unit   ???
      if(kpi.getScaleCode()!=null && !kpi.getScaleCode().equalsIgnoreCase("")){
        IMeasureUnitDAO muDao=DAOFactory.getMeasureUnitDAO();
        MeasureUnit mu=muDao.loadMeasureUnitByCd(kpi.getScaleCode());
        insertMeasureUnit(mu, session);
        SbiMeasureUnit sbiMu= (SbiMeasureUnit) session.load(SbiMeasureUnit.class, mu.getId());
        hibKpi.setSbiMeasureUnit(sbiMu);
      }

      Transaction tx = session.beginTransaction();
      Integer kpiIdReturned = (Integer)session.save(hibKpi);
      tx.commit();

      List kpiDocsList = kpi.getSbiKpiDocuments();
      Iterator i = kpiDocsList.iterator();
      while (i.hasNext()) {
        KpiDocuments doc = (KpiDocuments) i.next();
        String label = doc.getBiObjLabel();

        IBIObjectDAO biobjDAO = DAOFactory.getBIObjectDAO();
        BIObject biobj = biobjDAO.loadBIObjectByLabel(label);
        if(biobj!=null){
          insertBIObject(biobj, session, true);
          doc.setBiObjId(biobj.getId());       
        }

        Integer origDocId = doc.getBiObjId();
        Criterion labelCriterrion = Expression.eq("label",label);
        Criteria criteria = session.createCriteria(SbiObjects.class);
        criteria.add(labelCriterrion);
        SbiObjects hibObject = (SbiObjects) criteria.uniqueResult();

        if(hibObject!=null){
          SbiKpiDocument temp = new SbiKpiDocument();
          temp.setSbiKpi(hibKpi);
          temp.setSbiObjects(hibObject);
          KpiDocuments docK = kpiDao.loadKpiDocByKpiIdAndDocId(kpiId, origDocId);
          if(docK!=null && docK.getKpiDocId()!=null){
            temp.setIdKpiDoc(docK.getKpiDocId());
            Transaction tx2 = session.beginTransaction();
            session.save(temp);
            tx2.commit();
          }
        }
      }
      //manage insert of kpi relations
      List<KpiRel> relations = DAOFactory.getKpiDAO().loadKpiRelListByParentId(kpi.getKpiId());
      if(relations != null && !relations.isEmpty()){
        for (int j = 0; j < relations.size(); j++) {
          KpiRel kpiRel = (KpiRel)relations.get(j);
          //insert child kpi first
          insertKpi(kpiRel.getKpiChildId(), session);
View Full Code Here

TOP

Related Classes of it.eng.spagobi.kpi.config.bo.Kpi

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.