コード例 #1
0
  private JSONObject getBusinessMetadataFromRequest() {
    JSONObject businessMetadata;

    businessMetadata = null;
    try {
      if (requestContainsAttribute(INPUT_PARAMETER_BUSINESS_METADATA)) {
        logger.trace(
            "Reading input parametr [" + INPUT_PARAMETER_BUSINESS_METADATA + "] from request...");
        businessMetadata = this.getAttributeAsJSONObject(INPUT_PARAMETER_BUSINESS_METADATA);
        logger.debug(
            "Input parameter ["
                + INPUT_PARAMETER_BUSINESS_METADATA
                + "] is equal to ["
                + businessMetadata
                + "]");
      } else {
        LogMF.trace(
            logger, "Input parameter [{0}] not valorized", INPUT_PARAMETER_BUSINESS_METADATA);
      }
    } catch (Throwable t) {
      logger.error(
          "Impossible to parse input parameter [" + INPUT_PARAMETER_BUSINESS_METADATA + "]", t);
    }

    return businessMetadata;
  }
コード例 #2
0
  private Map<String, String> getDatasetParameterValuesMapFromRequest() {
    Map<String, String> parametersMap;

    parametersMap = new HashMap<String, String>();

    try {
      if (requestContainsAttribute(INPUT_PARAMETER_DS_PARAMETERS_VALUES)) {
        logger.trace(
            "Reading input parametr ["
                + INPUT_PARAMETER_DS_PARAMETERS_VALUES
                + "] from request...");
        JSONObject parameterValues =
            this.getAttributeAsJSONObject(INPUT_PARAMETER_DS_PARAMETERS_VALUES);
        logger.debug(
            "Input parameter ["
                + INPUT_PARAMETER_DS_PARAMETERS_VALUES
                + "] is equal to ["
                + parameterValues
                + "]");

        for (Iterator<String> iterator = parameterValues.keys(); iterator.hasNext(); ) {
          String key = iterator.next();
          String value =
              parameterValues.get(key) != null ? parameterValues.get(key).toString() : null;
          parametersMap.put(key, value);
        }
      } else {
        LogMF.trace(
            logger, "Input parameter [{0}] not valorized", INPUT_PARAMETER_DS_PARAMETERS_VALUES);
      }
    } catch (Throwable t) {
      logger.error(
          "Impossible to parse input parameter [" + INPUT_PARAMETER_DS_PARAMETERS_VALUES + "]", t);
    }

    return parametersMap;
  }
