Package it.eng.spagobi.tools.scheduler.to

Examples of it.eng.spagobi.tools.scheduler.to.SaveInfo


    TriggerInfo tInfo = (TriggerInfo)sessionContainer.getAttribute(SpagoBIConstants.TRIGGER_INFO);
    String idObjStr = treename.substring(5);
    String indexStr = idObjStr.substring(idObjStr.lastIndexOf("__"));
    Integer idBiobj = Integer.valueOf(idObjStr.substring(0, idObjStr.lastIndexOf("__")));
    Map saveOpts = tInfo.getSaveOptions();
    SaveInfo sInfo = (SaveInfo)saveOpts.get(idBiobj+indexStr);
    String functIdsConcat = sInfo.getFunctionalityIds();
    String[] functIds =  functIdsConcat.split(",");
    for(int i=0; i<functIds.length; i++) {
      String functIdStr = functIds[i];
      if(functIdStr.trim().equals(""))
        continue;
View Full Code Here


    List biobjIds = jInfo.getBiobjectIds();
    Iterator iterBiobjIds = biobjIds.iterator();
    int index = 0;
    while(iterBiobjIds.hasNext()) {
      index ++;
      SaveInfo sInfo = new SaveInfo();
      Integer biobjid = (Integer)iterBiobjIds.next();
      SourceBean objParSB = (SourceBean)triggerDetSB.getFilteredSourceBeanAttribute("JOB_PARAMETERS.JOB_PARAMETER", "name", "biobject_id_" + biobjid.toString()+"__"+index);
      if(objParSB!=null) {
        String parString = (String)objParSB.getAttribute("value");
        sInfo = SchedulerUtilities.fromSaveInfoString(parString);
View Full Code Here

   * @param saveinfostr the saveinfostr
   *
   * @return the save info
   */
  public static SaveInfo fromSaveInfoString(String saveinfostr) {
    SaveInfo sInfo = new SaveInfo();
    String[] couples = saveinfostr.split("%26");
    for(int i=0; i<couples.length; i++) {
      String couple = couples[i];
      if(couple.trim().equals("")) {
        continue;
      }
      String[] couplevals = couple.split("=");
      String name = couplevals[0];
      String value = couplevals[1];
      if(name.equals("saveassnapshot")) {
        sInfo.setSaveAsSnapshot(true);
      }
      if(name.equals("snapshotname")) {
        sInfo.setSnapshotName(value);
      }
      if(name.equals("snapshotdescription")) {
        sInfo.setSnapshotDescription(value);
      }
      if(name.equals("snapshothistorylength")) {
        sInfo.setSnapshotHistoryLength(value);
      }
      if(name.equals("sendtojavaclass")) {
        sInfo.setSendToJavaClass(true);
      }
      if(name.equals("javaclasspath")) {
        sInfo.setJavaClassPath(value);
      }
      if(name.equals("saveasdocument")) {
        sInfo.setSaveAsDocument(true);
      }
      if(name.equals("documentname")) {
        sInfo.setDocumentName(value);
      }
      if(name.equals("documentdescription")) {
        sInfo.setDocumentDescription(value);
      }
      if(name.equals("documenthistorylength")) {
        sInfo.setDocumentHistoryLength(value);
      }
      if(name.equals("datasetFolderLabel")) {
        sInfo.setUseFolderDataSet(true);
        sInfo.setDataSetFolderLabel(value);
      }
      if(name.equals("datasetFolderParameterLabel")) {
        sInfo.setDataSetFolderParameterLabel(value);
      }
      if(name.equals("functionalityids")) {
        sInfo.setUseFixedFolder(true);
        sInfo.setFunctionalityIds(value);
      }
      if(name.equals("sendmail")) {
        sInfo.setSendMail(true);
      }
      if(name.equals("mailtos")) {
        sInfo.setUseFixedRecipients(true);
        sInfo.setMailTos(value);
      }
      if(name.equals("datasetLabel")) {
        sInfo.setUseDataSet(true);
        sInfo.setDataSetLabel(value);
      }
      if(name.equals("datasetParameterLabel")) {
        sInfo.setDataSetParameterLabel(value);
      }
      if(name.equals("expression")) {
        sInfo.setUseExpression(true);
        sInfo.setExpression(value);
      }
      if(name.equals("mailsubj")) {
        sInfo.setMailSubj(value);
      }
      if(name.equals("mailtxt")) {
        sInfo.setMailTxt(value);
      }
      if(name.equals("sendtodl")) {
        sInfo.setSendToDl(true);
      }
      if(name.equals("dlId")) {
       
        String[] dlIds = value.split(",");
        for (int j=0; j<dlIds.length; j++){
          String dlId = dlIds[j];         
          sInfo.addDlId(new Integer(dlId));
        }
       
        sInfo.setSendToDl(true);
      }
    }
    return sInfo;
  }
View Full Code Here

      List biobjIds = jobInfo.getBiobjectIds();
      Iterator iterBiobjIds = biobjIds.iterator();
      int index = 0;
      while(iterBiobjIds.hasNext()){
        index ++;
        SaveInfo sInfo = new SaveInfo();
        Integer biobId = (Integer)iterBiobjIds.next();
        String saveassnap = (String)request.getAttribute("saveassnapshot_"+biobId+"__"+index)
        if(saveassnap!=null) {
          sInfo.setSaveAsSnapshot(true);
          String snapname = (String)request.getAttribute("snapshotname_"+biobId+"__"+index)
          sInfo.setSnapshotName(snapname);
          String snapdescr = (String)request.getAttribute("snapshotdescription_"+biobId+"__"+index);
          sInfo.setSnapshotDescription(snapdescr);
          String snaphistlength = (String)request.getAttribute("snapshothistorylength_"+biobId+"__"+index);
          sInfo.setSnapshotHistoryLength(snaphistlength);
       
     
        String sendToJavaClass = (String)request.getAttribute("sendtojavaclass_"+biobId+"__"+index)
        if(sendToJavaClass!=null) {
          sInfo.setSendToJavaClass(true);
          String javaClassPath = (String)request.getAttribute("javaclasspath_"+biobId+"__"+index)
          JavaClassDestination tryClass=null;
          try{
          tryClass=(JavaClassDestination)Class.forName(javaClassPath).newInstance();
          }
          catch (ClassCastException e) {
            logger.error("Error in istantiating class");
            EMFValidationError emfError=new EMFValidationError(EMFErrorSeverity.ERROR, "sendtojavaclass_"+biobId+"__"+index, "12200");
            errorHandler.addError(emfError);
         
          }       
          catch (Exception e) {
            logger.error("Error in istantiating class");
            EMFValidationError emfError=new EMFValidationError(EMFErrorSeverity.ERROR, "sendtojavaclass_"+biobId+"__"+index, "12100");
            errorHandler.addError(emfError);
          }         
          sInfo.setJavaClassPath(javaClassPath);
       
       
       
        String saveasdoc = (String)request.getAttribute("saveasdocument_"+biobId+"__"+index)
        if(saveasdoc!=null) {
          sInfo.setSaveAsDocument(true);
          String docname = (String)request.getAttribute("documentname_"+biobId+"__"+index)
          sInfo.setDocumentName(docname);
          String docdescr = (String)request.getAttribute("documentdescription_"+biobId+"__"+index)
          sInfo.setDocumentDescription(docdescr);
          boolean useFixedFolder = "true".equalsIgnoreCase((String) request.getAttribute("useFixedFolder_"+biobId+"__"+index));
          sInfo.setUseFixedFolder(useFixedFolder);
          if (useFixedFolder) {
            String functIdsConcat = "";
            String tmpValReq = "tree_"+biobId+"__"+index+"_funct_id";
            List functIds = request.getAttributeAsList(tmpValReq)
            Iterator iterFunctIds = functIds.iterator();
            while(iterFunctIds.hasNext()) {
              String idFunct = (String)iterFunctIds.next();
              functIdsConcat += idFunct;
              if(iterFunctIds.hasNext()){
                functIdsConcat += ",";
              }
            }
            sInfo.setFunctionalityIds(functIdsConcat);
          }
          //gestire acquisizione folder
          boolean useFolderDataset = "true".equalsIgnoreCase((String) request.getAttribute("useFolderDataset_"+biobId+"__"+index));
          sInfo.setUseFolderDataSet(useFolderDataset);
          if (useFolderDataset) {
            String dsLabel = (String)request.getAttribute("datasetFolderLabel_"+biobId+"__"+index)
            sInfo.setDataSetFolderLabel(dsLabel);
            String datasetParameterLabel = (String)request.getAttribute("datasetFolderParameter_"+biobId+"__"+index)
            sInfo.setDataSetFolderParameterLabel(datasetParameterLabel);
            if (dsLabel == null || dsLabel.trim().equals("")) {
              BIObject biobj = DAOFactory.getBIObjectDAO().loadBIObjectById(biobId);
              List params = new ArrayList();
              params.add(biobj.getName());
              this.getErrorHandler().addError(new EMFValidationError(EMFErrorSeverity.ERROR, null, "errors.trigger.missingDataSet", params, "component_scheduler_messages"));
            }
            if (datasetParameterLabel == null || datasetParameterLabel.trim().equals("")) {
              BIObject biobj = DAOFactory.getBIObjectDAO().loadBIObjectById(biobId);
              List params = new ArrayList();
              params.add(biobj.getName());
              this.getErrorHandler().addError(new EMFValidationError(EMFErrorSeverity.ERROR, null, "errors.trigger.missingDataSetParameter", params, "component_scheduler_messages"));
            }
          //  sInfo.setFunctionalityIds(functIdsConcat);
          }
        }
        String sendmail = (String)request.getAttribute("sendmail_"+biobId+"__"+index)
        if(sendmail!=null) {
          sInfo.setSendMail(true);
          boolean useFixedRecipients = "true".equalsIgnoreCase((String) request.getAttribute("useFixedRecipients_"+biobId+"__"+index));
          sInfo.setUseFixedRecipients(useFixedRecipients);
          if (useFixedRecipients) {
            String mailtos = (String)request.getAttribute("mailtos_"+biobId+"__"+index);
            sInfo.setMailTos(mailtos);
            if (mailtos == null || mailtos.trim().equals("")) {
              BIObject biobj = DAOFactory.getBIObjectDAO().loadBIObjectById(biobId);
              List params = new ArrayList();
              params.add(biobj.getName());
              this.getErrorHandler().addError(new EMFValidationError(EMFErrorSeverity.ERROR, null, "errors.trigger.missingFixedRecipients", params, "component_scheduler_messages"));
            }
          }
          boolean useDataset = "true".equalsIgnoreCase((String) request.getAttribute("useDataset_"+biobId+"__"+index));
          sInfo.setUseDataSet(useDataset);
          if (useDataset) {
            String dsLabel = (String)request.getAttribute("datasetLabel_"+biobId+"__"+index)
            sInfo.setDataSetLabel(dsLabel);
            String datasetParameterLabel = (String)request.getAttribute("datasetParameter_"+biobId+"__"+index)
            sInfo.setDataSetParameterLabel(datasetParameterLabel);
            if (dsLabel == null || dsLabel.trim().equals("")) {
              BIObject biobj = DAOFactory.getBIObjectDAO().loadBIObjectById(biobId);
              List params = new ArrayList();
              params.add(biobj.getName());
              this.getErrorHandler().addError(new EMFValidationError(EMFErrorSeverity.ERROR, null, "errors.trigger.missingDataSet", params, "component_scheduler_messages"));
            }
            if (datasetParameterLabel == null || datasetParameterLabel.trim().equals("")) {
              BIObject biobj = DAOFactory.getBIObjectDAO().loadBIObjectById(biobId);
              List params = new ArrayList();
              params.add(biobj.getName());
              this.getErrorHandler().addError(new EMFValidationError(EMFErrorSeverity.ERROR, null, "errors.trigger.missingDataSetParameter", params, "component_scheduler_messages"));
            }
          }
          boolean useExpression = "true".equalsIgnoreCase((String) request.getAttribute("useExpression_"+biobId+"__"+index));
          sInfo.setUseExpression(useExpression);
          if (useExpression) {
            String expression = (String)request.getAttribute("expression_"+biobId+"__"+index)
            sInfo.setExpression(expression);
            if (expression == null || expression.trim().equals("")) {
              BIObject biobj = DAOFactory.getBIObjectDAO().loadBIObjectById(biobId);
              List params = new ArrayList();
              params.add(biobj.getName());
              this.getErrorHandler().addError(new EMFValidationError(EMFErrorSeverity.ERROR, null, "errors.trigger.missingExpression", params, "component_scheduler_messages"));
            }
          }
         
          if (!useFixedRecipients && !useDataset && !useExpression) {
            BIObject biobj = DAOFactory.getBIObjectDAO().loadBIObjectById(biobId);
            List params = new ArrayList();
            params.add(biobj.getName());
            this.getErrorHandler().addError(new EMFValidationError(EMFErrorSeverity.ERROR, null, "errors.trigger.missingRecipients", params, "component_scheduler_messages"))
          }
         
          String mailsubj = (String)request.getAttribute("mailsubj_"+biobId+"__"+index)
          sInfo.setMailSubj(mailsubj);
          String mailtxt = (String)request.getAttribute("mailtxt_"+biobId+"__"+index)
          sInfo.setMailTxt(mailtxt);
        }
        String sendtodl = (String)request.getAttribute("saveasdl_"+biobId+"__"+index)
        if(sendtodl!=null) {
          sInfo.setSendToDl(true);
          sInfo.setBiobjId(biobId.intValue());
          List dlist = DAOFactory.getDistributionListDAO().loadAllDistributionLists()
          Iterator it = dlist.iterator();
          while(it.hasNext()){
            DistributionList dl = (DistributionList)it.next();
            int dlId = dl.getId();
            String listID = (String)request.getAttribute("sendtodl_"+dlId+"_"+biobId+"__"+index);
            if(listID!=null){
              sInfo.addDlId(new Integer(listID));
            }
            else{
             
              DAOFactory.getDistributionListDAO().eraseDistributionListObjects(dl,biobId.intValue(),triggername);
            }
View Full Code Here

        Iterator iterbiobjids = biobjids.iterator();
        int index = 0;
        while(iterbiobjids.hasNext()) {
          index ++;
          Integer idobj = (Integer)iterbiobjids.next();
          saveOptions.put(idobj+"__" + index, new SaveInfo());
        }
        ti.setSaveOptions(saveOptions);
      } else {
        throw new Exception("Cannot recover job " + jobName);
      }   
View Full Code Here

   
    message.append("   <PARAMETERS>");
    while(iterbiobjids_s.hasNext()) {
      String biobjidstr_so =  (String)iterbiobjids_s.next();
    //  Integer biobjid_so = Integer.valueOf(biobjidstr_so.substring(0, biobjidstr_so.lastIndexOf("__")));
      SaveInfo sInfo = (SaveInfo)saveOptions.get(biobjidstr_so);
      String saveOptString = "";
      if(sInfo.isSaveAsSnapshot()) {
        saveOptString += "saveassnapshot=true%26";
        if( (sInfo.getSnapshotName()!=null) && !sInfo.getSnapshotName().trim().equals("") ) {
          saveOptString += "snapshotname="+sInfo.getSnapshotName()+"%26";
        }
        if( (sInfo.getSnapshotDescription()!=null) && !sInfo.getSnapshotDescription().trim().equals("") ) {
          saveOptString += "snapshotdescription="+sInfo.getSnapshotDescription()+"%26";
        }
        if( (sInfo.getSnapshotHistoryLength()!=null) && !sInfo.getSnapshotHistoryLength().trim().equals("") ) {
          saveOptString += "snapshothistorylength="+sInfo.getSnapshotHistoryLength()+"%26";
        }
      }
      if(sInfo.isSendToJavaClass()) {
        saveOptString += "sendtojavaclass=true%26";
        if( (sInfo.getJavaClassPath()!=null) && !sInfo.getJavaClassPath().trim().equals("") ) {
          saveOptString += "javaclasspath="+sInfo.getJavaClassPath()+"%26";
        }
      }     
      if(sInfo.isSaveAsDocument()) {
        saveOptString += "saveasdocument=true%26";
        if( (sInfo.getDocumentName()!=null) && !sInfo.getDocumentName().trim().equals("") ) {
          saveOptString += "documentname="+sInfo.getDocumentName()+"%26";
        }
        if( (sInfo.getDocumentDescription()!=null) && !sInfo.getDocumentDescription().trim().equals("") ) {
          saveOptString += "documentdescription="+sInfo.getDocumentDescription()+"%26";
        }
        if(sInfo.isUseFixedFolder() && sInfo.getFoldersTo() != null && !sInfo.getFoldersTo().trim().equals("")) {
          saveOptString += "foldersTo="+sInfo.getFoldersTo()+"%26";
        }
        if(sInfo.isUseFolderDataSet() && sInfo.getDataSetFolderLabel() != null && !sInfo.getDataSetFolderLabel().trim().equals("")) {
          saveOptString += "datasetFolderLabel="+sInfo.getDataSetFolderLabel()+"%26";
          if (sInfo.getDataSetFolderParameterLabel() != null && !sInfo.getDataSetFolderParameterLabel().trim().equals("")) {
            saveOptString += "datasetFolderParameterLabel="+sInfo.getDataSetFolderParameterLabel()+"%26";
          }
        }
        if( (sInfo.getDocumentHistoryLength()!=null) && !sInfo.getDocumentHistoryLength().trim().equals("") ) {
          saveOptString += "documenthistorylength="+sInfo.getDocumentHistoryLength()+"%26";
        }
        if( (sInfo.getFunctionalityIds()!=null) && !sInfo.getFunctionalityIds().trim().equals("") ) {
          saveOptString += "functionalityids="+sInfo.getFunctionalityIds()+"%26";
        }
      }
      if(sInfo.isSendMail()) {
        saveOptString += "sendmail=true%26";
        if(sInfo.isUseFixedRecipients() && sInfo.getMailTos() != null && !sInfo.getMailTos().trim().equals("")) {
          saveOptString += "mailtos="+sInfo.getMailTos()+"%26";
        }
        if(sInfo.isUseDataSet() && sInfo.getDataSetLabel() != null && !sInfo.getDataSetLabel().trim().equals("")) {
          saveOptString += "datasetLabel="+sInfo.getDataSetLabel()+"%26";
          if (sInfo.getDataSetParameterLabel() != null && !sInfo.getDataSetParameterLabel().trim().equals("")) {
            saveOptString += "datasetParameterLabel="+sInfo.getDataSetParameterLabel()+"%26";
          }
        }
        if(sInfo.isUseExpression() && sInfo.getExpression() != null && !sInfo.getExpression().trim().equals("")) {
          saveOptString += "expression="+sInfo.getExpression()+"%26";
        }
        if( (sInfo.getMailSubj()!=null) && !sInfo.getMailSubj().trim().equals("") ) {
          saveOptString += "mailsubj="+sInfo.getMailSubj()+"%26";
        }
        if( (sInfo.getMailTxt()!=null) && !sInfo.getMailTxt().trim().equals("") ) {
          saveOptString += "mailtxt="+sInfo.getMailTxt()+"%26";
        }
      }
      if(sInfo.isSendToDl()) {
        String xml = "";
        if(!runImmediately){
          xml += "<SCHEDULE ";
          xml += " jobName=\""+jInfo.getJobName()+"\" ";         
          xml += " triggerName=\""+tInfo.getTriggerName()+"\" ";         
          xml += " startDate=\""+tInfo.getStartDate()+"\" ";         
          xml += " startTime=\""+tInfo.getStartTime()+"\" ";         
          xml += " chronString=\""+tInfo.getChronString()+"\" ";
          String enddate = tInfo.getEndDate();
          String endtime = tInfo.getEndTime();
          if(!enddate.trim().equals("")){
            xml += " endDate=\""+enddate+"\" ";
            if(!endtime.trim().equals("")){
              xml += " endTime=\""+endtime+"\" ";
            }
          }     
          if(!repeatinterval.trim().equals("")){
            xml += " repeatInterval=\""+repeatinterval+"\" ";
         
          xml += ">";
         
          String params = "<PARAMETERS>";
         
          List biObjects = jInfo.getBiobjects();
          Iterator iterbiobj = biObjects.iterator();
          int index = 0;
          while (iterbiobj.hasNext()){
            index ++;
            BIObject biobj = (BIObject)iterbiobj.next();
            String objpref = biobj.getId().toString()+"__" + new Integer(index).toString();
            if(biobjidstr_so.equals(objpref)){
           
            List pars = biobj.getBiObjectParameters();
            Iterator iterPars = pars.iterator();
            String queryString= "";
            while(iterPars.hasNext()) {
              BIObjectParameter biobjpar = (BIObjectParameter)iterPars.next();
              String concatenatedValue = "";
              List values = biobjpar.getParameterValues();
              if(values!=null) {
                Iterator itervalues = values.iterator();
                while(itervalues.hasNext()) {
                  String value = (String)itervalues.next();
                  concatenatedValue += value + ",";
                }
                if(concatenatedValue.length()>0) {
                  concatenatedValue = concatenatedValue.substring(0, concatenatedValue.length() - 1);
                  queryString += biobjpar.getParameterUrlName() + "=" + concatenatedValue + "%26";
                }
              }
            }
            if(queryString.length()>0) {
              queryString = queryString.substring(0, queryString.length()-3);
            }
            params += "<PARAMETER name=\""+biobj.getLabel()+"__"+index+"\" value=\""+queryString+"\" />";
            }else
              continue;
            }
          }
          params += "</PARAMETERS>";
         
          xml += params ;
          xml += "</SCHEDULE>";
        }
       
        saveOptString += "sendtodl=true%26";
       
        List l= sInfo.getDlIds();
        if(!l.isEmpty()){
         
          String dlIds = "dlId=";
          int objId = sInfo.getBiobjId();
          Iterator iter = l.iterator();
          while (iter.hasNext()){
           
            Integer dlId = (Integer)iter.next();
            try {if(!runImmediately){
View Full Code Here

        // load bidocument
        biobj = biobjdao.loadBIObjectByLabel(documentLabel);
       
        // get the save options
        String saveOptString = jobDataMap.getString("biobject_id_" + biobj.getId() + "__"+ (ind+1));
        SaveInfo saveInfo = SchedulerUtilities.fromSaveInfoString(saveOptString);
       
        // create the execution controller
        executionController = new ExecutionController();
        executionController.setBiObject(biobj);
       
        // fill parameters
        executionController.refreshParameters(biobj, inputParametersQueryString);

        String iterativeParametersString = jobDataMap.getString(documentInstanceName + "_iterative");
        logger.debug("Iterative parameter configuration for documet [" + documentLabel + "] is equal to [" + iterativeParametersString + "]");
        setIterativeParameters(biobj, iterativeParametersString);
       
        String loadAtRuntimeParametersString = jobDataMap.getString(documentInstanceName + "_loadAtRuntime");
        logger.debug("Runtime parameter configuration for documet [" + documentLabel + "] is equal to [" + loadAtRuntimeParametersString + "]");
        setLoadAtRuntimeParameters(biobj, loadAtRuntimeParametersString);
       
        String useFormulaParametersString = jobDataMap.getString(documentInstanceName + "_useFormula");
        logger.debug("Formuula based parameter configuration for documet [" + documentLabel + "] is equal to [" + useFormulaParametersString + "]");
        setUseFormulaParameters(biobj, useFormulaParametersString);

        retrieveParametersValues(biobj);

        //gets the dataset data about the email address
        IDataStore emailDispatchDataStore = null;
        if (saveInfo.isUseDataSet()) {
          IDataSet dataSet = DAOFactory.getDataSetDAO().loadActiveDataSetByLabel(saveInfo.getDataSetLabel());
          dataSet.setUserProfileAttributes(UserProfileUtils.getProfileAttributes(profile));
          dataSet.loadData();
          emailDispatchDataStore = dataSet.getDataStore();
        }
        //gets the dataset data about the folder for the document save
        IDataStore folderDispatchDataSotre = null;
        if (saveInfo.isUseFolderDataSet()) {
          IDataSet dataSet = DAOFactory.getDataSetDAO().loadActiveDataSetByLabel(saveInfo.getDataSetFolderLabel());
            dataSet.setUserProfileAttributes(UserProfileUtils.getProfileAttributes(profile));
          dataSet.loadData();
           folderDispatchDataSotre = dataSet.getDataStore();
        }
       
        eventManager = EventsManager.getInstance();
        List roles = DAOFactory.getBIObjectDAO().getCorrectRolesForExecution(biobj.getId());
       
        String startExecMsg = "${scheduler.startexecsched} " + biobj.getName()
        Integer idEvent = eventManager.registerEvent("Scheduler", startExecMsg, "", roles);

       
        Map tempParMap = new HashMap();
        BIObjectParametersIterator objectParametersIterator = new BIObjectParametersIterator(biobj.getBiObjectParameters());
        while (objectParametersIterator.hasNext()) {
          List parameters = (List) objectParametersIterator.next();
          biobj.setBiObjectParameters(parameters);
       

          StringBuffer toBeAppendedToName = new StringBuffer();
          StringBuffer toBeAppendedToDescription = new StringBuffer(" [");
          Iterator parametersIt = parameters.iterator();
          while (parametersIt.hasNext()) {
           
            BIObjectParameter aParameter = (BIObjectParameter) parametersIt.next();
           
            tempParMap.put(aParameter.getParameterUrlName(), aParameter.getParameterValuesAsString());
            if (aParameter.isIterative()) {
              toBeAppendedToName.append("_" + aParameter.getParameterValuesAsString());
              toBeAppendedToDescription.append(aParameter.getLabel() + ":" + aParameter.getParameterValuesAsString() + "; ");
            }
          }
          // if there are no iterative parameters, toBeAppendedToDescription is " [" and must be cleaned
          if (toBeAppendedToDescription.length() == 2) {
            toBeAppendedToDescription.delete(0, 2);
          } else {
            // toBeAppendedToDescription ends with "; " and must be cleaned
            toBeAppendedToDescription.delete(toBeAppendedToDescription.length() - 2, toBeAppendedToDescription.length());
            toBeAppendedToDescription.append("]");
          }

          // appending the current date
          Date date = new Date();
          SimpleDateFormat sdf = new SimpleDateFormat();
          sdf.applyPattern("dd:MM:yyyy");
          String dateStr = sdf.format(date);
          toBeAppendedToName.append("_" + dateStr);
         
         

          //check parameters value: if a parameter hasn't value but isn't mandatory the process
          //must go on and so hasValidValue is set to true
          List tmpBIObjectParameters = biobj.getBiObjectParameters();
          Iterator it = tmpBIObjectParameters.iterator();
          while (it.hasNext()){
            boolean isMandatory = false;
            BIObjectParameter aBIObjectParameter = (BIObjectParameter)it.next();
            List checks = aBIObjectParameter.getParameter().getChecks();
            if (checks != null && !checks.isEmpty()) {
              Iterator checksIt = checks.iterator();
              while (checksIt.hasNext()) {
                Check check = (Check) checksIt.next();
                if (check.getValueTypeCd().equalsIgnoreCase("MANDATORY")) {
                  isMandatory = true;
                  break;
                }
              }
            }
            if (!isMandatory &&
                (aBIObjectParameter.getParameterValues() == null  || aBIObjectParameter.getParameterValues().size() == 0)) {
              aBIObjectParameter.setParameterValues(new ArrayList());
              aBIObjectParameter.setHasValidValues(true);
            }
          }


          // exec the document only if all its parameter are filled
          if(executionController.directExecution()) {
           
            logger.debug("Save as snapshot is eual to [" + saveInfo.isSaveAsSnapshot() + "]");
            logger.debug("Dispatch to a distribution list is eual to [" + saveInfo.isSendToDl() + "]");
            logger.debug("Dispatch to a java class is eual to [" + saveInfo.isSendToJavaClass() + "]");
            logger.debug("Dispatch by mail-list is eual to [" + saveInfo.isSendMail() + "]");
            logger.debug("Dispatch by folder-list is eual to [" + saveInfo.isSaveAsDocument() + "]");
           
            if(!saveInfo.isSaveAsSnapshot() && !saveInfo.isSendToDl() && !saveInfo.isSendToJavaClass()) {
              boolean noValidDispatchTarget = false;
              if(saveInfo.isSendMail()) {
                String[] recipients = findRecipients(saveInfo, biobj, emailDispatchDataStore);
                if (recipients != null && recipients.length > 0) {
                  noValidDispatchTarget = false;
                  logger.debug("Found at least one target of type mail");
                }else{
                  noValidDispatchTarget = true;
                }
              }
             
              if(saveInfo.isSaveAsDocument()) {
                List storeInFunctionalities = findFolders(saveInfo, biobj, folderDispatchDataSotre);
                if(storeInFunctionalities != null && !storeInFunctionalities.isEmpty()) {
                  noValidDispatchTarget = false;
                  logger.debug("Found at least one target of type folder");
                }else{
                  noValidDispatchTarget = true;
                }
              }
             
              if(noValidDispatchTarget) {
                logger.debug("No valid dispatch target for document [" + (ind+1) + "] with label [" + documentInstanceName + "] and parameters [" + toBeAppendedToDescription +"]");
                logger.info("Document [" + (ind+1) + "] with label [" + documentInstanceName + "] and parameters " + toBeAppendedToDescription + " not executed: no valid dispatch target");
                continue;
              } else if(!saveInfo.isSaveAsDocument() && !saveInfo.isSendMail()){
                logger.debug("There are no dispatch targets for document with label [" + documentInstanceName + "] - if not an ETL, WEKA or KPI document a dispatch target should be added");
              }else{
                logger.debug("There is at list one dispatch target for document with label [" + documentInstanceName + "]");
              }
            }

            executionProxy = new ExecutionProxy();
            executionProxy.setBiObject(biobj);
           
           
           
           
            logger.info("Executing document [" + (ind+1) + "] with label [" + documentInstanceName + "] and parameters " + toBeAppendedToDescription +" ...");
            long start = System.currentTimeMillis();
            byte[] response = executionProxy.exec(profile, "SCHEDULATION", null);
            if (response == null || response.length == 0) {
              logger.debug("Document executed without any response");
            }
            String retCT = executionProxy.getReturnedContentType();
            String fileextension = executionProxy.getFileExtensionFromContType(retCT);
            long end = System.currentTimeMillis();     
            long elapsed = (end - start)/1000;
            logger.info("Document [" + (ind+1) + "] with label [" + documentInstanceName + "] and parameters " + toBeAppendedToDescription +" executed in [" + elapsed + "]");
           
           
            if(saveInfo.isSaveAsSnapshot()) {
              saveAsSnap(saveInfo, biobj, response, toBeAppendedToName.toString(), toBeAppendedToDescription.toString(),profile);
            }

            if(saveInfo.isSaveAsDocument()) {
              saveAsDocument(saveInfo, biobj,jobExecutionContext, response, fileextension, folderDispatchDataSotre, toBeAppendedToName.toString(), toBeAppendedToDescription.toString());
            }

            if(saveInfo.isSendMail()) {
              sendMail(saveInfo, biobj, tempParMap, response, retCT, fileextension, emailDispatchDataStore, toBeAppendedToName.toString(), toBeAppendedToDescription.toString());
            }
            if(saveInfo.isSendToDl()) {
              sendToDl(saveInfo, biobj, response, retCT, fileextension, toBeAppendedToName.toString(), toBeAppendedToDescription.toString());
              if(jobExecutionContext.getNextFireTime()== null){
                String triggername = jobExecutionContext.getTrigger().getName();
                List dlIds = saveInfo.getDlIds();
                it = dlIds.iterator();
                while(it.hasNext()){
                  Integer dlId = (Integer)it.next();
                  DistributionList dl = DAOFactory.getDistributionListDAO().loadDistributionListById(dlId);
                  DAOFactory.getDistributionListDAO().eraseDistributionListObjects(dl, (biobj.getId()).intValue(), triggername);
                }
              }
            }

            if(saveInfo.isSendToJavaClass()) {
              sendToJavaClass(saveInfo, biobj, response);
            }


          } else {
View Full Code Here

  private void startEmailSession(Map<SbiAlarmContact, List<AlertSendingItem>> alertSendingSessionMap)
  {
      logger.debug("IN");
     
      Set<SbiAlarmContact> keySet = alertSendingSessionMap.keySet();
      SaveInfo sInfo = new SaveInfo();
     
                                            if(logger.isDebugEnabled())
                                            logger.debug("Distribution list parsing.");
     
      for(SbiAlarmContact sbiAlarmContact : keySet)
      {
                                            if(logger.isDebugEnabled())
                                            logger.debug("Found contact '"+sbiAlarmContact.getName()+"'.");
   
    List<AlertSendingItem> alertSendingList = alertSendingSessionMap.get(sbiAlarmContact);
   
    SbiAlarm sbiAlarm = null;
    SbiAlarmEvent sbiAlarmEvent = null;
   
    StringBuffer subject = new StringBuffer();
    StringBuffer text = new StringBuffer();
    for(AlertSendingItem alertSendingItem : alertSendingList)
    {
        sbiAlarm = alertSendingItem.getSbiAlarm();
        sbiAlarmEvent = alertSendingItem.getSbiAlarmEvent();
       
                                            if(logger.isDebugEnabled())
                                            logger.debug("Found alarm "+sbiAlarm.getName()+".");       
                   
                    subject.append(sbiAlarm.getLabel());
                   
        text.append("<font size=\"4\">Allarme </font><font color=\"red\" size=\"4\"><b>");
        text.append(sbiAlarm.getName());
        text.append("</b></font><ul>");
       
                    text.append("<li><font size=\"2\">Lable: ");
                    text.append(sbiAlarm.getLabel());
                    text.append("</font></li>");
                    text.append("<li><font size=\"2\">Text: ");
                    text.append(sbiAlarm.getText());
                    text.append("</font></li>");
                    text.append("<li><font size=\"2\">Description: ");
                    text.append(sbiAlarm.getDescr());
                    text.append("</font></li>");
        text.append("</ul><br>");
        text.append("<font size=\"3\">Dettaglio KPI:</font><ul>");
        text.append("<li><font size=\"2\">Name: ");
        text.append(sbiAlarmEvent.getKpiName());
                    text.append("</font></li>");
        text.append("<li><font size=\"2\">Date: ");
        text.append(sbiAlarmEvent.getEventTs());
                    text.append("</font></li>");
                    text.append("<li><font size=\"2\">Value: ");
                    text.append(sbiAlarmEvent.getKpiValue());
                    text.append("</font></li>");
                    text.append("<li><font size=\"2\">Threshold: ");
                    text.append(sbiAlarmEvent.getThresholdValue());
                    text.append("</font></li>");
       
        String res = sbiAlarmEvent.getResources();
        if(res!=null){
                        text.append("<li><font size=\"2\">resources:");
                        text.append(res);
                        text.append("</font></li>");
        }
       
        text.append("</ul><hr width=\"90%\">");
    }
   
    String link = sbiAlarm.getUrl();
   
    text.append(link);
   
    String email = sbiAlarmContact.getEmail();
    if(email!=null){
        sInfo.setMailTos(email);
        sInfo.setMailSubj("MGC alarm: "+new Date()+" ["+ sbiAlarmContact.getName()+"]");
        sInfo.setMailTxt(text.toString());
    }
   
                                            if(logger.isDebugEnabled())
                                            logger.debug("Sending email to: "+sInfo.getMailTos());
   
    sendMail(sInfo, null, null, null);
      }
     
      logger.debug("OUT");
View Full Code Here

TOP

Related Classes of it.eng.spagobi.tools.scheduler.to.SaveInfo

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.