Package it.eng.spagobi.kpi.threshold.bo

Examples of it.eng.spagobi.kpi.threshold.bo.ThresholdValue


  }

  public static void restoreThresholdValue(Integer id, SourceBean serviceRequest,
      SourceBean serviceResponse) throws Exception {
    ThresholdValue toReturn = getThresholdValueFromRequest(serviceRequest);
    if (id != null) {
      toReturn.setId(id);
    }
    serviceResponse.setAttribute("THRESHOLDVALUE", toReturn);
  }
View Full Code Here



  public ThresholdValue toThresholdValue(SbiThresholdValue t) {

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

    Integer id = t.getIdThresholdValue();
    Integer thresholdId=t.getSbiThreshold().getThresholdId();
    String label = t.getLabel();
    SbiDomains d = t.getSeverity();
    Integer severityId = null;
    String severityCd = null;
    if(d!=null){
      severityId = d.getValueId();
      severityCd = d.getValueCd();
    }
    Integer position = t.getPosition();
    Double maxValue = t.getMaxValue();
    Double minValue = t.getMinValue();
    Boolean maxClosed = t.getMaxClosed();
    Boolean minClosed = t.getMinClosed();
    Double value = t.getThValue();
    SbiThreshold sbit = t.getSbiThreshold();
    Color color = new Color(255, 255, 0);
    String col = t.getColour();
    logger.debug("Threshold color is "+ col!=null ? col : "");
    if (col != null) {
      try{
        color = Color.decode(col);
        logger.debug("Color decoded");
      }
      catch (Exception e) {
        color=Color.RED;
      }
    }
   
    if(sbit.getThresholdType()!=null){
      toReturn.setThresholdType(sbit.getThresholdType().getValueCd());
    }
   
    if(sbit.getCode()!=null){
      toReturn.setThresholdCode(sbit.getCode());
    }

    toReturn.setId(id);
    toReturn.setThresholdId(thresholdId);
    toReturn.setLabel(label);
    toReturn.setSeverityId(severityId);
    toReturn.setSeverityCd(severityCd);
    toReturn.setPosition(position);
    toReturn.setMaxValue(maxValue);
    toReturn.setMinValue(minValue);
    toReturn.setColor(color);
    toReturn.setColourString(col);
   
    toReturn.setMaxClosed(maxClosed);
    toReturn.setMinClosed(minClosed);
    toReturn.setValue(value);

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

      Integer xValue = new Integer(5);
      List thValues = t.getThresholdValues();
      if(thValues!=null && !thValues.isEmpty()){
        Iterator thIt = thValues.iterator();
        while(thIt.hasNext()){
          ThresholdValue val = (ThresholdValue)thIt.next();
          if (val!=null){
            SourceBean semaphor1=new SourceBean(semaphor);
            SourceBean thresholdTextValue1=new SourceBean(thresholdTextValue);
           
            //Semaphore Threshold creation
           
            xValue = xValue + thresholdFieldWidth;
           
            if(xValue +thresholdSemaphoreWidth + thresholdFieldWidth>=maxSubTemplateWIdtht){ 
              xValue = new Integer(5) + thresholdFieldWidth;
              actualHeight+=valueHeight;
              yValue = actualHeight;
            }
              String colorSemaphor = val.getColourString();
              semaphor1.setAttribute("reportElement.x", xValue.toString());
              semaphor1.setAttribute("reportElement.y", new Integer(yValue.intValue()+2).toString());
              if(colorSemaphor!=null){
                semaphor1.setAttribute("reportElement.forecolor""#000000");
                semaphor1.setAttribute("reportElement.backcolor", colorSemaphor);
              }else{
                semaphor1.setAttribute("reportElement.forecolor", "#FFFFFF");
                semaphor1.setAttribute("reportElement.backcolor", "#FFFFFF");
              }
              sourceBeansToAdd.add(semaphor1);
           
              xValue = xValue + thresholdFieldSeparatorWidth; 
                       
              //Threshold Value Creation 
              String labelTh=val.getLabel() != null ? val.getLabel() : "";
              String min = val.getMinValue()!= null ? val.getMinValue().toString() : null;
              String max = val.getMaxValue()!= null ?  val.getMaxValue().toString() : null;
              String valueTh = "Value: ";
              if(val.getThresholdType().equalsIgnoreCase("RANGE")){
                if (min!=null && max !=null){
                    valueTh = valueTh + min+"-"+max+" "+labelTh;
                }else if (min!=null && max==null){
                  valueTh = valueTh + "> "+min+" "+labelTh;
                }else if (min==null && max!=null){
                   valueTh = valueTh + "< "+max+" "+labelTh;
                }
              }else if(val.getThresholdType().equalsIgnoreCase("MINIMUM")){
                valueTh = valueTh + "< "+min+" "+labelTh;
              }else if(val.getThresholdType().equalsIgnoreCase("MAXIMUM")){
                valueTh = valueTh + "> "+max+" "+labelTh;
              }
              if(valueTh.length()>25)valueTh = valueTh.substring(0, 24);
 
              thresholdTextValue1.setAttribute("reportElement.x", xValue.toString());
View Full Code Here

       
       
        List thrValuesList = new ArrayList();
        if(typeCD != null){
          if(typeCD.equals("MINIMUM") || typeCD.equals("MAXIMUM")){
            ThresholdValue tVal = new ThresholdValue();
            if(thrValId!= null && !thrValId.equals("") && !thrValId.equals("0")){
              tVal.setId(Integer.valueOf(thrValId));
            }
            tVal.setLabel(label);           
            tVal.setPosition(position);
            tVal.setColourString(colourString);
            tVal.setValue(value);
            tVal.setSeverityCd(severityCd);
            if(severityCd!=null && !severityCd.equals("")){
              Integer severityId = domainIds.get(severityCd);   
              tVal.setSeverityId(severityId);   
            }

            if(typeCD.equals("MINIMUM")){
              tVal.setMinClosed(minClosed);
              tVal.setMinValue(minValue);
            }else if(typeCD.equals("MAXIMUM")){
              tVal.setMaxClosed(maxClosed);
              tVal.setMaxValue(maxValue);
           
            thrValuesList.add(tVal);
                       
          }else if(typeCD.equals("RANGE")){
            if(thrValuesJSON!=null){
              try {
                thrValuesList = deserializeThresholdValuesJSONArray(thrValuesJSON, domainIds);
              } catch (JSONException e) {
                logger.error("JSON Exception");
                e.printStackTrace();
              }
            }
          }
          thr.setThresholdValues(thrValuesList);
        }
     
        try {

          Integer idToReturnToClient = null;
         
          if(id != null && !id.equals("") && !id.equals("0")){ 
            //modify
            thr.setId(Integer.valueOf(id));
            try{
              thrDao.modifyThreshold(thr);
            }catch(EMFUserError e){
              logger.error(e.getMessage(), e);
              throw e;
             
            }
            idToReturnToClient = Integer.valueOf(id);           
          }else{
            //insert new
            idToReturnToClient = thrDao.insertThreshold(thr);   
          }
         
          List thrValueIds = new ArrayList();
          if(thrValuesList!=null && !thrValuesList.isEmpty()){             
            Iterator it = thrValuesList.iterator();
            while(it.hasNext()){
              ThresholdValue tVal = (ThresholdValue)it.next();
              tVal.setThresholdId(Integer.valueOf(idToReturnToClient));             
              //insert or update all threshold values
              Integer thrValueId = null;
              thrValueId = tDao.saveOrUpdateThresholdValue(tVal);               
              tVal.setId(thrValueId);
              thrValueIds.add(thrValueId);
            }       
          }
         
          logger.debug("Threshold inserted or updated");
View Full Code Here

      }
      if(max!=null && !max.equals("")){
        maxValue = new Double(max);
      }
 
      ThresholdValue tVal = new ThresholdValue();
      if(thVId!= null && !thVId.equals("") && !thVId.equals("0")){
        Integer thrValId = new Integer(thVId);
        tVal.setId(thrValId);
      }
      tVal.setLabel(label);           
      tVal.setPosition(position);
      tVal.setColourString(colourString);
      tVal.setValue(value);
      tVal.setSeverityCd(severityCd);              
      tVal.setSeverityId(severityId);         
      tVal.setMinClosed(minClosed);
      tVal.setMinValue(minValue);
      tVal.setMaxClosed(maxClosed);
      tVal.setMaxValue(maxValue);

      toReturn.add(tVal);     
   
    return toReturn;
  }
View Full Code Here

      // load Threshold Value
      if (th.getThresholdValues() != null && th.getThresholdValues().size()>0) {
        Set thresholdValues=new HashSet(0);
        for (Iterator iterator = th.getThresholdValues().iterator(); iterator.hasNext();) {
          ThresholdValue thValue = (ThresholdValue) iterator.next();
          insertThresholdValue(thValue, session, hibTh);
          Integer thValueId=thValue.getId();
          SbiThresholdValue sbiTh= (SbiThresholdValue) session.load(SbiThresholdValue.class, thValue.getId());
          thresholdValues.add(sbiTh);
        }
        //hibTh.setSbiThresholdValues(thresholdValues);
      }
View Full Code Here

    if( !(o instanceof ThresholdValue) ) {
      throw new SerializationException("ThresholdValueJSONSerializer is unable to serialize object of type: " + o.getClass().getName());
    }
   
    try {
      ThresholdValue thrVal = (ThresholdValue)o;
      result = new JSONObject();
      result.put(THR_VAL_ID,  thrVal.getId());
      result.put(THR_VAL_LABEL,  thrVal.getLabel());
      result.put(THR_VAL_POSITION,  thrVal.getPosition());
      result.put(THR_VAL_MIN,  thrVal.getMinValue());
      result.put(THR_VAL_MIN_INCLUDED,  thrVal.getMinClosed());
      result.put(THR_VAL_MAX,  thrVal.getMaxValue());
      result.put(THR_VAL_MAX_INCLUDED,  thrVal.getMaxClosed());
      result.put(THR_VAL_VALUE,  thrVal.getValue());
      result.put(THR_VAL_COLOR,  thrVal.getColourString());
      result.put(THR_VAL_SEVERITY_ID,  thrVal.getSeverityId());
      result.put(THR_VAL_SEVERITY_CD,  thrVal.getSeverityCd());

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

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

          IThresholdValueDAO thDao=(IThresholdValueDAO)DAOFactory.getThresholdValueDAO();
          ThresholdValue tr = thDao.toThresholdValue(tls);
          thresholdValues.add(tr);
        }
      }     

    } else {// in case older thresholds have to be retrieved

      Set kpiInstHist = kpiInst.getSbiKpiInstanceHistories();
      Iterator i = kpiInstHist.iterator();
      while (i.hasNext()) {
        SbiKpiInstanceHistory ih = (SbiKpiInstanceHistory) i.next();
        Date ihBegDt = ih.getBeginDt();
        Date ihEndDt = ih.getEndDt();
        if ((d.after(ihBegDt) || d.equals(ihBegDt))
            && (d.before(ihEndDt) || d.equals(ihEndDt))) {

          weight = ih.getWeight();
          logger.debug("SbiKpiValue weight: "
              + (weight != null ? weight.toString()
                  : "weight null"));
          target = ih.getTarget();
          logger.debug("SbiKpiValue target: "
              + (target != null ? target.toString()
                  : "target null"));

          if (ih.getSbiMeasureUnit() != null) {
            scaleCode = ih.getSbiMeasureUnit().getScaleCd();
            logger.debug("SbiKpiValue scaleCode: "
                + (scaleCode != null ? scaleCode
                    : "scaleCode null"));
            scaleName = ih.getSbiMeasureUnit().getScaleNm();
            logger.debug("SbiKpiValue scaleName: "
                + (scaleName != null ? scaleName
                    : "scaleName null"));
          }
          SbiThreshold t = ih.getSbiThreshold();
          if(t!=null){
            Set ts = t.getSbiThresholdValues();
            Iterator it = ts.iterator();
            while (it.hasNext()) {
              SbiThresholdValue tls = (SbiThresholdValue) it.next();

              IThresholdValueDAO thDao=(IThresholdValueDAO)DAOFactory.getThresholdValueDAO();
              ThresholdValue tr = thDao.toThresholdValue(tls);
              thresholdValues.add(tr);
            }
          }   
        }
      }
View Full Code Here

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

        IThresholdValueDAO thDao=(IThresholdValueDAO)DAOFactory.getThresholdValueDAO();
        ThresholdValue tr = thDao.toThresholdValue(tls);
        thresholdValues.add(tr);
      }
    }     
    // TODO for the moment get actual values of weight/target etc check if it is correct
   
View Full Code Here

      List thrValues = thr.getThresholdValues();
      JSONArray thValues = new JSONArray();
      if(thrValues!=null){   
        if(!thrValues.isEmpty()){
          if(thrValues.size()==1 && !thr.getThresholdTypeCode().equalsIgnoreCase("RANGE")){
            ThresholdValue thrVal = (ThresholdValue) thrValues.get(0);
            if(thrVal != null){
             result.put(THR_VAL_ID,  thrVal.getId());
             result.put(THR_VAL_LABEL,  thrVal.getLabel());
             result.put(THR_VAL_POSITION,  thrVal.getPosition());
             result.put(THR_VAL_MIN,  thrVal.getMinValue());
             result.put(THR_VAL_MIN_INCLUDED,  thrVal.getMinClosed());
             result.put(THR_VAL_MAX,  thrVal.getMaxValue());
             result.put(THR_VAL_MAX_INCLUDED,  thrVal.getMaxClosed());
             result.put(THR_VAL_VALUE,  thrVal.getValue());
             result.put(THR_VAL_COLOR,  thrVal.getColourString());
             result.put(THR_VAL_SEVERITY_ID,  thrVal.getSeverityId());
             result.put(THR_VAL_SEVERITY_CD,  thrVal.getSeverityCd());
            }
          }else{         
            for (Iterator iterator = thrValues.iterator(); iterator.hasNext();) {
             
               ThresholdValue thrVal = (ThresholdValue) iterator.next();
               JSONObject temp = new JSONObject();
               temp.put(THR_VAL_ID,  thrVal.getId());
               temp.put(THR_VAL_LABEL,  thrVal.getLabel());
               temp.put(THR_VAL_POSITION,  thrVal.getPosition());
               temp.put(THR_VAL_MIN,  thrVal.getMinValue());
               temp.put(THR_VAL_MIN_INCLUDED,  thrVal.getMinClosed());
               temp.put(THR_VAL_MAX,  thrVal.getMaxValue());
               temp.put(THR_VAL_MAX_INCLUDED,  thrVal.getMaxClosed());
               temp.put(THR_VAL_VALUE,  thrVal.getValue());
               temp.put(THR_VAL_COLOR,  thrVal.getColourString());
               temp.put(THR_VAL_SEVERITY_ID,  thrVal.getSeverityId());
               temp.put(THR_VAL_SEVERITY_CD,  thrVal.getSeverityCd());
               thValues.put(temp);
 
            }
          }
        }
View Full Code Here

TOP

Related Classes of it.eng.spagobi.kpi.threshold.bo.ThresholdValue

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.