/** * 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; }
/** * 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"); }
/** * 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 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; }
/** * Returns the number of empty occurrence of the Analytical Driver associated to the input * BIObjectParameter in the contained document's parameters. * * @param biParameter * @param configuredDocumentParameters * @param parameters * @return */ private int getAnalyticalDriverEmptyOccurrences( BIObjectParameter biParameter, List configuredDocumentParameters, Map parameters) { int toReturn = 0; logger.debug("IN"); Iterator it = configuredDocumentParameters.iterator(); while (it.hasNext()) { BIObjectParameter aBIObjectParameter = (BIObjectParameter) it.next(); if (aBIObjectParameter.getParID().equals(biParameter.getParID()) && isEmpty(biParameter, parameters)) { toReturn++; } } logger.debug("OUT: returning " + toReturn); return toReturn; }
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 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 HashMap<Integer, List<BIObjectParameter>> getAnalyticalDriverCount(List parameters) { logger.debug("IN"); HashMap<Integer, List<BIObjectParameter>> toReturn = new HashMap<Integer, List<BIObjectParameter>>(); Iterator it = parameters.iterator(); while (it.hasNext()) { BIObjectParameter biParameter = (BIObjectParameter) it.next(); Integer key = biParameter.getParID(); List<BIObjectParameter> list = toReturn.get(key); if (list == null) { list = new ArrayList<BIObjectParameter>(); } list.add(biParameter); toReturn.put(key, list); } logger.debug("OUT"); return toReturn; }
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"); }
private BIObjectParameter getEmptyOccurrence( BIObjectParameter biParameter, List configuredDocumentParameters, Map parameters, int c) { BIObjectParameter toReturn = null; int counter = 0; logger.debug("IN"); Iterator it = configuredDocumentParameters.iterator(); while (it.hasNext()) { BIObjectParameter aBIObjectParameter = (BIObjectParameter) it.next(); if (aBIObjectParameter.getParID().equals(biParameter.getParID()) && isEmpty(biParameter, parameters)) { if (counter == c) { toReturn = aBIObjectParameter; break; } else { counter++; } } } logger.debug("OUT"); return toReturn; }
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 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"); }
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"); }
/** * 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; }
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"); }
private boolean isEmpty(BIObjectParameter biParameter, Map parameters) { String key = biParameter.getParameterUrlName(); String value = (String) parameters.get(key); return value == null || value.trim().equals(""); }