protected Engine getEngineByDocumentType(String type) {
    Engine engine;
    List<Engine> engines;

    engine = null;
    try {
      Assert.assertNotNull(DAOFactory.getEngineDAO(), "EngineDao cannot be null");
      engines = DAOFactory.getEngineDAO().loadAllEnginesForBIObjectType(type);
      if (engines == null || engines.size() == 0) {
        throw new SpagoBIServiceException(
            SERVICE_NAME, "There are no engines for documents of type [" + type + "] available");
      } else {
        engine = engines.get(0);
        if (engines.size() > 1) {
          LogMF.warn(
              logger,
              "There are more than one engine for document of type [WORKSHEET]. We will use the one whose label is equal to [{0}]",
              engine.getLabel());
        } else {
          LogMF.debug(logger, "Using worksheet engine with label [{0}]", engine.getLabel());
        }
      }
    } catch (Throwable t) {
      throw new SpagoBIServiceException(
          SERVICE_NAME, "Impossible to load a valid engine for document of type [WORKSHEET]", t);
    } finally {
      logger.debug("OUT");
    }

    return engine;
  }
  public static Engine getEngineByDocumentType(String type) {
    Engine engine;
    List<Engine> engines;

    engine = null;
    try {
      Assert.assertNotNull(DAOFactory.getEngineDAO(), "EngineDao cannot be null");
      engines = DAOFactory.getEngineDAO().loadAllEnginesForBIObjectType(type);
      if (engines == null || engines.size() == 0) {
        throw new SpagoBIRuntimeException(
            "There are no engines for documents of type [" + type + "] available");
      } else {
        engine = (Engine) engines.get(0);
        LogMF.warn(
            logger,
            "There are more than one engine for document of type ["
                + type
                + "]. We will use the one whose label is equal to [{0}]",
            engine.getLabel());
      }
    } catch (Throwable t) {
      throw new SpagoBIRuntimeException(
          "Impossible to load a valid engine for document of type [" + type + "]", t);
    } finally {
      logger.debug("OUT");
    }

    return engine;
  }
 private void newConfiguredDocumentHandler(SourceBean request, SourceBean response)
     throws SourceBeanException, EMFUserError {
   logger.debug("IN");
   String tempFolder = (String) request.getAttribute(DossierConstants.DOSSIER_TEMP_FOLDER);
   Object objIdObj = request.getAttribute(DossierConstants.DOSSIER_CONFIGURED_BIOBJECT_ID);
   if (!(objIdObj instanceof String)) {
     Map errBackPars = new HashMap();
     errBackPars.put("PAGE", DossierConstants.DOSSIER_MANAGEMENT_PAGE);
     errBackPars.put(DossierConstants.DOSSIER_TEMP_FOLDER, tempFolder);
     errBackPars.put(LightNavigationManager.LIGHT_NAVIGATOR_DISABLED, "true");
     errBackPars.put(SpagoBIConstants.OPERATION, DossierConstants.OPERATION_DETAIL_DOSSIER);
     throw new EMFUserError(
         EMFErrorSeverity.ERROR, "102", null, errBackPars, "component_dossier_messages");
   }
   String objIdStr = (String) objIdObj;
   Integer objId = new Integer(objIdStr);
   BIObject obj = null;
   List params = null;
   List roleList = null;
   try {
     IBIObjectDAO biobjdao = DAOFactory.getBIObjectDAO();
     obj = biobjdao.loadBIObjectById(objId);
     Integer id = obj.getId();
     IBIObjectParameterDAO biobjpardao = DAOFactory.getBIObjectParameterDAO();
     params = biobjpardao.loadBIObjectParametersById(id);
     IRoleDAO roleDao = DAOFactory.getRoleDAO();
     roleList = roleDao.loadAllRoles();
   } catch (Exception e) {
     SpagoBITracer.major(
         DossierConstants.NAME_MODULE,
         this.getClass().getName(),
         "newConfiguredDocumentHandler",
         "Error while loading biobje parameters and roles",
         e);
   }
   Integer id = obj.getId();
   String descr = obj.getDescription();
   String label = obj.getLabel();
   String name = obj.getName();
   Iterator iterParams = params.iterator();
   HashMap parNamesMap = new HashMap();
   HashMap parValueMap = new HashMap();
   while (iterParams.hasNext()) {
     BIObjectParameter par = (BIObjectParameter) iterParams.next();
     String parLabel = par.getLabel();
     String parUrlName = par.getParameterUrlName();
     parNamesMap.put(parLabel, parUrlName);
     parValueMap.put(parUrlName, "");
   }
   response.setAttribute("parnamemap", parNamesMap);
   response.setAttribute("parvaluemap", parValueMap);
   response.setAttribute("idobj", id);
   response.setAttribute("description", descr);
   response.setAttribute("label", label);
   response.setAttribute("name", name);
   response.setAttribute(DossierConstants.PUBLISHER_NAME, "DossierConfiguredDocumentDetail");
   logger.debug("OUT");
 }
 private String initDossier(SourceBean request, SourceBean response)
     throws EMFUserError, SourceBeanException {
   logger.debug("IN");
   String objIdStr = (String) request.getAttribute(SpagoBIConstants.OBJECT_ID);
   Integer objId = new Integer(objIdStr);
   BIObject dossier = DAOFactory.getBIObjectDAO().loadBIObjectById(objId);
   IDossierDAO dossierDao = DAOFactory.getDossierDAO();
   String tempFolder = dossierDao.init(dossier);
   logger.debug("OUT");
   return tempFolder;
 }
 public List<EMFValidationError> adjustRequiredAnalyticalDrivers(Integer dossierId, List docs) {
   logger.debug("IN");
   BIObject dossier = null;
   try {
     dossier = DAOFactory.getBIObjectDAO().loadBIObjectById(dossierId);
     dossier.setBiObjectParameters(DAOFactory.getBIObjectDAO().getBIObjectParameters(dossier));
   } catch (EMFUserError e) {
     throw new RuntimeException("Cannot load details of dossier with id " + dossierId, e);
   }
   List<EMFValidationError> list = removeNotEmptyAnalyticalDrivers(dossier, docs);
   addEmptyAnalyticalDrivers(dossier, docs);
   logger.debug("OUT");
   return list;
 }
 private void addBIObjectParameterToDossier(
     BIObject dossier, BIObjectParameter parameterToBeAdded) {
   logger.debug("IN");
   IBIObjectParameterDAO objParDAO;
   try {
     objParDAO = DAOFactory.getBIObjectParameterDAO();
     BIObjectParameter objPar = new BIObjectParameter();
     objPar.setId(new Integer(-1));
     objPar.setBiObjectID(dossier.getId());
     objPar.setParID(parameterToBeAdded.getParID());
     Parameter par = new Parameter();
     par.setId(parameterToBeAdded.getParID());
     objPar.setParameter(par);
     objPar.setLabel(parameterToBeAdded.getLabel());
     objPar.setParameterUrlName(parameterToBeAdded.getParameterUrlName());
     objPar.setRequired(parameterToBeAdded.getRequired());
     objPar.setModifiable(parameterToBeAdded.getModifiable());
     objPar.setVisible(parameterToBeAdded.getVisible());
     objPar.setMultivalue(parameterToBeAdded.getMultivalue());
     List existingParameters = dossier.getBiObjectParameters();
     int priority = existingParameters != null ? existingParameters.size() + 1 : 1;
     objPar.setPriority(new Integer(priority));
     parameterToBeAdded.setId(new Integer(-1));
     objParDAO.insertBIObjectParameter(objPar);
   } catch (EMFUserError e) {
     throw new RuntimeException(
         "Cannot save new parameter into dossier with label " + dossier.getLabel(), e);
   }
   updateBIObjectParameters(dossier);
   logger.debug("OUT");
 }
