Examples of BIObject


Examples of it.eng.spagobi.analiticalmodel.document.bo.BIObject

      Integer id = this.getAttributeAsInteger(SpagoBIConstants.OBJECT_ID);
      if(id==null){
        logger.error("Document id not found");
        return;
      }
      BIObject document=null;
      document = DAOFactory.getBIObjectDAO().loadBIObjectById(id);

      IEngUserProfile profile=getUserProfile();

      // CALL EXPORTER
View Full Code Here

Examples of it.eng.spagobi.analiticalmodel.document.bo.BIObject

      buffer = decoder.decodeBuffer(encodedTemplate);
      String template = new String(buffer);
      attributes.put("TEMPLATE", template);
      String label = (String) attributes.get("LABEL");
      BIObject obj = DAOFactory.getBIObjectDAO().loadBIObjectByLabel(label);
      if (obj == null) {
    obj = createBIObject();
    initBIObject(attributes, obj);
      } else {
    obj = updateBIObject(attributes, obj);
View Full Code Here

Examples of it.eng.spagobi.analiticalmodel.document.bo.BIObject

  logger.debug("OUT");
    }

    private BIObject createBIObject() {
  logger.debug("IN");
  BIObject obj = new BIObject();

  List functionalitites = new ArrayList();

  obj.setId(new Integer(0));
  obj.setEngine(null);
  obj.setDescription("");
  obj.setLabel("");
  obj.setName("");
  obj.setEncrypt(new Integer(0));
  obj.setVisible(new Integer(1));
  obj.setRelName("");
  obj.setStateID(null);
  obj.setStateCode("");
  obj.setBiObjectTypeID(null);
  obj.setBiObjectTypeCode("");
  obj.setFunctionalities(functionalitites);
  logger.debug("OUT");
  return obj;
    }
View Full Code Here

