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

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


   *
   * @return The Color of the interval in which the value falls
   */
  public ThresholdValue getThresholdOfValue() {
    logger.debug("IN");
    ThresholdValue toReturn = null;
    Double val = new Double(value);
    if (thresholdValues != null && !thresholdValues.isEmpty()) {
      Iterator it = thresholdValues.iterator();

      while (it.hasNext()) {
        ThresholdValue t = (ThresholdValue) it.next();
        String type = t.getThresholdType();
        Double min = t.getMinValue();
        Double max = t.getMaxValue();
        Boolean min_closed = t.getMinClosed()!=null?t.getMinClosed():false;
        Boolean max_closed = t.getMaxClosed()!=null?t.getMaxClosed():false;

        if (type.equals("RANGE")) {
          logger.debug("Threshold type RANGE");
          if(min_closed && max_closed){
            if (min != null && min.doubleValue()<= val.doubleValue()&& max!=null && val.doubleValue() <= max.doubleValue()) {
              toReturn = t;
              break;
            }else if(min==null && max!=null && val.doubleValue() <= max.doubleValue()){
              toReturn = t;
              break;
            }else if(max == null && min != null && min.doubleValue()<= val.doubleValue()){
              toReturn = t;
              break;
            }
          }else if(min_closed && !max_closed){
            if (min != null && min.doubleValue()<= val.doubleValue()&& max!=null && val.doubleValue() < max.doubleValue()) {
              toReturn = t;
              break;
            }else if(min==null && max!=null && val.doubleValue() < max.doubleValue()){
              toReturn = t;
              break;
            }else if(max == null && min != null && min.doubleValue()<= val.doubleValue()){
              toReturn = t;
              break;
            }         
          }else if(!min_closed && max_closed){
            if (min != null && min.doubleValue()< val.doubleValue()&& max!=null && val.doubleValue() <= max.doubleValue()) {
              toReturn = t;
              break;
            }else if(min==null && max!=null && val.doubleValue() <= max.doubleValue()){
              toReturn = t;
              break;
            }else if(max == null && min != null && min.doubleValue()< val.doubleValue()){
              toReturn = t;
              break;
            }           
          }else{
            if (min != null && min.doubleValue()< val.doubleValue()&& max!=null && val.doubleValue() < max.doubleValue()) {
              toReturn = t;
              break;
            }else if(min==null && max!=null && val.doubleValue() < max.doubleValue()){
              toReturn = t;
              break;
            }else if(max == null && min != null && min.doubleValue()< val.doubleValue()){
              toReturn = t;
              break;
           
          }
   
        } else if (type.equals("MINIMUM")) {
          logger.debug("Threshold type MINIMUM");
          if(min_closed){
            if (val.doubleValue() <= min.doubleValue()) {
              toReturn = t;
              break;
            }else {
              t.setColor(Color.WHITE) ;
              toReturn = t;
              break;
            }
          }else{
            if (val.doubleValue() < min.doubleValue()) {
              toReturn = t;
              break;
            }else {
              t.setColor(Color.WHITE) ;
              toReturn = t;
              break;
            }
          }
        } else if (type.equals("MAXIMUM")) {
          logger.debug("Threshold type MAXIMUM");
          if(max_closed){
            if (val.doubleValue() >= max.doubleValue()) {
              toReturn = t;
            } else {
              t.setColor(Color.WHITE);
              toReturn = t;
              break;
            }
          }else{
            if (val.doubleValue() > max.doubleValue()) {
              toReturn = t;
            } else {
              t.setColor(Color.WHITE);
              toReturn = t;
              break;
            }
          }       
        }
View Full Code Here


          String code = "";
          List thValues = t2.getThresholdValues();
          if(thValues!=null && !thValues.isEmpty()){
            Iterator th2 = thValues.iterator();
            while(th2.hasNext()){
              ThresholdValue t = (ThresholdValue)th2.next();
              SourceBean range = new SourceBean(rangeS);
              code = t.getThresholdCode() != null ? t.getThresholdCode() : "";             
              String label = t.getLabel() != null ? t.getLabel() : "";
              String min = t.getMinValue()!= null ? t.getMinValue().toString() : "";
              String max = t.getMaxValue()!= null ?  t.getMaxValue().toString() : "";
              String color = t.getColourString()!= null ?  t.getColourString() : "";
              type = t.getThresholdType()!= null ?   t.getThresholdType() : "";
             
              range.setAttribute("label",label);
              range.setAttribute("min",min);
              range.setAttribute("max",max);
              range.setAttribute("color",color);
View Full Code Here

          modelNodeL.setAttribute(kpiToAdd);
        }
       
        if(line.getValue()!=null){
        SourceBean kpiValueToAdd = newKpiValue(line.getValue());
        ThresholdValue t = null;
        if ( line.getValue()!=null && line.getValue().getValue() != null) {
          t = line.getValue().getThresholdOfValue();
       
        if(t!=null){
          try {
            Threshold tr = DAOFactory.getThresholdDAO().loadThresholdById(t.getThresholdId());
            if (!thresholdsList.contains(tr)){
              thresholdsList.add(tr);
            }
            kpiValueToAdd.setAttribute("thresholdid",t.getThresholdId()!=null ? t.getThresholdId().toString() :"");
           
          } catch (EMFUserError e) {
            logger.error("error in loading the Threshold by Id",e);
            e.printStackTrace();
          }
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.