Beispiel #7
0
  private ObjTemplate getTemplate(BIObject biObject) {
    ObjTemplate template;
    IObjTemplateDAO templateDAO;

    logger.debug("IN");

    try {
      Assert.assertNotNull(biObject, "Input [biObject] cannot be null");

      templateDAO = DAOFactory.getObjTemplateDAO();
      Assert.assertNotNull(templateDAO, "Impossible to instantiate templateDAO");

      template = templateDAO.getBIObjectActiveTemplate(biObject.getId());
      Assert.assertNotNull(template, "Loaded template cannot be null");

      logger.debug(
          "Active template ["
              + template.getName()
              + "] of document ["
              + biObject.getLabel()
              + "] loaded succesfully");
    } catch (Throwable t) {
      throw new RuntimeException(
          "Impossible to load template for document [" + biObject.getLabel() + "]", t);
    } finally {
      logger.debug("OUT");
    }

    return template;
  }
 private void dossierDetailHandler(SourceBean request, SourceBean response)
     throws SourceBeanException, EMFUserError {
   logger.debug("IN");
   String tempFolder = (String) request.getAttribute(DossierConstants.DOSSIER_TEMP_FOLDER);
   IDossierDAO dossierDao = new DossierDAOHibImpl();
   //		List roleList = null;
   //		try{
   //			IRoleDAO roleDao = DAOFactory.getRoleDAO();
   //			roleList = roleDao.loadAllRoles();
   //		} catch(Exception e) {
   //			logger.error("Error while loading all roles", e);
   //		}
   // get the current template file name
   String tempFileName = dossierDao.getPresentationTemplateFileName(tempFolder);
   if (tempFileName == null) tempFileName = "";
   // get list of the configured document
   List confDoc = dossierDao.getConfiguredDocumentList(tempFolder);
   // get the current process definition file name
   String procDefFileName = dossierDao.getProcessDefinitionFileName(tempFolder);
   if (procDefFileName == null) procDefFileName = "";
   // WorkflowConfiguration workConf = bookDao.getWorkflowConfiguration(pathConfBook);
   List functionalities;
   try {
     functionalities = DAOFactory.getLowFunctionalityDAO().loadAllLowFunctionalities(true);
   } catch (EMFUserError e) {
     logger.error("Error while loading documents tree", e);
     throw new EMFUserError(EMFErrorSeverity.ERROR, 100);
   }
   response.setAttribute(SpagoBIConstants.FUNCTIONALITIES_LIST, functionalities);
   response.setAttribute(DossierConstants.CONFIGURED_DOCUMENT_LIST, confDoc);
   response.setAttribute(DossierConstants.PUBLISHER_NAME, "DossierDetail");
   response.setAttribute(DossierConstants.OO_TEMPLATE_FILENAME, tempFileName);
   response.setAttribute(DossierConstants.WF_PROCESS_DEFINTIION_FILENAME, procDefFileName);
   logger.debug("OUT");
 }
  public SDKEngine[] getEngines() throws NotAllowedOperationException {
    SDKEngine[] toReturn = null;
    logger.debug("IN");

    this.setTenant();

    try {
      super.checkUserPermissionForFunctionality(
          SpagoBIConstants.ENGINES_MANAGEMENT, "User cannot see engines congifuration.");
      List enginesList = DAOFactory.getEngineDAO().loadAllEngines();
      List sdkEnginesList = new ArrayList();
      if (enginesList != null && enginesList.size() > 0) {
        for (Iterator it = enginesList.iterator(); it.hasNext(); ) {
          Engine engine = (Engine) it.next();
          SDKEngine sdkEngine = new SDKObjectsConverter().fromEngineToSDKEngine(engine);
          sdkEnginesList.add(sdkEngine);
        }
      }
      toReturn = new SDKEngine[sdkEnginesList.size()];
      toReturn = (SDKEngine[]) sdkEnginesList.toArray(toReturn);
    } catch (NotAllowedOperationException e) {
      throw e;
    } catch (Exception e) {
      logger.error("Error while retrieving SDKEngine list", e);
      logger.debug("Returning null");
      return null;
    } finally {
      this.unsetTenant();
      logger.debug("OUT");
    }
    return toReturn;
  }
  public SDKEngine getEngine(Integer engineId) throws NotAllowedOperationException {
    SDKEngine toReturn = null;
    logger.debug("IN: engineId in input = " + engineId);

    this.setTenant();

    try {
      super.checkUserPermissionForFunctionality(
          SpagoBIConstants.ENGINES_MANAGEMENT, "User cannot see engines congifuration.");
      if (engineId == null) {
        logger.warn("Engine identifier in input is null!");
        return null;
      }
      Engine engine = DAOFactory.getEngineDAO().loadEngineByID(engineId);
      if (engine == null) {
        logger.warn("Engine with identifier [" + engineId + "] not existing.");
        return null;
      }
      toReturn = new SDKObjectsConverter().fromEngineToSDKEngine(engine);
    } catch (NotAllowedOperationException e) {
      throw e;
    } catch (Exception e) {
      logger.error("Error while retrieving SDKEngine", e);
      logger.debug("Returning null");
      return null;
    } finally {
      this.unsetTenant();
      logger.debug("OUT");
    }
    return toReturn;
  }
  /* (non-Javadoc)
   * @see it.eng.spago.dispatching.service.list.basic.IFaceBasicListService#getList(it.eng.spago.base.SourceBean, it.eng.spago.base.SourceBean)
   */
  public ListIFace getList(SourceBean request, SourceBean response) throws Exception {

    logger.debug("IN");
    ListIFace list = null;
    // get role / par id / par field name name
    String roleName = (String) request.getAttribute("roleName");
    String parIdStr = (String) request.getAttribute("parameterId");
    logger.debug("roleName=" + roleName);
    logger.debug("parameterId=" + parIdStr);

    Integer parId = new Integer(parIdStr);
    // check if the parameter use is manual input
    IParameterUseDAO parusedao = DAOFactory.getParameterUseDAO();
    ParameterUse paruse = parusedao.loadByParameterIdandRole(parId, roleName);
    Integer manInp = paruse.getManualInput();
    if (manInp.intValue() == 1) {
      String message = "";
      try {
        message =
            PortletUtilities.getMessage(
                "scheduler.fillparmanually", "component_scheduler_messages");
      } catch (Exception e) {
        IMessageBuilder msgBuilder = MessageBuilderFactory.getMessageBuilder();
        message =
            msgBuilder.getMessage("scheduler.fillparmanually", "component_scheduler_messages");
      }
      response.setAttribute(SpagoBIConstants.MESSAGE_INFO, message);
    } else {
      list = loadSpagoList(request, response, parId, roleName);
    }
    // fill response
    response.setAttribute(SpagoBIConstants.PUBLISHER_NAME, "LovLookupAjax");
    logger.debug("OUT");
    return list;
  }
 private void saveNotes(
     String execIdentifier,
     Integer objectId,
     String notes,
     ObjNote objnote,
     String owner,
     String visibility,
     IEngUserProfile profile)
     throws Exception {
   logger.debug("IN");
   try {
     IObjNoteDAO objNoteDAO = DAOFactory.getObjNoteDAO();
     objNoteDAO.setUserProfile(profile);
     if (objnote != null) {
       // Modify note
       objnote.setContent(notes.getBytes());
       objnote.setIsPublic((visibility.equalsIgnoreCase("PUBLIC") ? true : false));
       objNoteDAO.modifyExecutionNotes(objnote);
     } else {
       // Insert new note
       objnote = new ObjNote();
       objnote.setContent(notes.getBytes());
       objnote.setExecReq(execIdentifier);
       objnote.setIsPublic((visibility.equalsIgnoreCase("PUBLIC") ? true : false));
       objnote.setOwner(owner);
       objNoteDAO.saveExecutionNotes(objectId, objnote);
     }
   } finally {
     logger.debug("OUT");
   }
 }
  /**
   * Method called by document composition publisher , that returns alla available exporters for a
   * single document contained in the composed one.
   *
   * @param objLabel
   * @param sessionContainer
   * @param requestSB
   * @return
   */
  public static List getAvailableExporters(
      String objLabel, SessionContainer sessionContainer, SourceBean requestSB) {
    logger.debug("IN");

    List<Exporters> exporters = null;
    List<String> exportersTypes = null;
    if (objLabel == null || objLabel.equals("")) {
      logger.error("Object Label is null: cannot get engine's url.");
      return null;
    }

    try {
      // get the user profile from session
      SessionContainer permSession = sessionContainer.getPermanentContainer();
      IEngUserProfile profile =
          (IEngUserProfile) permSession.getAttribute(IEngUserProfile.ENG_USER_PROFILE);
      BIObject obj = DAOFactory.getBIObjectDAO().loadBIObjectByLabel(objLabel);
      if (obj == null) {
        logger.error(
            "Cannot obtain engine url. Document with label "
                + objLabel
                + " doesn't exist into database.");
        List l = new ArrayList();
        l.add(objLabel);
        throw new EMFUserError(EMFErrorSeverity.ERROR, "1005", l, messageBundle);
      }
      Engine engine = obj.getEngine();
      exporters = DAOFactory.getEngineDAO().getAssociatedExporters(engine);
      if (exporters != null) {
        exportersTypes = new ArrayList<String>();
        for (int i = 0; i < exporters.size(); i++) {
          Domain domain = DAOFactory.getDomainDAO().loadDomainById(exporters.get(i).getDomainId());
          String cd = domain.getValueCd();
          exportersTypes.add(cd);
        }
      }
    } catch (Exception e) {
      logger.error("Error while getting document's exporters for label :" + objLabel + ": " + e);
      return null;
    } finally {
      logger.debug("OUT");
    }

    return exportersTypes;
  }
  public static Engine getEngineByDriver(String driver) {
    Engine engine;

    engine = null;
    try {
      Assert.assertNotNull(DAOFactory.getEngineDAO(), "EngineDao cannot be null");
      engine = DAOFactory.getEngineDAO().loadEngineByDriver(driver);
      if (engine == null) {
        throw new SpagoBIRuntimeException(
            "There are no engines with driver equal to [" + driver + "] available");
      }
    } catch (Throwable t) {
      throw new SpagoBIRuntimeException(
          "Impossible to load a valid engine whose drover is equal to [" + driver + "]", t);
    } finally {
      logger.debug("OUT");
    }

    return engine;
  }
  private void persistValues(
      String businessUnitCode,
      String businessAreaCode,
      String cdc,
      String year,
      String closureCode,
      String userId,
      String ricavi,
      String primoMargine,
      String margineContribuzione,
      String ricaviVarPer,
      String ricaviVarAbs,
      String primoMargineVarPer,
      String primoMargineVarAbs,
      String margineContribuzioneVarPer,
      String margineContribuzioneVarAbs) {

    try {

      IDataSourceDAO dataSourceDAO = DAOFactory.getDataSourceDAO();
      IDataSource dataSource = dataSourceDAO.loadDataSourceByLabel("DWH BIENG");
      Connection connection = dataSource.getConnection();
      String insertQuery =
          "INSERT INTO SUPP_REP02_T8 (BUSINESS_UNIT, BUSINESS_AREA, CDC, YEAR, CLOSURE, INSERT_USER, FC_RICAVI, FC_PM, FC_MDC, "
              + "VAR_PERC_RICAVI,VAR_ABS_RICAVI,VAR_PERC_PM,VAR_ABS_PM,VAR_PERC_MDC,VAR_ABS_MDC ) "
              + "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
      PreparedStatement preparedStatement = connection.prepareStatement(insertQuery);

      preparedStatement.setString(1, businessUnitCode);
      preparedStatement.setString(2, businessAreaCode);
      preparedStatement.setString(3, cdc);
      preparedStatement.setInt(4, Integer.valueOf(year));
      preparedStatement.setInt(5, Integer.valueOf(closureCode));
      preparedStatement.setString(6, userId);
      preparedStatement.setDouble(7, Double.valueOf(ricavi));
      preparedStatement.setDouble(8, Double.valueOf(primoMargine));
      preparedStatement.setDouble(9, Double.valueOf(margineContribuzione));

      preparedStatement.setDouble(10, Double.valueOf(ricaviVarPer));
      preparedStatement.setDouble(11, Double.valueOf(ricaviVarAbs));
      preparedStatement.setDouble(12, Double.valueOf(primoMargineVarPer));
      preparedStatement.setDouble(13, Double.valueOf(primoMargineVarAbs));
      preparedStatement.setDouble(14, Double.valueOf(margineContribuzioneVarPer));
      preparedStatement.setDouble(15, Double.valueOf(margineContribuzioneVarAbs));

      preparedStatement.executeUpdate();
      preparedStatement.close();
    } catch (Exception e) {
      logger.error("An unexpected error occured while updating Forecast Edit");
      throw new SpagoBIServiceException(
          "An unexpected error occured while updating Forecast Edit", e);
    }
  }
 private void updateBIObjectParameters(BIObject dossier) {
   logger.debug("IN");
   try {
     List parameters =
         DAOFactory.getBIObjectParameterDAO().loadBIObjectParametersById(dossier.getId());
     dossier.setBiObjectParameters(parameters);
   } catch (EMFUserError e) {
     throw new RuntimeException(
         "Cannot reload parameters of dossier with label " + dossier.getLabel(), e);
   }
   logger.debug("OUT");
 }
