protected void buildTitleJSON() throws Exception {

    SourceBean confSB = null;
    String titleName = null;

    logger.debug("IN");
    confSB = (SourceBean) template.getAttribute(MobileConstants.TITLE_TAG);
    if (confSB == null) {
      logger.warn(
          "Cannot find title configuration settings: tag name " + MobileConstants.TITLE_TAG);
      return;
    }
    titleName = (String) confSB.getAttribute(MobileConstants.TITLE_VALUE_ATTR);

    //		Map<String, String> params = getNotNullPrameters();
    //
    String titleWithPars = titleName;
    //		if(params!=null && titleName!=null){
    //			titleWithPars = StringUtilities.substituteParametersInString(titleName, params, null,
    // false);
    //		}

    String titleStyle = (String) confSB.getAttribute(MobileConstants.TITLE_STYLE_ATTR);

    title.put("value", titleWithPars);
    title.put("style", titleStyle);
    documentProperties.put("title", title);
    logger.debug("OUT");
  }
  /**
   * Creates a form into the jsp page.
   *
   * @throws JspException If any exception occurs.
   */
  protected void makeForm() throws JspException {

    String titleCode = (String) _layout.getAttribute("TITLE");
    SourceBean buttonsSB = (SourceBean) _layout.getAttribute("BUTTONS");
    List buttons = buttonsSB.getContainedSourceBeanAttributes();

    if (titleCode != null && buttons.size() > 0) {
      // String title = PortletUtilities.getMessage(titleCode, "messages");
      String title = msgBuilder.getMessage(titleCode, _bundle, httpRequest);
      _htmlStream.append(" <table class=\"header-table-portlet-section\">\n");
      _htmlStream.append("	<tr class='header-row-portlet-section'>\n");
      _htmlStream.append(
          "			<td class=\"header-title-column-portlet-section\" style=\"vertical-align:middle;padding-left:5px;\" >"
              + title
              + "</td>\n");
      _htmlStream.append("			<td class=\"header-empty-column-portlet-section\">&nbsp;</td>\n");
      _htmlStream.append(makeButton(buttons) + "\n");
      _htmlStream.append("	</tr>\n");
      _htmlStream.append(" </table>\n");
    }

    makeColumns();
    makeRows();
    makeNavigationButton();
  } // public void makeForm()
  /* (non-Javadoc)
   * @see it.eng.spago.dispatching.service.list.basic.IFaceBasicListService#getList(it.eng.spago.base.SourceBean, it.eng.spago.base.SourceBean)
   */
  public ListIFace getList(SourceBean request, SourceBean response) throws Exception {

    logger.debug("IN");
    ListIFace list = null;
    // get role / par id / par field name name
    String roleName = (String) request.getAttribute("roleName");
    String parIdStr = (String) request.getAttribute("parameterId");
    logger.debug("roleName=" + roleName);
    logger.debug("parameterId=" + parIdStr);

    Integer parId = new Integer(parIdStr);
    // check if the parameter use is manual input
    IParameterUseDAO parusedao = DAOFactory.getParameterUseDAO();
    ParameterUse paruse = parusedao.loadByParameterIdandRole(parId, roleName);
    Integer manInp = paruse.getManualInput();
    if (manInp.intValue() == 1) {
      String message = "";
      try {
        message =
            PortletUtilities.getMessage(
                "scheduler.fillparmanually", "component_scheduler_messages");
      } catch (Exception e) {
        IMessageBuilder msgBuilder = MessageBuilderFactory.getMessageBuilder();
        message =
            msgBuilder.getMessage("scheduler.fillparmanually", "component_scheduler_messages");
      }
      response.setAttribute(SpagoBIConstants.MESSAGE_INFO, message);
    } else {
      list = loadSpagoList(request, response, parId, roleName);
    }
    // fill response
    response.setAttribute(SpagoBIConstants.PUBLISHER_NAME, "LovLookupAjax");
    logger.debug("OUT");
    return list;
  }
