Example #1
0
  /**
   * Updates the designer value. Designer values only contain Driver-defined parameters.
   *
   * @param setDesign the data set design
   * @param setHandle the data set handle
   * @param designerValues the designer values
   * @param userDefinedList the user defined parameters
   * @throws SemanticException
   */
  private void updateDesignerValue(
      DataSetDesign setDesign,
      OdaDataSetHandle setHandle,
      DataSetParameters requestParameters,
      List userDefinedList,
      ResultSets requestResultSets)
      throws SemanticException {

    DesignValues designerValues = null;

    // update design values.

    org.eclipse.datatools.connectivity.oda.design.DataSetParameters setDefinedParams =
        setDesign.getParameters();

    if (setDefinedParams == null) {
      if (requestParameters != null) {
        designerValues = ModelFactory.eINSTANCE.createDesignValues();
        designerValues.setDataSetParameters(null);
      }
    } else {
      org.eclipse.datatools.connectivity.oda.design.DataSetParameters driverParams =
          DataSetParameterAdapter.getDriverDefinedParameters(
              setDefinedParams.getParameterDefinitions(), userDefinedList);

      if (driverParams.getParameterDefinitions().size() > 0) {
        designerValues = ModelFactory.eINSTANCE.createDesignValues();

        DataSetParameters adapterParams =
            SchemaConversionUtil.convertToAdapterParameters(driverParams);
        designerValues.setDataSetParameters(adapterParams);

        clearReportParameterRelatedValues(
            adapterParams.getParameters(), setHandle.getModuleHandle());
      }
    }

    if (designerValues == null && requestResultSets == null) {
      setHandle.setDesignerValues(null);
      return;
    }

    if (requestResultSets != null) {
      if (designerValues == null) {
        designerValues = ModelFactory.eINSTANCE.createDesignValues();
        designerValues.setDataSetParameters(null);
      }

      designerValues.setResultSets(requestResultSets);
    } else designerValues.setResultSets(null);

    // Set DesignerValues

    try {
      String dValue = SerializerImpl.instance().write(designerValues);
      setHandle.setDesignerValues(dValue);
    } catch (IOException e) {
    }
  }
Example #2
0
  /**
   * Gets the serializable string for design values. Design values include data set parameter
   * definitions and result set definitions.
   *
   * @param setDesign the data set desgin
   * @return the serializable string for design values
   */
  private String serializeOdaValues(DataSetDesign setDesign) {
    DataSetParameters params =
        SchemaConversionUtil.convertToAdapterParameters(setDesign.getParameters());
    ResultSets resultSets = setDesign.getResultSets();

    DesignValues values = ModelFactory.eINSTANCE.createDesignValues();
    values.setVersion(IConstants.DESINGER_VALUES_VERSION);
    boolean hasData = false;

    if (params != null) {
      values.setDataSetParameters((DataSetParameters) EcoreUtil.copy(params));
      hasData = true;
    }

    if (resultSets != null) {
      values.setResultSets((ResultSets) EcoreUtil.copy(resultSets));
      hasData = true;
    }

    if (!hasData) return IConstants.EMPTY_STRING;

    try {
      return SerializerImpl.instance().write(values);
    } catch (IOException e) {
      return null;
    }
  }
  /**
   * Converts ROM result set columns with column hints to ODA data set resultSets.
   *
   * @throws Exception
   */
  public void testToODAResultSetsWithColumnHint() throws Exception {
    // create oda set handle.

    openDesign("OdaDataSetConvertResultSetsTest.xml"); // $NON-NLS-1$
    OdaDataSetHandle setHandle =
        (OdaDataSetHandle) designHandle.findDataSet("myDataSet1"); // $NON-NLS-1$

    DataSetDesign setDesign = new ModelOdaAdapter().createDataSetDesign(setHandle);

    DesignValues values = ModelFactory.eINSTANCE.createDesignValues();
    values.setResultSets(setDesign.getResultSets());

    saveDesignValuesToFile(values);
    save();

    saveAndOpenDesign();
    setHandle = (OdaDataSetHandle) designHandle.findDataSet("myDataSet1"); // $NON-NLS-1$

    setDesign = new ModelOdaAdapter().createDataSetDesign(setHandle);

    String hint =
        setDesign
            .getResultSets()
            .getResultSetDefinitions()
            .get(0)
            .getResultSetColumns()
            .getResultColumnDefinitions()
            .get(0)
            .getUsageHints()
            .getHelpText();

    assertEquals(hint, "Help me!");

    // assertTrue( compareTextFile( "ResultSetsWithHint_golden.xml" ) ); //$NON-NLS-1$

  }