Beispiel #17
0
 private Map applyDatasourceForWriting(Map parameters, BIObject biObject) {
   IDataSource datasource;
   try {
     datasource = DAOFactory.getDataSourceDAO().loadDataSourceWriteDefault();
   } catch (EMFUserError e) {
     throw new SpagoBIRuntimeException("Error while loading default datasource for writing", e);
   }
   if (datasource != null) {
     parameters.put(EngineConstants.DEFAULT_DATASOURCE_FOR_WRITING_LABEL, datasource.getLabel());
   } else {
     logger.debug("There is no default datasource for writing");
   }
   return parameters;
 }
 private void exitFromDetailHandler(SourceBean request, SourceBean response)
     throws EMFUserError, SourceBeanException {
   logger.debug("IN");
   String tempFolder = (String) request.getAttribute(DossierConstants.DOSSIER_TEMP_FOLDER);
   IDossierDAO dossierDao = DAOFactory.getDossierDAO();
   // cleans temp folder
   dossierDao.clean(tempFolder);
   // propagates dossier id (usefull to return to document main detail page if light navigator is
   // disabled)
   Integer dossierId = dossierDao.getDossierId(tempFolder);
   response.setAttribute(ObjectsTreeConstants.OBJECT_ID, dossierId.toString());
   response.setAttribute(DossierConstants.PUBLISHER_NAME, "ExitFromDossierDetailLoop");
   logger.debug("OUT");
 }
 private EMFValidationError removeAnalyticalDriver(BIObjectParameter aParameter) {
   logger.debug("IN");
   EMFValidationError error = null;
   try {
     error = DetailBIObjectModule.checkForDependancies(aParameter.getId());
     if (error == null) {
       DAOFactory.getBIObjectParameterDAO().eraseBIObjectParameter(aParameter, true);
     }
   } catch (EMFUserError e) {
     throw new SpagoBIRuntimeException(
         "Cannot remove document parameter " + aParameter.getLabel(), e);
   }
   logger.debug("OUT");
   return error;
 }
 private void detailConfiguredDocumentHandler(SourceBean request, SourceBean response)
     throws Exception {
   logger.debug("IN");
   String tempFolder = (String) request.getAttribute(DossierConstants.DOSSIER_TEMP_FOLDER);
   String confDocIdent = (String) request.getAttribute("configureddocumentidentifier");
   // get configured document
   IDossierDAO dossierDao = new DossierDAOHibImpl();
   ConfiguredBIDocument confDoc = dossierDao.getConfiguredDocument(confDocIdent, tempFolder);
   // get parameter value map
   Map paramValueMap = confDoc.getParameters();
   // create parameter name map
   //		Integer idobj = confDoc.getId();
   String label = confDoc.getLabel();
   BIObject obj = DAOFactory.getBIObjectDAO().loadBIObjectByLabel(label);
   Integer idobj = obj.getId();
   IBIObjectParameterDAO biobjpardao = DAOFactory.getBIObjectParameterDAO();
   List params = biobjpardao.loadBIObjectParametersById(idobj);
   Iterator iterParams = params.iterator();
   Map paramNameMap = new HashMap();
   while (iterParams.hasNext()) {
     BIObjectParameter par = (BIObjectParameter) iterParams.next();
     String parLabel = par.getLabel();
     String parUrlName = par.getParameterUrlName();
     paramNameMap.put(parLabel, parUrlName);
   }
   // set attribute into response
   response.setAttribute("parnamemap", paramNameMap);
   response.setAttribute("parvaluemap", paramValueMap);
   //		response.setAttribute("idobj", confDoc.getId());
   response.setAttribute("description", confDoc.getDescription());
   response.setAttribute("label", confDoc.getLabel());
   response.setAttribute("name", confDoc.getName());
   response.setAttribute("logicalname", confDoc.getLogicalName());
   response.setAttribute(DossierConstants.PUBLISHER_NAME, "DossierConfiguredDocumentDetail");
   logger.debug("OUT");
 }
  /**
   * Returns an url for the test of the EXTERNAL engine.
   *
   * @param objLabel the logical label of the document (gets from the template file)
   * @param sessionContainer session object
   * @param requestSB request object
   * @return String the complete url. It use this format: <code_error>|<url>. If there is an error
   *     during the execution <code_error> is valorized and url is null, else it is null and the url
   *     is complete.
   */
  public static String getEngineTestUrl(
      String objLabel, SessionContainer sessionContainer, SourceBean requestSB) {
    logger.debug("IN");

    Monitor monitor =
        MonitorFactory.start("spagobi.engines.DocumentCompositionUtils.getEngineTestUrl");

    String baseUrlReturn = "";
    String urlReturn = "";

    if (objLabel == null || objLabel.equals("")) {
      logger.error("Object Label is null: cannot get engine's url.");
      return "1008|";
    }

    try {
      // get the user profile from session
      SessionContainer permSession = sessionContainer.getPermanentContainer();
      BIObject obj = DAOFactory.getBIObjectDAO().loadBIObjectByLabel(objLabel);
      if (obj == null) {
        logger.error(
            "Cannot obtain engine url. Document with label "
                + objLabel
                + " doesn't exist into database.");
        List l = new ArrayList();
        l.add(objLabel);
        throw new EMFUserError(EMFErrorSeverity.ERROR, "1005", l, messageBundle);
      }

      String className = obj.getEngine().getClassName();
      if (className == null || className.trim().equals("")) {
        // external engine
        baseUrlReturn = obj.getEngine().getUrl() + "Test?";
        urlReturn = baseUrlReturn;
        logger.debug("urlReturn: " + "|" + urlReturn);
      }
    } catch (Exception ex) {
      logger.error("Error while getting execution url: " + ex);
      return null;
    } finally {
      monitor.stop();
    }

    logger.debug("OUT");

    return "|" + urlReturn;
  }
  @GET
  @Path("/listValueDescriptionByType")
  @Produces(MediaType.APPLICATION_JSON)
  public String getListDomainsByType(@Context HttpServletRequest req) {
    IDomainDAO domaindao = null;
    List<Domain> domains = null;

    String language = (String) req.getSession().getAttribute(Constants.USER_LANGUAGE);
    String country = (String) req.getSession().getAttribute(Constants.USER_COUNTRY);
    Locale locale = Locale.UK;
    if (language != null) {
      if (country == null && language != null) {
        locale = new Locale(language);
      } else {
        new Locale(language, country);
      }
    }

    JSONArray domainsJSONArray = new JSONArray();
    JSONObject domainsJSONObject = new JSONObject();

    String type = (String) req.getParameter(DOMAIN_TYPE);
    String extVersion = (String) req.getParameter(EXT_VERSION);

    JSONObject datasorcesJSON = new JSONObject();
    String result = null;
    try {

      domaindao = DAOFactory.getDomainDAO();
      domains = domaindao.loadListDomainsByType(type);
      domainsJSONArray = translate(domains, locale);
      domainsJSONObject.put("domains", domainsJSONArray);

      if ((extVersion != null) && (extVersion.equals("3"))) {
        result = domainsJSONObject.toString();
      } else {
        result = domainsJSONArray.toString();
      }

    } catch (Throwable t) {
      throw new SpagoBIServiceException(
          "An unexpected error occured while instatiating the dao", t);
    }

    return result;
  }
 private void newTemplateHandler(SourceBean request, SourceBean response)
     throws SourceBeanException, EMFUserError {
   logger.debug("IN");
   String tempOOFileName = "";
   List confDoc = new ArrayList();
   WorkflowConfiguration workConf = new WorkflowConfiguration();
   List functionalities;
   try {
     functionalities = DAOFactory.getLowFunctionalityDAO().loadAllLowFunctionalities(true);
   } catch (EMFUserError e) {
     logger.error("Error while loading documents tree", e);
     throw new EMFUserError(EMFErrorSeverity.ERROR, 100);
   }
   response.setAttribute(SpagoBIConstants.FUNCTIONALITIES_LIST, functionalities);
   response.setAttribute(DossierConstants.CONFIGURED_DOCUMENT_LIST, confDoc);
   response.setAttribute(DossierConstants.PUBLISHER_NAME, "DossierDetail");
   response.setAttribute(DossierConstants.OO_TEMPLATE_FILENAME, tempOOFileName);
   response.setAttribute(DossierConstants.WORKFLOW_CONFIGURATION, workConf);
   logger.debug("OUT");
 }
