Beispiel #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 List<EMFValidationError> removeNotEmptyAnalyticalDrivers(BIObject dossier, List docs) {
   logger.debug("IN");
   List parameters = dossier.getBiObjectParameters();
   List<BIObjectParameter> biParametersToBeRemoved = new ArrayList<BIObjectParameter>();
   if (parameters != null && parameters.size() > 0) {
     HashMap<Integer, List<BIObjectParameter>> analyticalDrivers =
         getAnalyticalDriverCount(parameters);
     Set<Entry<Integer, List<BIObjectParameter>>> entries = analyticalDrivers.entrySet();
     Iterator<Entry<Integer, List<BIObjectParameter>>> it = entries.iterator();
     while (it.hasNext()) {
       Entry<Integer, List<BIObjectParameter>> entry = it.next();
       List<BIObjectParameter> biParameters = entry.getValue();
       int occurrences = biParameters.size();
       int emptyOccurences = getMaxEmptyOccurrences(biParameters.get(0), docs);
       int difference = occurrences - emptyOccurences;
       for (int i = 1; i <= difference; i++) {
         // remove last ones
         biParametersToBeRemoved.add(biParameters.get(biParameters.size() - i));
       }
     }
   }
   Iterator<BIObjectParameter> biParametersToBeRemovedIt = biParametersToBeRemoved.iterator();
   List<EMFValidationError> toReturn = new ArrayList<EMFValidationError>();
   while (biParametersToBeRemovedIt.hasNext()) {
     BIObjectParameter aBIObjectParameter = biParametersToBeRemovedIt.next();
     EMFValidationError error = removeAnalyticalDriver(aBIObjectParameter);
     if (error != null) {
       toReturn.add(error);
     }
   }
   updateBIObjectParameters(dossier);
   logger.debug("OUT");
   return toReturn;
 }
 public void fillEmptyAnalyticalDrivers(
     Map parameters, BIObject dossier, BIObject containedDocument) {
   logger.debug("IN");
   List dossierParameters = dossier.getBiObjectParameters();
   if (dossierParameters != null && dossierParameters.size() > 0) {
     Iterator it = dossierParameters.iterator();
     while (it.hasNext()) {
       BIObjectParameter dossierParameter = (BIObjectParameter) it.next();
       List<BIObjectParameter> containedDocumentParameters =
           getRelevantContainedDocumentAnalyticalDrivers(dossierParameter, containedDocument);
       if (containedDocumentParameters != null && containedDocumentParameters.size() > 0) {
         Iterator<BIObjectParameter> containedDocumentParametersIt =
             containedDocumentParameters.iterator();
         while (containedDocumentParametersIt.hasNext()) {
           BIObjectParameter containedDocumentParameter = containedDocumentParametersIt.next();
           if (isEmpty(containedDocumentParameter, parameters)) {
             logger.debug(
                 "Updating parameters of document ["
                     + "label : "
                     + containedDocument.getLabel()
                     + "name : "
                     + containedDocument.getName()
                     + "]");
             fillEmptyAnalyticalDriver(dossierParameter, containedDocumentParameter, parameters);
             break;
           }
         }
       }
     }
   }
   logger.debug("OUT");
 }
 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 #5
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;
 }
  /**
   * 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;
  }
 /**
  * Returns the number of occurrences of the same Analytical Driver in the document, i.e. the
  * number of BIObjectParameter that are related to the same Parameter object.
  *
  * @param dossier The dossier document
  * @param biParameter Th dossier's BIObjectParameter
  * @return the number of occurrences of the same Analytical Driver in the document
  */
 private int getAnalyticalDriverOccurrenciesInDossier(BIObject dossier, Integer parameterId) {
   int toReturn = 0;
   logger.debug("IN");
   List parameters = dossier.getBiObjectParameters();
   Iterator it = parameters.iterator();
   while (it.hasNext()) {
     BIObjectParameter aParameter = (BIObjectParameter) it.next();
     if (aParameter.getParID().equals(parameterId)) {
       toReturn++;
     }
   }
   logger.debug("OUT: returning " + toReturn);
   return toReturn;
 }
  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 List<BIObjectParameter> getRelevantContainedDocumentAnalyticalDrivers(
     BIObjectParameter dossierParameter, BIObject containedDocument) {
   List<BIObjectParameter> toReturn = new ArrayList<BIObjectParameter>();
   logger.debug("IN");
   List containedDocumentParameters = containedDocument.getBiObjectParameters();
   if (containedDocumentParameters != null && containedDocumentParameters.size() > 0) {
     Iterator it = containedDocumentParameters.iterator();
     while (it.hasNext()) {
       BIObjectParameter containedDocumentParameter = (BIObjectParameter) it.next();
       if (containedDocumentParameter.getParID().equals(dossierParameter.getParID())) {
         toReturn.add(containedDocumentParameter);
       }
     }
   }
   logger.debug("OUT");
   return toReturn;
 }
 private int getMaxEmptyOccurrences(BIObjectParameter biParameter, List docs) {
   int toReturn = 0;
   logger.debug("IN");
   Iterator it = docs.iterator();
   while (it.hasNext()) {
     ConfiguredBIDocument configuredBIDocument = (ConfiguredBIDocument) it.next();
     Map parameters = configuredBIDocument.getParameters();
     BIObject configuredDocument = configuredBIDocument.loadBIObjectDetails();
     List configuredDocumentParameters = configuredDocument.getBiObjectParameters();
     int emptyOccurrences =
         getAnalyticalDriverEmptyOccurrences(
             biParameter, configuredDocumentParameters, parameters);
     if (emptyOccurrences > toReturn) {
       toReturn = emptyOccurrences;
     }
   }
   logger.debug("OUT: " + toReturn);
   return toReturn;
 }
 private void addEmptyAnalyticalDrivers(
     BIObject dossier, ConfiguredBIDocument configuredBIDocument) {
   logger.debug("IN");
   Map parameters = configuredBIDocument.getParameters();
   BIObject configuredDocument = configuredBIDocument.loadBIObjectDetails();
   List configuredDocumentParameters = configuredDocument.getBiObjectParameters();
   Iterator configuredBIObjectParametersIt = configuredDocumentParameters.iterator();
   while (configuredBIObjectParametersIt.hasNext()) {
     BIObjectParameter biParameter = (BIObjectParameter) configuredBIObjectParametersIt.next();
     int emptyOccurrences =
         getAnalyticalDriverEmptyOccurrences(
             biParameter, configuredDocumentParameters, parameters);
     if (emptyOccurrences > 0) {
       int occurrenciesInDossier =
           getAnalyticalDriverOccurrenciesInDossier(dossier, biParameter.getParID());
       for (int c = occurrenciesInDossier; c < emptyOccurrences; c++) {
         BIObjectParameter parameterToBeAdded =
             getEmptyOccurrence(biParameter, configuredDocumentParameters, parameters, c);
         addBIObjectParameterToDossier(dossier, parameterToBeAdded);
       }
     }
   }
   logger.debug("OUT");
 }