Esempio n. 1
0
  /**
   * Add into the parameters map the BIObject's BIParameter names and values
   *
   * @param biobj BIOBject to execute
   * @param pars Map of the parameters for the execution call
   * @return Map The map of the execution call parameters
   */
  private Map appendAnalyticalDriversToRequestParameters(BIObject biobj, Map pars) {
    logger.debug("IN");

    if (biobj == null) {
      logger.warn("BIObject parameter null");
      return pars;
    }

    ParameterValuesEncoder parValuesEncoder = new ParameterValuesEncoder();
    if (biobj.getBiObjectParameters() != null) {
      BIObjectParameter biobjPar = null;
      for (Iterator it = biobj.getBiObjectParameters().iterator(); it.hasNext(); ) {
        try {
          biobjPar = (BIObjectParameter) it.next();
          String value = parValuesEncoder.encode(biobjPar);
          pars.put(biobjPar.getParameterUrlName(), value);
          logger.debug("Add parameter:" + biobjPar.getParameterUrlName() + "/" + value);
        } catch (Exception e) {
          logger.error("Error while processing a BIParameter", e);
        }
      }
    }

    logger.debug("OUT");
    return pars;
  }
 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");
 }
Esempio n. 3
0
 /**
  * Adds a system parameter contaning info about document parameters (url name, label, type)
  *
  * @param biobject The BIObject under execution
  * @param map The parameters map
  * @return the modified map with the new parameter
  */
 private Map addDocumentParametersInfo(Map map, BIObject biobject) {
   logger.debug("IN");
   JSONArray parametersJSON = new JSONArray();
   try {
     Locale locale = getLocale();
     List parameters = biobject.getBiObjectParameters();
     if (parameters != null && parameters.size() > 0) {
       Iterator iter = parameters.iterator();
       while (iter.hasNext()) {
         BIObjectParameter biparam = (BIObjectParameter) iter.next();
         JSONObject jsonParam = new JSONObject();
         jsonParam.put("id", biparam.getParameterUrlName());
         IMessageBuilder msgBuilder = MessageBuilderFactory.getMessageBuilder();
         // String interLabel = msgBuilder.getUserMessage(biparam.getLabel(),
         // SpagoBIConstants.DEFAULT_USER_BUNDLE, locale);
         String interLabel = msgBuilder.getI18nMessage(locale, biparam.getLabel());
         jsonParam.put("label", interLabel);
         jsonParam.put("type", biparam.getParameter().getType());
         parametersJSON.put(jsonParam);
       }
     }
   } catch (Exception e) {
     logger.error("Error while adding document parameters info", e);
   }
   map.put("SBI_DOCUMENT_PARAMETERS", parametersJSON.toString());
   logger.debug("OUT");
   return map;
 }
 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 void fillEmptyAnalyticalDriver(
     BIObjectParameter dossierParameter,
     BIObjectParameter containedDocumentParameter,
     Map parameters) {
   logger.debug("IN");
   String value = dossierParameter.getParameterValuesAsString();
   String key = containedDocumentParameter.getParameterUrlName();
   logger.debug(
       "Updating value of parameter ["
           + "label : "
           + containedDocumentParameter.getLabel()
           + "urlName : "
           + containedDocumentParameter.getParameterUrlName()
           + "] to : "
           + value);
   parameters.put(key, value);
   logger.debug("OUT");
 }
  /**
   * Return the BIObjectParameter with the key passed
   *
   * @param key String with url (identifier) of parameter
   * @return BIObjectParameter
   */
  private static BIObjectParameter getBIObjectParameter(BIObject obj, String urlKey) {
    if (urlKey == null || urlKey.equals("")) return null;

    BIObjectParameter par = null;
    List objParams = obj.getBiObjectParameters();
    for (int i = 0, l = objParams.size(); i < l; i++) {
      par = (BIObjectParameter) objParams.get(i);
      if (par.getParameterUrlName().equals(urlKey)) break;
    }

    return par;
  }
  private static List getInstanceValue(String key, ExecutionInstance instance) {
    List retVal = new ArrayList();
    BIObject obj = instance.getBIObject();
    List objPars = obj.getBiObjectParameters();

    for (int i = 0; i < objPars.size(); i++) {
      BIObjectParameter objPar = (BIObjectParameter) objPars.get(i);
      if (objPar.getParameterUrlName().equalsIgnoreCase(key)) {
        retVal.add(
            (objPar.getParameterValues() == null)
                ? ""
                : (String) objPar.getParameterValues().get(0));
        break;
      }
    }
    return retVal;
  }
 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");
 }
  private void saveConfiguredDocumentHandler(SourceBean request, SourceBean response)
      throws Exception {
    logger.debug("IN");
    String tempFolder = (String) request.getAttribute(DossierConstants.DOSSIER_TEMP_FOLDER);
    String label = (String) request.getAttribute("biobject_label");
    // get logical name assigned to the configured document
    String logicalName = (String) request.getAttribute("logicalname");
    if ((logicalName == null) || logicalName.trim().equalsIgnoreCase("")) {
      logicalName = "";
      // throw new EMFUserError(EMFErrorSeverity.ERROR, 103, "component_dossier_messages");
    }
    // load biobject using label
    //		Integer id = new Integer(idobj);
    IBIObjectDAO biobjdao = DAOFactory.getBIObjectDAO();
    BIObject obj = biobjdao.loadBIObjectByLabel(label);
    IBIObjectParameterDAO biobjpardao = DAOFactory.getBIObjectParameterDAO();
    // gets parameters of the biobject
    List params = biobjpardao.loadBIObjectParametersById(obj.getId());
    Iterator iterParams = params.iterator();
    // get map of the param url name and value assigned
    boolean findOutFormat = false;
    Map paramValueMap = new HashMap();
    Map paramNameMap = new HashMap();
    while (iterParams.hasNext()) {
      BIObjectParameter par = (BIObjectParameter) iterParams.next();
      String parUrlName = par.getParameterUrlName();
      if (parUrlName.equalsIgnoreCase("outputType")) findOutFormat = true;
      String value = (String) request.getAttribute(parUrlName);
      paramValueMap.put(parUrlName, value);
      paramNameMap.put(par.getLabel(), par.getParameterUrlName());
    }
    if (!findOutFormat) {
      paramValueMap.put("outputType", "JPGBASE64");
    }
    // fill a configured document bo with data retrived
    ConfiguredBIDocument confDoc = new ConfiguredBIDocument();
    confDoc.setDescription(obj.getDescription());
    //		confDoc.setId(obj.getId());
    confDoc.setLabel(obj.getLabel());
    confDoc.setParameters(paramValueMap);
    confDoc.setName(obj.getName());
    confDoc.setLogicalName(logicalName);

    // check if the error handler contains validation errors
    EMFErrorHandler errorHandler = getResponseContainer().getErrorHandler();
    if (errorHandler.isOKByCategory(EMFErrorCategory.VALIDATION_ERROR)) {
      // store the configured document
      IDossierDAO dossierDao = new DossierDAOHibImpl();
      dossierDao.addConfiguredDocument(confDoc, tempFolder);
      response.setAttribute(DossierConstants.PUBLISHER_NAME, "DossierLoopbackDossierDetail");
    } else {
      // 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");
  }
 private boolean isEmpty(BIObjectParameter biParameter, Map parameters) {
   String key = biParameter.getParameterUrlName();
   String value = (String) parameters.get(key);
   return value == null || value.trim().equals("");
 }