Beispiel #24
0
  /**
   * Starting from a BIObject extracts from it the map of the paramaeters for the execution call
   *
   * @param biObject BIObject to execute
   * @return Map The map of the execution call parameters
   */
  private Map getRequestParameters(BIObject biObject) {
    logger.debug("IN");

    Map parameters;
    ObjTemplate template;
    IBinContentDAO contentDAO;
    byte[] content;

    logger.debug("IN");

    parameters = null;

    try {
      parameters = new Hashtable();
      template = this.getTemplate(biObject);

      try {
        contentDAO = DAOFactory.getBinContentDAO();
        Assert.assertNotNull(contentDAO, "Impossible to instantiate contentDAO");

        content = contentDAO.getBinContent(template.getBinId());
        Assert.assertNotNull(content, "Template content cannot be null");
      } catch (Throwable t) {
        throw new RuntimeException(
            "Impossible to load template content for document [" + biObject.getLabel() + "]", t);
      }

      appendRequestParameter(parameters, "document", biObject.getId().toString());
      appendAnalyticalDriversToRequestParameters(biObject, parameters);
      addBIParameterDescriptions(biObject, parameters);

      addMetadataAndContent(biObject, parameters);

    } finally {
      logger.debug("OUT");
    }

    return parameters;
  }
Beispiel #25
0
  public Object serialize(Object o, Locale locale) throws SerializationException {
    JSONObject result = null;

    if (!(o instanceof Goal)) {
      throw new SerializationException(
          "GoalJSONSerializer is unable to serialize object of type: " + o.getClass().getName());
    }

    try {
      Goal goal = (Goal) o;
      result = new JSONObject();
      result.put(ID, goal.getId());
      result.put(NAME, goal.getName());
      result.put(DESCRIPTION, goal.getDescription());
      result.put(LABEL, goal.getLabel());
      String df = GeneralUtilities.getServerDateFormat();
      SimpleDateFormat dateFormat = new SimpleDateFormat();
      dateFormat.applyPattern(df);
      dateFormat.setLenient(false);
      result.put(START_DATE, dateFormat.format(goal.getStartDate()));
      result.put(END_DATE, dateFormat.format(goal.getEndDate()));

      if (goal.getGrant() != null) {

        OrganizationalUnitGrant grant =
            DAOFactory.getOrganizationalUnitDAO().getGrant(goal.getGrant());
        result.put(GRANT_ID, goal.getGrant());
        result.put(GRANT_NAME, grant.getName());
      }

    } catch (Throwable t) {
      throw new SerializationException("An error occurred while serializing object: " + o, t);
    }

    return result;
  }