コード例 #3
0
  /**
   * Read dataset's attributes from request and save them in a bean object.
   *
   * @return GuiGenericDataSet the bean object that collect all the dataset attributes read from
   *     request.
   */
  private IDataSet getDatasetAttributesFromRequest() {

    IDataSet datasetBean;

    String label;
    String name;
    String description;
    String customData;
    String jClassName;
    String metadata;
    String parametersDefinitionJson;
    String parametersDefinitionXML;

    logger.debug("IN");

    datasetBean = null;

    try {
      logger.trace("Reading from request attributes used to build the new dataset...");

      LogMF.trace(logger, "Reading input parametr [{0}] from request...", INPUT_PARAMETER_DS_LABEL);
      label = getAttributeAsString(INPUT_PARAMETER_DS_LABEL);
      LogMF.debug(
          logger, "Input parameter [{0}] is equal to [{1}]", INPUT_PARAMETER_DS_LABEL, label);
      Assert.assertNotNull(
          label, "Input parameter [" + INPUT_PARAMETER_DS_LABEL + "] cannot be null");

      LogMF.trace(logger, "Reading input parametr [{0}] from request...", INPUT_PARAMETER_DS_NAME);
      name = getAttributeAsString(INPUT_PARAMETER_DS_NAME);
      LogMF.debug(
          logger, "Input parameter [{0}] is equal to [{1}]", INPUT_PARAMETER_DS_LABEL, name);

      LogMF.trace(
          logger, "Reading input parametr [{0}] from request...", INPUT_PARAMETER_DS_DESCRIPTION);
      description = getAttributeAsString(INPUT_PARAMETER_DS_DESCRIPTION);
      LogMF.debug(
          logger,
          "Input parameter [{0}] is equal to [{1}]",
          INPUT_PARAMETER_DS_DESCRIPTION,
          description);

      LogMF.trace(
          logger, "Reading input parametr [{0}] from request...", INPUT_PARAMETER_DS_CUSTOM_DATA);
      customData = getAttributeAsString(INPUT_PARAMETER_DS_CUSTOM_DATA);
      LogMF.debug(
          logger,
          "Input parameter [{0}] is equal to [{1}]",
          INPUT_PARAMETER_DS_CUSTOM_DATA,
          customData);

      LogMF.trace(
          logger, "Reading input parametr [{0}] from request...", INPUT_PARAMETER_DS_JCLASS_NAME);
      jClassName = getAttributeAsString(INPUT_PARAMETER_DS_JCLASS_NAME);
      LogMF.debug(
          logger,
          "Input parameter [{0}] is equal to [{1}]",
          INPUT_PARAMETER_DS_JCLASS_NAME,
          jClassName);

      LogMF.trace(
          logger, "Reading input parametr [{0}] from request...", INPUT_PARAMETER_DS_METADATA);
      metadata = getAttributeAsString(INPUT_PARAMETER_DS_METADATA);
      LogMF.debug(
          logger, "Input parameter [{0}] is equal to [{1}]", INPUT_PARAMETER_DS_METADATA, metadata);

      LogMF.trace(
          logger,
          "Reading input parametr [{0}] from request...",
          INPUT_PARAMETER_DS_PARAMETER_DEFINITION);
      parametersDefinitionJson = getAttributeAsString(INPUT_PARAMETER_DS_PARAMETER_DEFINITION);
      LogMF.debug(
          logger,
          "Input parameter [{0}] is equal to [{1}]",
          INPUT_PARAMETER_DS_METADATA,
          parametersDefinitionJson);

      parametersDefinitionXML = null;
      if (!StringUtilities.isEmpty(parametersDefinitionJson)) {
        LogMF.trace(
            logger,
            "Coverting input parameter [{0}] from JSON format to XML format ...",
            INPUT_PARAMETER_DS_PARAMETER_DEFINITION);
        parametersDefinitionXML = parametersJsonToXML(parametersDefinitionJson);
        LogMF.trace(
            logger,
            "Input parameter [{0}] succesfully converted to xml formt [{1}]",
            INPUT_PARAMETER_DS_PARAMETER_DEFINITION,
            parametersDefinitionXML);
      }

      logger.trace("Attributes used to build the new dataset succesfully read from request");

      logger.trace("Building the dataset bean...");

      datasetBean = new CustomDataSet();
      datasetBean.setLabel(label);
      datasetBean.setName(name);
      datasetBean.setDescription(description);

      ((CustomDataSet) datasetBean).setCustomData(customData);
      ((CustomDataSet) datasetBean).setJavaClassName(jClassName);
      datasetBean.setParameters(parametersDefinitionXML);
      datasetBean.setDsType(DataSetConstants.DS_CUSTOM);
      if (!StringUtilities.isEmpty(metadata)) {
        datasetBean.setDsMetadata(metadata);
      }

      try {
        JSONObject jsonConf = new JSONObject();
        jsonConf.put(CUSTOM_DATA, customData);
        jsonConf.put(JCLASS_NAME, jClassName);
        jsonConf.put(DataSetConstants.PARS, parametersDefinitionXML);
        jsonConf.put(DataSetConstants.DS_CUSTOM, DataSetConstants.DS_CUSTOM);
        jsonConf.put(DataSetConstants.DS_TYPE_CD, DataSetConstants.DS_CUSTOM);
        datasetBean.setConfiguration(jsonConf.toString());
      } catch (Exception e) {
        logger.error("Error while defining dataset configuration.  Error: " + e.getMessage());
      }

      logger.trace("Dataset bean succesfully built");

    } catch (Throwable t) {
      throw new SpagoBIServiceException(
          SERVICE_NAME,
          "Impossible to read from request all parameters required to create the new dataset",
          t);
    } finally {
      logger.debug("OUT");
    }

    return datasetBean;
  }