Package it.eng.spagobi.tools.dataset.bo

Examples of it.eng.spagobi.tools.dataset.bo.GuiDataSetDetail


   * @throws EMFUserError the EMF user error
   */
  public GuiGenericDataSet loadDataSetByLabel(String dsLabel)throws EMFUserError {
    logger.debug("IN");
    GuiGenericDataSet toReturn = null;
    GuiDataSetDetail detail = null;

    Session aSession = null;
    Transaction tx = null;

    try {
View Full Code Here


   
    return dsActiveDetail;
  }
 
  private GuiDataSetDetail instantiateCorrectDsDetail(String dsType){
    GuiDataSetDetail dsActiveDetail = null;
   
    if(dsType.equalsIgnoreCase(DataSetConstants.DS_FILE)){
      dsActiveDetail = new FileDataSetDetail();
      String fileName = getAttributeAsString(DataSetConstants.FILE_NAME);
      if(fileName!=null && !fileName.equals("")){
View Full Code Here

      }
     
      SbiDataSetHistory hibDataSetHistory =null;
      if(dataSet!=null){
        // get active dataset
        GuiDataSetDetail dataSetActiveDetail = dataSet.getActiveDetail();

        if(dataSetActiveDetail instanceof FileDataSetDetail){
          hibDataSetHistory=new SbiFileDataSet();
          if(((FileDataSetDetail)dataSetActiveDetail).getFileName()!=null){
            ((SbiFileDataSet)hibDataSetHistory).setFileName(((FileDataSetDetail)dataSetActiveDetail).getFileName());
          }
        } 
        else if(dataSetActiveDetail instanceof QueryDataSetDetail){
          hibDataSetHistory=new SbiQueryDataSet();
          if(((QueryDataSetDetail)dataSetActiveDetail).getQuery()!=null){
            ((SbiQueryDataSet)hibDataSetHistory).setQuery(((QueryDataSetDetail)dataSetActiveDetail).getQuery().toString());
          }
          if(((QueryDataSetDetail)dataSetActiveDetail).getDataSourceLabel()!=null){
            SbiDataSource hibDataSource = null;
            String dataSourceLabel = ((QueryDataSetDetail)dataSetActiveDetail).getDataSourceLabel();
            if(dataSourceLabel!=null && !dataSourceLabel.equals("")){
              IDataSourceDAO dataSourceDao = DAOFactory.getDataSourceDAO();
              IDataSource ds = dataSourceDao.loadDataSourceByLabel(dataSourceLabel);
              insertDataSource(ds, session);       
              Criterion labelCriterrion = Expression.eq("label", dataSourceLabel);
              Criteria criteria = session.createCriteria(SbiDataSource.class);
              criteria.add(labelCriterrion)
              hibDataSource = (SbiDataSource) criteria.uniqueResult();
              ((SbiQueryDataSet)hibDataSetHistory).setDataSource(hibDataSource)
            }
          }       
        }else if(dataSetActiveDetail instanceof QbeDataSetDetail){
          hibDataSetHistory = new SbiQbeDataSet();
          SbiQbeDataSet hibQbeDataSet = (SbiQbeDataSet) hibDataSetHistory;
          QbeDataSetDetail qbeDataSet = (QbeDataSetDetail) dataSetActiveDetail;
          hibQbeDataSet.setSqlQuery(qbeDataSet.getSqlQuery());
          hibQbeDataSet.setJsonQuery(qbeDataSet.getJsonQuery());
          hibQbeDataSet.setDatamarts(qbeDataSet.getDatamarts());
          String dataSourceLabel = qbeDataSet.getDataSourceLabel();
          Criterion labelCriterrion = Expression.eq("label", dataSourceLabel);
          Criteria criteria = session.createCriteria(SbiDataSource.class);
          criteria.add(labelCriterrion)
          SbiDataSource hibDataSource = (SbiDataSource) criteria.uniqueResult();
          hibQbeDataSet.setDataSource(hibDataSource)
        }   
        else if(dataSetActiveDetail instanceof WSDataSetDetail){
          hibDataSetHistory=new SbiWSDataSet();
          if(((WSDataSetDetail)dataSetActiveDetail).getAddress()!=null){
            ((SbiWSDataSet)hibDataSetHistory).setAdress(((WSDataSetDetail)dataSetActiveDetail).getAddress());
          }
          if(((WSDataSetDetail)dataSetActiveDetail).getOperation()!=null){
            ((SbiWSDataSet)hibDataSetHistory).setOperation(((WSDataSetDetail)dataSetActiveDetail).getOperation());
         
        }

        else if(dataSetActiveDetail instanceof JClassDataSetDetail){
          hibDataSetHistory=new SbiJClassDataSet();
          if(((JClassDataSetDetail)dataSetActiveDetail).getJavaClassName()!=null){
            ((SbiJClassDataSet)hibDataSetHistory).setJavaClassName(((JClassDataSetDetail)dataSetActiveDetail).getJavaClassName());
          }
        }

        else if(dataSetActiveDetail instanceof ScriptDataSetDetail){
          hibDataSetHistory=new SbiScriptDataSet();
          if(((ScriptDataSetDetail)dataSetActiveDetail).getScript()!=null){
            ((SbiScriptDataSet)hibDataSetHistory).setScript(((ScriptDataSetDetail)dataSetActiveDetail).getScript());
          }
          if(((ScriptDataSetDetail)dataSetActiveDetail).getLanguageScript()!=null){
            ((SbiScriptDataSet)hibDataSetHistory).setLanguageScript(((ScriptDataSetDetail)dataSetActiveDetail).getLanguageScript());
          }
        }

        SbiDomains transformer = null;
        if (dataSetActiveDetail.getTransformerId() != null){
          Criterion aCriterion = Expression.eq("valueId",  dataSetActiveDetail.getTransformerId());
          Criteria criteria = session.createCriteria(SbiDomains.class);
          criteria.add(aCriterion);

          transformer = (SbiDomains) criteria.uniqueResult();

          if (transformer == null){
            logger.error("The Domain with value_id= "+dataSetActiveDetail.getTransformerId()+" does not exist.");
            throw new EMFUserError(EMFErrorSeverity.ERROR, 1035);
          }
        }

        SbiDomains category = null;
        if (dataSetActiveDetail.getCategoryId()!= null){
          Criterion aCriterion = Expression.eq("valueId",  dataSetActiveDetail.getCategoryId());
          Criteria criteria = session.createCriteria(SbiDomains.class);
          criteria.add(aCriterion);

          category = (SbiDomains) criteria.uniqueResult();

          if (category == null){
            logger.error("The Domain with value_id= "+dataSetActiveDetail.getCategoryId()+" does not exist.");
            throw new EMFUserError(EMFErrorSeverity.ERROR, 1035);
          }
        }
        Date currentTStamp = new Date();

        // Fill dataset config values

        SbiDataSetConfig hibDataSetConfig = new SbiDataSetConfig()

        hibDataSetConfig.setDsId(dataSet.getDsId());
        hibDataSetConfig.setLabel(dataSet.getLabel());
        hibDataSetConfig.setDescription(dataSet.getDescription());
        hibDataSetConfig.setName(dataSet.getName())

        tx = session.beginTransaction();
        session.save(hibDataSetConfig);
        tx.commit();

        // Fill Data set history values
        hibDataSetHistory.setSbiDsConfig(hibDataSetConfig);
        if(dataSetActiveDetail.getDsHId()!=0){
          hibDataSetHistory.setDsHId(dataSetActiveDetail.getDsHId());
        }     
        hibDataSetHistory.setVersionNum(1);
        hibDataSetHistory.setActive(true);     

        hibDataSetHistory.setTransformer(transformer);
        hibDataSetHistory.setPivotColumnName(dataSetActiveDetail.getPivotColumnName());
        hibDataSetHistory.setPivotRowName(dataSetActiveDetail.getPivotRowName());
        hibDataSetHistory.setPivotColumnValue(dataSetActiveDetail.getPivotColumnValue());
        hibDataSetHistory.setNumRows(dataSetActiveDetail.isNumRows());

        hibDataSetHistory.setCategory(category);
        hibDataSetHistory.setParameters(dataSetActiveDetail.getParameters());
        hibDataSetHistory.setDsMetadata(dataSetActiveDetail.getDsMetadata());
       
        tx2 = session.beginTransaction();
        session.save(hibDataSetHistory);
        tx2.commit();
      }
View Full Code Here

            JSONObject attributesResponseSuccessJSON = new JSONObject();
            attributesResponseSuccessJSON.put("success", true);
            attributesResponseSuccessJSON.put("responseText", "Operation succeded");
            attributesResponseSuccessJSON.put("id", dsID);
            if(dsSaved!=null){
              GuiDataSetDetail dsDetailSaved = dsSaved.getActiveDetail();
              attributesResponseSuccessJSON.put("dateIn", dsDetailSaved.getTimeIn());
              attributesResponseSuccessJSON.put("userIn", dsDetailSaved.getUserIn());
              attributesResponseSuccessJSON.put("versId", dsDetailSaved.getDsHId());
              attributesResponseSuccessJSON.put("versNum", dsDetailSaved.getVersionNum());
            }
            writeBackToClient( new JSONSuccess(attributesResponseSuccessJSON) );
          }
        } catch (Throwable e) {
          logger.error(e.getMessage(), e);
View Full Code Here

        ds.setName(name);
       
        if(description != null && !description.equals("")){
          ds.setDescription(description);
        }
        GuiDataSetDetail dsActiveDetail = constructDataSetDetail(dsType);
        ds.setActiveDetail(dsActiveDetail)
      }else{
        logger.error("DataSet type is not existent");
        throw new SpagoBIServiceException(SERVICE_NAME,  "sbi.ds.dsTypeError");
      }
View Full Code Here

    }   
    return ds;
  }
 
  private GuiDataSetDetail constructDataSetDetail(String dsType){
    GuiDataSetDetail dsActiveDetail = instantiateCorrectDsDetail(dsType);
   
    if(dsActiveDetail!=null){
      dsActiveDetail.setDsType(dsType);
     
      String catTypeCd = getAttributeAsString(DataSetConstants.CATEGORY_TYPE_VN);     
      JSONArray parsJSON = getAttributeAsJSONArray(DataSetConstants.PARS);
      String meta = getAttributeAsString(DataSetConstants.METADATA);         
      String trasfTypeCd = getAttributeAsString(DataSetConstants.TRASFORMER_TYPE_CD);
     
      List<Domain> domainsCat = (List<Domain>)getSessionContainer().getAttribute("catTypesList");     
      HashMap<String, Integer> domainIds = new HashMap<String, Integer> ();
        if(domainsCat != null){
          for(int i=0; i< domainsCat.size(); i++){
            domainIds.put(domainsCat.get(i).getValueCd(), domainsCat.get(i).getValueId());
          }
        }
        Integer catTypeID = domainIds.get(catTypeCd);
        if(catTypeID!=null){
        dsActiveDetail.setCategoryValueName(catTypeCd);
        dsActiveDetail.setCategoryId(catTypeID);
      }

      if(meta != null && !meta.equals("")){
        dsActiveDetail.setDsMetadata(meta);
      }
     
      if(parsJSON != null){
        String pars;
        try {
          pars = deserializeParsListJSONArray(parsJSON);
          dsActiveDetail.setParameters(pars);
        } catch (JSONException e) {
          logger.error("Error in deserializing parameter",e);
          e.printStackTrace();
        } catch (SourceBeanException e) {
          logger.error("Source Bean Exception",e);
          e.printStackTrace();
        }
      }

      if(trasfTypeCd!=null && !trasfTypeCd.equals("")){
        dsActiveDetail = setTransformer(dsActiveDetail, trasfTypeCd);
      }
     
      IDataSet ds = null;   
      try {
        if ( dsType!=null && !dsType.equals("")) {
         
          ds = instantiateCorrectIDataSetType(dsType);   
          if(ds!=null){                 
            if(trasfTypeCd!=null && !trasfTypeCd.equals("")){
              ds = setTransformer(ds, trasfTypeCd);
            }
            HashMap h = new HashMap();
            if(parsJSON!=null){
              h = deserializeParValuesListJSONArray(parsJSON);
            }
            IEngUserProfile profile = getUserProfile();
            String dsMetadata = getDatasetTestMetadata(ds, h, profile)
            dsActiveDetail.setDsMetadata(dsMetadata);
          }             
        }else{
          logger.error("DataSet type is not existent");
          throw new SpagoBIServiceException(SERVICE_NAME,  "sbi.ds.dsTypeError");
        }
View Full Code Here

   
    return dsActiveDetail;
  }
 
  private GuiDataSetDetail instantiateCorrectDsDetail(String dsType){
    GuiDataSetDetail dsActiveDetail = null;
   
    if(dsType.equalsIgnoreCase(DataSetConstants.DS_FILE)){
      dsActiveDetail = new FileDataSetDetail();
      String fileName = getAttributeAsString(DataSetConstants.FILE_NAME);
      if(fileName!=null && !fileName.equals("")){
View Full Code Here

    if (dataset == null) {
      logger.warn("SDKDataSet in input is null!!");
      return null;
    }
    GuiGenericDataSet ds = null;
    GuiDataSetDetail dsDetail = null;
    try {
      ds = new GuiGenericDataSet();
      if (dataset.getId() != null){
        ds.setDsId(dataset.getId());
      }
      ds.setLabel(dataset.getLabel());
      ds.setName(dataset.getName());
      ds.setDescription(dataset.getDescription())

      //defines correct dataset detail
      if(dataset.getType().equalsIgnoreCase(DataSetConstants.DS_FILE)){
        dsDetail = new FileDataSetDetail();
        String fileName = dataset.getFileName();
        if(fileName!=null && !fileName.equals("")){
          ((FileDataSetDetail)dsDetail).setFileName(fileName);
        }
      }else if(dataset.getType().equalsIgnoreCase(DataSetConstants.DS_JCLASS)){
        dsDetail = new JClassDataSetDetail();
        String jclassName = dataset.getJavaClassName();
        if(jclassName!=null && !jclassName.equals("")){
          ((JClassDataSetDetail)dsDetail).setJavaClassName(jclassName);
        }
      }else if(dataset.getType().equalsIgnoreCase(DataSetConstants.DS_QUERY)){
        dsDetail = new QueryDataSetDetail();
        String query = dataset.getJdbcQuery();
        Integer dataSourceId = dataset.getJdbcDataSourceId();
        if(query!=null && !query.equals("")){
          ((QueryDataSetDetail)dsDetail).setQuery(query);
        }
        if(dataSourceId!=null){
          IDataSource dataSource = DAOFactory.getDataSourceDAO().loadDataSourceByID(dataSourceId);
          if(dataSource!=null){
            ((QueryDataSetDetail)dsDetail).setDataSourceLabel(dataSource.getLabel());
          }
         
        }
      }else if(dataset.getType().equalsIgnoreCase(DataSetConstants.DS_QBE)){
        dsDetail = new QbeDataSetDetail();
        String sqlQuery = dataset.getJdbcQuery();
        String jsonQuery = dataset.getJsonQuery();
        Integer dataSourceId = dataset.getJdbcDataSourceId();
        String datamarts = dataset.getDatamarts();       
        ((QbeDataSetDetail) dsDetail).setSqlQuery(sqlQuery);
        ((QbeDataSetDetail) dsDetail).setJsonQuery(jsonQuery);
        ((QbeDataSetDetail) dsDetail).setDatamarts(datamarts);
        IDataSource dataSource = DAOFactory.getDataSourceDAO().loadDataSourceByID(dataSourceId);
        if(dataSource!=null){
          ((QbeDataSetDetail)dsDetail).setDataSourceLabel(dataSource.getLabel());
        }
      }else if(dataset.getType().equalsIgnoreCase(DataSetConstants.DS_SCRIPT)){
        dsDetail = new ScriptDataSetDetail();
        String script = dataset.getScriptText();
        String scriptLanguage = dataset.getScriptLanguage();
        if(scriptLanguage!=null && !scriptLanguage.equals("")){
          ((ScriptDataSetDetail)dsDetail).setLanguageScript(scriptLanguage);
        }
        if(script!=null && !script.equals("")){
          ((ScriptDataSetDetail)dsDetail).setScript(script);
        }
      }else if(dataset.getType().equalsIgnoreCase(DataSetConstants.DS_WS)){
        dsDetail = new WSDataSetDetail();
        String wsAddress = dataset.getWebServiceAddress();
        String wsOperation = dataset.getWebServiceOperation();
        if(wsOperation!=null && !wsOperation.equals("")){
          ((WSDataSetDetail)dsDetail).setOperation(wsOperation);
        }
        if(wsAddress!=null && !wsAddress.equals("")){
          ((WSDataSetDetail)dsDetail).setAddress(wsAddress);
        }
      }
      //sets other general GuiDetailDataset object's fields
      if(dataset.getPivotColumnName()!=null && !dataset.getPivotColumnName().equals("")){
        dsDetail.setPivotColumnName(dataset.getPivotColumnName());
      }
      if(dataset.getPivotRowName()!=null && !dataset.getPivotRowName().equals("")){
        dsDetail.setPivotRowName(dataset.getPivotRowName());
      }
      if(dataset.getPivotColumnValue()!=null && !dataset.getPivotColumnValue().equals("")){
        dsDetail.setPivotColumnValue(dataset.getPivotColumnValue());
      }
      if(dataset.getNumberingRows()!=null){
        dsDetail.setNumRows(dataset.getNumberingRows());
      }

      //dsDetail.setDsMetadata(dataset.getXXX);
     
      //sets dataset's parameters     
      String parameters = null;
      if (dataset.getParameters() != null) {       
        parameters = this.fromSDKDataSetParameterArrayToBIDataSetParameterList(dataset.getParameters());
      }
      dsDetail.setParameters(parameters);

     
      /*
      private String dsMetadata=null;
       */
     
      IDomainDAO domainDAO = DAOFactory.getDomainDAO();
      // sets dataset's transformer type domain
      if (dataset.getTransformer() != null) {
        Domain transformer = domainDAO.loadDomainByCodeAndValue("TRANSFORMER_TYPE", dataset.getTransformer());
        dsDetail.setTransformerCd(transformer.getValueCd());
        dsDetail.setTransformerId(transformer.getValueId());
      }
      // sets dataset's category domain
      if (dataset.getCategory() != null){
        Domain category = domainDAO.loadDomainByCodeAndValue("CATEGORY_TYPE", dataset.getCategory());
        dsDetail.setCategoryValueName(category.getValueCd());
        dsDetail.setCategoryId(category.getValueId());
      }
      ds.setActiveDetail(dsDetail);

    } catch (Exception e) {
      logger.error("Error while converting SDKDataSet into GuiGenericDataSet.", e);
View Full Code Here

      Integer numObjAssociated = DAOFactory.getDataSetDAO().countBIObjAssociated(new Integer(ds.getDsId()));
      if(numObjAssociated!=null){
        result.put(USED_BY_N_DOCS, numObjAssociated );
      }
     
      GuiDataSetDetail dsDetail = ds.getActiveDetail();
     
      result.put(CATEGORY_TYPE_VN, dsDetail.getCategoryValueName());

      JSONArray parsListJSON = new JSONArray();
      String pars = dsDetail.getParameters();
      if(pars!=null && !pars.equals("")){
        SourceBean source = SourceBean.fromXMLString(pars);
        if(source!=null && 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");
            String type = (String)row.getAttribute("TYPE");
            JSONObject jsonPar = new JSONObject();
            jsonPar.put("name", name);
            jsonPar.put("type", type);
            parsListJSON.put(jsonPar);
          }       
        }
      }
      result.put(PARS, parsListJSON)
     
      JSONArray metaListJSON = new JSONArray();
      String meta = dsDetail.getDsMetadata();
      if(meta!=null && !meta.equals("")){
        SourceBean source = SourceBean.fromXMLString(meta);
        if(source!=null && source.getName().equals("METADATALIST")){
          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");
            String type = (String)row.getAttribute("TYPE");
            JSONObject jsonMeta = new JSONObject();
            jsonMeta.put("name", name);
            jsonMeta.put("type", type);
            metaListJSON.put(jsonMeta);
          }       
        }
      }
      result.put(METADATA, metaListJSON)
     
      JSONArray versionsListJSON = new JSONArray();
      List<GuiDataSetDetail> nonActiveDetails = ds.getNonActiveDetails();
      if(nonActiveDetails!=null && !nonActiveDetails.isEmpty()){
        Iterator it = nonActiveDetails.iterator();
        while(it.hasNext()){
          GuiDataSetDetail tempDetail = (GuiDataSetDetail)it.next();
          String dsType = tempDetail.getDsType();
          String userIn = tempDetail.getUserIn();
          Integer dsVersionNum = tempDetail.getVersionNum();
          Integer dsVersionId = tempDetail.getDsHId();
          Date timeIn = tempDetail.getTimeIn();
          JSONObject jsonOldVersion = new JSONObject();
          jsonOldVersion.put(TYPE, dsType);
          jsonOldVersion.put(USER_IN, userIn);
          jsonOldVersion.put(VERSION_NUM, dsVersionNum);
          jsonOldVersion.put(VERSION_ID, dsVersionId);
View Full Code Here

TOP

Related Classes of it.eng.spagobi.tools.dataset.bo.GuiDataSetDetail

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.