Exemple #4
0
  public Target(SourceBean sb) {
    documentLabel = (String) sb.getAttribute(WhatIfXMLTemplateParser.TAG_TG_DOCUMENT_LABEL);
    customizedView = (String) sb.getAttribute(WhatIfXMLTemplateParser.TAG_TG_CUSTOMIZED_VIEW);
    List list = sb.getAttributeAsList(WhatIfXMLTemplateParser.TAG_TG_TITLE);
    targetCross = (String) sb.getAttribute(WhatIfXMLTemplateParser.TAG_TG_TARGET);
    Object titleObject = list.get(0);
    if (titleObject instanceof String) {
      titleCross = (String) list.get(0);
    } else {
      titleCross = ((SourceBean) list.get(0)).getCharacters();
    }

    if (customizedView != null && customizedView.trim().equals("")) {
      customizedView = null;
    }
    SourceBean descrSB = (SourceBean) sb.getAttribute(WhatIfXMLTemplateParser.TAG_CN_DESCRIPTION);
    description = descrSB.getCharacters();
    SourceBean titleSB = (SourceBean) list.get(1);
    title = titleSB.getCharacters();
    List parametersSB = sb.getAttributeAsList(WhatIfXMLTemplateParser.TAG_TN_PARAMETERS);
    List parameterSB =
        ((SourceBean) parametersSB.get(0))
            .getAttributeAsList(WhatIfXMLTemplateParser.TAG_TN_PARAMETER);
    boolean hasParameters = parameterSB != null && !parameterSB.isEmpty();
    parameters = new ArrayList<TargetParameter>();
    if (hasParameters) {
      for (int i = 0; i < parameterSB.size(); i++) {
        SourceBean temp = (SourceBean) parameterSB.get(i);
        TargetParameter aParameter = new TargetParameter(temp);
        if (aParameter != null) {
          parameters.add(aParameter);
        }
      }
    }
  }
 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");
 }
 private void deleteConfiguredDocumentHandler(SourceBean request, SourceBean response)
     throws Exception {
   logger.debug("IN");
   String tempFolder = (String) request.getAttribute(DossierConstants.DOSSIER_TEMP_FOLDER);
   String confDocIdent = (String) request.getAttribute("configureddocumentidentifier");
   IDossierDAO dossierDao = new DossierDAOHibImpl();
   // delete the configured document
   dossierDao.deleteConfiguredDocument(confDocIdent, tempFolder);
   response.setAttribute(DossierConstants.PUBLISHER_NAME, "DossierLoopbackDossierDetail");
   logger.debug("OUT");
 }
  /* (non-Javadoc)
   * @see it.eng.spagobi.commons.services.BaseProfileAction#service(it.eng.spago.base.SourceBean, it.eng.spago.base.SourceBean)
   */
  public void service(SourceBean request, SourceBean response) throws Exception {
    logger.debug("IN");

    String message = (String) request.getAttribute("MESSAGEDET");

    EMFErrorHandler errorHandler = getErrorHandler();
    try {
      if (message == null) {
        EMFUserError userError = new EMFUserError(EMFErrorSeverity.ERROR, 101);
        logger.debug("The message parameter is null");
        throw userError;
      }
      logger.debug("The message parameter is: " + message.trim());
      if (message.trim().equalsIgnoreCase("GOTO_DOCUMENT_RATE")) {
        goToDocumentRating(request, "GOTO_DOCUMENT_RATE", response);
      } else if (message.trim().equalsIgnoreCase("DOCUMENT_RATE")) {
        documentRating(request, "DOCUMENT_RATE", response);
      }
    } catch (EMFUserError eex) {
      errorHandler.addError(eex);
      return;
    } catch (Exception ex) {
      EMFInternalError internalError = new EMFInternalError(EMFErrorSeverity.ERROR, ex);
      errorHandler.addError(internalError);
      return;
    }

    logger.debug("OUT");
  }
 private void dossierDetailHandler(SourceBean request, SourceBean response)
     throws SourceBeanException, EMFUserError {
   logger.debug("IN");
   String tempFolder = (String) request.getAttribute(DossierConstants.DOSSIER_TEMP_FOLDER);
   IDossierDAO dossierDao = new DossierDAOHibImpl();
   //		List roleList = null;
   //		try{
   //			IRoleDAO roleDao = DAOFactory.getRoleDAO();
   //			roleList = roleDao.loadAllRoles();
   //		} catch(Exception e) {
   //			logger.error("Error while loading all roles", e);
   //		}
   // get the current template file name
   String tempFileName = dossierDao.getPresentationTemplateFileName(tempFolder);
   if (tempFileName == null) tempFileName = "";
   // get list of the configured document
   List confDoc = dossierDao.getConfiguredDocumentList(tempFolder);
   // get the current process definition file name
   String procDefFileName = dossierDao.getProcessDefinitionFileName(tempFolder);
   if (procDefFileName == null) procDefFileName = "";
   // WorkflowConfiguration workConf = bookDao.getWorkflowConfiguration(pathConfBook);
   List functionalities;
   try {
     functionalities = DAOFactory.getLowFunctionalityDAO().loadAllLowFunctionalities(true);
   } catch (EMFUserError e) {
     logger.error("Error while loading documents tree", e);
     throw new EMFUserError(EMFErrorSeverity.ERROR, 100);
   }
   response.setAttribute(SpagoBIConstants.FUNCTIONALITIES_LIST, functionalities);
   response.setAttribute(DossierConstants.CONFIGURED_DOCUMENT_LIST, confDoc);
   response.setAttribute(DossierConstants.PUBLISHER_NAME, "DossierDetail");
   response.setAttribute(DossierConstants.OO_TEMPLATE_FILENAME, tempFileName);
   response.setAttribute(DossierConstants.WF_PROCESS_DEFINTIION_FILENAME, procDefFileName);
   logger.debug("OUT");
 }
  private Map applyService(Map parameters, BIObject biObject) {
    logger.debug("IN");

    try {
      Assert.assertNotNull(parameters, "Input [parameters] cannot be null");

      ObjTemplate objectTemplate = biObject.getActiveTemplate();
      byte[] content = objectTemplate.getContent();
      SourceBean sbTemplate = getTemplateAsSourceBean(content);

      if (sbTemplate.getName().equals(EngineConstants.SMART_FILTER_TAG)) {
        parameters.put(PARAM_SERVICE_NAME, "FORM_ENGINE_FROM_DATASET_START_ACTION");
        if (sbTemplate.containsAttribute("DATASET")) {
          String label =
              (String) ((SourceBean) sbTemplate.getAttribute("DATASET")).getAttribute("label");
          parameters.put("dataset_label", label);
        }
      } else {
        parameters.put(PARAM_SERVICE_NAME, "FORM_ENGINE_START_ACTION");
      }
      parameters.put(PARAM_MODALITY, "VIEW");

      parameters.put(PARAM_NEW_SESSION, "TRUE");
    } catch (Throwable t) {
      throw new RuntimeException("Cannot apply service parameters", t);
    } finally {
      logger.debug("OUT");
    }

    return parameters;
  }
  private void saveDossierDetailHandler(SourceBean request, SourceBean response) throws Exception {
    logger.debug("IN");
    String tempFolder = (String) request.getAttribute(DossierConstants.DOSSIER_TEMP_FOLDER);
    IDossierDAO dossierDao = new DossierDAOHibImpl();
    List docs = dossierDao.getConfiguredDocumentList(tempFolder);
    EMFErrorHandler errorHandler = getErrorHandler();
    if (dossierDao.getPresentationTemplateFileName(tempFolder) == null) {
      logger.error("Presentation template not loaded");
      EMFValidationError error =
          new EMFValidationError(EMFErrorSeverity.ERROR, "", "104", "component_dossier_messages");
      errorHandler.addError(error);
    }
    if (dossierDao.getProcessDefinitionFileName(tempFolder) == null) {
      logger.error("Process definition file not loaded");
      EMFValidationError error =
          new EMFValidationError(EMFErrorSeverity.ERROR, "", "105", "component_dossier_messages");
      errorHandler.addError(error);
    }
    if (docs == null || docs.size() == 0) {
      logger.error("No documents configured in dossier");
      EMFValidationError error =
          new EMFValidationError(EMFErrorSeverity.ERROR, "", "106", "component_dossier_messages");
      errorHandler.addError(error);
    }

    Integer dossierId = dossierDao.getDossierId(tempFolder);
    adjustRequiredAnalyticalDrivers(dossierId, docs);
    if (errorHandler.isOKBySeverity(EMFErrorSeverity.ERROR)) {
      dossierDao.storeTemplate(dossierId, tempFolder);
    }

    String saveAndGoBackStr = (String) request.getAttribute("SAVE_AND_GO_BACK");
    boolean saveAndGoBack =
        saveAndGoBackStr != null && saveAndGoBackStr.trim().equalsIgnoreCase("TRUE");
    if (saveAndGoBack) {
      response.setAttribute(DossierConstants.PUBLISHER_NAME, "DossierSaveAndGoBackLoop");
    } else {
      response.setAttribute(DossierConstants.DOSSIER_SAVED_MSG_CODE_ATTR_NAME, "dossier.savedOk");
      response.setAttribute(DossierConstants.PUBLISHER_NAME, "DossierLoopbackDossierDetail");
    }

    logger.debug("OUT");
  }
  protected void buildDrillJSON() throws Exception {

    SourceBean confSB = null;
    String documentName = null;

    logger.debug("IN");
    confSB = (SourceBean) template.getAttribute(MobileConstants.DRILL_TAG);
    if (confSB == null) {
      logger.debug("Cannot find title drill settings: tag name " + MobileConstants.DRILL_TAG);
      return;
    }
    documentName = (String) confSB.getAttribute(MobileConstants.DRILL_DOCUMENT_ATTR);
    List paramslist =
        (List)
            template.getAttributeAsList(
                MobileConstants.DRILL_TAG + "." + MobileConstants.PARAM_TAG);

    if (paramslist != null) {
      JSONArray params = new JSONArray();
      for (int k = 0; k < paramslist.size(); k++) {
        SourceBean param = (SourceBean) paramslist.get(k);
        String paramName = (String) param.getAttribute(MobileConstants.PARAM_NAME_ATTR);
        String paramType = (String) param.getAttribute(MobileConstants.PARAM_TYPE_ATTR);
        String paramValue = (String) param.getAttribute(MobileConstants.PARAM_VALUE_ATTR);
        JSONObject paramJSON = new JSONObject();
        paramJSON.put("paramName", paramName);
        paramJSON.put("paramType", paramType);

        // FILLS RELATIVE TYPE PARAMETERS' VALUE FROM REQUEST
        if (paramType.equalsIgnoreCase(MobileConstants.PARAM_TYPE_RELATIVE)) {
          paramJSON.putOpt("paramValue", paramsMap.get(paramName));
        } else {
          paramJSON.putOpt("paramValue", paramValue); // should be applied only on absolute type
        }
        params.put(paramJSON);
      }
      drill.put("params", params);
    }

    drill.put("document", documentName);

    logger.debug("OUT");
  }
  /**
   * Starting tag.
   *
   * @return the int
   * @throws JspException the jsp exception
   */
  public int doStartTag() throws JspException {
    httpRequest = (HttpServletRequest) pageContext.getRequest();
    RequestContainer requestContainer = ChannelUtilities.getRequestContainer(httpRequest);
    ResponseContainer responseContainer = ChannelUtilities.getResponseContainer(httpRequest);
    SourceBean serviceRequest = requestContainer.getServiceRequest();
    SourceBean serviceResponse = responseContainer.getServiceResponse();
    SourceBean moduleResponse = (SourceBean) serviceResponse.getAttribute(moduleName);

    List functionalitiesList = null;
    if (attributeToRender == null || attributeToRender.trim().equals("")) {
      functionalitiesList =
          (List) moduleResponse.getAttribute(SpagoBIConstants.FUNCTIONALITIES_LIST);
    } else {
      functionalitiesList = (List) moduleResponse.getAttribute(attributeToRender);
    }
    String initialPath = (String) moduleResponse.getAttribute(TreeObjectsModule.PATH_SUBTREE);
    ITreeHtmlGenerator gen = null;
    try {
      gen = (ITreeHtmlGenerator) Class.forName(htmlGeneratorClass).newInstance();
    } catch (Exception e) {
      return -1;
    }

    StringBuffer htmlStream = null;
    if (treeName == null) {
      htmlStream = gen.makeTree(functionalitiesList, httpRequest, initialPath);
    } else {
      htmlStream = gen.makeTree(functionalitiesList, httpRequest, initialPath, treeName);
    }

    try {
      pageContext.getOut().print(htmlStream);
    } catch (IOException ioe) {
      SpagoBITracer.major(
          SpagoBIConstants.NAME_MODULE,
          this.getClass().getName(),
          "doStartTag",
          "cannot start object tree tag: IOexception occurred",
          ioe);
    }
    return SKIP_BODY;
  }
 private String initDossier(SourceBean request, SourceBean response)
     throws EMFUserError, SourceBeanException {
   logger.debug("IN");
   String objIdStr = (String) request.getAttribute(SpagoBIConstants.OBJECT_ID);
   Integer objId = new Integer(objIdStr);
   BIObject dossier = DAOFactory.getBIObjectDAO().loadBIObjectById(objId);
   IDossierDAO dossierDao = DAOFactory.getDossierDAO();
   String tempFolder = dossierDao.init(dossier);
   logger.debug("OUT");
   return tempFolder;
 }
  private void goToDocumentRating(SourceBean request, String mod, SourceBean response)
      throws EMFUserError, SourceBeanException {

    RequestContainer requestContainer = this.getRequestContainer();
    SessionContainer session = requestContainer.getSessionContainer();
    SessionContainer permanentSession = session.getPermanentContainer();
    String objId = (String) request.getAttribute("OBJECT_ID");

    response.setAttribute("OBJECT_ID", objId);
    response.setAttribute("MESSAGEDET", mod);
    response.setAttribute(SpagoBIConstants.PUBLISHER_NAME, "ratingBIObjectPubJ");
  }
  /**
   * Function not implemented. Thid method should not be called
   *
   * @param biobject The BIOBject to edit
   * @param profile the profile
   * @return the edits the document template build url
   * @throws InvalidOperationRequest the invalid operation request
   */
  public EngineURL getEditDocumentTemplateBuildUrl(Object biobject, IEngUserProfile profile)
      throws InvalidOperationRequest {

    EngineURL engineURL;
    BIObject obj;
    String documentId;
    Engine engine;
    String url;
    HashMap parameters;

    logger.debug("IN");

    try {
      obj = null;
      try {
        obj = (BIObject) biobject;
      } catch (ClassCastException cce) {
        logger.error("The input object is not a BIObject type", cce);
        return null;
      }

      documentId = obj.getId().toString();
      engine = obj.getEngine();
      url = engine.getUrl();

      parameters = new HashMap();

      // getting the dataset label from template, if smart filter is based on a dataset
      ObjTemplate objectTemplate = obj.getActiveTemplate();
      byte[] content = objectTemplate.getContent();
      SourceBean sbTemplate = getTemplateAsSourceBean(content);
      if (sbTemplate.getName().equals(EngineConstants.SMART_FILTER_TAG)
          && sbTemplate.containsAttribute("DATASET")) {
        String label =
            (String) ((SourceBean) sbTemplate.getAttribute("DATASET")).getAttribute("label");
        parameters.put("dataset_label", label);
      }
      parameters.put("document", documentId);
      parameters.put(PARAM_SERVICE_NAME, "FORM_ENGINE_TEMPLATE_BUILD_ACTION");
      parameters.put(PARAM_NEW_SESSION, "TRUE");
      parameters.put(PARAM_MODALITY, "EDIT");
      applySecurity(parameters, profile);

      engineURL = new EngineURL(url, parameters);
    } catch (Throwable t) {
      throw new RuntimeException("Cannot get engine edit URL", t);
    } finally {
      logger.debug("OUT");
    }

    return engineURL;
  }
 /**
  * Finds the user identifier from http request or from SSO system (by the http request in input).
  * Use the SsoServiceInterface for read the userId in all cases, if SSO is disabled use
  * FakeSsoService. Check spagobi_sso.xml
  *
  * @param httpRequest The http request
  * @param serviceRequest the service request
  * @return the current user unique identified
  * @throws Exception in case the SSO is enabled and the user identifier specified on service
  *     request is different from the SSO detected one.
  */
 private static String findUserId(SourceBean serviceRequest, HttpServletRequest httpRequest)
     throws Exception {
   logger.debug("IN");
   String userId = null;
   try {
     // Get userid from request
     Object requestUserIdObj = serviceRequest.getAttribute("userid");
     if (requestUserIdObj != null) userId = requestUserIdObj.toString();
   } finally {
     logger.debug("OUT: userId = [" + userId + "]");
   }
   return userId;
 }
  /**
   * Starting from the module <code>buttonsSB</code> object, creates all buttons for the jsp list.
   *
   * @param buttons The list of the buttons
   * @throws JspException If any exception occurs.
   */
  protected StringBuffer makeButton(List buttons) throws JspException {

    StringBuffer htmlStream = new StringBuffer();

    Iterator iter = buttons.listIterator();
    while (iter.hasNext()) {
      SourceBeanAttribute buttonSBA = (SourceBeanAttribute) iter.next();
      SourceBean buttonSB = (SourceBean) buttonSBA.getValue();
      List parameters = buttonSB.getAttributeAsList("PARAMETER");
      HashMap paramsMap = getParametersMap(parameters, null);

      String name = (String) buttonSB.getAttribute("name");
      String img = (String) buttonSB.getAttribute("image");
      String labelCode = (String) buttonSB.getAttribute("label");
      String label = msgBuilder.getMessage(labelCode, _bundle, httpRequest);

      PortletURL buttonUrl = createUrl(paramsMap);

      htmlStream.append("<td class=\"header-button-column-portlet-section\">\n");
      htmlStream.append(
          "<input type='image' "
              + "name='"
              + name
              + "' "
              + "title='"
              + label
              + "' "
              + "class='header-button-image-portlet-section'"
              + "src ='"
              + renderResponse.encodeURL(renderRequest.getContextPath() + img)
              + "' "
              + "alt='"
              + label
              + "'>\n");
      htmlStream.append("</td>\n");
    }

    return htmlStream;
  }
 /**
  * This function returns the value of the attribute required, if existent in the xml field
  *
  * @param String attribute for which the value is requested
  * @return The value of the attribute
  */
 public String getValueFromStandardXmlValue(String attribute) {
   String valToReturn = "";
   if (valueXml != null) {
     try {
       SourceBean xmlValueSB = SourceBean.fromXMLString(valueXml);
       valToReturn = (String) xmlValueSB.getAttribute(attribute);
     } catch (SourceBeanException e) {
       logger.error("Source Bean Exception", e);
       e.printStackTrace();
     }
   }
   return valToReturn;
 }
 private void exitFromDetailHandler(SourceBean request, SourceBean response)
     throws EMFUserError, SourceBeanException {
   logger.debug("IN");
   String tempFolder = (String) request.getAttribute(DossierConstants.DOSSIER_TEMP_FOLDER);
   IDossierDAO dossierDao = DAOFactory.getDossierDAO();
   // cleans temp folder
   dossierDao.clean(tempFolder);
   // propagates dossier id (usefull to return to document main detail page if light navigator is
   // disabled)
   Integer dossierId = dossierDao.getDossierId(tempFolder);
   response.setAttribute(ObjectsTreeConstants.OBJECT_ID, dossierId.toString());
   response.setAttribute(DossierConstants.PUBLISHER_NAME, "ExitFromDossierDetailLoop");
   logger.debug("OUT");
 }
 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");
 }
  /**
   * Get a new ticket.
   *
   * @param session HttpSession
   * @return String
   * @throws IOException Signals that an I/O exception has occurred.
   */
  public String readTicket(HttpSession session) throws IOException {
    logger.debug("IN");
    String ticket = null;
    String spagoBiServerURL = EnginConf.getInstance().getSpagoBiServerUrl();
    logger.debug("Read spagoBiServerURL=" + spagoBiServerURL);
    SourceBean engineConfig = EnginConf.getInstance().getConfig();
    SourceBean sourceBeanConf = (SourceBean) engineConfig.getAttribute("FILTER_RECEIPT");
    String filterReceipt = (String) sourceBeanConf.getCharacters();
    logger.debug("Read filterReceipt=" + filterReceipt);
    filterReceipt = spagoBiServerURL + filterReceipt;

    Assertion assertion = (Assertion) session.getAttribute(AbstractCasFilter.CONST_CAS_ASSERTION);
    ticket = assertion.getPrincipal().getProxyTicketFor(filterReceipt);

    logger.debug("OUT.ticket=" + ticket);
    return ticket;
  }
  /**
   * Builds Table list columns, reading all request information.
   *
   * @throws JspException If any Exception occurs.
   */
  protected void makeColumns() throws JspException {

    SourceBean captionSB = (SourceBean) _layout.getAttribute("CAPTIONS");
    List captions = captionSB.getContainedSourceBeanAttributes();
    int numCaps = captions.size();

    _columns = new Vector();
    List columnsVector = _layout.getAttributeAsList("COLUMNS.COLUMN");
    for (int i = 0; i < columnsVector.size(); i++) {
      String hidden = (String) ((SourceBean) columnsVector.get(i)).getAttribute("HIDDEN");
      if (hidden == null || hidden.trim().equalsIgnoreCase("FALSE"))
        _columns.add((SourceBean) columnsVector.get(i));
    }
    if ((_columns == null) || (_columns.size() == 0)) {
      SpagoBITracer.critical("Admintools", "ListTag", "doStartTag", "Columns names not defined");
      throw new JspException("Columns names not defined");
    }

    _htmlStream.append("<TABLE style='width:100%;margin-top:1px'>\n");
    _htmlStream.append("	<TR>\n");

    for (int i = 0; i < _columns.size(); i++) {
      String nameColumn = (String) ((SourceBean) _columns.elementAt(i)).getAttribute("NAME");
      String labelColumnCode = (String) ((SourceBean) _columns.elementAt(i)).getAttribute("LABEL");
      String labelColumn = "";
      if (labelColumnCode != null)
        labelColumn = msgBuilder.getMessage(labelColumnCode, _bundle, httpRequest);
      else labelColumn = nameColumn;
      // if an horizontal-align is specified it is considered, otherwise the defualt is align='left'
      String align = (String) ((SourceBean) _columns.elementAt(i)).getAttribute("horizontal-align");
      if (align == null || align.trim().equals("")) align = "left";
      _htmlStream.append(
          "<TD class='portlet-section-header' valign='center' align='"
              + align
              + "'  >"
              + labelColumn
              + "</TD>\n");
    }
    for (int i = 0; i < numCaps; i++) {
      _htmlStream.append("<TD class='portlet-section-header' align='center'>&nbsp;</TD>\n");
    }
    _htmlStream.append("</TR>\n");
  }
  /**
   * Gets all parameter information from a module, putting them into a HashMap.
   *
   * @param parameters The parameters list
   * @param row The value objects Source Bean
   * @return The parameters Hash Map
   * @throws JspException If any Exception occurred
   */
  protected HashMap getParametersMap(List parameters, SourceBean row) throws JspException {

    HashMap params = new HashMap();

    for (int i = 0; i < parameters.size(); i++) {
      String name = (String) ((SourceBean) parameters.get(i)).getAttribute("NAME");
      String type = (String) ((SourceBean) parameters.get(i)).getAttribute("TYPE");
      String value = (String) ((SourceBean) parameters.get(i)).getAttribute("VALUE");
      String scope = (String) ((SourceBean) parameters.get(i)).getAttribute("SCOPE");

      if (name != null) {
        // name = JavaScript.escape(name.toUpperCase());
        name = name.toUpperCase();

        if ((type != null) && type.equalsIgnoreCase("RELATIVE")) {
          if ((scope != null) && scope.equalsIgnoreCase("LOCAL")) {
            if (row == null) {
              SpagoBITracer.critical(
                  "adminTools",
                  "ListTag",
                  "getParametersMap",
                  "Impossible to associate local scope to the button");
              throw new JspException("Impossible to associate local scope to the button");
            } // if (row == null)
            Object valueObject = row.getAttribute(value);
            if (valueObject != null) value = valueObject.toString();
          } // if ((scope != null) && scope.equalsIgnoreCase("LOCAL"))
          else
            value =
                (String)
                    (ContextScooping.getScopedParameter(
                            _requestContainer, _responseContainer, value, scope))
                        .toString();
        } // if ((type != null) && type.equalsIgnoreCase("RELATIVE"))
        if (value == null) value = "";
        // value = JavaScript.escape(value);
      } // if (name != null)

      params.put(name, value);
    } // for (int i = 0; i < parameters.size(); i++)
    return params;
  } // protected StringBuffer getParametersList(Vector parameters, SourceBean row) throws
  public Object deserialize(Object o, Class clazz) throws DeserializationException {
    Object result = null;

    try {
      Assert.assertNotNull(o, "Input parameter [" + o + "] cannot be null");
      Assert.assertNotNull(o, "Input parameter [" + clazz + "] cannot be null");

      SourceBean xml = null;
      if (o instanceof SourceBean) {
        xml = (SourceBean) o;
      } else if (o instanceof String) {
        xml = SourceBean.fromXMLString((String) o);
      } else {
        throw new DeserializationException(
            "Impossible to deserialize from an object of type [" + o.getClass().getName() + "]");
      }

      Deserializer deserializer = mappings.get(clazz);
      if (deserializer == null) {
        throw new DeserializationException(
            "Impossible to deserialize to an object of type [" + clazz.getName() + "]");
      }

      if (xml.getAttribute("ROWS") != null) {
        List list = new ArrayList();
        List<SourceBean> rows = xml.getAttributeAsList("ROWS.ROW");
        for (SourceBean row : rows) {
          list.add(deserializer.deserialize(row, clazz));
        }
        result = list;
      } else {
        result = deserializer.deserialize(o, clazz);
      }
    } catch (Throwable t) {
      throw new DeserializationException("An error occurred while deserializing object: " + o, t);
    } finally {

    }

    return result;
  }
  public void service(SourceBean serviceRequest, SourceBean serviceResponse) throws Exception {
    logger.debug("IN");
    RequestContainer reqCont = RequestContainer.getRequestContainer();
    SessionContainer sessCont = reqCont.getSessionContainer();
    SessionContainer permSess = sessCont.getPermanentContainer();

    String theme_name = (String) serviceRequest.getAttribute(THEME_NAME);
    logger.debug("theme selected: " + theme_name);

    permSess.setAttribute(SpagoBIConstants.THEME, theme_name);

    IEngUserProfile profile =
        (IEngUserProfile) permSess.getAttribute(IEngUserProfile.ENG_USER_PROFILE);
    userProfile = null;
    if (profile instanceof UserProfile) {
      userProfile = (UserProfile) profile;
    }

    MenuUtilities.getMenuItems(serviceRequest, serviceResponse, profile);

    serviceResponse.setAttribute("MENU_MODE", "ALL_TOP");
    serviceResponse.setAttribute(SpagoBIConstants.PUBLISHER_NAME, "userhome");
    logger.debug("OUT");
  }
  /** This action is called by the user who wants to export the result of a Kpi in PDF */
  public void service(SourceBean serviceRequest, SourceBean serviceResponse) throws Exception {

    File tmpFile = null;
    logger.debug("IN");
    HttpServletRequest httpRequest = getHttpRequest();
    HttpSession session = httpRequest.getSession();

    this.freezeHttpResponse();

    try {
      // get KPI result
      List<KpiResourceBlock> listKpiBlocks =
          (List<KpiResourceBlock>) session.getAttribute("KPI_BLOCK");

      // List<KpiResourceBlock> listKpiBlocks=executeKpi(objectId);

      // recover BiObject Name
      Object idObject = serviceRequest.getAttribute(SpagoBIConstants.OBJECT_ID);
      if (idObject == null) {
        logger.error("Document id not found");
        return;
      }

      Integer id = Integer.valueOf(idObject.toString());
      BIObject document = DAOFactory.getBIObjectDAO().loadBIObjectById(id);
      String docName = document.getName();

      // Recover user Id
      HashedMap parameters = new HashedMap();
      String userId = null;
      Object userIdO = serviceRequest.getAttribute("user_id");
      if (userIdO != null) userId = userIdO.toString();

      it.eng.spagobi.engines.exporters.KpiExporter exporter = new KpiExporter();
      tmpFile = exporter.getKpiReportPDF(listKpiBlocks, document, userId);

      String outputType = "PDF";

      String mimeType = "application/pdf";

      logger.debug("Report exported succesfully");

      HttpServletResponse response = getHttpResponse();
      response.setContentType(mimeType);
      response.setHeader("Content-Disposition", "filename=\"report." + outputType + "\";");
      response.setContentLength((int) tmpFile.length());

      BufferedInputStream in = new BufferedInputStream(new FileInputStream(tmpFile));
      int b = -1;
      while ((b = in.read()) != -1) {
        response.getOutputStream().write(b);
      }
      response.getOutputStream().flush();
      in.close();
      logger.debug("OUT");

    } catch (Throwable e) {
      logger.error("An exception has occured", e);
      throw new Exception(e);
    } finally {

      tmpFile.delete();
    }
  }
