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

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


      result.put(MODEL_DESCRIPTION, model.getDescription() );   
     
      //find kpi name
      if(model.getKpiId() != null){
        result.put(MODEL_KPI_ID, model.getKpiId());
        Kpi kpi = DAOFactory.getKpiDAO().loadKpiById(model.getKpiId());
        if(kpi != null){
          result.put(MODEL_KPI, kpi.getKpiName());
        }else{
          result.put(MODEL_KPI, "");
        }
        result.put(KPI_NAME, kpi.getKpiName());
        result.put(KPI_LABEL, kpi.getModelReference());
        if(kpi.getThreshold() != null){
          result.put(KPI_THRESHOLD, kpi.getThreshold().getName());
        }
        result.put(KPI_WEIGHT, kpi.getStandardWeight());
        result.put(KPI_TARGET, kpi.getTargetAudience());

     
      }
      result.put(MODEL_TYPE, model.getTypeCd() );
      result.put(MODEL_TYPE_ID, model.getTypeId() );
View Full Code Here


      result.put(MODEL_DESCRIPTION, model.getDescription() );   
     
      //find kpi name
      if(model.getKpiId() != null){
        result.put(MODEL_KPI_ID, model.getKpiId());
        Kpi kpi = DAOFactory.getKpiDAO().loadKpiById(model.getKpiId());
        if(kpi != null){
          result.put(MODEL_KPI, kpi.getKpiName());
          result.put(MODEL_KPI_CODE, kpi.getCode());
        }else{
          result.put(MODEL_KPI, "");
        }
      }
      result.put(MODEL_TYPE, model.getTypeCd() );
