Package it.eng.spagobi.tools.dataset.dao

Examples of it.eng.spagobi.tools.dataset.dao.IDataSetDAO


    return contentBytes;
  }
 
  public IDataSet getDataSet() {
    IDataSet dataSet;
    IDataSetDAO dataSetDAO;
   
    dataSet = null;
   
    try {
      dataSetDAO = DAOFactory.getDataSetDAO();
      dataSet = dataSetDAO.loadActiveIDataSetByID(getObj().getDataSetId());
    } catch(Throwable t) {
      throw new SpagoBIEngineRuntimeException(t);
    }
   
    return dataSet;
View Full Code Here


  public static Logger logger = Logger.getLogger(ManageDatasets.class);

  @Override
  public void doService() {
    logger.debug("IN");
    IDataSetDAO dsDao;
    IEngUserProfile profile = getUserProfile();
    try {
      dsDao = DAOFactory.getDataSetDAO();
      dsDao.setUserProfile(profile);
    } catch (EMFUserError e1) {
      logger.error(e1.getMessage(), e1);
      throw new SpagoBIServiceException(SERVICE_NAME,  "Error occurred");
    }
    Locale locale = getLocale();
View Full Code Here

  public static Logger logger = Logger.getLogger(ExecuteDatasets.class);

  @Override
  public void doService() {
    logger.debug("IN");
    IDataSetDAO dsDao;
    IEngUserProfile profile = getUserProfile();
    try {
      dsDao = DAOFactory.getDataSetDAO();
      dsDao.setUserProfile(profile);
    } catch (EMFUserError e1) {
      logger.error(e1.getMessage(), e1);
      throw new SpagoBIServiceException(SERVICE_NAME,  "Error occurred");
    }
    Locale locale = getLocale();
View Full Code Here

  @Override
  public void doService() {
    logger.debug("IN");
    IKpiDAO kpiDao;
    IDataSetDAO dsDao;
    IThresholdDAO thrDao;
    try {
      kpiDao = DAOFactory.getKpiDAO();
      dsDao = DAOFactory.getDataSetDAO();
      thrDao = DAOFactory.getThresholdDAO();
      kpiDao.setUserProfile(getUserProfile());
      dsDao.setUserProfile(getUserProfile());
      thrDao.setUserProfile(getUserProfile());
    } catch (EMFUserError e1) {
      logger.error(e1.getMessage(), e1);
      throw new SpagoBIServiceException(SERVICE_NAME,  "Error occurred");
    }
    Locale locale = getLocale();

    String serviceType = this.getAttributeAsString(MESSAGE_DET);
    logger.debug("Service type "+serviceType);
    if (serviceType != null && serviceType.equalsIgnoreCase(KPIS_LIST)) {

      try {
        JSONObject filtersJSON = null;

        Integer start = getAttributeAsInteger( START );
        Integer limit = getAttributeAsInteger( LIMIT );

        if(start==null){
          start = START_DEFAULT;
        }
        if(limit==null){
          limit = LIMIT_DEFAULT;
        }

        Integer totalItemsNum = kpiDao.countKpis();
       
        List kpis = null;
        if(this.requestContainsAttribute( FILTERS ) ) {
          filtersJSON = getAttributeAsJSONObject( FILTERS );
          String hsql = filterList(filtersJSON);
          kpis = kpiDao.loadKpiListFiltered(hsql, start, limit);
        }else{//not filtered
          kpis = kpiDao.loadPagedKpiList(start,limit);
        }

        logger.debug("Loaded thresholds list");

        Integer kpiParent = this.getAttributeAsInteger("id");
        if(kpiParent != null){
          kpis =cleanKpiListForRelation((ArrayList<Kpi>)kpis, kpiParent);
        }
        JSONArray resourcesJSON = (JSONArray) SerializerFactory.getSerializer("application/json").serialize(kpis, locale);
        JSONObject resourcesResponseJSON = createJSONResponseResources(resourcesJSON, totalItemsNum);

        writeBackToClient(new JSONSuccess(resourcesResponseJSON));

      } catch (Throwable e) {
        logger.error("Exception occurred while retrieving thresholds", e);
        throw new SpagoBIServiceException(SERVICE_NAME,
            "Exception occurred while retrieving thresholds", e);
      }
    } else if (serviceType != null  && serviceType.equalsIgnoreCase(KPI_INSERT)) {

      String id = getAttributeAsString(ID);
      String code = getAttributeAsString(CODE);
      String name = getAttributeAsString(NAME);
      String description = getAttributeAsString(DESCRIPTION);
      String weight = getAttributeAsString(WEIGHT);
      Boolean isAdditive = getAttributeAsBoolean(ISADDITIVE);
     
      String dsLabel = getAttributeAsString(DATASET);
      String thresholdCode = getAttributeAsString(THR);
      JSONArray docLabelsJSON = null;
      String docs = getAttributeAsString(DOCS);
      if(docs!=null && !docs.contains(",")){
        //Don't do anything
      }else{
        docLabelsJSON = getAttributeAsJSONArray(DOCS);
      }

      String interpretation = getAttributeAsString(INTERPRETATION);
      String algdesc = getAttributeAsString(ALGDESC);
      String inputAttr = getAttributeAsString(INPUT_ATTR);
      String modelReference = getAttributeAsString(MODEL_REFERENCE);
      String targetAudience = getAttributeAsString(TARGET_AUDIENCE);

      String kpiTypeCd = getAttributeAsString(KPI_TYPE_CD)
      String metricScaleCd = getAttributeAsString(METRIC_SCALE_TYPE_CD);
      String measureTypeCd = getAttributeAsString(MEASURE_TYPE_CD);       

      JSONArray udpValuesArrayJSon = getAttributeAsJSONArray(UDP_VALUE_LIST);

      List<Domain> domains = (List<Domain>)getSessionContainer().getAttribute("kpiTypesList");
      List<Domain> domains1 = (List<Domain>)getSessionContainer().getAttribute("measureTypesList");
      List<Domain> domains2 = (List<Domain>)getSessionContainer().getAttribute("metricScaleTypesList");
      domains.addAll(domains1);
      domains.addAll(domains2);

      HashMap<String, Integer> domainIds = new HashMap<String, Integer> ();
      if(domains != null){
        for(int i=0; i< domains.size(); i++){
          domainIds.put(domains.get(i).getValueCd(), domains.get(i).getValueId());
        }
      }

      Integer kpiTypeId = domainIds.get(kpiTypeCd);
      Integer metricScaleId = domainIds.get(metricScaleCd);
      Integer measureTypeId = domainIds.get(measureTypeCd);

      if (name != null && code != null) {
        Kpi k = new Kpi();

        try {

          k.setKpiName(name);
          k.setCode(code);

          if(description != null){
            k.setDescription(description);
          }
          if(weight != null && !weight.equalsIgnoreCase("")){
            k.setStandardWeight(Double.valueOf(weight));
         
          if(isAdditive != null && isAdditive.booleanValue()==true){
            k.setIsAdditive(new Boolean(true));
          }else{
            k.setIsAdditive(new Boolean(false));
          }
          if(dsLabel != null){
            k.setDsLabel(dsLabel);
            IDataSet ds = dsDao.loadActiveDataSetByLabel(dsLabel);

            if(ds!=null){
              int dsId = ds.getId();
              k.setKpiDsId(new Integer(dsId));
            }       
          }
          if(thresholdCode != null){
            Threshold t = thrDao.loadThresholdByCode(thresholdCode);
            k.setThreshold(t);
          }

          k.setKpiName(name);
          k.setCode(code);

          if(description != null){
            k.setDescription(description);
          }
          if(weight != null && !weight.equalsIgnoreCase("")){
            k.setStandardWeight(Double.valueOf(weight));
         
          if(dsLabel != null){
            k.setDsLabel(dsLabel);
            IDataSet ds = dsDao.loadActiveDataSetByLabel(dsLabel);

            if(ds!=null){
              int dsId = ds.getId();
              k.setKpiDsId(new Integer(dsId));
            }       
View Full Code Here

      }
      Integer dataSetId = biobj.getDataSetId();

      if (dataSetId != null) {
        // if the transaction is new insert dataset if missing  
        IDataSetDAO datasetDao=DAOFactory.getDataSetDAO();
        // insert dataset if parameter insertDataSet is true (in case of KPI export)
        if(insertDataSet){
          GuiGenericDataSet guiGenericDataSet = datasetDao.loadDataSetById(dataSetId);
          if(guiGenericDataSet!=null){
            insertDataSet(guiGenericDataSet, session);
          }
        }
        SbiDataSetConfig dataset = (SbiDataSetConfig) session.load(SbiDataSetConfig.class, dataSetId);
View Full Code Here

        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() + " : " +
View Full Code Here

        else{
          logger.warn("No datasets associated to the console "+biobj.getLabel());
        }

        // insert all datasets
        IDataSetDAO dataSetDAO = DAOFactory.getDataSetDAO();
        for (Iterator iterator = dsLabels.iterator(); iterator.hasNext();) {
          String string = (String) iterator.next();
          logger.debug("get dataset with label " + string);
          GuiGenericDataSet ds = dataSetDAO.loadDataSetByLabel(string);
          // insert dataset if parameter insertDataSet is true (in case of KPI export)
          if(ds != null){
            logger.debug("found dataset with label " + string);
            exporter.insertDataSet(ds, session);
          }
          else {
            logger.error("could not find dataset with label "+string+" : ignore it");
          }

          // search for xxxErrors dataset
          String labelErrors = string+"Errors";
          logger.debug("get dataset with label " + labelErrors+" if present");
          GuiGenericDataSet datasetErrors = dataSetDAO.loadDataSetByLabel(labelErrors);
          if(datasetErrors != null){
            logger.debug("found dataset with label " + labelErrors+"");
            exporter.insertDataSet(datasetErrors, session);
          }
          else {
            logger.warn("could not find dataset with label "+labelErrors);
          }

          // search for xxxAlarms dataset
          String labelAlarms = string+"Alarms";
          logger.debug("get dataset with label " + labelAlarms+" if present");
          GuiGenericDataSet datasetAlarms = dataSetDAO.loadDataSetByLabel(labelAlarms);
          if(datasetAlarms != null){
            logger.debug("found dataset with label " + labelAlarms+"");
            exporter.insertDataSet(datasetAlarms, session);
          }
          else {
View Full Code Here


  @Override
  public void doService() {
    logger.debug("IN");
    IDataSetDAO dsDao;
    IEngUserProfile profile = getUserProfile();
    try {
      dsDao = DAOFactory.getDataSetDAO();
      dsDao.setUserProfile(profile);
    } catch (EMFUserError e1) {
      logger.error(e1.getMessage(), e1);
      throw new SpagoBIServiceException(SERVICE_NAME,  "Error occurred");
    }
    Locale locale = getLocale();
    String serviceType = this.getAttributeAsString(DataSetConstants.MESSAGE_DET);
    logger.debug("Service type "+serviceType);
   
    if (serviceType != null && serviceType.equalsIgnoreCase(DataSetConstants.DATASETS_FOR_KPI_LIST)) {     
      try
        Integer totalItemsNum = dsDao.countDatasets();
        List<SbiDataSetConfig> items = getListOfGenericDatasetsForKpi(dsDao);
        logger.debug("Loaded items list");
        JSONArray itemsJSON = (JSONArray) SerializerFactory.getSerializer("application/json").serialize(items, locale);
        JSONObject responseJSON = createJSONResponse(itemsJSON, totalItemsNum);
        writeBackToClient(new JSONSuccess(responseJSON));

      } catch (Throwable e) {
        logger.error("Exception occurred while retrieving items", e);
        throw new SpagoBIServiceException(SERVICE_NAME, "sbi.general.retrieveItemsError", e);
      }
    } else if(serviceType != null && serviceType.equalsIgnoreCase(DataSetConstants.DATASETS_LIST)) {     
      try {   
        Integer totalItemsNum = dsDao.countDatasets();
        List<GuiGenericDataSet> items = getListOfGenericDatasets(dsDao);
        logger.debug("Loaded items list");
        JSONArray itemsJSON = (JSONArray) SerializerFactory.getSerializer("application/json").serialize(items, locale);
        JSONObject responseJSON = createJSONResponse(itemsJSON, totalItemsNum);
        writeBackToClient(new JSONSuccess(responseJSON));

      } catch (Throwable e) {
        logger.error("Exception occurred while retrieving items", e);
        throw new SpagoBIServiceException(SERVICE_NAME,  "sbi.general.retrieveItemsError", e);
      }
    } else if (serviceType != null  && serviceType.equalsIgnoreCase(DataSetConstants.DATASET_INSERT)) {     
      GuiGenericDataSet ds = getGuiGenericDatasetToInsert();   
      if(ds!=null){
        String id = getAttributeAsString(DataSetConstants.ID);
        try {
          if(id != null && !id.equals("") && !id.equals("0")){             
            ds.setDsId(Integer.valueOf(id));
            dsDao.modifyDataSet(ds);
            logger.debug("Resource "+id+" updated");
            JSONObject attributesResponseSuccessJSON = new JSONObject();
            attributesResponseSuccessJSON.put("success", true);
            attributesResponseSuccessJSON.put("responseText", "Operation succeded");
            attributesResponseSuccessJSON.put("id", id);
            writeBackToClient( new JSONSuccess(attributesResponseSuccessJSON) );
          }else{
            Integer dsID = dsDao.insertDataSet(ds);
            GuiGenericDataSet dsSaved = dsDao.loadDataSetById(dsID);
            logger.debug("New Resource inserted");
            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);
          throw new SpagoBIServiceException(SERVICE_NAME,"sbi.ds.saveDsError", e);
        }
      }else{
        logger.error("DataSet name, label or type are missing");
        throw new SpagoBIServiceException(SERVICE_NAME,  "sbi.ds.fillFieldsError");
      }
    } else if (serviceType != null  && serviceType.equalsIgnoreCase(DataSetConstants.DATASET_TEST)) {     
      try {
        JSONObject dataSetJSON = datasetTest();
        if(dataSetJSON!=null){
          try {
            writeBackToClient( new JSONSuccess( dataSetJSON ) );
          } catch (IOException e) {
            throw new SpagoBIServiceException("Impossible to write back the responce to the client", e);
          }
        }else{
          throw new SpagoBIServiceException(SERVICE_NAME,"sbi.ds.testError");
        }
      } catch (Throwable e) {
        logger.error(e.getMessage(), e);
        throw new SpagoBIServiceException(SERVICE_NAME,"sbi.ds.testError", e);
      }
    } else if (serviceType != null  && serviceType.equalsIgnoreCase(DataSetConstants.DATASET_DELETE)) {
      Integer dsID = getAttributeAsInteger(DataSetConstants.ID);
      try {
        dsDao.deleteDataSet(dsID);
        logger.debug("Dataset deleted");
        writeBackToClient( new JSONAcknowledge("Operation succeded") );
      } catch (Throwable e) {
        logger.error("Exception occurred while retrieving dataset to delete", e);
        throw new SpagoBIServiceException(SERVICE_NAME,"sbi.ds.deleteDsError", e);
      }
    }else if (serviceType != null  && serviceType.equalsIgnoreCase(DataSetConstants.DATASET_VERSION_DELETE)) {
      Integer dsVersionID = getAttributeAsInteger(DataSetConstants.VERSION_ID);
      try {
        boolean deleted = dsDao.deleteInactiveDataSetVersion(dsVersionID)
        if(deleted){
          logger.debug("Dataset Version deleted");
          writeBackToClient( new JSONAcknowledge("Operation succeded") );
        }else{
          throw new SpagoBIServiceException(SERVICE_NAME,"sbi.ds.deleteVersion");
        }
      } catch (Throwable e) {
        logger.error("Exception occurred while retrieving dataset version to delete", e);
        throw new SpagoBIServiceException(SERVICE_NAME,"sbi.ds.deleteVersion", e);
      }
    }else if (serviceType != null  && serviceType.equalsIgnoreCase(DataSetConstants.DATASET_ALL_VERSIONS_DELETE)) {
      Integer dsID = getAttributeAsInteger(DataSetConstants.DS_ID);
      try {
        dsDao.deleteAllInactiveDataSetVersions(dsID);
        logger.debug("All Older Dataset versions deleted");
        writeBackToClient( new JSONAcknowledge("Operation succeded") );
      } catch (Throwable e) {
        logger.error("Exception occurred while retrieving dataset to delete", e);
        throw new SpagoBIServiceException(SERVICE_NAME,"sbi.ds.deleteVersion", e);
      }
    }else if (serviceType != null  && serviceType.equalsIgnoreCase(DataSetConstants.DATASET_VERSION_RESTORE)) {
      Integer dsID = getAttributeAsInteger(DataSetConstants.DS_ID);
      Integer dsVersionNum = getAttributeAsInteger(DataSetConstants.VERSION_NUM);
      try {
        GuiGenericDataSet dsNewDetail= dsDao.restoreOlderDataSetVersion(dsID, dsVersionNum);
        logger.debug("Dataset Version correctly Restored");
        List temp = new ArrayList();
        temp.add(dsNewDetail);
        JSONArray itemJSON = (JSONArray) SerializerFactory.getSerializer("application/json").serialize(temp, locale)
        JSONObject version = itemJSON.getJSONObject(0);
View Full Code Here



  public static String getDataSetResultFromId(IEngUserProfile profile,String dsId, Map parameters) throws Exception {
   
    IDataSetDAO dsDAO = DAOFactory.getDataSetDAO();
    IDataSet ds = dsDAO.loadActiveIDataSetByID(Integer.valueOf(dsId));
 
    String result=DataSetAccessFunctions.getDataSetResult(profile, ds, parameters);
    return result;
  }
View Full Code Here

   *
   * @throws Exception the exception
   */
  public static String getDataSetResultFromLabel(IEngUserProfile profile,String label, Map parameters) throws Exception {
   
    IDataSetDAO dsDAO = DAOFactory.getDataSetDAO();
    IDataSet ds = dsDAO.loadActiveDataSetByLabel(label);
 
    String result=DataSetAccessFunctions.getDataSetResult(profile, ds, parameters);
    return result;
   
  }
View Full Code Here

TOP

Related Classes of it.eng.spagobi.tools.dataset.dao.IDataSetDAO

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.