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");
  }
Esempio n. 2
0
  @POST
  @Produces(MediaType.TEXT_HTML)
  // TODO: change produced output
  public String insertValues(@Context HttpServletRequest req) {
    try {
      IEngUserProfile profile =
          (IEngUserProfile) req.getSession().getAttribute(IEngUserProfile.ENG_USER_PROFILE);
      if (profile == null) {
        return "User must be logged in";
      }
      String userId = (String) profile.getUserUniqueIdentifier();
      IBIObjectDAO sbiObjectsDAO = DAOFactory.getBIObjectDAO();
      BIObject document = sbiObjectsDAO.loadBIObjectByLabel("EII_RPT_0015_frc"); // TODO: to change
      Integer documentId = document.getId();
      List enabledRoles = sbiObjectsDAO.getCorrectRolesForExecution(documentId, profile);
      // check if current user can see this document
      if ((enabledRoles != null) && (enabledRoles.size() > 0)) {
        // Get fixed parameters values
        String year = req.getParameter("par_year");
        String closureCode = req.getParameter("par_closure_cd");
        String businessAreaCode = req.getParameter("par_ba");
        String businessUnitCode = req.getParameter("par_bu");
        String cdc = req.getParameter("par_cdc");

        String ricavi = req.getParameter("Ricavi_resValue");
        String ricaviVarPer = req.getParameter("Ricavi_variationPerc");
        if (ricaviVarPer == null) {
          ricaviVarPer = "0";
        }
        String ricaviVarAbs = req.getParameter("Ricavi_variationAbsolute");
        if (ricaviVarAbs == null) {
          ricaviVarAbs = "0";
        }

        String primoMargine = req.getParameter("PM_resValue");
        String primoMargineVarPer = req.getParameter("PM_variationPerc");
        if (primoMargineVarPer == null) {
          primoMargineVarPer = "0";
        }
        String primoMargineVarAbs = req.getParameter("PM_variationAbsolute");
        if (primoMargineVarAbs == null) {
          primoMargineVarAbs = "0";
        }

        String margineContribuzione = req.getParameter("MC_resValue");
        String margineContribuzioneVarPer = req.getParameter("MC_variationPerc");
        if (margineContribuzioneVarPer == null) {
          margineContribuzioneVarPer = "0";
        }
        String margineContribuzioneVarAbs = req.getParameter("MC_variationAbsolute");
        if (margineContribuzioneVarAbs == null) {
          margineContribuzioneVarAbs = "0";
        }

        // ----------------------

        // 2- Insert values on database
        persistValues(
            businessUnitCode,
            businessAreaCode,
            cdc,
            year,
            closureCode,
            userId,
            ricavi,
            primoMargine,
            margineContribuzione,
            ricaviVarPer,
            ricaviVarAbs,
            primoMargineVarPer,
            primoMargineVarAbs,
            margineContribuzioneVarPer,
            margineContribuzioneVarAbs);

        return "<b>Values Updated</b>";

        // Uncomment next line for test
        // return printSubmittedValues(req);

      } else {
        // User cannot execute operation
        return "Operation forbidden";
      }

    } catch (Exception e) {
      logger.error("An unexpected error occured while executing Forecast Edit");
      throw new SpagoBIServiceException(
          "An unexpected error occured while executing Forecast Edit", e);
    }
  }