Package it.eng.spagobi.utilities.service

Examples of it.eng.spagobi.utilities.service.JSONSuccess


        List items = boDao.loadPagedObjectsList(start,limit);
        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,
            "Exception occurred while retrieving items", e);
View Full Code Here


        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);
        JSONObject attributesResponseSuccessJSON = new JSONObject();
        attributesResponseSuccessJSON.put("success", true);
        attributesResponseSuccessJSON.put("responseText", "Operation succeded");
        attributesResponseSuccessJSON.put("result", version);
        writeBackToClient( new JSONSuccess(attributesResponseSuccessJSON) );
      } catch (Throwable e) {
        logger.error("Exception occurred while retrieving dataset to delete", e);
        throw new SpagoBIServiceException(SERVICE_NAME,"sbi.ds.restoreVersionError", e);
      }
    }else if(serviceType == null){
View Full Code Here

          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);
                par.setId(null);
                DAOFactory.getBIObjectParameterDAO().insertBIObjectParameter(par);
              }
            }
          }
          logger.debug("New document inserted");
          JSONObject attributesResponseSuccessJSON = new JSONObject();
          attributesResponseSuccessJSON.put("responseText", "Operation succeded");
          writeBackToClient( new JSONSuccess(attributesResponseSuccessJSON) );
        }

      } catch (Throwable e) {
        logger.error(e.getMessage(), e);
        throw new SpagoBIServiceException(SERVICE_NAME,"sbi.document.saveError", e);
View Full Code Here

    logger.info(new String(objTemp.getContent()));
    objDao.modifyBIObject(biobj, objTemp);
    logger.debug("Template of document with id " + biobj.getId() + ", label " + biobj.getLabel() + ", name " + biobj.getName() + " updated");
    JSONObject response = new JSONObject();
    response.put("text", "Operation succeded");
    writeBackToClient( new JSONSuccess(response) );
    logger.debug("OUT");
  }
View Full Code Here

     
      JSONArray foldersJSON = (JSONArray)SerializerFactory.getSerializer("application/json").serialize( functionalities,locale );     
      JSONObject foldersResponseJSON =  createJSONResponseFolders(foldersJSON);
   
      try {
        writeBackToClient( new JSONSuccess( createJSONResponse(foldersResponseJSON, documentsResponseJSON) ) );
      } catch (IOException e) {
        throw new SpagoBIException("Impossible to write back the responce to the client", e);
      }
     
    } catch (Throwable t) {
View Full Code Here

        // look for binary content mimetype
        ObjMetadata metadata = (ObjMetadata)results.get(i);     
        objects.add(metadata);
      }
      toReturn = (JSONArray) SerializerFactory.getSerializer("application/json").serialize(objects, null);
      writeBackToClient( new JSONSuccess( toReturn ) );
    } catch (EMFUserError e) {
      // TODO Auto-generated catch block
      logger.error(e.getMessage(), e);
    } catch (SerializationException e) {
      logger.error(e.getMessage(), e);
View Full Code Here

      Locale locale = m.getLocale(httpRequest);
      JSONArray jsonFTree = new JSONArray();
      jsonFTree = (JSONArray)SerializerFactory.getSerializer("application/json").serialize( folders,locale );

      try {
        writeBackToClient( new JSONSuccesscreateNode(jsonFTree) ) ) ;
      } catch (IOException e) {
        throw new SpagoBIException("Impossible to write back the responce to the client", e);
      }
    } catch (Throwable t) {
      throw new SpagoBIException("An unexpected error occured while executing GET_FTREE_FOLDERS_ACTION", t);
View Full Code Here

      }
     
      try {
        JSONObject result = new JSONObject();
        result.put("result", resultStr);
        writeBackToClient( new JSONSuccess( result ) );
      } catch (IOException e) {
        throw new SpagoBIServiceException(SERVICE_NAME, "Impossible to write back the responce to the client", e);
      } catch (JSONException e) {
        throw new SpagoBIServiceException(SERVICE_NAME, "Cannot serialize objects into a JSON object", e);
      }
View Full Code Here

       
      }
      try {
        JSONObject results = new JSONObject();
        results.put("result", "OK");
        writeBackToClient( new JSONSuccess( results ) );
      } catch (IOException e) {
        throw new SpagoBIServiceException(SERVICE_NAME, "Impossible to write back the responce to the client", e);
      } catch (JSONException e) {
        throw new SpagoBIServiceException(SERVICE_NAME, "Cannot serialize objects into a JSON object", e);
      }
View Full Code Here

   
    String callback = getAttributeAsString( CALLBACK );
    logger.debug("Parameter [" + CALLBACK + "] is equals to [" + callback + "]");
   
    try {
      writeBackToClient( new JSONSuccess( parametersJSON, callback )  );
    } catch (IOException e) {
      throw new SpagoBIServiceException("Impossible to write back the responce to the client", e);
    }
  }
View Full Code Here

TOP

Related Classes of it.eng.spagobi.utilities.service.JSONSuccess

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.