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

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


    logger.debug("IN");
    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();
        String label = t.getLabel();
        Color c = t.getColor();
       
        if (type.equals("RANGE")){
          if (min!= null && min.doubleValue()<lower){
            lower = min.doubleValue();
          }else if(min==null && max!=null)  {
View Full Code Here


      Set thresholdValues = t.getSbiThresholdValues();
      Iterator it = thresholdValues.iterator();
      while (it.hasNext()) {
        SbiThresholdValue val = (SbiThresholdValue) it.next();
//        TODO mettere a posto
        ThresholdValue tr = toThresholdValue(val);
        logger.debug("Added threshold value with label " + tr.getLabel());
        toReturn.add(tr);
      }

    } catch (HibernateException he) {
      logger.error("Error while loading the Model Instance with id "
View Full Code Here

      if(t!=null){
        Set thresholdValues = t.getSbiThresholdValues();
        Iterator it = thresholdValues.iterator();
        while (it.hasNext()) {
          SbiThresholdValue val = (SbiThresholdValue) it.next();
          ThresholdValue tr = toThresholdValue(val);
          logger.debug("Added threshold value with label " + tr.getLabel());
          thresholdValueList.add(tr);
        }
      }     

    } catch (HibernateException he) {
View Full Code Here

public class DetailThresholdsValueUtil {

  public static void selectThresholdValue(Integer id,
      SourceBean serviceResponse) throws SourceBeanException,
      EMFUserError {
    ThresholdValue toReturn = DAOFactory.getThresholdValueDAO()
    .loadThresholdValueById(id);
    serviceResponse.setAttribute("THRESHOLDVALUE", toReturn);
  }
View Full Code Here

    serviceResponse.setAttribute("THRESHOLDVALUE", toReturn);
  }

  public static void updateThresholdValueFromRequest(
      SourceBean serviceRequest, Integer id) throws EMFUserError {
    ThresholdValue threshold = getThresholdValueFromRequest(serviceRequest);
    threshold.setId(id);
    DAOFactory.getThresholdValueDAO().modifyThresholdValue(threshold);

  }
View Full Code Here

      toTransform = crit.list();

      for (Iterator iterator = toTransform.iterator(); iterator.hasNext();) {
        SbiThresholdValue hibThresholdValue = (SbiThresholdValue) iterator
        .next();
        ThresholdValue thresholdValue = new ThresholdValue();

        thresholdValue.setId(hibThresholdValue.getIdThresholdValue());
        thresholdValue.setLabel(hibThresholdValue.getLabel());
        thresholdValue.setPosition(hibThresholdValue.getPosition());
        thresholdValue.setMaxValue(hibThresholdValue.getMaxValue());
        thresholdValue.setMinValue(hibThresholdValue.getMinValue());
        thresholdValue.setMinClosed(hibThresholdValue.getMinClosed());
        thresholdValue.setMaxClosed(hibThresholdValue.getMaxClosed());
        thresholdValue.setValue(hibThresholdValue.getThValue());

        thresholdValue.setThresholdId(hibThresholdValue
            .getSbiThreshold().getThresholdId());
        toReturn.add(thresholdValue);
      }

    } catch (HibernateException he) {
View Full Code Here

   
    String sSeverityId = (String) serviceRequest
    .getAttribute("severity_id");
    String sThresholdType = null;

    ThresholdValue toReturn = new ThresholdValue();

    Integer id = null;
    if (sId != null && !(sId.trim().equals(""))) {
      id = Integer.parseInt(sId);
    }

    Integer thresholdId = null;
    if (sThresholdId != null && !(sThresholdId.trim().equals(""))) {
      thresholdId = Integer.parseInt(sThresholdId);
      try {
        Threshold threshold = DAOFactory.getThresholdDAO().loadThresholdById(thresholdId);
        Domain threshodlType = DAOFactory.getDomainDAO().loadDomainById(threshold.getThresholdTypeId());
        sThresholdType = threshodlType.getValueCd();
      } catch (EMFUserError e) {
      }
     
    }

    Integer position = null;
    if (sPosition != null && !(sPosition.trim().equals(""))) {
      try{
        position = Integer.parseInt(sPosition);
      } catch(NumberFormatException nfe){

      }
    }

    Double minValue = null;
    if (sMinValue != null && !(sMinValue.trim().equals(""))) {
      try{
        minValue = new Double(sMinValue);
      } catch(NumberFormatException nfe){

      }
    }

    Double maxValue = null;
    if (sMaxValue != null && !(sMaxValue.trim().equals(""))) {
      try{
        maxValue = new Double(sMaxValue);
      } catch(NumberFormatException nfe){

      }
    }
   
    Double value = null;
    if (sValue != null && !(sValue.trim().equals(""))) {
      try{
        value = new Double(sValue);
      } catch(NumberFormatException nfe){

      }
    }
   
   

    Integer severityId = null;
    if (sSeverityId != null && !(sSeverityId.trim().equals(""))) {
      severityId = Integer.parseInt(sSeverityId);
    }

    toReturn.setId(id);
    toReturn.setThresholdId(thresholdId);
    toReturn.setPosition(position);
    toReturn.setLabel(label);
    toReturn.setMinValue(minValue);
    toReturn.setMaxValue(maxValue);
   
    toReturn.setMaxClosed(maxClosed);
    toReturn.setMinClosed(minClosed);
    toReturn.setValue(value);

    Color col=null;
    try{
      col=Color.decode(colour);
    }
    catch (Exception e) {
      col=Color.red;
    }
    toReturn.setColor(col);
    toReturn.setColourString(colour);
    toReturn.setSeverityId(severityId);
    toReturn.setThresholdType(sThresholdType);

    return toReturn;

  }
View Full Code Here

  }

  public ThresholdValue loadThresholdValueById(Integer id)
  throws EMFUserError {
    logger.debug("IN");
    ThresholdValue toReturn = null;
    Session aSession = null;
    Transaction tx = null;
    try {
      aSession = getSession();
      tx = aSession.beginTransaction();
      SbiThresholdValue hibThresholdValue = (SbiThresholdValue) aSession
      .load(SbiThresholdValue.class, id);
      toReturn = new ThresholdValue();
      toReturn.setId(hibThresholdValue.getIdThresholdValue());
      toReturn.setPosition(hibThresholdValue.getPosition());
      toReturn.setLabel(hibThresholdValue.getLabel());
      toReturn.setMinValue(hibThresholdValue.getMinValue());
      toReturn.setMaxValue(hibThresholdValue.getMaxValue());
      toReturn.setMinClosed(hibThresholdValue.getMinClosed());
      toReturn.setMaxClosed(hibThresholdValue.getMaxClosed());
      toReturn.setValue(hibThresholdValue.getThValue());

      Color color=null;
      String col=hibThresholdValue.getColour();
      if (col != null) {
        try{
          color = Color.decode(col);
        }
        catch (Exception e) {
          color=Color.RED;
        }
        logger.debug("Color decoded");
      }
      toReturn.setColor(color);
      toReturn.setColourString(hibThresholdValue.getColour());
      toReturn.setSeverityId(hibThresholdValue.getSeverity().getValueId());
      toReturn.setSeverityCd(hibThresholdValue.getSeverity().getValueCd());
      toReturn.setThresholdId(hibThresholdValue.getSbiThreshold()
          .getThresholdId());
      toReturn.setThresholdType(hibThresholdValue.getSbiThreshold().getThresholdType().getValueCd());
      tx.commit();
    } catch (HibernateException he) {
      logger.error("Error while loading the ThresholdValue with id "
          + ((id == null) ? "" : id.toString()), he);
View Full Code Here

      SourceBean textWeight, SourceBean image1, int level, SourceBean separatorline,SourceBean threshCode,SourceBean threshValue, SourceBean extraimageToAdd){
    logger.debug("IN");
   
    KpiValue kpiValue=line.getValue();
   
    ThresholdValue t = null;
    Color colorSemaphor = null;
    if ( kpiValue!=null && kpiValue.getValue() != null) {
      t = kpiValue.getThresholdOfValue();
      if(t!=null){
        colorSemaphor = t.getColor()
      }
    } 

    Integer xValue=xStarter+(xIncrease*Integer.valueOf(level));
    Integer yValue=actualHeight;

    try {
      //set Semaphor
      semaphor.setAttribute("reportElement.x", xValue.toString());
      semaphor.setAttribute("reportElement.y", new Integer(yValue.intValue()+2).toString());
      if(colorSemaphor!=null){

        String color=Integer.toHexString(colorSemaphor.getRGB());
        color="#"+color.substring(2);

        semaphor.setAttribute("reportElement.forecolor""#000000");
        semaphor.setAttribute("reportElement.backcolor", color);
      }else{
        semaphor.setAttribute("reportElement.forecolor", "#FFFFFF");
        semaphor.setAttribute("reportElement.backcolor", "#FFFFFF");
      }
      xValue=xValue+semaphorWidth+separatorWidth;

      // set text 1: Model CODE - Model NAME
      textCodeName.setAttribute("reportElement.x", (xValue));
      textCodeName.setAttribute("reportElement.y", yValue.toString());
      SourceBean textValue1=(SourceBean)textCodeName.getAttribute("text");
      textValue1.setCharacters(line.getModelInstanceCode()+"-"+line.getModelNodeName());

      xValue=xValue+textWidth+separatorWidth;

      //Set Value, weight and threshold code and value
      if(kpiValue!=null){
        String value1=kpiValue.getValue() != null ? kpiValue.getValue() : "";
        //set text2
        textValue.setAttribute("reportElement.y", yValue.toString());
        SourceBean textValue2=(SourceBean)textValue.getAttribute("text");
        textValue2.setCharacters(value1);

        String weight=(kpiValue.getWeight()!=null) ? kpiValue.getWeight().toString() : "";
        //set text2
        xValue=xValue+numbersWidth+separatorWidth;
        textWeight.setAttribute("reportElement.y", new Integer(yValue.intValue()+2).toString());
        SourceBean textValue3=(SourceBean)textWeight.getAttribute("text");
        textValue3.setCharacters(weight);
       
       
        if(t!=null){
          try {
            Threshold tr = DAOFactory.getThresholdDAO().loadThresholdById(t.getThresholdId());
            if (!thresholdsList.contains(tr)){
              thresholdsList.add(tr);
            }
           
          } catch (EMFUserError e) {
            logger.error("error in loading the Threshold by Id",e);
            e.printStackTrace();
          }
          String code=t.getThresholdCode() != null ? t.getThresholdCode() : "";
          String codeTh = "Code: "+code;
          if(codeTh.length()>20)codeTh = codeTh.substring(0, 19);
         
          threshCode.setAttribute("reportElement.y"new Integer(yValue.intValue()-2).toString());
          SourceBean threshCode2=(SourceBean)threshCode.getAttribute("text");
          threshCode2.setCharacters(codeTh);
       
       
          String labelTh=t.getLabel() != null ? t.getLabel() : "";
          String min = t.getMinValue()!= null ? t.getMinValue().toString() : null;
          String max = t.getMaxValue()!= null ?  t.getMaxValue().toString() : null;
          String valueTh = "Value: ";
          if(t.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(t.getThresholdType().equalsIgnoreCase("MINIMUM")){
            valueTh = valueTh + "< "+min+" "+labelTh;
          }else if(t.getThresholdType().equalsIgnoreCase("MAXIMUM")){
            valueTh = valueTh + "> "+max+" "+labelTh;
          }
          if(valueTh.length()>25)valueTh = valueTh.substring(0, 24);
         
          threshValue.setAttribute("reportElement.y", new Integer(yValue.intValue()+7).toString());
          SourceBean threshValue2=(SourceBean)threshValue.getAttribute("text");
          threshValue2.setCharacters(valueTh);
        }

      }
      //Sets the bullet chart and or the threshold image
      if(options.getDisplay_bullet_chart() && options.getDisplay_threshold_image()){
        //both threshold image and bullet chart have to be seen
        if ( kpiValue!=null &&  kpiValue.getValue()!= null && kpiValue.getThresholdValues()!=null && !kpiValue.getThresholdValues().isEmpty()) {

          List thresholdValues = kpiValue.getThresholdValues();     
          // String chartType = value.getChartType();
          String chartType = "BulletGraph";
          Double val = new Double(kpiValue.getValue());
          Double target = kpiValue.getTarget();
          ChartImpl sbi = ChartImpl.createChart(chartType);
          sbi.setValueDataSet(val);
          if (target != null) {
            sbi.setTarget(target);
          }
          sbi.setShowAxis(options.getShow_axis())
          sbi.setThresholdValues(thresholdValues);
       
          JFreeChart chart = sbi.createChart();
          ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
          String requestIdentity = null;
          UUIDGenerator uuidGen  = UUIDGenerator.getInstance();
          UUID uuid = uuidGen.generateTimeBasedUUID();
          requestIdentity = uuid.toString();
          requestIdentity = requestIdentity.replaceAll("-", "");
          String path_param = requestIdentity;
          String dir=System.getProperty("java.io.tmpdir");
          String path=dir+"/"+requestIdentity+".png";
          java.io.File file1 = new java.io.File(path);
          logger.debug("Where is the image: "+path);
          try {
            ChartUtilities.saveChartAsPNG(file1, chart, 89, 11, info);
          } catch (IOException e) {
            e.printStackTrace();
            logger.error("Error in saving chart",e);
          }
          String urlPng=GeneralUtilities.getSpagoBiHost()+GeneralUtilities.getSpagoBiContext() + GeneralUtilities.getSpagoAdapterHttpUrl() +
          "?ACTION_NAME=GET_PNG2&NEW_SESSION=TRUE&path="+path_param+"&LIGHT_NAVIGATOR_DISABLED=TRUE";
          urlPng = "new java.net.URL(\""+urlPng+"\")";
          logger.debug("Image url: "+urlPng);
         
          image1.setAttribute("reportElement.y", yValue.toString());
          image1.setAttribute("reportElement.x", new Integer(310).toString());
          image1.setAttribute("reportElement.width", 90);
          SourceBean imageValue=(SourceBean)image1.getAttribute("imageExpression");
          imageValue.setCharacters(urlPng);
        }
        ThresholdValue tOfVal = line.getThresholdOfValue();
        if (tOfVal!=null && tOfVal.getPosition()!=null && tOfVal.getThresholdCode()!=null){
          String fileName ="position_"+tOfVal.getPosition().intValue();
          String dirName = tOfVal.getThresholdCode();
          String urlPng=GeneralUtilities.getSpagoBiHost()+GeneralUtilities.getSpagoBiContext() + GeneralUtilities.getSpagoAdapterHttpUrl() +
          "?ACTION_NAME=GET_THR_IMAGE&NEW_SESSION=TRUE&fileName="+fileName+"&dirName="+dirName+"&LIGHT_NAVIGATOR_DISABLED=TRUE"
         
          urlPng = "new java.net.URL(\""+urlPng+"\")";
          logger.debug("url: "+urlPng);
         
          extraimageToAdd=new SourceBean(image);
          extraimageToAdd.setAttribute("reportElement.y", yValue.toString());
          extraimageToAdd.setAttribute("reportElement.width",35);
          extraimageToAdd.setAttribute("reportElement.x", new Integer(408).toString());
          SourceBean imageValue=(SourceBean)extraimageToAdd.getAttribute("imageExpression");
          imageValue.setCharacters(urlPng);     
        }
      }else if(options.getDisplay_bullet_chart() && !options.getDisplay_threshold_image()){
        //only bullet chart has to be seen
        if ( kpiValue!=null &&  kpiValue.getValue()!= null && kpiValue.getThresholdValues()!=null && !kpiValue.getThresholdValues().isEmpty()) {

          List thresholdValues = kpiValue.getThresholdValues();     
          // String chartType = value.getChartType();
          String chartType = "BulletGraph";
          Double val = new Double(kpiValue.getValue());
          Double target = kpiValue.getTarget();
          ChartImpl sbi = ChartImpl.createChart(chartType);
          sbi.setValueDataSet(val);
          if (target != null) {
            sbi.setTarget(target);
          }
          sbi.setShowAxis(options.getShow_axis())
          sbi.setThresholdValues(thresholdValues);
         
          JFreeChart chart = sbi.createChart();
          ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
          String requestIdentity = null;
          UUIDGenerator uuidGen  = UUIDGenerator.getInstance();
          UUID uuid = uuidGen.generateTimeBasedUUID();
          requestIdentity = uuid.toString();
          requestIdentity = requestIdentity.replaceAll("-", "");
          String path_param = requestIdentity;
          String dir=System.getProperty("java.io.tmpdir");
          String path=dir+"/"+requestIdentity+".png";
          java.io.File file1 = new java.io.File(path);
          logger.debug("Where is the image: "+path);
          try {
            ChartUtilities.saveChartAsPNG(file1, chart, 130, 11, info);
          } catch (IOException e) {
            e.printStackTrace();
            logger.error("Error in saving chart",e);
          }
          String urlPng=GeneralUtilities.getSpagoBiHost()+GeneralUtilities.getSpagoBiContext() + GeneralUtilities.getSpagoAdapterHttpUrl() +
          "?ACTION_NAME=GET_PNG2&NEW_SESSION=TRUE&path="+path_param+"&LIGHT_NAVIGATOR_DISABLED=TRUE";
          urlPng = "new java.net.URL(\""+urlPng+"\")";
          logger.debug("Image url: "+urlPng);
         
          image1.setAttribute("reportElement.y", yValue.toString());
          SourceBean imageValue=(SourceBean)image1.getAttribute("imageExpression");
          imageValue.setCharacters(urlPng);
        }
      }else if(!options.getDisplay_bullet_chart() && options.getDisplay_threshold_image()){
        //only threshold image has to be seen
        ThresholdValue tOfVal = line.getThresholdOfValue();
        if (tOfVal!=null && tOfVal.getPosition()!=null && tOfVal.getThresholdCode()!=null){
          String fileName ="position_"+tOfVal.getPosition().intValue();
          String dirName = tOfVal.getThresholdCode();
          String urlPng=GeneralUtilities.getSpagoBiHost()+GeneralUtilities.getSpagoBiContext() + GeneralUtilities.getSpagoAdapterHttpUrl() +
          "?ACTION_NAME=GET_THR_IMAGE&NEW_SESSION=TRUE&fileName="+fileName+"&dirName="+dirName+"&LIGHT_NAVIGATOR_DISABLED=TRUE"
         
          urlPng = "new java.net.URL(\""+urlPng+"\")";
          logger.debug("url: "+urlPng);
View Full Code Here

  }

  public static void newThresholdValue(SourceBean serviceRequest,
      SourceBean serviceResponse) throws EMFUserError,
      SourceBeanException {
    ThresholdValue toCreate = getThresholdValueFromRequest(serviceRequest);

    Integer thresholdValueId = DAOFactory.getThresholdValueDAO()
    .insertThresholdValue(toCreate);

    serviceResponse.setAttribute("ID", thresholdValueId);
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.