Esempio n. 1
0
  /**
   * 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;
  }
Esempio n. 2
0
  /**
   * Function not implemented. Thid method should not be called
   *
   * @param biobject The BIOBject to edit
   * @param profile the profile
   * @return the new document template build url
   * @throws InvalidOperationRequest the invalid operation request
   */
  public EngineURL getNewDocumentTemplateBuildUrl(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();
      // url = url.replaceFirst("/servlet/AdapterHTTP", "");
      // url += "/templateBuilder.jsp";

      parameters = new HashMap();
      parameters.put("document", documentId);
      parameters.put(PARAM_SERVICE_NAME, "FORM_ENGINE_TEMPLATE_BUILD_ACTION");
      parameters.put(PARAM_NEW_SESSION, "TRUE");
      parameters.put(PARAM_MODALITY, "NEW");
      applySecurity(parameters, profile);

      engineURL = new EngineURL(url, parameters);
    } finally {
      logger.debug("OUT");
    }

    return engineURL;
  }
  @Override
  public void doService() {

    DatasetManagementAPI creationUtilities;
    IDataSet datasetBean;

    logger.debug("IN");

    try {

      // create the input parameters to pass to the WorkSheet Edit Service
      Map worksheetEditActionParameters = buildWorksheetEditServiceBaseParametersMap();

      String executionId = ExecuteAdHocUtility.createNewExecutionId();
      worksheetEditActionParameters.put("SBI_EXECUTION_ID", executionId);

      Engine worksheetEngine = getWorksheetEngine();
      LogMF.debug(logger, "Engine label is equal to [{0}]", worksheetEngine.getLabel());

      IDataSource datasource;
      try {
        datasource = DAOFactory.getDataSourceDAO().loadDataSourceWriteDefault();
      } catch (EMFUserError e) {
        throw new SpagoBIRuntimeException("Error while loading default datasource for writing", e);
      }
      if (datasource != null) {
        LogMF.debug(logger, "Datasource label is equal to [{0}]", datasource.getLabel());
        worksheetEditActionParameters.put(
            EngineConstants.DEFAULT_DATASOURCE_FOR_WRITING_LABEL, datasource.getLabel());
      } else {
        logger.debug("There is no default datasource for writing");
      }

      datasetBean = getDatasetAttributesFromRequest();
      worksheetEditActionParameters.put("dataset_label", datasetBean.getLabel());

      Map<String, String> datasetParameterValuesMap = getDatasetParameterValuesMapFromRequest();
      worksheetEditActionParameters.putAll(datasetParameterValuesMap);

      // create the WorkSheet Edit Service's URL
      String worksheetEditActionUrl =
          GeneralUtilities.getUrl(worksheetEngine.getUrl(), worksheetEditActionParameters);
      LogMF.debug(
          logger, "Worksheet edit service invocation url is equal to [{}]", worksheetEditActionUrl);

      // create the dataset
      logger.trace("Creating the dataset...");
      Integer datasetId = null;
      try {
        creationUtilities = new DatasetManagementAPI();
        datasetId = creationUtilities.creatDataSet(datasetBean);
        Assert.assertNotNull(datasetId, "Dataset Id cannot be null");
      } catch (Throwable t) {
        throw new SpagoBIServiceException(
            SERVICE_NAME,
            "An error occurred while creating dataset from bean [" + datasetBean + "]",
            t);
      }
      LogMF.debug(logger, "Datset [{0}]succesfully created with id [{1}]", datasetBean, datasetId);

      logger.trace("Copying output parameters to response...");
      try {
        getServiceResponse().setAttribute(OUTPUT_PARAMETER_EXECUTION_ID, executionId);
        getServiceResponse()
            .setAttribute(OUTPUT_PARAMETER_WORKSHEET_EDIT_SERVICE_URL, worksheetEditActionUrl);
        getServiceResponse().setAttribute(OUTPUT_PARAMETER_DATASET_LABEL, datasetBean.getLabel());
        getServiceResponse()
            .setAttribute(OUTPUT_PARAMETER_DATASET_PARAMETERS, datasetParameterValuesMap);

        // business metadata
        JSONObject businessMetadata = getBusinessMetadataFromRequest();
        if (businessMetadata != null) {
          getServiceResponse()
              .setAttribute(OUTPUT_PARAMETER_BUSINESS_METADATA, businessMetadata.toString());
        }
      } catch (Throwable t) {
        throw new SpagoBIServiceException(
            SERVICE_NAME,
            "An error occurred while creating dataset from bean [" + datasetBean + "]",
            t);
      }
      logger.trace("Output parameter succesfully copied to response");

    } finally {
      logger.debug("OUT");
    }
  }