Exemple #27
0
  public String composeWorksheetTemplate(
      String workSheetDef, String workSheetQuery, String smartFilterValues, String originalQbeTempl)
      throws SourceBeanException {
    SourceBean templateSB = new SourceBean(TAG_WORKSHEET);
    templateSB.setAttribute(ATTRIBUTE_VERSION, CURRENT_VERSION);
    SourceBean confSB = SourceBean.fromXMLString(originalQbeTempl);
    // from version 0 to version 1 worksheet change compensation: on version 0 the
    // worksheet definition was inside QBE tag; on version 1 the QBE tag is inside
    // WORKSHEET tag
    if (confSB.getName().equalsIgnoreCase(TAG_QBE)
        || confSB.getName().equalsIgnoreCase(TAG_QBE_COMPOSITE)
        || confSB.getName().equalsIgnoreCase(TAG_SMART_FILTER)) {

      if (confSB.containsAttribute(TAG_WORKSHEET_DEFINITION)) {
        confSB.delAttribute(TAG_WORKSHEET_DEFINITION);
      }
      templateSB.setAttribute(confSB);
      SourceBean wk_def_sb = new SourceBean(TAG_WORKSHEET_DEFINITION);
      wk_def_sb.setCharacters(workSheetDef);
      templateSB.setAttribute(wk_def_sb);

      if (workSheetQuery != null && !workSheetQuery.equals("")) {
        SourceBean query_sb = new SourceBean(QUERY);
        query_sb.setCharacters(workSheetQuery);
        confSB.updAttribute(query_sb);
      }

      if (smartFilterValues != null && !smartFilterValues.equals("")) {
        SourceBean smartFilterValuesSB = new SourceBean(FORM_VALUES);
        smartFilterValuesSB.setCharacters(smartFilterValues);
        confSB.updAttribute(smartFilterValuesSB);
      }

    } else {

      SourceBean qbeSB = null;

      if (confSB.containsAttribute(TAG_QBE)) {
        qbeSB = (SourceBean) confSB.getAttribute(TAG_QBE);
      } else if (confSB.containsAttribute(TAG_QBE_COMPOSITE)) {
        qbeSB = (SourceBean) confSB.getAttribute(TAG_QBE_COMPOSITE);
      } else if (confSB.containsAttribute(TAG_SMART_FILTER)) {
        qbeSB = (SourceBean) confSB.getAttribute(TAG_SMART_FILTER);
      }

      if (qbeSB != null) {
        templateSB.setAttribute(qbeSB);
        if (workSheetQuery != null && !workSheetQuery.equals("")) {
          SourceBean query_sb = new SourceBean(QUERY);
          query_sb.setCharacters(workSheetQuery);
          qbeSB.updAttribute(query_sb);
        }

        if (smartFilterValues != null && !smartFilterValues.equals("")) {
          SourceBean smartFilterValuesSB = new SourceBean(FORM_VALUES);
          smartFilterValuesSB.setCharacters(smartFilterValues);
          qbeSB.updAttribute(smartFilterValuesSB);
        }
      }

      SourceBean wk_def_sb = new SourceBean(TAG_WORKSHEET_DEFINITION);
      wk_def_sb.setCharacters(workSheetDef);
      templateSB.setAttribute(wk_def_sb);
    }

    String template = templateSB.toXML(false);
    return template;
  }
  public void load(SourceBean template)
      throws it.eng.spagobi.engines.commonj.exception.TemplateParseException {
    logger.debug("IN");
    SourceBean workSB;

    Assert.assertNotNull(template, "Input parameter [template] cannot be null");

    workSB = (SourceBean) template.getAttribute("WORK");
    Assert.assertNotNull(workSB, "template cannot be null");

    workName = (String) workSB.getAttribute("workName");
    if (workName == null) {
      logger.error("Missing  work name in document template");
      throw new it.eng.spagobi.engines.commonj.exception.TemplateParseException(
          template, "Missing  work name in document template");
    }

    className = (String) workSB.getAttribute("className");
    if (className == null) {
      logger.error("Missing class specification in document template");
      throw new it.eng.spagobi.engines.commonj.exception.CommonjEngineException(
          "Missing class specification in document template");
    }

    cmdParameters = new Vector<String>();
    analyticalParameters = new Vector<String>();
    classpathParameters = new Vector<String>();

    // check for parameters, in particular cmd and cmd_env
    SourceBean parametersSB = (SourceBean) workSB.getAttribute("PARAMETERS");
    if (parametersSB != null) {
      List parameterList = parametersSB.getAttributeAsList("PARAMETER");
      if (parameterList != null) {
        for (Iterator iterator = parameterList.iterator(); iterator.hasNext(); ) {
          SourceBean parameter = (SourceBean) iterator.next();
          String name = (String) parameter.getAttribute("name");
          String value = (String) parameter.getAttribute("value");

          // if it is the command name
          if (name.equalsIgnoreCase(COMMAND)) {
            logger.debug("command parameter " + value);
            command = value;
          } else // if it is the command environment
          if (name.equalsIgnoreCase(COMMAND_ENVIRONMENT)) {
            logger.debug("command environment parameter" + value);
            command_environment = value;
          } else {
            logger.debug("general parameter" + value);
            // if it is a spagobi Analytical driver url name
            if (name.equalsIgnoreCase(SBI_ANALYTICAL_DRIVER)) {
              analyticalParameters.add(value);
            }
            // if it is a classpath variable
            else if (name.equalsIgnoreCase(CLASSPATH)) {
              classpathParameters.add(value);
            } else if (name.equalsIgnoreCase(CMD_PAR)) {
              // else it is a command parameter name = value
              cmdParameters.add(value);
            }
          }
        }

        // Build arrays
        //				if(cmdparametersVect.size()>0){
        //					cmdParameters=new String[cmdparametersVect.size()];
        //					int i=0;
        //					for (Iterator iterator = cmdparametersVect.iterator(); iterator.hasNext();) {
        //						String string = (String) iterator.next();
        //						cmdParameters[i]=string;
        //					}
        //				}
        //				if(analyticalVect.size()>0){
        //					analyticalDriverParameters=new String[analyticalVect.size()];
        //					int i=0;
        //					for (Iterator iterator = analyticalVect.iterator(); iterator.hasNext();) {
        //						String string = (String) iterator.next();
        //						analyticalDriverParameters[i]=string;
        //					}
        //				}
        //				if(classPathVect.size()>0){
        //					classpathParameters=new String[classPathVect.size()];
        //					int i=0;
        //					for (Iterator iterator = classPathVect.iterator(); iterator.hasNext();) {
        //						String string = (String) iterator.next();
        //						classpathParameters[i]=string;
        //					}
        //				}

      }
    }
    logger.debug("OUT");
  }
 public void getDocumentContainerStyle() {
   documentProperties.put(
       "style", (String) template.getAttribute(MobileConstants.DOCUMENT_STYLE_ATTR));
 }
 /**
  * Reads the operation asked by the user and calls the right operation handler.
  *
  * @param request The Source Bean containing all request parameters
  * @param response The Source Bean containing all response parameters
  * @throws exception If an exception occurs
  * @throws Exception the exception
  */
 public void service(SourceBean request, SourceBean response) throws Exception {
   logger.debug("IN");
   EMFErrorHandler errorHandler = getErrorHandler();
   String operation = (String) request.getAttribute(SpagoBIConstants.OPERATION);
   logger.debug(
       "Begin of detail Engine modify/visualization service with operation =" + operation);
   String tempFolder = (String) request.getAttribute(DossierConstants.DOSSIER_TEMP_FOLDER);
   if (tempFolder == null) {
     tempFolder = initDossier(request, response);
     request.setAttribute(DossierConstants.DOSSIER_TEMP_FOLDER, tempFolder);
   }
   response.setAttribute(DossierConstants.DOSSIER_TEMP_FOLDER, tempFolder);
   try {
     if ((operation == null) || (operation.trim().equals(""))) {
       EMFUserError userError =
           new EMFUserError(EMFErrorSeverity.ERROR, "100", "component_dossier_messages");
       logger.error("The operation parameter is null");
       throw userError;
     } else if (operation.equalsIgnoreCase(SpagoBIConstants.NEW_DOCUMENT_TEMPLATE)) {
       newTemplateHandler(request, response);
     } else if (operation.equalsIgnoreCase(SpagoBIConstants.EDIT_DOCUMENT_TEMPLATE)) {
       dossierDetailHandler(request, response);
     } else if (operation.equalsIgnoreCase(DossierConstants.OPERATION_NEW_CONFIGURED_DOCUMENT)) {
       newConfiguredDocumentHandler(request, response);
     } else if (operation.equalsIgnoreCase(DossierConstants.OPERATION_SAVE_CONFIGURED_DOCUMENT)) {
       saveConfiguredDocumentHandler(request, response);
     } else if (operation.equalsIgnoreCase(DossierConstants.OPERATION_DETAIL_DOSSIER)) {
       dossierDetailHandler(request, response);
     } else if (operation.equalsIgnoreCase(
         DossierConstants.OPERATION_DELETE_CONFIGURED_DOCUMENT)) {
       deleteConfiguredDocumentHandler(request, response);
     } else if (operation.equalsIgnoreCase(
         DossierConstants.OPERATION_DETAIL_CONFIGURED_DOCUMENT)) {
       detailConfiguredDocumentHandler(request, response);
     } else if (operation.equalsIgnoreCase(DossierConstants.OPERATION_SAVE_DETAIL_DOSSIER)) {
       saveDossierDetailHandler(request, response);
     } else if (operation.equalsIgnoreCase(
         DossierConstants.OPERATION_LOAD_PRESENTATION_TEMPLATE)) {
       loadPresentationTemplateHandler(request, response);
     } else if (operation.equalsIgnoreCase(
         DossierConstants.OPERATION_LOAD_PROCESS_DEFINITION_FILE)) {
       loadProcessDefinitionFileHandler(request, response);
     } else if (operation.equalsIgnoreCase(DossierConstants.OPERATION_EXIT_FROM_DETAIL)) {
       exitFromDetailHandler(request, response);
     }
   } catch (EMFUserError eex) {
     errorHandler.addError(eex);
     return;
   } catch (Exception ex) {
     SpagoBITracer.major(
         DossierConstants.NAME_MODULE,
         this.getClass().getName(),
         "service",
         "Error while processin request",
         ex);
     EMFUserError emfue = new EMFUserError(EMFErrorSeverity.ERROR, 100);
     EMFInternalError internalError = new EMFInternalError(EMFErrorSeverity.ERROR, ex);
     errorHandler.addError(internalError);
     return;
   } finally {
     logger.debug("OUT");
   }
 }