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;
  }
  @Override
  public void service(SourceBean request, SourceBean response) {

    try {
      if (!request.containsAttribute(START)) request.setAttribute(START, new Integer(0));
      if (!request.containsAttribute(LIMIT)) request.setAttribute(LIMIT, Integer.MAX_VALUE);
    } catch (SourceBeanException e) {
      throw new SpagoBIEngineServiceException(getActionName(), e);
    }
    super.service(request, response);
  }
  /**
   * 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;
  }
Exemple #4
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;
  }