View Full Code Here

    if( !(o instanceof Kpi) ) {
      throw new SerializationException("KpiJSONSerializer is unable to serialize object of type: " + o.getClass().getName());
    }

    try {
      Kpi kpi = (Kpi)o;
      result = new JSONObject();

      result.put(KPI_ID, kpi.getKpiId() );
      result.put(KPI_NAME, kpi.getKpiName());
      result.put(KPI_DESCRIPTION, kpi.getDescription() );
      result.put(KPI_CODE, kpi.getCode() );
      result.put(KPI_WEIGHT, kpi.getStandardWeight() );
      boolean isAdd = false;
      if(kpi.getIsAdditive()!=null){
        isAdd = kpi.getIsAdditive().booleanValue();
      }
      result.put(IS_ADDITIVE, isAdd);
      result.put(KPI_DATASET, kpi.getDsLabel());
      if(kpi.getThreshold()!=null){
        result.put(KPI_THR, kpi.getThreshold().getCode() );
      }
      //roles
      List userDocs = kpi.getSbiKpiDocuments();
      Iterator itDocs = userDocs.iterator();
      JSONArray documentsJSON = new JSONArray();
      //documentsJSON.put("documents");

      while(itDocs.hasNext()){
        //JSONObject jsonDoc = new JSONObject();
        KpiDocuments kpiDoc = (KpiDocuments)itDocs.next();
        //jsonDoc.put("label", kpiDoc.getBiObjLabel());
        documentsJSON.put(kpiDoc.getBiObjLabel());
     
      result.put(KPI_DOCS, documentsJSON);

      // put udpValues assocated to KPI
      List udpValues = kpi.getUdpValues();
      JSONArray udpValuesJSON = new JSONArray();

      if(udpValues != null){
        Iterator itUdpValues = udpValues.iterator();
        while(itUdpValues.hasNext()){
          UdpValue udpValue = (UdpValue)itUdpValues.next();
          if(udpValue != null){
            JSONObject jsonVal = new JSONObject();
            //jsonVal.put("family", udpValue.getFamily());
            jsonVal.put("label", udpValue.getLabel());
            jsonVal.put("value", udpValue.getValue());
            jsonVal.put("family", udpValue.getFamily());
            jsonVal.put("type", udpValue.getTypeLabel());
            udpValuesJSON.put(jsonVal);
          }       
        } 
        result.put(UDP_VALUES, udpValuesJSON);
      }


      //result.put(KPI_DOCS, kpi.getDocumentLabel() );
      result.put(KPI_INTERPRETATION, kpi.getInterpretation() );
      result.put(KPI_ALGDESC, kpi.getMetric() );
      result.put(KPI_INPUT_ATTR, kpi.getInputAttribute() );
      result.put(KPI_MODEL_REFERENCE, kpi.getModelReference() );
      result.put(KPI_TARGET_AUDIENCE, kpi.getTargetAudience() );

      result.put(KPI_TYPE_ID, kpi.getKpiTypeId() );
      result.put(KPI_TYPE_CD, kpi.getKpiTypeCd());   
      result.put(METRIC_SCALE_TYPE_ID, kpi.getMetricScaleId() );
      result.put(METRIC_SCALE_TYPE_CD, kpi.getMetricScaleCd())
      result.put(MEASURE_TYPE_ID, kpi.getMeasureTypeId() );
      result.put(MEASURE_TYPE_CD, kpi.getMeasureTypeCd())

    } catch (Throwable t) {
      throw new SerializationException("An error occurred while serializing object: " + o, t);
    } finally {
View Full Code Here

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

    }else if (serviceType != null  && serviceType.equalsIgnoreCase(MODELINSTS_KPI_RESTORE)) {

      Integer kpiId = getAttributeAsInteger("kpiId");
      try {
        Kpi kpiToRestore = DAOFactory.getKpiDAO().loadKpiById(kpiId);

        logger.debug("Found kpi to restore");
        JSONObject kpiJson = (JSONObject) SerializerFactory.getSerializer("application/json").serialize(kpiToRestore,  locale);
        writeBackToClient(new JSONSuccess(kpiJson));
      } catch (Throwable e) {
View Full Code Here

    modelInstNode.setParentId(parentId);
    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

  }


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

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

    return toReturn;
  }

  private Kpi toKpiDefinition(SbiKpi kpi) throws EMFUserError {
    logger.debug("IN");
    Kpi toReturn = new Kpi();

    String code = kpi.getCode();
    String description = kpi.getDescription();

    Integer kpiId = kpi.getKpiId();
    String kpiName = kpi.getName();

    SbiDataSetConfig dsC = kpi.getSbiDataSet();
    Integer dsId = null;
    String dsLabel = null;
    if (dsC != null) {
      dsId = dsC.getDsId();
      dsLabel = dsC.getLabel();
    }

    Double standardWeight = kpi.getWeight();

    String metric = kpi.getMetric();

    String interpretation = kpi.getInterpretation();
    String inputAttribute = kpi.getInputAttributes();
    String modelReference = kpi.getModelReference();
    String targetAudience = kpi.getTargetAudience();

    Integer kpiTypeId = null;
    String kpiTypeCd = null;
    Integer metricScaleId = null;
    String metricScaleCd = null;
    Integer measureTypeId = null;
    String measureTypeCd = null;

    if (kpi.getSbiDomainsByKpiType() != null) {
      kpiTypeId = kpi.getSbiDomainsByKpiType().getValueId();
      kpiTypeCd = kpi.getSbiDomainsByKpiType().getValueCd();
    }

    if (kpi.getSbiDomainsByMeasureType() != null) {
      measureTypeId = kpi.getSbiDomainsByMeasureType().getValueId();
      measureTypeCd = kpi.getSbiDomainsByMeasureType().getValueCd();
    }

    if (kpi.getSbiDomainsByMetricScaleType() != null) {
      metricScaleId = kpi.getSbiDomainsByMetricScaleType().getValueId();
      metricScaleCd = kpi.getSbiDomainsByMetricScaleType().getValueCd();
    }

    Set kpiDocs = kpi.getSbiKpiDocumentses();
    List kpiDocsList = new ArrayList();
    if(kpiDocs!=null && !kpiDocs.isEmpty()){
      Iterator i = kpiDocs.iterator();
      while (i.hasNext()) {
        SbiKpiDocument doc = (SbiKpiDocument) i.next();
        if(doc!=null){       
          KpiDocuments temp = new KpiDocuments();
          temp.setBiObjId(doc.getSbiObjects().getBiobjId());
          temp.setBiObjLabel(doc.getSbiObjects().getLabel());
          temp.setKpiDocId(doc.getIdKpiDoc());
          temp.setKpiId(doc.getSbiKpi().getKpiId());
          kpiDocsList.add(temp);
        }
      }
    }

    toReturn.setKpiName(kpiName);
    logger.debug("Kpi name setted");
    toReturn.setSbiKpiDocuments(kpiDocsList);
    logger.debug("Kpi DocumentIds setted");
    toReturn.setCode(code);
    logger.debug("Kpi code setted");
    toReturn.setMetric(metric);
    logger.debug("Kpi metric setted");
    toReturn.setDescription(description);
    logger.debug("Kpi description setted");
    toReturn.setStandardWeight(standardWeight);
    logger.debug("Kpi weight setted");
    toReturn.setIsAdditive(kpi.getIsAdditive());

    toReturn.setKpiId(kpiId);
    logger.debug("Kpi Id setted");
    toReturn.setDsLabel(dsLabel);
    toReturn.setKpiDsId(dsId);
    logger.debug("Kpi dataset setted");

    if (kpi.getSbiThreshold() != null) {
      Threshold threshold = DAOFactory.getThresholdDAO().loadThresholdById(
          kpi.getSbiThreshold().getThresholdId());
      toReturn.setThreshold(threshold);
      logger.debug("Kpi threshold setted");

    }

    // add also associated UDP
    List udpValues = DAOFactory.getUdpDAOValue().findByReferenceId(kpiId, "KPI");
    toReturn.setUdpValues(udpValues);


    toReturn.setInterpretation(interpretation);
    logger.debug("Kpi Interpretation setted");
    toReturn.setInputAttribute(inputAttribute);
    logger.debug("Kpi InputAttribute setted");
    toReturn.setModelReference(modelReference)
    logger.debug("Kpi ModelReference se  tted");
    toReturn.setTargetAudience(targetAudience);
    logger.debug("Kpi TargetAudience setted");

    toReturn.setKpiTypeId(kpiTypeId);
    toReturn.setKpiTypeCd(kpiTypeCd);
    logger.debug("Kpi KpiTypeId setted");
    toReturn.setMetricScaleId(metricScaleId);
    toReturn.setMetricScaleCd(metricScaleCd);
    logger.debug("Kpi MetricScaleId setted");
    toReturn.setMeasureTypeId(measureTypeId);
    toReturn.setMeasureTypeCd(measureTypeCd);
    logger.debug("Kpi MeasureTypeId setted");

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

  }

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

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


  public Kpi toKpi(SbiKpi kpi) throws EMFUserError {

    logger.debug("IN");
    Kpi toReturn = new Kpi();

    String code = kpi.getCode();
    String description = kpi.getDescription();
    String metric = kpi.getMetric();
    String interpretation = kpi.getInterpretation();

    String inputAttributes=kpi.getInputAttributes();
    String modelReference=kpi.getModelReference();
    String targetAudience=kpi.getTargetAudience();

    Boolean isParent = false;
    if (kpi.getFlgIsFather() != null
        && kpi.getFlgIsFather().equals(new Character('T'))) {
      isParent = true;
    }

    Integer kpiId = kpi.getKpiId();
    String kpiName = kpi.getName();
    SbiDataSetConfig dsC = kpi.getSbiDataSet();
    Integer dsId = null;
    String dsLabel = null;
    if (dsC != null) {
      dsId = dsC.getDsId();
      dsLabel = dsC.getLabel();
    }

    IThresholdDAO thresholdDAO=DAOFactory.getThresholdDAO();
    SbiThreshold thresh = kpi.getSbiThreshold();
    if(thresh!=null){
      Threshold threshold=thresholdDAO.toThreshold(thresh);
      toReturn.setThreshold(threshold);
      logger.debug("Kpi threshold setted");
    }

    Double standardWeight = kpi.getWeight();

    // Gets the father
    SbiKpi dad = kpi.getSbiKpi();
    Boolean isRoot = false;
    Integer father = null;
    if (dad != null) {
      father = dad.getKpiId();
    } else {
      isRoot = true;
    }

    String scaleCode = "";
    String scaleName = "";
    if (kpi.getSbiMeasureUnit() != null) {
      scaleCode = kpi.getSbiMeasureUnit().getScaleCd();
      scaleName = kpi.getSbiMeasureUnit().getScaleNm();
    }


    Set kpiDocs = kpi.getSbiKpiDocumentses();
    List kpiDocsList = new ArrayList();
    if(kpiDocs!=null && !kpiDocs.isEmpty()){
      Iterator i = kpiDocs.iterator();
      while (i.hasNext()) {
        SbiKpiDocument doc = (SbiKpiDocument) i.next();
        if(doc!=null){
          KpiDocuments temp = new KpiDocuments();
          temp.setBiObjId(doc.getSbiObjects().getBiobjId());
          temp.setBiObjLabel(doc.getSbiObjects().getLabel());
          temp.setKpiDocId(doc.getIdKpiDoc());
          temp.setKpiId(doc.getSbiKpi().getKpiId());
          kpiDocsList.add(temp);
        }
      }
    }

    // add also associated UDP
    List udpValues = DAOFactory.getUdpDAOValue().findByReferenceId(kpiId, "KPI");
    toReturn.setUdpValues(udpValues);


    toReturn.setDescription(description);
    logger.debug("Kpi description setted");
    toReturn.setSbiKpiDocuments(kpiDocsList);
    logger.debug("Kpi Documentlabels setted");
    toReturn.setIsParent(isParent);
    logger.debug("Kpi isParent setted");
    toReturn.setIsRoot(isRoot);
    logger.debug("Kpi isRoot setted");
    toReturn.setKpiDsId(dsId);
    toReturn.setDsLabel(dsLabel);
    logger.debug("Kpi dataset setted");
    toReturn.setKpiId(kpiId);
    logger.debug("Kpi Id setted");
    toReturn.setKpiName(kpiName);
    logger.debug("Kpi name setted");
    toReturn.setStandardWeight(standardWeight);
    logger.debug("Kpi weight setted");
    toReturn.setIsAdditive(kpi.getIsAdditive());
    toReturn.setCode(code);
    logger.debug("Kpi code setted");
    toReturn.setMetric(metric);
    logger.debug("Kpi metric setted");
    toReturn.setScaleCode(scaleCode);
    logger.debug("Kpi scaleCode setted");
    toReturn.setScaleName(scaleName);
    logger.debug("Kpi scaleName setted");
    toReturn.setInterpretation(interpretation);
    logger.debug("Interpretation setted");
    toReturn.setModelReference(modelReference);
    logger.debug("modelReference setted");
    toReturn.setTargetAudience(targetAudience);
    logger.debug("targetAudience setted");
    toReturn.setInputAttribute(inputAttributes);
    logger.debug("inputAttributes setted")

    if(kpi.getSbiDomainsByKpiType()!=null){
      toReturn.setKpiTypeId(kpi.getSbiDomainsByKpiType().getValueId());
      toReturn.setKpiTypeCd(kpi.getSbiDomainsByKpiType().getValueCd());
    }
    if(kpi.getSbiDomainsByMeasureType()!=null){
      toReturn.setMeasureTypeId(kpi.getSbiDomainsByMeasureType().getValueId());
      toReturn.setMeasureTypeCd(kpi.getSbiDomainsByMeasureType().getValueCd());
    }
    if(kpi.getSbiDomainsByMetricScaleType()!=null){
      toReturn.setMetricScaleId(kpi.getSbiDomainsByMetricScaleType().getValueId());
      toReturn.setMetricScaleCd(kpi.getSbiDomainsByMetricScaleType().getValueCd());
    }

    logger.debug("OUT");
    return toReturn;
  }
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.