Examples of it.eng.spagobi.analiticalmodel.document.bo.BIObject

     
    }
    idxPar++;
    //add other input parameter of the crossed doc not refreshed (will get values by the request)
    try{
      BIObject obj = DAOFactory.getBIObjectDAO().loadBIObjectByLabel(objLabel);
      List objParams = obj.getBiObjectParameters();
      for (int j=0; j<objParams.size(); j++) {
        BIObjectParameter par = (BIObjectParameter)objParams.get(j);
        if (!param.containsValue(par.getParameterUrlName())) {
          param.setProperty("sbi_par_label_param_"+idxDoc+"_"+idxPar, par.getParameterUrlName());
          param.setProperty("default_value_param_"+idxDoc+"_"+idxPar, "");
View Full Code Here

Examples of it.eng.spagobi.analiticalmodel.document.bo.BIObject

        commit();

        //updates lucene index
          BIObjectDAOHibImpl daoObj = (BIObjectDAOHibImpl)DAOFactory.getBIObjectDAO();
          BIObject biObj = daoObj.toBIObject(obj);
        indexer.addBiobjToIndex(biObj);

        // TODO controllare che fa questo e se serve!!!
        //updateSubObject(obj, exportedObj.getBiobjId());
      }
View Full Code Here

Examples of it.eng.spagobi.analiticalmodel.document.bo.BIObject

     * @throws EMFUserError the EMF user error
     * @throws EMFInternalError the EMF internal error
     */
    public Content readTemplate(String user, String document, HashMap parameters) throws SecurityException, EMFUserError, EMFInternalError {
      Content content;
      BIObject biobj;
     
      logger.debug("IN");
   
      logger.debug("user: [" + user + "]");
    logger.debug("document: [" + document + "]");
   
      if (parameters == null) {
        logger.debug("Input parameters map is null. It will be considered as an empty map");
        parameters = new HashMap();
      }
   
    content = new Content();
    try {
        Integer id = new Integer(document);
        biobj = DAOFactory.getBIObjectDAO().loadBIObjectById(id);
        // only if the user is not Scheduler or Workflow system user or it is a call to retrieve a subreport,
        //check visibility on document and parameter values
        boolean checkNeeded = true;
        boolean modContained = parameters.containsKey("SBI_READ_ONLY_TEMPLATE");
        if(modContained){
           boolean onlytemplate = parameters.containsValue("true");
           if(onlytemplate){
             checkNeeded = false;
           }
        }
       
        if (checkNeeded && !UserProfile.isSchedulerUser(user) && !UserProfile.isWorkflowUser(user&& !isSubReportCall(biobj, parameters)) {
          checkRequestCorrectness(user, biobj, parameters);
        }
       
        IObjTemplateDAO tempdao = DAOFactory.getObjTemplateDAO();
        ObjTemplate temp = tempdao.getBIObjectActiveTemplate(biobj.getId());
        if (temp==null){
           logger.warn("The template dor document [" + id + "] is NULL");
           throw new SecurityException("The template dor document [" + id + "] is NULL");
        }
        byte[] template = temp.getContent();
View Full Code Here

Examples of it.eng.spagobi.analiticalmodel.document.bo.BIObject

     * @throws EMFUserError the EMF user error
     * @throws EMFInternalError the EMF internal error
     */
    public Content readTemplateByLabel(String user, String label, HashMap parameters) throws SecurityException, EMFUserError, EMFInternalError {
      Content content;
      BIObject biobj;
     
      logger.debug("IN");
   
      logger.debug("user: [" + user + "]");
    logger.debug("document: [" + label + "]");
   
   
    content = new Content();
    try {
        biobj = DAOFactory.getBIObjectDAO().loadBIObjectByLabel(label);
        // only if the user is not Scheduler or Workflow system user or it is a call to retrieve a subreport,
        //check visibility on document and parameter values
        if (!UserProfile.isSchedulerUser(user) && !UserProfile.isWorkflowUser(user&& !isSubReportCall(biobj, parameters)) {
          checkRequestCorrectness(user, biobj, parameters);
        }
       
        IObjTemplateDAO tempdao = DAOFactory.getObjTemplateDAO();
        ObjTemplate temp = tempdao.getBIObjectActiveTemplate(biobj.getId());
        if (temp==null){
           logger.warn("The template dor document [" + label + "] is NULL");
           throw new SecurityException("The template dor document [" + label + "] is NULL");
        }
        byte[] template = temp.getContent();
View Full Code Here

Examples of it.eng.spagobi.analiticalmodel.document.bo.BIObject

      SbiDistributionListsObjects dlo =(SbiDistributionListsObjects) it.next();
      SbiObjects so = dlo.getSbiObjects();
      BIObjectDAOHibImpl objDAO=null;
      try {
        objDAO = (BIObjectDAOHibImpl)DAOFactory.getBIObjectDAO();
        BIObject obj = objDAO.toBIObject(so);
        documents.add(obj);
      } catch (EMFUserError e) {

      }
View Full Code Here

Examples of it.eng.spagobi.analiticalmodel.document.bo.BIObject

        SourceBean docLblSB = (SourceBean)jobParSB.getFilteredSourceBeanAttribute("JOB_PARAMETER", "name", "documentLabels");
        String docLblStr = (String)docLblSB.getAttribute("value");
        String[] docLbls = docLblStr.split(",");
        for(int i=0; i<docLbls.length; i++) {
          //BIObject biobj = biobjdao.loadBIObjectByLabel(docLbls[i]);
          BIObject biobj = biobjdao.loadBIObjectByLabel(docLbls[i].substring(0, docLbls[i].indexOf("__")));
          List biobjpars = biobjpardao.loadBIObjectParametersById(biobj.getId());
          biobj.setBiObjectParameters(biobjpars);
          String biobjlbl = biobj.getLabel() + "__" + (i+1);
          SourceBean queryStringSB = (SourceBean)jobParSB.getFilteredSourceBeanAttribute("JOB_PARAMETER", "name", biobjlbl);
          SourceBean iterativeSB = (SourceBean)jobParSB.getFilteredSourceBeanAttribute("JOB_PARAMETER", "name", biobjlbl + "_iterative");
          List iterativeParameters = new ArrayList();
          if (iterativeSB != null) {
            String iterativeParametersStr = (String) iterativeSB.getAttribute("value");
View Full Code Here

Examples of it.eng.spagobi.analiticalmodel.document.bo.BIObject

   
    // par1=val1&par2=val2... for parameters already set in scheduled activity's configuration
    String inputParametersQueryString;
   
    IBIObjectDAO biobjdao;
    BIObject biobj;
    ExecutionController executionController;
    ExecutionProxy executionProxy;
    EventsManager eventManager;
   
    logger.debug("IN");
   
    try {
      profile = UserProfile.createSchedulerUserProfile();
      jobDataMap = jobExecutionContext.getMergedJobDataMap();
      biobjdao = DAOFactory.getBIObjectDAO();
     
      String doclabelsConcat = jobDataMap.getString("documentLabels");
      String[] docLabels = doclabelsConcat.split(",");
      Iterator itr = jobDataMap.keySet().iterator();
      while(itr.hasNext()) {
        Object key = itr.next();
        Object value = jobDataMap.get(key);
        logger.debug("jobDataMap parameter [" + key + "] is equal to [" + value + "]");
      }
     
      long startSchedule = System.currentTimeMillis();
      logger.debug("Scheduled activity contains [" + docLabels.length + "] documnt(s)");

      for(int ind = 0; ind < docLabels.length; ind++) {
        documentInstanceName = docLabels[ind];
        documentLabel = documentInstanceName.substring(0, documentInstanceName.lastIndexOf("__"));
        logger.debug("Processing document [" + (ind+1) + "] with label [" + documentLabel + "] ...");
       
        inputParametersQueryString = jobDataMap.getString(documentInstanceName);
        logger.debug("Input parameters query string for documet [" + documentLabel + "] is equal to [" + inputParametersQueryString + "]");
       
        // 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 {
            logger.warn("The document with label "+documentInstanceName+" cannot be executed directly, " +
            "maybe some prameters are not filled ");
            throw new Exception("The document with label "+documentInstanceName+" cannot be executed directly, " +
            "maybe some prameters are not filled ");
          }
        }
       
        String endExecMsg = "${scheduler.endexecsched} " + biobj.getName();
        eventManager.registerEvent("Scheduler", endExecMsg, "", roles);

      }

     
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.