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"); }
/** * Return a string representative an url with all parameters set with a request value (if it is * present) or with the default's value. * * @param doc the document object that is managed * @param document the document configurator * @param requestSB the request object * @return a string with the url completed */ private static String getParametersUrl( BIObject obj, Document document, SourceBean requestSB, ExecutionInstance instance) { logger.debug("IN"); String paramUrl = ""; // set others parameters value Properties lstParams = document.getParams(); String key = ""; List values = new ArrayList(); String singleValue = ""; int cont = 0; try { if (lstParams != null) { ParameterValuesEncoder encoderUtility = new ParameterValuesEncoder(); // while(enParams.hasMoreElements()) { for (int i = 0; i < lstParams.size(); i++) { String typeParam = lstParams.getProperty("type_par_" + document.getNumOrder() + "_" + cont); // only for parameter in input to the document managed (type equal 'IN') if (typeParam != null && typeParam.indexOf("IN") >= 0) { String tmpKey = "sbi_par_label_param_" + document.getNumOrder() + "_" + cont; key = lstParams.getProperty(tmpKey); if (key == null && !document.getTypeCross().equalsIgnoreCase(Constants.CROSS_EXTERNAL)) break; values = (List) requestSB.getAttributeAsList(key); // if value isn't defined, check if there is a value into the instance(there is when a // document is called from a refresh o viewpoint mode) if (values == null || values.size() == 0 || ((String) values.get(0)).equals("")) { List instanceValue = getInstanceValue(key, instance); if (instanceValue != null && instanceValue.size() > 0 && !instanceValue.get(0).equals("")) values = instanceValue; } // if value isn't defined, gets the default value from the template if (values == null || values.size() == 0 || ((String) values.get(0)).equals("")) { values.add( lstParams.getProperty( ("default_value_param_" + document.getNumOrder() + "_" + cont))); } logger.debug("Values to pass : "******"")) { // EXTERNAL ENGINES BIObjectParameter par = getBIObjectParameter(obj, key); par.setParameterValues(values); Parameter tmpPar = par.getParameter(); logger.debug("Manage parameter : " + tmpPar.getLabel() + "..."); if (tmpPar != null && values.size() > 1 && tmpPar.getModalityValue() != null && ((!(par).isMultivalue()) || tmpPar .getModalityValue() .getITypeCd() .equalsIgnoreCase(SpagoBIConstants.INPUT_TYPE_MAN_IN_CODE))) { logger.debug("Force the multivalue modality for parameter " + tmpPar.getLabel()); // force the multivalue management if the parameter has defined as MANUAL INPUT and // the values is multiple. tmpPar.getModalityValue().setMultivalue(true); tmpPar.getModalityValue().setITypeCd(SpagoBIConstants.INPUT_TYPE_QUERY_CODE); par.setParameter(tmpPar); } String parsValue = encoderUtility.encode(par); // conversion in UTF-8 of the par Map parsMap = new HashMap(); parsMap.put(key, parsValue); String tmpUrl = GeneralUtilities.getUrl("", parsMap); logger.debug("tmpUrl for " + obj.getLabel() + ": " + tmpUrl); paramUrl += "&" + tmpUrl.substring(tmpUrl.indexOf("?") + 1); // paramUrl += "&" + key + "=" + tmpUrl; } else { // INTERNAL ENGINES for (int j = 0; j < values.size(); j++) { singleValue = (String) values.get(j); if (singleValue.equals("%")) singleValue = "%25"; // setting an url likes &key=val1;val2;valn if (j == 0) { paramUrl += "&" + key + "=" + singleValue; } else { paramUrl += ";" + singleValue; } } } cont++; } } } } catch (Exception ex) { logger.error( "Error while getting parameter's document " + document.getSbiObjLabel() + " param: " + key + ": " + ex); return null; } /* if (forInternalEngine) paramUrl = paramUrl.substring(0, paramUrl.length()-3); else paramUrl = paramUrl.substring(0, paramUrl.length()-5); */ logger.debug("paramUrl: " + paramUrl); logger.debug("OUT"); return paramUrl; }