Package it.eng.spago.base

Examples of it.eng.spago.base.SourceBean


    profile = (IEngUserProfile) permanentSession.getAttribute(IEngUserProfile.ENG_USER_PROFILE);
//    HttpServletRequest httpReq = (HttpServletRequest)requestContainer.getInternalRequest();
//    HttpSession httpSess = httpReq.getSession();
//    profile = (IEngUserProfile)httpSess.getAttribute(IEngUserProfile.ENG_USER_PROFILE);
    // based on lov type fill the spago list / paginator object / valColName
    SourceBean rowsSourceBean = null;
    if(typeLov.equalsIgnoreCase("QUERY")) {
      QueryDetail qd = QueryDetail.fromXML(looProvider);
//      if (qd.requireProfileAttributes()) {
//        String message = PortletUtilities.getMessage("scheduler.noProfileAttributesSupported", "component_scheduler_messages");
//        response.setAttribute(SpagoBIConstants.MESSAGE_INFO, message);
//        return list;
//      }
      valColName = qd.getValueColumnName();     
      //String pool = qd.getConnectionName();
      String datasource = qd.getDataSource();
      String statement = qd.getQueryDefinition();
      // execute query
      try {
        statement = StringUtilities.substituteProfileAttributesInString(statement, profile);
        //rowsSourceBean = (SourceBean) executeSelect(getRequestContainer(), getResponseContainer(), pool, statement);
        rowsSourceBean = (SourceBean) executeSelect(getRequestContainer(), getResponseContainer(), datasource, statement);
      } catch (Exception e) {
        String stacktrace = e.toString();
        response.setAttribute("stacktrace", stacktrace);
        int startIndex = stacktrace.indexOf("java.sql.");
        int endIndex = stacktrace.indexOf("\n\tat ", startIndex);
        if (endIndex == -1) endIndex = stacktrace.indexOf(" at ", startIndex);
        if (startIndex != -1 && endIndex != -1)
          response.setAttribute("errorMessage", stacktrace.substring(startIndex, endIndex));
        response.setAttribute("testExecuted", "false");
      }
    } else if(typeLov.equalsIgnoreCase("FIXED_LIST")) {
      FixedListDetail fixlistDet = FixedListDetail.fromXML(looProvider);
//      if (fixlistDet.requireProfileAttributes()) {
//        String message = PortletUtilities.getMessage("scheduler.noProfileAttributesSupported", "component_scheduler_messages");
//        response.setAttribute(SpagoBIConstants.MESSAGE_INFO, message);
//        return list;
//      }
      valColName = fixlistDet.getValueColumnName();
      try{
        String result = fixlistDet.getLovResult(profile, null, null);
        rowsSourceBean = SourceBean.fromXMLString(result);
        if(!rowsSourceBean.getName().equalsIgnoreCase("ROWS")) {
          throw new Exception("The fix list is empty");
        } else if (rowsSourceBean.getAttributeAsList(DataRow.ROW_TAG).size()==0) {
          throw new Exception("The fix list is empty");
        }
      } catch (Exception e) {
        SpagoBITracer.major(SpagoBIConstants.NAME_MODULE, this.getClass().getName(),
                        "getList", "Error while converting fix lov into spago list", e);
        String stacktrace = e.toString();
        response.setAttribute("stacktrace", stacktrace);
        response.setAttribute("errorMessage", "Error while executing fix list lov");
        response.setAttribute("testExecuted", "false");
        return list;
      }
    } else if(typeLov.equalsIgnoreCase("SCRIPT")) {
      ScriptDetail scriptDetail = ScriptDetail.fromXML(looProvider);
//      if (scriptDetail.requireProfileAttributes()) {
//        String message = PortletUtilities.getMessage("scheduler.noProfileAttributesSupported", "component_scheduler_messages");
//        response.setAttribute(SpagoBIConstants.MESSAGE_INFO, message);
//        return list;
//      }
      valColName = scriptDetail.getValueColumnName();
      try{
        String result = scriptDetail.getLovResult(profile, null, null);
        rowsSourceBean = SourceBean.fromXMLString(result);
      } catch (Exception e) {
        SpagoBITracer.major(SpagoBIConstants.NAME_MODULE, this.getClass().getName(),
                        "getList", "Error while executing the script lov", e);
        String stacktrace = e.toString();
        response.setAttribute("stacktrace", stacktrace);
        response.setAttribute("errorMessage", "Error while executing script");
        response.setAttribute("testExecuted", "false");
        return list;
      }
    } else if(typeLov.equalsIgnoreCase("JAVA_CLASS")) {
      JavaClassDetail javaClassDetail = JavaClassDetail.fromXML(looProvider);
//      if (javaClassDetail.requireProfileAttributes()) {
//        String message = PortletUtilities.getMessage("scheduler.noProfileAttributesSupported", "component_scheduler_messages");
//        response.setAttribute(SpagoBIConstants.MESSAGE_INFO, message);
//        return list;
//      }
      valColName = javaClassDetail.getValueColumnName();
      try{   
        String javaClassName = javaClassDetail.getJavaClassName();
        IJavaClassLov javaClassLov = (IJavaClassLov) Class.forName(javaClassName).newInstance();
          String result = javaClassLov.getValues(profile);
            rowsSourceBean = SourceBean.fromXMLString(result);
      } catch (Exception e) {
        SpagoBITracer.major(SpagoBIConstants.NAME_MODULE, this.getClass().getName(),
                              "getList", "Error while executing the java class lov", e);
        String stacktrace = e.toString();
        response.setAttribute("stacktrace", stacktrace);
        response.setAttribute("errorMessage", "Error while executing java class");
        response.setAttribute("testExecuted", "false");
        return list;
      }
    }
    // fill paginator
    int count = 0;
    if(rowsSourceBean != null) {
      List rows = rowsSourceBean.getAttributeAsList(DataRow.ROW_TAG);
      for (int i = 0; i < rows.size(); i++){
        paginator.addRow(rows.get(i));
        count++;
      }
    }
    paginator.setPageSize(count);
    list.setPaginator(paginator);
   
    // get all the columns name
      rowsSourceBean = list.getPaginator().getAll();
    List colNames = new ArrayList();
    List rows = null;
    if(rowsSourceBean != null) {
      rows = rowsSourceBean.getAttributeAsList(DataRow.ROW_TAG);
      if((rows!=null) && (rows.size()!=0)) {
        SourceBean row = (SourceBean)rows.get(0);
        List rowAttrs = row.getContainedAttributes();
        Iterator rowAttrsIter = rowAttrs.iterator();
        while(rowAttrsIter.hasNext()) {
          SourceBeanAttribute rowAttr = (SourceBeanAttribute)rowAttrsIter.next();
          colNames.add(rowAttr.getKey());
        }
      }
    }
   
    // build module configuration for the list
    String moduleConfigStr = "";
    moduleConfigStr += "<CONFIG>";
    moduleConfigStr += "  <QUERIES/>";
    moduleConfigStr += "  <COLUMNS>";
      // if there's no colum name add a fake column to show that there's no data
    if(colNames.size()==0) {
      moduleConfigStr += "  <COLUMN name=\"No Result Found\" />";
    } else {
      Iterator iterColNames = colNames.iterator();
      while(iterColNames.hasNext()) {
        String colName = (String)iterColNames.next();
        moduleConfigStr += "  <COLUMN name=\"" + colName + "\" />";
      }
    }
    moduleConfigStr += "  </COLUMNS>";
    moduleConfigStr += "  <CAPTIONS/>";
    moduleConfigStr += "  <BUTTONS/>";
    moduleConfigStr += "</CONFIG>";
    SourceBean moduleConfig = SourceBean.fromXMLString(moduleConfigStr);
    response.setAttribute(moduleConfig);

   
    // filter the list
    String valuefilter = (String) request.getAttribute(SpagoBIConstants.VALUE_FILTER);
