/** * 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 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; }