Beispiel #26
0
  /** This action is called by the user who wants to export the result of a Kpi in PDF */
  public void service(SourceBean serviceRequest, SourceBean serviceResponse) throws Exception {

    File tmpFile = null;
    logger.debug("IN");
    HttpServletRequest httpRequest = getHttpRequest();
    HttpSession session = httpRequest.getSession();

    this.freezeHttpResponse();

    try {
      // get KPI result
      List<KpiResourceBlock> listKpiBlocks =
          (List<KpiResourceBlock>) session.getAttribute("KPI_BLOCK");

      // List<KpiResourceBlock> listKpiBlocks=executeKpi(objectId);

      // recover BiObject Name
      Object idObject = serviceRequest.getAttribute(SpagoBIConstants.OBJECT_ID);
      if (idObject == null) {
        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");
      if (userIdO != null) userId = userIdO.toString();

      it.eng.spagobi.engines.exporters.KpiExporter exporter = new KpiExporter();
      tmpFile = exporter.getKpiReportPDF(listKpiBlocks, document, userId);

      String outputType = "PDF";

      String mimeType = "application/pdf";

      logger.debug("Report exported succesfully");

      HttpServletResponse response = getHttpResponse();
      response.setContentType(mimeType);
      response.setHeader("Content-Disposition", "filename=\"report." + outputType + "\";");
      response.setContentLength((int) tmpFile.length());

      BufferedInputStream in = new BufferedInputStream(new FileInputStream(tmpFile));
      int b = -1;
      while ((b = in.read()) != -1) {
        response.getOutputStream().write(b);
      }
      response.getOutputStream().flush();
      in.close();
      logger.debug("OUT");

    } catch (Throwable e) {
      logger.error("An exception has occured", e);
      throw new Exception(e);
    } finally {

      tmpFile.delete();
    }
  }
Beispiel #27
0
  private void addMetadataAndContent(BIObject biObject, Map pars) {
    logger.debug("IN");
    try {
      if (biObject.getObjMetaDataAndContents() != null) {
        MetadataJSONSerializer jsonSerializer = new MetadataJSONSerializer();
        JSONArray metaArray = new JSONArray();
        Locale locale = getLocale();

        Domain typeDom = DAOFactory.getDomainDAO().loadDomainById(biObject.getBiObjectTypeID());
        MessageBuilder msgBuild = new MessageBuilder();
        // fill thecnical metadata

        JSONObject labelJSON = new JSONObject();
        String label = msgBuild.getMessage(GetMetadataAction.LABEL, locale);
        labelJSON.put("meta_name", label);
        labelJSON.put("meta_content", biObject.getLabel());
        labelJSON.put("meta_type", "GENERAL_META");

        JSONObject nameJSON = new JSONObject();
        String name = msgBuild.getMessage(GetMetadataAction.NAME, locale);
        nameJSON.put("meta_name", name);
        nameJSON.put("meta_content", biObject.getName());
        nameJSON.put("meta_type", "GENERAL_META");

        JSONObject typeJSON = new JSONObject();
        String typeL = msgBuild.getMessage(GetMetadataAction.TYPE, locale);
        String valueType = msgBuild.getMessage(typeDom.getValueName(), locale);
        typeJSON.put("meta_name", typeL);
        typeJSON.put("meta_content", valueType);
        typeJSON.put("meta_type", "GENERAL_META");

        JSONObject engineJSON = new JSONObject();
        String engine = msgBuild.getMessage(GetMetadataAction.ENG_NAME, locale);
        engineJSON.put("meta_name", engine);
        engineJSON.put("meta_content", biObject.getEngine().getName());
        engineJSON.put("meta_type", "GENERAL_META");

        metaArray.put(labelJSON);
        metaArray.put(nameJSON);
        metaArray.put(typeJSON);
        metaArray.put(engineJSON);

        for (Iterator iterator = biObject.getObjMetaDataAndContents().iterator();
            iterator.hasNext(); ) {
          DocumentMetadataProperty type = (DocumentMetadataProperty) iterator.next();
          Object o = jsonSerializer.serialize(type, locale);
          metaArray.put(o);
          logger.debug("Metadata serialzied " + o);
        }
        logger.debug("Metadata array serialzied " + metaArray);
        pars.put(METADATA_AND_METACONTENT, metaArray);
      } else {
        logger.debug("no meta and metacontent defined");
      }

    } catch (Exception e) {
      logger.error(
          "Impossibile to serialize metadata and metacontent for object with label "
              + biObject.getLabel(),
          e);
      throw new RuntimeException(
          "Impossibile to serialize metadata and metacontent for object with label "
              + biObject.getLabel(),
          e);
    }

    logger.debug("OUT");
  }
  @Override
  public void doService() {
    logger.debug("IN");
    IPeriodicityDAO perDao;
    try {
      perDao = DAOFactory.getPeriodicityDAO();
      perDao.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(PERIODICTIES_LIST)) {

      try {
        List periodicities = perDao.loadPeriodicityList();
        logger.debug("Loaded periodicities list");
        JSONArray periodicitiesJSON =
            (JSONArray)
                SerializerFactory.getSerializer("application/json")
                    .serialize(periodicities, locale);
        JSONObject periodicitiesResponseJSON = createJSONResponsePeriodicities(periodicitiesJSON);

        writeBackToClient(new JSONSuccess(periodicitiesResponseJSON));

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

      String id = getAttributeAsString(ID);
      String name = getAttributeAsString(NAME);
      String months = getAttributeAsString(MONTHS);
      String days = getAttributeAsString(DAYS);
      String hours = getAttributeAsString(HOURS);
      String minutes = getAttributeAsString(MINUTES);

      if (name != null) {
        Periodicity per = new Periodicity();
        per.setName(name);

        if (months != null && !months.equals("")) {
          per.setMonths(new Integer(months));
        } else {
          per.setMonths(new Integer("0"));
        }
        if (days != null && !days.equals("")) {
          per.setDays(new Integer(days));
        } else {
          per.setDays(new Integer("0"));
        }
        if (hours != null && !hours.equals("")) {
          per.setHours(new Integer(hours));
        } else {
          per.setHours(new Integer("0"));
        }
        if (minutes != null && !minutes.equals("")) {
          per.setMinutes(new Integer(minutes));
        } else {
          per.setMinutes(new Integer("0"));
        }

        try {
          if (id != null && !id.equals("") && !id.equals("0")) {
            per.setIdKpiPeriodicity(Integer.valueOf(id));
            perDao.modifyPeriodicity(per);
            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 perID = perDao.insertPeriodicity(per);
            logger.debug("New Resource inserted");
            JSONObject attributesResponseSuccessJSON = new JSONObject();
            attributesResponseSuccessJSON.put("success", true);
            attributesResponseSuccessJSON.put("responseText", "Operation succeded");
            attributesResponseSuccessJSON.put("id", perID);
            writeBackToClient(new JSONSuccess(attributesResponseSuccessJSON));
          }

        } catch (Throwable e) {
          logger.error(e.getMessage(), e);
          throw new SpagoBIServiceException(
              SERVICE_NAME, "Exception occurred while saving new resource", e);
        }

      } else {
        logger.error("Resource name, code or type are missing");
        throw new SpagoBIServiceException(SERVICE_NAME, "Please fill resource name, code and type");
      }
    } else if (serviceType != null && serviceType.equalsIgnoreCase(PERIODICITY_DELETE)) {
      Integer id = getAttributeAsInteger(ID);
      try {
        perDao.deletePeriodicity(id);
        logger.debug("Resource deleted");
        writeBackToClient(new JSONAcknowledge("Operation succeded"));
      } catch (Throwable e) {
        logger.error("Exception occurred while retrieving resource to delete", e);
        throw new SpagoBIServiceException(
            SERVICE_NAME, "Exception occurred while retrieving resource to delete", e);
      }
    }
    logger.debug("OUT");
  }
  @Override
  public void doService() {
    logger.debug("IN");

    try {
      modelDao = DAOFactory.getModelDAO();
      modelDao.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(MODELS_LIST)) {

      try {
        List modelRootsList = modelDao.loadModelsRoot();

        logger.debug("Loaded models list");
        JSONArray modelsListJSON =
            (JSONArray)
                SerializerFactory.getSerializer("application/json")
                    .serialize(modelRootsList, locale);
        JSONObject modelsResponseJSON =
            createJSONResponseModelsList(modelsListJSON, new Integer(6));

        writeBackToClient(new JSONSuccess(modelsResponseJSON));

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

      try {

        String parentId = (String) getAttributeAsString("modelId");
        if (parentId == null || parentId.startsWith("xnode")) {
          writeBackToClient(new JSONSuccess("'OK'"));
          return;
        }
        Model aModel = modelDao.loadModelWithChildrenById(Integer.parseInt(parentId));

        logger.debug("Loaded model tree");
        JSONArray modelChildrenJSON =
            (JSONArray)
                SerializerFactory.getSerializer("application/json")
                    .serialize(aModel.getChildrenNodes(), locale);
        writeBackToClient(new JSONSuccess(modelChildrenJSON));

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

      try {

        String parentId = (String) getAttributeAsString("modelId");
        if (parentId == null || parentId.startsWith("xnode")) {
          writeBackToClient(new JSONSuccess("'OK'"));
          return;
        }
        Model dbModel = modelDao.loadModelWithChildrenById(Integer.parseInt(parentId));

        ModelExtended aModel = new ModelExtended(dbModel);

        aModel.setExtendedChildrenNodes(dbModel.getChildrenNodes());

        logger.debug("Loaded model tree");
        JSONArray modelChildrenJSON =
            (JSONArray)
                SerializerFactory.getSerializer("application/json")
                    .serialize(aModel.getExtendedChildrenNodes(), locale);
        writeBackToClient(new JSONSuccess(modelChildrenJSON));

      } catch (Throwable e) {
        logger.error("Exception occurred while retrieving model tree", e);
        throw new SpagoBIServiceException(
            SERVICE_NAME, "Exception occurred while retrieving model tree", e);
      }
    } else if (serviceType != null && serviceType.equalsIgnoreCase(MODEL_NODES_SAVE)) {
      JSONArray nodesToSaveJSON = getAttributeAsJSONArray(NODES_TO_SAVE);
      List<Model> modelNodes = null;
      if (nodesToSaveJSON != null) {
        try {
          modelNodes = deserializeNodesJSONArray(nodesToSaveJSON);

          // save them
          JSONObject response = saveModelNodes(modelNodes);
          writeBackToClient(new JSONSuccess(response));

        } catch (Exception e) {
          logger.error(e.getMessage(), e);
          writeErrorsBackToClient();
          throw new SpagoBIServiceException(SERVICE_NAME, "Exception saving model nodes", e);
        }
      }

    } else if (serviceType != null && serviceType.equalsIgnoreCase(MODEL_NODE_DELETE)) {

      Integer modelId = getAttributeAsInteger("modelId");
      logger.warn("DELETING NODE WITH MODEL_ID:" + modelId);
      try {
        modelDao.deleteModel(modelId);
        logger.debug("Model deleted");
        writeBackToClient(new JSONSuccess("'Operation succeded'"));
      } catch (Throwable e) {
        logger.error("Exception occurred while retrieving model to delete", e);
        throw new SpagoBIServiceException(
            SERVICE_NAME, "Exception occurred while retrieving model to delete", e);
      }

    } else if (serviceType == null) {
      try {
        List nodeTypesNodes =
            DAOFactory.getDomainDAO().loadListDomainsByType(MODEL_DOMAIN_TYPE_NODE);
        List nodeTypesRoot =
            DAOFactory.getDomainDAO().loadListDomainsByType(MODEL_DOMAIN_TYPE_ROOT);
        List nodeTypes = new ArrayList();
        nodeTypes.addAll(nodeTypesNodes);
        nodeTypes.addAll(nodeTypesRoot);
        getSessionContainer().setAttribute("nodeTypesList", nodeTypes);
        List kpiTypesList = DAOFactory.getDomainDAO().loadListDomainsByType(KPI_DOMAIN_TYPE);
        getSessionContainer().setAttribute("kpiTypesList", kpiTypesList);
        List thrSeverityTypes =
            DAOFactory.getDomainDAO().loadListDomainsByType(THRESHOLD_SEVERITY_TYPE);
        getSessionContainer().setAttribute("thrSeverityTypes", thrSeverityTypes);
        List measureTypesList =
            DAOFactory.getDomainDAO().loadListDomainsByType(MEASURE_DOMAIN_TYPE);
        getSessionContainer().setAttribute("measureTypesList", measureTypesList);
        List metricScaleTypesList =
            DAOFactory.getDomainDAO().loadListDomainsByType(METRIC_SCALE_DOMAIN_TYPE);
        getSessionContainer().setAttribute("metricScaleTypesList", metricScaleTypesList);
        List thrTypesList = DAOFactory.getDomainDAO().loadListDomainsByType(THRESHOLD_DOMAIN_TYPE);
        getSessionContainer().setAttribute("thrTypesList", thrTypesList);
        // Add Udp Values to sessionContainer
        List udpModelList = DAOFactory.getUdpDAO().loadAllByFamily("Model");
        getSessionContainer().setAttribute("udpModelList", udpModelList);
        List udpKpiList = DAOFactory.getUdpDAO().loadAllByFamily("Kpi");
        getSessionContainer().setAttribute("udpKpiList", udpKpiList);

      } catch (EMFUserError e) {
        logger.error(e.getMessage(), e);
        throw new SpagoBIServiceException(SERVICE_NAME, "Exception retrieving model types", e);
      }
    }
    logger.debug("OUT");
  }
  private List<Model> deserializeNodesJSONArray(JSONArray rows) throws JSONException {
    List<Model> toReturn = new ArrayList<Model>();
    HashMap<String, Model> labels = new HashMap<String, Model>();
    for (int i = 0; i < rows.length(); i++) {

      JSONObject obj = (JSONObject) rows.get(i);

      Model model = new Model();
      // always present guiId
      String guiId = obj.getString("id");
      model.setGuiId(guiId);

      try {
        model.setId(obj.getInt("modelId"));
      } catch (Throwable t) {
        // nothing
        model.setId(null);
      }

      try {
        model.setParentId(obj.getInt("parentId"));
      } catch (Throwable t) {
        // nothing
        model.setParentId(null);
      }
      try {
        model.setCode(obj.getString("code"));
        try {
          model.setDescription(obj.getString("description"));
        } catch (Throwable t) {
          // nothing
          model.setDescription(null);
        }

        String labelKey;
        try {
          labelKey = obj.getString("label");
        } catch (Throwable t) {
          labelKey = java.util.UUID.randomUUID().toString();
        }
        model.setLabel(labelKey);
        if (!labels.containsKey(labelKey)) {
          labels.put(labelKey, model);
        } else {
          // skip it
          continue;
        }
        model.setName(obj.getString("name"));
        model.setTypeCd(obj.getString("type"));
        model.setTypeId(obj.getInt("typeId"));
        try {
          model.setTypeDescription(obj.getString("typeDescr"));
        } catch (Throwable t) {
          // nothing
          model.setTypeDescription(null);
        }
        try {
          model.setKpiId(obj.getInt("kpiId"));
        } catch (Throwable t) {
          // nothing
          model.setKpiId(null);
        }
        // add the udpValues to Model Instance Definition, that will be serialized
        List<UdpValue> udpValues = new ArrayList<UdpValue>();
        JSONArray jsonArray = null;
        try {
          jsonArray = obj.getJSONArray("udpValues");
        } catch (Throwable t) {
          jsonArray = new JSONArray();
        }
        logger.debug("found udpValues Array containing number of Udp " + jsonArray.length());
        for (int j = 0; j < jsonArray.length(); j++) {
          JSONObject objJS = (JSONObject) jsonArray.get(j);
          // only label and value information are retrieved by JSON object
          String labelJ = objJS.getString("name");
          String value = objJS.getString("value");

          UdpValue udpValue = new UdpValue();

          // reference id is the kpi id
          udpValue.setLabel(obj.getString("label"));
          udpValue.setValue(value);
          udpValue.setReferenceId(model.getId());

          // get the UDP to get ID (otherwise could be taken in js page)
          Udp udp = DAOFactory.getUdpDAO().loadByLabelAndFamily(labelJ, "MODEL");
          Domain familyDomain = DAOFactory.getDomainDAO().loadDomainById(udp.getFamilyId());
          logger.debug(
              "Udp value assigning value "
                  + value
                  + " to UDP with label "
                  + udp.getLabel()
                  + " and Model Instance with label "
                  + model.getLabel());
          udpValue.setLabel(udp.getLabel());
          udpValue.setName(udp.getName());
          udpValue.setFamily(familyDomain != null ? familyDomain.getValueCd() : null);
          udpValue.setUdpId(udp.getUdpId());

          udpValues.add(udpValue);
        }
        model.setUdpValues(udpValues);

        String value = obj.getString("toSave");
      } catch (Throwable t) {
        logger.debug("Deserialization error on node: " + guiId);
      }
      toReturn.add(model);
    }
    return toReturn;
  }