Package it.eng.spagobi.analiticalmodel.document.bo

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


        logger.error("Document id not found");
        return;
      }

      Integer id=Integer.valueOf(idObject.toString());
      BIObject document=DAOFactory.getBIObjectDAO().loadBIObjectById(id);
      String docName=document.getName();

      //Recover user Id
      HashedMap parameters=new HashedMap();
      String userId=null;
      Object userIdO=serviceRequest.getAttribute("user_id")
View Full Code Here


    logger.debug("IN");
    if (document == null) {
      logger.warn("SDKDocument in input is null!!");
      return null;
    }
    BIObject obj = null;
    try {
      obj = new BIObject();
      obj.setId(document.getId());
      obj.setLabel(document.getLabel());
      obj.setName(document.getName());
      obj.setDescription(document.getDescription());
      obj.setDataSourceId(document.getDataSourceId());
      obj.setDataSetId(document.getDataSetId());

      IDomainDAO domainDAO = DAOFactory.getDomainDAO();

      // sets biobject type domain
      Domain type = domainDAO.loadDomainByCodeAndValue("BIOBJ_TYPE", document.getType());
      obj.setBiObjectTypeCode(type.getValueCd());
      obj.setBiObjectTypeID(type.getValueId());

      // sets biobject state domain
      Domain state = domainDAO.loadDomainByCodeAndValue("STATE", document.getState());
      obj.setStateCode(state.getValueCd());
      obj.setStateID(state.getValueId());

      // gets engine
      Engine engine = null;
      IEngineDAO engineDAO = DAOFactory.getEngineDAO();
      if (document.getEngineId() == null) {
        // if engine id is not specified take the first engine for the biobject type
        List engines = engineDAO.loadAllEnginesForBIObjectType(document.getType());
        if (engines.size() == 0) {
          throw new Exception("No engines defined for document type = [" + document.getType() + "]");
        }
        engine = (Engine) engines.get(0);
      } else {
        engine = engineDAO.loadEngineByID(document.getEngineId());
      }
      obj.setEngine(engine);

    } catch (Exception e) {
      logger.error("Error while converting SDKDocument into BIObject.", e);
      logger.debug("Returning null.");
      return null;
View Full Code Here

    try {
      if ((idObj == null) || idObj.trim().equals(""))
        return;
      IBIObjectDAO biobjDAO = DAOFactory.getBIObjectDAO();
      BIObject biobj = biobjDAO.loadBIObjectForDetail(new Integer(idObj));

      IDataSourceDAO dataSourceDao = DAOFactory.getDataSourceDAO();
      IDataSetDAO dataSetDao = DAOFactory.getDataSetDAO();
      // Data source, if present
      Integer objataSourceId = biobj.getDataSourceId();
      if (objataSourceId != null) {
        IDataSource ds = dataSourceDao.loadDataSourceByID(objataSourceId);
        exporter.insertDataSource(ds, session);
      }
     
      // Data set if present
      Integer objDataSetId = biobj.getDataSetId();
      if (objDataSetId != null) {

        GuiGenericDataSet genericDs = dataSetDao.loadDataSetById(objDataSetId);
        if(genericDs!=null){
          exporter.insertDataSet(genericDs, session);
        }

      }     

      // Engine if present, and data source if engine uses data source
      Engine engine = biobj.getEngine();
      if (engine.getUseDataSource() && engine.getDataSourceId() != null) {
        Integer engineDataSourceId = engine.getDataSourceId();
        IDataSource ds = dataSourceDao.loadDataSourceByID(engineDataSourceId);
        exporter.insertDataSource(ds, session);
      }

      exporter.insertEngine(engine, session);  
      exporter.insertBIObject(biobj, session, false); // do not insert dataset


      logger.debug("Export metadata associated to the object");
      IObjMetacontentDAO objMetacontentDAO = DAOFactory.getObjMetacontentDAO();
      //  get metacontents associated to object
      List metacontents = objMetacontentDAO.loadObjOrSubObjMetacontents(biobj.getId(), null);
      for (Iterator iterator = metacontents.iterator(); iterator.hasNext();) {
        ObjMetacontent metacontent = (ObjMetacontent) iterator.next();
        exporter.insertObjMetacontent(metacontent, session);
      }


      // if the document is a chart, export the relevant dataset that is referenced by the template
      boolean isChart = false;
      if (biobj.getBiObjectTypeCode().equalsIgnoreCase("DASH")
          && engine.getClassName() != null && engine.getClassName().equals("it.eng.spagobi.engines.chart.SpagoBIChartInternalEngine")) {
        isChart = true;
      }

      if (isChart) {
        ObjTemplate template = biobj.getActiveTemplate();
        if (template != null) {
          try {
            byte[] tempFileCont = template.getContent();
            String tempFileStr = new String(tempFileCont);
            SourceBean tempFileSB = SourceBean.fromXMLString(tempFileStr);
            SourceBean datasetnameSB = (SourceBean) tempFileSB.getFilteredSourceBeanAttribute("CONF.PARAMETER", "name", "confdataset");
            if (datasetnameSB != null) {
              String datasetLabel = (String) datasetnameSB.getAttribute("value");
              IDataSetDAO datasetDao = DAOFactory.getDataSetDAO();
              IDataSet dataset = datasetDao.loadActiveDataSetByLabel(datasetLabel);
              GuiGenericDataSet guiGenericDataSet = datasetDao.loadDataSetByLabel(datasetLabel);



              if (dataset == null) {
                logger.warn("Error while exporting dashboard with id " + idObj + " and label " + biobj.getLabel() + " : " +
                    "the template refers to a dataset with label " + datasetLabel + " that does not exist!");
              } else {
                exporter.insertDataSet(guiGenericDataSet, session);
              }
            }
          } catch (Exception e) {
            logger.error("Error while exporting dashboard with id " + idObj + " and label " + biobj.getLabel() + " : " +
            "could not find dataset reference in its template.");         
          }
        }
      }


      // use Types Manager to handle specific export types, by now only KPI and CONSOLE.. TODO with all types

      ITypesExportManager typeManager = TypesExportManagerFactory.createTypesExportManager(biobj, engine, exporter, this);
      // if null means it is not defined
      if (typeManager != null)
        typeManager.manageExport(biobj, session);


      //maps kpi export
      //      boolean isKpi = false;
      //      if (biobj.getBiObjectTypeCode().equalsIgnoreCase("KPI")
      //          && engine.getClassName() != null && engine.getClassName().equals("it.eng.spagobi.engines.kpi.SpagoBIKpiInternalEngine")) {
      //        isKpi = true;
      //      }

      //      if (isKpi) {
      //        List objsToInsert=new ArrayList();
      //        ObjTemplate template = biobj.getActiveTemplate();
      //        if (template != null) {
      //          try {
      //            byte[] tempFileCont = template.getContent();
      //            String tempFileStr = new String(tempFileCont);
      //            SourceBean tempFileSB = SourceBean.fromXMLString(tempFileStr);
      //
      //
      //            String modelInstanceLabel = (String) tempFileSB.getAttribute("model_node_instance");
      //
      //            // biObjectToInsert keeps track of objects that have to be inserted beacuse related to Kpi
      //
      //            if (modelInstanceLabel != null) {
      //              IModelInstanceDAO modelInstanceDao = DAOFactory.getModelInstanceDAO();
      //              ModelInstance modelInstance = modelInstanceDao.loadModelInstanceWithoutChildrenByLabel(modelInstanceLabel);
      //              if (modelInstance == null) {
      //                logger.warn("Error while exporting kpi with id " + idObj + " and label " + biobj.getLabel() + " : " +
      //                    "the template refers to a Model Instance with label " + modelInstanceLabel + " that does not exist!");
      //              } else {
      //                objsToInsert=exporter.insertAllFromModelInstance(modelInstance, session);
      //                //exporter.insertModelInstance(modelInstance, session);
      //              }
      //            }
      //          } catch (Exception e) {
      //            logger.error("Error while exporting kpi with id " + idObj + " and label " + biobj.getLabel());
      //            throw new EMFUserError(EMFErrorSeverity.ERROR, "8010", "component_impexp_messages");
      //
      //          }
      //        }
      //
      //        for (Iterator iterator = objsToInsert.iterator(); iterator.hasNext();) {
      //          Integer id = (Integer) iterator.next();
      //          BIObject obj=(BIObject)biobjDAO.loadBIObjectById(id);
      //          if(obj!=null){
      //            exportSingleObj(obj.getId().toString());
      //          }
      //          else{
      //            logger.error("Could not find object with id"+id);
      //          }
      //        }
      //
      //      }



      // maps catalogue export
      boolean isMap = false;
      if (biobj.getBiObjectTypeCode().equalsIgnoreCase("MAP")) isMap = true;
      if (isMap) {
        exporter.insertMapCatalogue(session);
      }

      if (exportSubObjects) {
        ISubObjectDAO subDao = DAOFactory.getSubObjectDAO();
        List subObjectLis = subDao.getSubObjects(biobj.getId());
        if (subObjectLis != null && !subObjectLis.isEmpty())
          exporter.insertAllSubObject(biobj, subObjectLis, session);
      }
      if (exportSnapshots) {
        ISnapshotDAO subDao = DAOFactory.getSnapshotDAO();
        List snapshotLis = subDao.getSnapshots(biobj.getId());
        if (snapshotLis != null && !snapshotLis.isEmpty())
          exporter.insertAllSnapshot(biobj, snapshotLis, session);
      }

      // insert functionalities and association with object
      List functs = biobj.getFunctionalities();
      Iterator iterFunct = functs.iterator();
      while (iterFunct.hasNext()) {
        Integer functId = (Integer) iterFunct.next();
        ILowFunctionalityDAO lowFunctDAO = DAOFactory.getLowFunctionalityDAO();
        LowFunctionality funct = lowFunctDAO.loadLowFunctionalityByID(functId, false);
        if (funct.getCodType().equals(SpagoBIConstants.USER_FUNCTIONALITY_TYPE_CODE)) {
          logger.debug("User folder [" + funct.getPath() + "] will be not exported.");
          // if the folder is a personal folder, it is not exported
          continue;
        }
        exporter.insertFunctionality(funct, session);
        exporter.insertObjFunct(biobj, funct, session);
      }
      // export parameters
      List biparams = biobjDAO.getBIObjectParameters(biobj);
      exportBIParamsBIObj(biparams, biobj);
      // export parameters dependecies
      exporter.insertBiParamDepend(biparams, session);

      // export subReport relation
      ISubreportDAO subRepDao = DAOFactory.getSubreportDAO();
      List subList = subRepDao.loadSubreportsByMasterRptId(biobj.getId());
      Iterator itersub = subList.iterator();
      while (itersub.hasNext()) {
        Subreport subRep = (Subreport) itersub.next();
        exporter.insertSubReportAssociation(subRep, session);
        exportSingleObj(subRep.getSub_rpt_id().toString());
View Full Code Here

      while (i.hasNext()) {
        KpiDocuments doc = (KpiDocuments) i.next();
        String label = doc.getBiObjLabel();

        IBIObjectDAO biobjDAO = DAOFactory.getBIObjectDAO();
        BIObject biobj = biobjDAO.loadBIObjectByLabel(label);
        if(biobj!=null){
          insertBIObject(biobj, session, true);
          doc.setBiObjId(biobj.getId());       
        }

        Integer origDocId = doc.getBiObjId();
        Criterion labelCriterrion = Expression.eq("label",label);
        Criteria criteria = session.createCriteria(SbiObjects.class);
View Full Code Here

      while (i.hasNext()) {
        KpiDocuments doc = (KpiDocuments) i.next();
        String label = doc.getBiObjLabel();

        IBIObjectDAO biobjDAO = DAOFactory.getBIObjectDAO();
        BIObject biobj = biobjDAO.loadBIObjectByLabel(label);
        if(biobj!=null){
          insertBIObject(biobj, session, true);
          doc.setBiObjId(biobj.getId());       
        }

        Integer origDocId = doc.getBiObjId();
        Criterion labelCriterrion = Expression.eq("label",label);
        Criteria criteria = session.createCriteria(SbiObjects.class);
View Full Code Here

    IBIObjectDAO biobjDAO = DAOFactory.getBIObjectDAO();

    for (Iterator iterator = objsToInsert.iterator(); iterator.hasNext();) {
      Integer id = (Integer) iterator.next();
      BIObject obj=(BIObject)biobjDAO.loadBIObjectById(id);
      if(obj!=null){
        exportManager.exportSingleObj(obj.getId().toString());
      }
      else{
        logger.error("Could not find object with id"+id);
      }
    }
View Full Code Here

        String imgFolder = urlBuilder.getResourceLinkByTheme(httpRequest, "/img/treefolder.gif",currTheme);
        String imgFolderOp = urlBuilder.getResourceLinkByTheme(httpRequest, "/img/treefolderopen.gif",currTheme);
        htmlStream.append("  treeCMS.add(" + idFolder + ", " + parentId + ",'" + name + "', 'javascript:linkEmpty()', '', '', '"+imgFolder+"', '"+imgFolderOp+"', '', 'menu" + requestIdentity + "(event, \\'"+path+"\\')');\n");
        List objects = folder.getBiObjects();
        for (Iterator it = objects.iterator(); it.hasNext(); ) {
          BIObject obj = (BIObject) it.next();
          String nameObj = obj.getName();
          Integer idObj = obj.getId();
          obj.getFunctionalities();
          String stateObj = obj.getStateCode();
          htmlStream.append("  treeCMS.add("+dTreeObjects--+", "+idFolder+",'"+nameObj+"', 'javascript:linkEmpty()', '', '', '', '', '', '', '"+ImportExportConstants.OBJECT_ID_PATHFUNCT+"', '"+idObj+"_"+path+"');\n");
        }
      }
    }
    logger.debug("OUT");
View Full Code Here

  private void editDocumentTemplateHandler(SourceBean request, SourceBean response) throws Exception {
    debug("editDocumentTemplateHandler", "start method");
    // get the id of the object
    String idStr = (String) request.getAttribute(ObjectsTreeConstants.OBJECT_ID);
    Integer biObjectID = new Integer(idStr);
    BIObject obj = DAOFactory.getBIObjectDAO().loadBIObjectForDetail(biObjectID);
    Engine engine = obj.getEngine();
   
    // GET THE TYPE OF ENGINE (INTERNAL / EXTERNAL) AND THE SUITABLE BIOBJECT TYPES
    Domain engineType = null;
    Domain compatibleBiobjType = null;
    engineType = DAOFactory.getDomainDAO().loadDomainById(engine.getEngineTypeId());
    compatibleBiobjType = DAOFactory.getDomainDAO().loadDomainById(engine.getBiobjTypeId());
    String compatibleBiobjTypeCd = compatibleBiobjType.getValueCd();
    String biobjTypeCd = obj.getBiObjectTypeCode();
   
    // CHECK IF THE BIOBJECT IS COMPATIBLE WITH THE TYPES SUITABLE FOR THE ENGINE
    if (!compatibleBiobjTypeCd.equalsIgnoreCase(biobjTypeCd)) {
      // the engine document type and the biobject type are not compatible
       logger.fatal("Engine cannot execute input document type: " +
               "the engine " + engine.getName() + " can execute '" + compatibleBiobjTypeCd + "' type documents " +
               "while the input document is a '" + biobjTypeCd + "'.");
      Vector params = new Vector();
      params.add(engine.getName());
      params.add(compatibleBiobjTypeCd);
      params.add(biobjTypeCd);
      errorHandler.addError(new EMFUserError(EMFErrorSeverity.ERROR, 2002, params));
      return;
    }
   
    // IF THE ENGINE IS EXTERNAL
    if ("EXT".equalsIgnoreCase(engineType.getValueCd())) {
      try {
        // instance the driver class
        String driverClassName = obj.getEngine().getDriverName();
        IEngineDriver aEngineDriver = (IEngineDriver)Class.forName(driverClassName).newInstance();
        EngineURL templateBuildUrl = null;
        try {
          templateBuildUrl = aEngineDriver.getEditDocumentTemplateBuildUrl(obj, profile);
        } catch (InvalidOperationRequest ior) {
View Full Code Here

    logger.debug("IN");
   
    try {
      // retrieving execution instance from session, no need to check if user is able to execute the current document
      ExecutionInstance executionInstance = getContext().getExecutionInstance( ExecutionInstance.class.getName() );
      BIObject obj = executionInstance.getBIObject();
      UserProfile userProfile = (UserProfile) this.getUserProfile();
      ISubObjectDAO dao = null;
      try {
        dao = DAOFactory.getSubObjectDAO();
      } catch (EMFUserError e) {
        logger.error("Error while istantiating DAO", e);
        throw new SpagoBIServiceException(SERVICE_NAME, "Cannot access database", e);
      }
      String ids = this.getAttributeAsString(SUBOBJECT_ID);
      // ids contains the id of the subobjects to be deleted separated by ,
      String[] idArray = ids.split(",");
      for (int i = 0; i < idArray.length; i++) {
        Integer id = new Integer(idArray[i]);
        SubObject subObject = null;
        try {
          subObject = dao.getSubObject(id);
        } catch (EMFUserError e) {
          logger.error("SubObject with id = " + id + " not found", e);
          throw new SpagoBIServiceException(SERVICE_NAME, "Customized view not found", e);
        }
        if (subObject.getBiobjId().equals(obj.getId())) {
          boolean canDeleteSubObject = false;
          if (userProfile.isAbleToExecuteAction(SpagoBIConstants.DOCUMENT_MANAGEMENT_ADMIN)
              || subObject.getOwner().equals(userProfile.getUserId().toString())) {
            canDeleteSubObject = true;
          }
          if (canDeleteSubObject) {
            logger.info("User [id: " + userProfile.getUserUniqueIdentifier() + ", userId: " + userProfile.getUserId() + ", name: " + userProfile.getUserName() + "] " +
                "is deleting customized view [id: " + subObject.getId() + ", name: " + subObject.getName() + "] ...");
            try {
              dao.deleteSubObject(id);
            } catch (EMFUserError e) {
              throw new SpagoBIServiceException(SERVICE_NAME, "Error while deleting customized view", e);
            }
            logger.debug("Customized view [id: " + subObject.getId() + ", name: " + subObject.getName() + "] deleted.");
          } else {
            logger.error("User [id: " + userProfile.getUserUniqueIdentifier() + ", userId: " + userProfile.getUserId() + ", name: " + userProfile.getUserName() + "] cannot delete customized view");
            throw new SpagoBIServiceException(SERVICE_NAME, "User cannot delete customized view");
          }
        } else {
          logger.error("Cannot delete customized view with id = " + subObject.getBiobjId() + ": " +
              "it is not relevant to the current document [id: " + obj.getId() + ", label: " + obj.getLabel() + ", name: " + obj.getName() + "]");
          throw new SpagoBIServiceException(SERVICE_NAME, "Cannot delete customized view: it is not relevant to the current document");
        }
       
      }
      try {
View Full Code Here

    String query = getAttributeAsString(OBJECT_QUERY);

    if (name != null && name != "" && label != null && label != "" &&
       type!=null && functsArrayJSon!=null && functsArrayJSon.length()!= 0) {
     
      BIObject o = new BIObject();
      BIObject objAlreadyExisting = objDao.loadBIObjectByLabel(label);
      if(objAlreadyExisting!=null){
        logger.error("Document with the same label already exists");
        throw new SpagoBIServiceException(SERVICE_NAME,  "sbi.document.labelAlreadyExistent");
      }
      o.setName(name);
      o.setLabel(label);
      o.setDescription(description);
      o.setVisible(new Integer(1));
     
      if(engineId!=null){
        Engine engine = DAOFactory.getEngineDAO().loadEngineByID(new Integer(engineId));
        o.setEngine(engine);
      }else{
        List<Engine> engines = DAOFactory.getEngineDAO().loadAllEnginesForBIObjectType(type);
        if(engines!=null && !engines.isEmpty()){
          o.setEngine(engines.get(0));
        }
      }
     
      Domain objType = DAOFactory.getDomainDAO().loadDomainByCodeAndValue(SpagoBIConstants.BIOBJ_TYPE, type);
      Integer biObjectTypeID = objType.getValueId();
      o.setBiObjectTypeID(biObjectTypeID);
      o.setBiObjectTypeCode(objType.getValueCd());
         
      UserProfile userProfile = (UserProfile) this.getUserProfile();
      String creationUser =  userProfile.getUserId().toString();
      o.setCreationUser(creationUser);
      if(dataSourceId!=null && dataSourceId!=""){
        o.setDataSourceId(new Integer(dataSourceId));
     
      List<Integer> functionalities = new ArrayList<Integer>();
      for(int i=0; i< functsArrayJSon.length(); i++){
        String funcIdStr = functsArrayJSon.getString(i);
        Integer funcId = new Integer(funcIdStr);
        if (funcId.intValue() == -1) {
          // -1 stands for personal folder: check is it exists
          boolean exists = UserUtilities.userFunctionalityRootExists(userProfile);
          if (!exists) {
            // create personal folder if it doesn't exist
            UserUtilities.createUserFunctionalityRoot(userProfile);
          }
          // load personal folder to get its id
          LowFunctionality lf = UserUtilities.loadUserFunctionalityRoot(userProfile);
          funcId = lf.getId();
        }
        functionalities.add(funcId);
      }   
      o.setFunctionalities(functionalities);
     
      Domain objState = DAOFactory.getDomainDAO().loadDomainByCodeAndValue(SpagoBIConstants.DOC_STATE, SpagoBIConstants.DOC_STATE_REL);     
      Integer stateID = objState.getValueId();
      o.setStateID(stateID);
      o.setStateCode(objState.getValueCd());   
     
      BIObject orig_obj = objDao.loadBIObjectById(new Integer(orig_biobj_id));
      ObjTemplate objTemp = new ObjTemplate();
      byte[] content = null;
      if(template != null && template != ""){
        content = template.getBytes();
      }else if(smartFilterValues!=null){
        content = getSmartFilterTemplateContent();
      }else if(wk_definition!=null && query!=null && orig_obj!=null){
        ObjTemplate qbETemplate = orig_obj.getActiveTemplate();
        String templCont = new String(qbETemplate.getContent());
        WorksheetDriver q = new WorksheetDriver();
        String temp = q.composeWorksheetTemplate(wk_definition, query, null, templCont);
        content = temp.getBytes();
      }else{
        logger.error("Document template not available");
        throw new SpagoBIServiceException(SERVICE_NAME,  "sbi.document.saveError");
      }
     
      objTemp.setContent(content);
      objTemp.setCreationUser(creationUser);
      objTemp.setDimension(Long.toString(content.length/1000)+" KByte");
      objTemp.setName("template.sbiworksheet");
     
      try {
        if(id != null && !id.equals("") && !id.equals("0")){             
          o.setId(Integer.valueOf(id));
          objDao.modifyBIObject(o, objTemp);
          logger.debug("Document with id "+id+" updated");
          JSONObject attributesResponseSuccessJSON = new JSONObject();
          attributesResponseSuccessJSON.put("success", true);
          attributesResponseSuccessJSON.put("responseText", "Operation succeded");
          writeBackToClient( new JSONSuccess(attributesResponseSuccessJSON) );
        }else{
          Integer biObjectID = objDao.insertBIObject(o, objTemp);
          if(orig_biobj_id!=null && orig_biobj_id!=""){         
            List obj_pars = orig_obj.getBiObjectParameters();
            if(obj_pars!=null && !obj_pars.isEmpty()){
              Iterator it = obj_pars.iterator();
              while(it.hasNext()){
                BIObjectParameter par = (BIObjectParameter)it.next();
                par.setBiObjectID(biObjectID);
View Full Code Here

TOP

Related Classes of it.eng.spagobi.analiticalmodel.document.bo.BIObject

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.