View Full Code Here


        description = description.replaceAll("<", "&lt;");
        description = description.replaceAll("\"", "&quot;");
      }
      rowSBStr += "    DESCRIPTION=\"" + (description != null ? description : "") + "\"";
      rowSBStr += "     />";
      SourceBean rowSB = SourceBean.fromXMLString(rowSBStr);
      paginator.addRow(rowSB);
    }
    ListIFace list = new GenericList();
    list.setPaginator(paginator);
    // filter the list
View Full Code Here

    nameResolution();

    // Create Source Bean of template of template
    String templateStr = getTemplateTemplate();

    SourceBean templateBaseContent =null;
    List toReturn = new ArrayList();
    String finalTemplate="";

    logger.debug("Recovered template START ");
    logger.debug(templateStr);
    logger.debug("Recovered template END ");
    if(templateStr!=null){
      try {
        templateBaseContent = SourceBean.fromXMLString(templateStr);
      } catch (Exception e) {
        logger.error("Error in converting template of template into a SOurce Bean, check the XML code");
      }

    try {
      staticTextName = SourceBean.fromXMLString(staticTextNameS); // this is for text
      staticTextNumber = SourceBean.fromXMLString(staticTextNumberS);
      staticTextWeightNumber = SourceBean.fromXMLString(staticTextWeightS);
      image = SourceBean.fromXMLString(imageS);
      resourceBand=SourceBean.fromXMLString(resourceBandS);
      resourceName=SourceBean.fromXMLString(resourceNameS);
      semaphor=SourceBean.fromXMLString(semaphorS);
      evenLineS=SourceBean.fromXMLString(evenLineSeparator);
      oddLineS=SourceBean.fromXMLString(oddLineSeparator);
      columnHeaderBand=SourceBean.fromXMLString(columnHeaderBandS);
      columnModelHeader=SourceBean.fromXMLString(columnModelHeaderS);
      columnKPIHeader=SourceBean.fromXMLString(columnKPIHeaderS);
      columnWeightHeader=SourceBean.fromXMLString(columnWeightHeaderS);
      columnThresholdHeader=SourceBean.fromXMLString(columnThresholdHeaderS);
      thresholdCode=SourceBean.fromXMLString(thresholdCodeS);
      thresholdValue=SourceBean.fromXMLString(thresholdValueS);
     
      thresholdBand=SourceBean.fromXMLString(thresholdBandS);
      thresholdTitle=SourceBean.fromXMLString(thresholdTitleS);
      thresholdTextValue=SourceBean.fromXMLString(thresholdValuesCodeS);
      thresholdTextCode=SourceBean.fromXMLString(thresholdTextCodeS);
      thresholdLineSeparator=SourceBean.fromXMLString(thresholdLineSeparatorS);
     
      subReport=SourceBean.fromXMLString(subReportS);
    } catch (Exception e) {
      logger.error("Error in converting static elemnts into Source Beans, check the XML code");
    }

    //change title
    SourceBean titleSB=(SourceBean)templateBaseContent.getAttribute("title");
    SourceBean titleText=(SourceBean)titleSB.getAttribute("band.staticText.text");
    titleText.setCharacters(documentName);
   
    // make DETAIL BAND of master with subreports
    detailMaster=(SourceBean)templateBaseContent.getAttribute("DETAIL");
    detailBandMaster=(SourceBean)detailMaster.getAttribute("BAND");
    masterHeight = new Integer(0);
   
    List subreports = createSubreports(resources);
   
    finalTemplate=templateBaseContent.toXML(false, false);
    for (Iterator iterator = nameResolution.iterator(); iterator.hasNext();) {
      NameRes nameR = (NameRes) iterator.next();
      String toReplace = nameR.getToSubstitute();
      String replaceWith=nameR.getCorrectString();
      finalTemplate=finalTemplate.replaceAll("<"+toReplace, "<"+replaceWith);
      finalTemplate=finalTemplate.replaceAll("</"+toReplace, "</"+replaceWith);   
    }
    toReturn.add(finalTemplate);
    logger.debug("Built template START");
    logger.debug(finalTemplate);
    logger.debug("Built template END");
   
   
    if(subreports!=null && !subreports.isEmpty()){
      logger.debug("There are subreports!");
      Iterator suit = subreports.iterator();
      while(suit.hasNext()){
        SourceBean subTemplateContent = (SourceBean)suit.next();
        String subTemplate = subTemplateContent.toXML(false);
        for (Iterator iterator = nameResolution.iterator(); iterator.hasNext();) {
          NameRes nameR = (NameRes) iterator.next();
          String toReplace = nameR.getToSubstitute();
          String replaceWith=nameR.getCorrectString();
          subTemplate=subTemplate.replaceAll("<"+toReplace, "<"+replaceWith);
View Full Code Here

        if(actualHeight+separatorModelsHeight+resourceBandHeight+10<maxFirstSubTemplateHeight){
          List sourceBeansToAdd = newResource(thisBlock,bandDetailReport)
          if (sourceBeansToAdd!=null && !sourceBeansToAdd.isEmpty()){
          Iterator it = sourceBeansToAdd.iterator();
            while(it.hasNext()){
              SourceBean toAdd = (SourceBean)it.next();
              bandDetailReport.setAttribute(toAdd);
            }
          }
        }else{
         
          //Add last subreport to the List
          increaseHeight(subTemplateBaseContent);
          subreports.add(subTemplateBaseContent);
          actualHeight = new Integer(0);
          subTemplateBaseContent = createNewSubReport(countSubreports);
          countSubreports ++;
          //Get my bandDetailReport from new subreport
          subtitleSB=(SourceBean)subTemplateBaseContent.getAttribute("title");
          bandDetailReport=(SourceBean)subtitleSB.getAttribute("BAND");
          //change subtemplatesummary
          subSummarySB=(SourceBean)subTemplateBaseContent.getAttribute("summary");
          bandSummaryReport=(SourceBean)subSummarySB.getAttribute("BAND")
          //NEW SUBREPORT
          List sourceBeansToAdd = newResource(thisBlock,bandDetailReport)
          if (sourceBeansToAdd!=null && !sourceBeansToAdd.isEmpty()){
          Iterator it = sourceBeansToAdd.iterator();
            while(it.hasNext()){
              SourceBean toAdd = (SourceBean)it.next();
              bandDetailReport.setAttribute(toAdd);
           
          }
        }
     
     
     
         
          if (actualHeight+separatorHeight+valueHeight+10<maxFirstSubTemplateHeight){
            KpiLine lineRoot=thisBlock.getRoot();
            List sourceBeansToAdd2 = newLine(lineRoot, 0,true);
            if (sourceBeansToAdd2!=null && !sourceBeansToAdd2.isEmpty()){
            Iterator it = sourceBeansToAdd2.iterator();
              while(it.hasNext()){
                SourceBean toAdd = (SourceBean)it.next();
                bandDetailReport.setAttribute(toAdd);
             
            }
          }else{
            //Add last subreport to the List
            increaseHeight(subTemplateBaseContent);
            subreports.add(subTemplateBaseContent);
            actualHeight = new Integer(0);
            subTemplateBaseContent = createNewSubReport(countSubreports);
            countSubreports ++;
            //Get my bandDetailReport from new subreport
            subtitleSB=(SourceBean)subTemplateBaseContent.getAttribute("title");
            bandDetailReport=(SourceBean)subtitleSB.getAttribute("BAND");
            //change subtemplatesummary
            subSummarySB=(SourceBean)subTemplateBaseContent.getAttribute("summary");
            bandSummaryReport=(SourceBean)subSummarySB.getAttribute("BAND")
            //NEW SUBREPORT
            KpiLine lineRoot=thisBlock.getRoot();
            List sourceBeansToAdd2 = newLine(lineRoot, 0,true);
            if (sourceBeansToAdd2!=null && !sourceBeansToAdd2.isEmpty()){
            Iterator it = sourceBeansToAdd2.iterator();
              while(it.hasNext()){
                SourceBean toAdd = (SourceBean)it.next();
                bandDetailReport.setAttribute(toAdd);
             
            }
          }
        }
   
      if (actualHeight+separatorModelsHeight+columnHeaderHeight+10<maxFirstSubTemplateHeight){
        List sourceBeansToAdd3 = newThresholdBlock(bandDetailReport);
        if (sourceBeansToAdd3!=null && !sourceBeansToAdd3.isEmpty()){
        Iterator it = sourceBeansToAdd3.iterator();
          while(it.hasNext()){
            SourceBean toAdd = (SourceBean)it.next();
            bandDetailReport.setAttribute(toAdd);
         
        }
      }else{
        //Add last subreport to the List
        increaseHeight(subTemplateBaseContent);
        subreports.add(subTemplateBaseContent);
        actualHeight = new Integer(0);
        subTemplateBaseContent = createNewSubReport(countSubreports);
        countSubreports ++;
        //Get my bandDetailReport from new subreport
        subtitleSB=(SourceBean)subTemplateBaseContent.getAttribute("title");
        bandDetailReport=(SourceBean)subtitleSB.getAttribute("BAND");
        //change subtemplatesummary
        subSummarySB=(SourceBean)subTemplateBaseContent.getAttribute("summary");
        bandSummaryReport=(SourceBean)subSummarySB.getAttribute("BAND")
        //NEW SUBREPORT
        List sourceBeansToAdd3 = newThresholdBlock(bandDetailReport);
        if (sourceBeansToAdd3!=null && !sourceBeansToAdd3.isEmpty()){
        Iterator it = sourceBeansToAdd3.iterator();
          while(it.hasNext()){
            SourceBean toAdd = (SourceBean)it.next();
            bandDetailReport.setAttribute(toAdd);
         
        }
      }
   

    if(thresholdsList!=null && !thresholdsList.isEmpty()){
      Iterator th = thresholdsList.iterator();
      while(th.hasNext()){
        Threshold t =(Threshold)th.next();

          if (actualHeight+separatorHeight+10<maxFirstSubTemplateHeight){
            List sourceBeansToAdd4 = newThresholdLine(t);
            if (sourceBeansToAdd4!=null && !sourceBeansToAdd4.isEmpty()){
            Iterator it = sourceBeansToAdd4.iterator();
              while(it.hasNext()){
                SourceBean toAdd = (SourceBean)it.next();
                bandDetailReport.setAttribute(toAdd);
             
            }
          }else{
           
            //Add last subreport to the List
            increaseHeight(subTemplateBaseContent);
            subreports.add(subTemplateBaseContent);
            actualHeight = new Integer(0);
            subTemplateBaseContent = createNewSubReport(countSubreports);
            countSubreports ++;
            //Get my bandDetailReport from new subreport
            subtitleSB=(SourceBean)subTemplateBaseContent.getAttribute("title");
            bandDetailReport=(SourceBean)subtitleSB.getAttribute("BAND");
            //change subtemplatesummary
            subSummarySB=(SourceBean)subTemplateBaseContent.getAttribute("summary");
            bandSummaryReport=(SourceBean)subSummarySB.getAttribute("BAND")
            //NEW SUBREPORT
            List sourceBeansToAdd4 = newThresholdLine(t);
            if (sourceBeansToAdd4!=null && !sourceBeansToAdd4.isEmpty()){
            Iterator it = sourceBeansToAdd4.iterator();
              while(it.hasNext()){
                SourceBean toAdd = (SourceBean)it.next();
                bandDetailReport.setAttribute(toAdd);
             
            }
          }
        }
View Full Code Here

  }
 
  public SourceBean createNewSubReport(int numOfSubreport){
    logger.debug("IN");

    SourceBean subTemplateBaseContent =null;
    // Create Source Bean of template of subtemplate
    String subTemplateStr = getTemplateSubTemplate();
    try {
      subTemplateBaseContent = SourceBean.fromXMLString(subTemplateStr);
    } catch (Exception e) {
      logger.error("Error in converting template of template into a SOurce Bean, check the XML code");
    }
   
    SourceBean subreport1;
    try {
      subreport1 = new SourceBean(subReport);
      subreport1.setAttribute("reportElement.y", new Integer(0));
      SourceBean subreport2=(SourceBean)subreport1.getAttribute("subreportExpression");
      String dirS=System.getProperty("java.io.tmpdir");
      String subr = dirS+ File.separatorChar + "Detail"+numOfSubreport+".jasper";
      subr = subr.replaceAll("\\\\", "/");
      subreport2.setCharacters("\""+subr+"\"");
      if(numOfSubreport==0){
        detailBandMaster.setAttribute(subreport1);
      }else{
        bandSummaryReport.setAttribute(subreport1);
      }
View Full Code Here

    Resource res=block.getR();
     
      try{
        actualHeight+=separatorModelsHeight;

        SourceBean bandRes=new SourceBean(resourceBand);
        SourceBean bandName=new SourceBean(resourceName);
        SourceBean columnHeadBand=new SourceBean(columnHeaderBand);
        SourceBean modelColHeader=new SourceBean(columnModelHeader);
        SourceBean weightColHeader=new SourceBean(columnWeightHeader);
        SourceBean kpiColHeader=new SourceBean(columnKPIHeader);
        SourceBean kthreshColHeader=new SourceBean(columnThresholdHeader);
       
        if(res!=null){
          bandRes.setAttribute("reportElement.y", actualHeight.toString());
          bandName.setAttribute("reportElement.y", actualHeight.toString());
          logger.debug("add resource band for resource "+res.getName());
          SourceBean textValue1=(SourceBean)bandName.getAttribute("text");
          textValue1.setCharacters("RESOURCE: "+res.getName());

          sourceBeansToAdd.add(bandRes);
          sourceBeansToAdd.add(bandName);
          actualHeight+=resourceBandHeight;
        }
       
        columnHeadBand.setAttribute("reportElement.y",actualHeight.toString());
        modelColHeader.setAttribute("reportElement.y",actualHeight.toString());
        kpiColHeader.setAttribute("reportElement.y",actualHeight.toString());
        weightColHeader.setAttribute("reportElement.y",actualHeight.toString());
        kthreshColHeader.setAttribute("reportElement.y",actualHeight.toString());
       
        if(options.getModel_title()!=null ){
          SourceBean textValue=(SourceBean)modelColHeader.getAttribute("text");
          textValue.setCharacters(options.getModel_title());
        }
        if(options.getKpi_title()!=null ){
        SourceBean textValue1=(SourceBean)kpiColHeader.getAttribute("text");
        textValue1.setCharacters(options.getKpi_title());
        }
        if(options.getWeight_title()!=null ){
        SourceBean textValue2=(SourceBean)weightColHeader.getAttribute("text");
        textValue2.setCharacters(options.getWeight_title());
        }
        /*SourceBean textValue3=(SourceBean)kthreshColHeader.getAttribute("text");
        textValue3.setCharacters(options.getBullet_chart_title());*/
       
        sourceBeansToAdd.add(columnHeadBand);
 
View Full Code Here

  public List newLine(KpiLine kpiLine, int level,Boolean evenLevel){
    logger.debug("IN");
    List sourceBeansToAdd = new ArrayList();
    try {
      actualHeight+=separatorHeight;
      SourceBean textCodeName=new SourceBean(staticTextName);   // code - name
      SourceBean textValue=new SourceBean(staticTextNumber)//value number
      SourceBean textWeight=new SourceBean(staticTextWeightNumber)// weight number
      SourceBean image1=new SourceBean(image);// Bullet Chart
      SourceBean semaphor1=new SourceBean(semaphor);// Semaphore
      SourceBean threshCode=new SourceBean(thresholdCode);// Threshold Code
      SourceBean threshValue=new SourceBean(thresholdValue);// Threshold Value
      SourceBean evenLine=new SourceBean(evenLineS);// Separator for even lines
      SourceBean oddLine=new SourceBean(oddLineS);// Separator for odd lines
      SourceBean extraimageToAdd = null;//in case 2 images are required
      if(evenLevel){
        extraimageToAdd =setLineAttributes(kpiLine,semaphor1,textCodeName,textValue,textWeight,image1,level,evenLine,threshCode,threshValue,extraimageToAdd);
      }else{
        extraimageToAdd = setLineAttributes(kpiLine,semaphor1,textCodeName,textValue,textWeight,image1,level,oddLine,threshCode,threshValue,extraimageToAdd);
      }
      actualHeight+=valueHeight;

      sourceBeansToAdd.add(semaphor1);
      sourceBeansToAdd.add(textCodeName);
      sourceBeansToAdd.add(textValue);
      sourceBeansToAdd.add(textWeight);
      sourceBeansToAdd.add(image1);
      if(extraimageToAdd!=null){
        sourceBeansToAdd.add(extraimageToAdd);
      }
      sourceBeansToAdd.add(threshCode);
      sourceBeansToAdd.add(threshValue);
      if(evenLevel){
        sourceBeansToAdd.add(evenLine);
      }else{
        sourceBeansToAdd.add(oddLine);
     
     
    } catch (SourceBeanException e) {
      logger.error("error while adding a line");
      return null;
    }

    List<KpiLine> children=kpiLine.getChildren();
    children = orderChildren(new ArrayList(),children);
    try {
     
    if(children!=null){
      for (Iterator iterator = children.iterator(); iterator.hasNext();) {
        KpiLine kpiLineChild = (KpiLine) iterator.next()
       
        Iterator it3 = sourceBeansToAdd.iterator();
        while(it3.hasNext()){
          SourceBean toAdd = (SourceBean)it3.next();
          bandDetailReport.setAttribute(toAdd);
       
        sourceBeansToAdd = new ArrayList()
       
          if (actualHeight+10<maxFirstSubTemplateHeight){
            List sourceBeansToAdd2 = newLine(kpiLineChild, level+1,!evenLevel);
            if (sourceBeansToAdd2!=null && !sourceBeansToAdd2.isEmpty()){
            Iterator it = sourceBeansToAdd2.iterator();
              while(it.hasNext()){
                SourceBean toAdd = (SourceBean)it.next();
                bandDetailReport.setAttribute(toAdd);
             
            }
          }else{
               
            //Add last subreport to the List
            increaseHeight(subTemplateBaseContent);
            subreports.add(subTemplateBaseContent);
            actualHeight = new Integer(0);
            subTemplateBaseContent = createNewSubReport(countSubreports);
            countSubreports ++;
            //Get my bandDetailReport from new subreport
            subtitleSB=(SourceBean)subTemplateBaseContent.getAttribute("title");
            bandDetailReport=(SourceBean)subtitleSB.getAttribute("BAND");
            //change subtemplatesummary
            subSummarySB=(SourceBean)subTemplateBaseContent.getAttribute("summary");
            bandSummaryReport=(SourceBean)subSummarySB.getAttribute("BAND")
            //NEW SUBREPORT
            List sourceBeansToAdd2 = newLine(kpiLineChild, level+1,!evenLevel);
            if (sourceBeansToAdd2!=null && !sourceBeansToAdd2.isEmpty()){
            Iterator it2 = sourceBeansToAdd2.iterator();
              while(it2.hasNext()){
                SourceBean toAdd = (SourceBean)it2.next();
                bandDetailReport.setAttribute(toAdd);
             
            }
          }
        }
View Full Code Here

      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);
          image1.setAttribute("reportElement.y", yValue.toString());
          SourceBean imageValue=(SourceBean)image1.getAttribute("imageExpression");
          imageValue.setCharacters(urlPng);
         
        }
      }

      separatorline.setAttribute("reportElement.y", new Integer(yValue.intValue()+16).toString());
View Full Code Here

            String parametersString = dataSet.getParameters();
   
            ArrayList<String> parameters = new ArrayList<String>();
            logger.debug("Dataset Parameters loaded");
            if(parametersString != null){
              SourceBean source = SourceBean.fromXMLString(parametersString);
              if(source.getName().equals("PARAMETERSLIST")) {
                List<SourceBean> rows = source.getAttributeAsList("ROWS.ROW");
                for(int i=0; i< rows.size(); i++){
                  SourceBean row = rows.get(i);
                  String name = (String)row.getAttribute("name");
                  parameters.add(name);
                }
              }
              JSONArray paramsJSON = serializeParametersList(parameters, relations);
              JSONObject paramsResponseJSON = createJSONResponseResources(paramsJSON, parameters.size());
              writeBackToClient(new JSONSuccess(paramsResponseJSON));
            }else{
              writeBackToClient(new JSONSuccess(new JSONObject()));
            }
          }else{
            writeBackToClient(new JSONSuccess(new JSONObject()));
          }
        }else{
          writeBackToClient(new JSONSuccess(new JSONObject()));
        }

      } catch (Throwable e) {
        logger.error("Exception occurred while retrieving kpi links", e);
        throw new SpagoBIServiceException(SERVICE_NAME,
            "Exception occurred while retrieving kpi links", e);
      }
    } else if (serviceType != null  && serviceType.equalsIgnoreCase(KPI_LINKS_BY_DS)) {     
      try {
        String labelDS = getAttributeAsString("label");
        //looks up for relations
        ArrayList <KpiRel> relations = new ArrayList <KpiRel>();

        //looks up for dataset parameters       
        IDataSet dataSet = DAOFactory.getDataSetDAO().loadActiveDataSetByLabel(labelDS);
        String parametersString = dataSet.getParameters();

        ArrayList<String> parameters = new ArrayList<String>();
        logger.debug("Dataset Parameters loaded");
        if(parametersString != null){
          SourceBean source = SourceBean.fromXMLString(parametersString);
          if(source.getName().equals("PARAMETERSLIST")) {
            List<SourceBean> rows = source.getAttributeAsList("ROWS.ROW");
            for(int i=0; i< rows.size(); i++){
              SourceBean row = rows.get(i);
              String name = (String)row.getAttribute("name");
              parameters.add(name);
            }
          }
          JSONArray paramsJSON = serializeParametersList(parameters, relations);
          JSONObject paramsResponseJSON = createJSONResponseResources(paramsJSON, parameters.size());
View Full Code Here

  public List newThresholdBlock( SourceBean bandDetailReport){
    logger.debug("IN");
    List sourceBeansToAdd = new ArrayList();
      try{//Draws the Threshold Band and Title
        actualHeight+=separatorModelsHeight;
        SourceBean thresholdBand1=new SourceBean(thresholdBand)
        SourceBean thresholdTitle1=new SourceBean(thresholdTitle);
       
        thresholdBand1.setAttribute("reportElement.y",actualHeight.toString());
        thresholdTitle1.setAttribute("reportElement.y",actualHeight.toString())
       
        sourceBeansToAdd.add(thresholdBand1);
        sourceBeansToAdd.add(thresholdTitle1);
       
        actualHeight+=columnHeaderHeight;
View Full Code Here

TOP

Related Classes of it.eng.spago.base.SourceBean

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.