예제 #1
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;
    }
  }
예제 #2
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) {
    }
  }
예제 #3
0
  /**
   * @param setHandle
   * @param setDesign
   * @param propertyName
   */
  void updateDataSetDesign(
      OdaDataSetHandle setHandle, DataSetDesign setDesign, String propertyName) {
    if (setHandle == null || setDesign == null || propertyName == null) return;

    // properties on ReportElement, like name, displayNames, etc.

    if (OdaDataSetHandle.NAME_PROP.equalsIgnoreCase(propertyName))
      setDesign.setName(setHandle.getName());
    else if (OdaDataSetHandle.DISPLAY_NAME_PROP.equalsIgnoreCase(propertyName))
      setDesign.setDisplayName(setHandle.getDisplayName());
    else if (OdaDataSetHandle.DISPLAY_NAME_ID_PROP.equalsIgnoreCase(propertyName))
      setDesign.setDisplayNameKey(setHandle.getDisplayNameKey());

    // properties such as comments, extends, etc are kept in
    // DataSourceHandle, not DataSourceDesign.

    // scripts of DataSource are kept in
    // DataSourceHandle, not DataSourceDesign.

    else if (OdaDataSourceHandle.EXTENSION_ID_PROP.equalsIgnoreCase(propertyName))
      setDesign.setOdaExtensionDataSetId(setHandle.getExtensionID());
    else if (OdaDataSetHandle.PRIVATE_DRIVER_PROPERTIES_PROP.equalsIgnoreCase(propertyName))
      setDesign.setPrivateProperties(
          newOdaPrivateProperties(setHandle.privateDriverPropertiesIterator()));
    else if (OdaDataSetHandle.RESULT_SET_NAME_PROP.equalsIgnoreCase(propertyName))
      setDesign.setPrimaryResultSetName(setHandle.getResultSetName());
    else if (OdaDataSetHandle.QUERY_TEXT_PROP.equalsIgnoreCase(propertyName))
      setDesign.setQueryText(setHandle.getQueryText());

    // create a new data source design for this set design.

    else if (OdaDataSetHandle.DATA_SOURCE_PROP.equalsIgnoreCase(propertyName)) {
      OdaDataSourceHandle sourceHandle = (OdaDataSourceHandle) setHandle.getDataSource();

      if (sourceHandle != null)
        setDesign.setDataSourceDesign(new DataSourceAdapter().createDataSourceDesign(sourceHandle));
    } else if (OdaDataSetHandle.PARAMETERS_PROP.equalsIgnoreCase(propertyName)) {
      org.eclipse.datatools.connectivity.oda.design.DataSetParameters dsParams =
          new DataSetParameterAdapter(setHandle, setDesign)
              .newOdaDataSetParams(
                  SchemaConversionUtil.convertToDesignParameters(getCachedParameters(setHandle)));

      if (dsParams != null) setDesign.setParameters(dsParams);
      else setDesign.setParameters(null);
    } else if (OdaDataSetHandle.RESULT_SET_PROP.equalsIgnoreCase(propertyName))
      new ResultSetsAdapter(setHandle, setDesign).updateOdaResultSetDefinition();
    else if (OdaDataSetHandle.COLUMN_HINTS_PROP.equalsIgnoreCase(propertyName))
      new ResultSetsAdapter(setHandle, setDesign).updateOdaColumnHints();
    else if (OdaDataSetHandle.FILTER_PROP.equalsIgnoreCase(propertyName))
      new ResultSetCriteriaAdapter(setHandle, setDesign).updateODAResultSetCriteria();

    updateODAMessageFile(setDesign.getDataSourceDesign(), setHandle.getModuleHandle());
  }
예제 #4
0
  /**
   * @param dataSetHandle
   * @param completedSession
   * @throws SemanticException
   */
  public void updateDataSetHandle(OdaDataSetHandle dataSetHandle, OdaDesignSession completedSession)
      throws SemanticException {
    if (completedSession == null || dataSetHandle == null) return;

    DataSetDesign responseDesign = completedSession.getResponseDataSetDesign();
    DataSetDesign requestDesign = completedSession.getRequestDataSetDesign();

    updateDataSetHandle(
        responseDesign,
        dataSetHandle,
        false,
        SchemaConversionUtil.convertToAdapterParameters(requestDesign.getParameters()),
        requestDesign.getResultSets());

    DesignerStateAdapter.updateROMDesignerState(
        completedSession.getResponse().getDesignerState(), dataSetHandle);
    ;
  }
예제 #5
0
  /**
   * Update parameters in DataSetHandle with DataSetDesign's.
   *
   * @param setDesign data set design contains driver-defined parameters
   * @param setHandle data set handle
   * @param cachedParameters the cached data set parameters in the designer values
   * @param userDefinedList a list contains user-defined parameters. Each item is <code>
   *     OdaDataSetParameter</code>.
   * @throws SemanticException
   */
  private void updateROMDataSetParams(
      DataSetParameterAdapter setParamAdapter, DataSetParameters cachedParameters)
      throws SemanticException {
    List newParams =
        setParamAdapter.newROMSetParams(
            SchemaConversionUtil.convertToDesignParameters(cachedParameters));

    // Merge all parameter list with data set handle.

    // If the name is the same , should rename it.
    // when you have three driver-defined parameter in DataSetDesign,but you
    // remove two of them
    // in handle, then when you back to 'parameter' page, you can get three
    // parameter and in this
    // time it's easy to duplicate name.

    IdentifierUtility.updateParams2UniqueName(newParams);

    // if one parameter in newParams has the corresponding data set
    // parameter in data set handle, use the new parameter to update the one
    // on set handle.

    setParamAdapter.updateRomDataSetParamsWithNewParams(newParams);
  }
예제 #6
0
  /**
   * @param setHandle
   * @param setDesign
   */
  void updateDataSetDesign(OdaDataSetHandle setHandle, DataSetDesign setDesign) {
    // properties on ReportElement, like name, displayNames, etc.

    setDesign.setName(setHandle.getName());

    String displayName = setHandle.getDisplayName();
    String displayNameKey = setHandle.getDisplayNameKey();

    if (displayName != null || displayNameKey != null) {
      setDesign.setDisplayName(displayName);
      setDesign.setDisplayNameKey(displayNameKey);
    }

    // properties such as comments, extends, etc are kept in
    // DataSourceHandle, not DataSourceDesign.

    // scripts of DataSource are kept in
    // DataSourceHandle, not DataSourceDesign.

    setDesign.setOdaExtensionDataSetId(setHandle.getExtensionID());

    setDesign.setPublicProperties(
        newOdaPublicProperties(setHandle.getExtensionPropertyDefinitionList(), setHandle));

    setDesign.setPrivateProperties(
        newOdaPrivateProperties(setHandle.privateDriverPropertiesIterator()));

    setDesign.setPrimaryResultSetName(setHandle.getResultSetName());

    setDesign.setQueryText(setHandle.getQueryText());

    // create a new data source design for this set design.

    OdaDataSourceHandle sourceHandle = (OdaDataSourceHandle) setHandle.getDataSource();

    if (sourceHandle != null)
      setDesign.setDataSourceDesign(new DataSourceAdapter().createDataSourceDesign(sourceHandle));

    // when converts the ODA to BIRT, some information for parameter
    // definitions may be lost. So, must get the cached values first. Then
    // try to restore to latest value.

    String strDesignValues = setHandle.getDesignerValues();

    DesignValues designerValues = null;

    try {
      if (strDesignValues != null) designerValues = SerializerImpl.instance().read(strDesignValues);

    } catch (IOException e) {
    }

    // the driver defined parameters are in the designer values

    DataSetParameters cachedParams = null;
    if (designerValues != null) {
      cachedParams = designerValues.getDataSetParameters();
    }

    DataSetParameterAdapter dataParamAdapter = new DataSetParameterAdapter(setHandle, setDesign);

    org.eclipse.datatools.connectivity.oda.design.DataSetParameters designDefinedParams = null;
    if (cachedParams != null) {
      // cached are driver-defined parameters
      designDefinedParams =
          SchemaConversionUtil.convertToDesignParameters(EcoreUtil.copy(cachedParams));

      setDesign.setParameters(designDefinedParams);

      dataParamAdapter.updateDriverDefinedParameter(
          designDefinedParams, SchemaConversionUtil.getCachedDynamicList(cachedParams));
    }

    // if there is no driver defined parameters, update parameters with set
    // handle defined with cached in the last request

    if (designDefinedParams == null) {
      designDefinedParams = dataParamAdapter.newOdaDataSetParams(designDefinedParams);
      setDesign.setParameters(designDefinedParams);
    }

    // handle those parameters defined by user

    dataParamAdapter.updateUserDefinedParameter(designDefinedParams);

    org.eclipse.datatools.connectivity.oda.design.DataSetParameters userDefinedParams =
        dataParamAdapter.newOdaDataSetParams(dataParamAdapter.getUserDefinedParams());

    if (designDefinedParams == null) {
      designDefinedParams = userDefinedParams;
      setDesign.setParameters(designDefinedParams);
    } else if (userDefinedParams != null)
      designDefinedParams
          .getParameterDefinitions()
          .addAll(userDefinedParams.getParameterDefinitions());

    new ResultSetsAdapter(setHandle, setDesign).updateOdaResultSetDefinition();

    updateODAMessageFile(setDesign.getDataSourceDesign(), setHandle.getModuleHandle());
  }
예제 #7
0
  /**
   * Updates the data set handle with specified values.
   *
   * @param setDesign the data set design
   * @param setHandle the data set handle
   * @param isSourceChanged
   * @param requestParameters
   * @param requestResultSets
   * @throws SemanticException
   */
  private void updateDataSetHandle(
      DataSetDesign setDesign,
      OdaDataSetHandle setHandle,
      boolean isSourceChanged,
      DataSetParameters requestParameters,
      ResultSets requestResultSets)
      throws SemanticException {
    if (setDesign == null || setHandle == null) return;

    DesignUtil.validateObject(setDesign);

    CommandStack stack = setHandle.getModuleHandle().getCommandStack();

    stack.startTrans(null);
    try {
      // extension id is set without undo/redo support.

      setHandle
          .getElement()
          .setProperty(OdaDataSourceHandle.EXTENSION_ID_PROP, setDesign.getOdaExtensionDataSetId());

      setHandle.setName(setDesign.getName());
      setHandle.setDisplayName(setDesign.getDisplayName());
      setHandle.setDisplayNameKey(setDesign.getDisplayNameKey());

      // set public properties.

      Properties props = setDesign.getPublicProperties();
      if (props != null) {
        EList propList = props.getProperties();
        for (int i = 0; i < propList.size(); i++) {
          Property prop = (Property) propList.get(i);
          setHandle.setProperty(prop.getName(), prop.getValue());
        }
      }

      // set private properties.

      props = setDesign.getPrivateProperties();
      if (props != null) {
        EList propList = props.getProperties();
        for (int i = 0; i < propList.size(); i++) {
          Property prop = (Property) propList.get(i);
          setHandle.setPrivateDriverProperty(prop.getName(), prop.getValue());
        }
      }

      ResultSetDefinition cachedResultDefn = null;

      if (requestResultSets != null && !requestResultSets.getResultSetDefinitions().isEmpty())
        cachedResultDefn = (ResultSetDefinition) requestResultSets.getResultSetDefinitions().get(0);

      ResultSetsAdapter tmpAdapter = new ResultSetsAdapter(setHandle, setDesign);
      updateROMResultSets(setHandle, tmpAdapter, cachedResultDefn);

      setHandle.setResultSetName(setDesign.getPrimaryResultSetName());

      setHandle.setQueryText(setDesign.getQueryText());

      // designer values must be saved after convert data set parameters
      // and result set columns.

      // Set Parameter

      // Get user-defined parameters

      DataSetParameterAdapter dataParamAdapter = new DataSetParameterAdapter(setHandle, setDesign);
      dataParamAdapter.updateUserDefinedParameter(
          SchemaConversionUtil.convertToDesignParameters(requestParameters));

      // Update parameters of dataset handle.

      updateROMDataSetParams(dataParamAdapter, requestParameters);

      DataSourceDesign sourceDesign = setDesign.getDataSourceDesign();
      if (sourceDesign != null) {
        OdaDataSourceHandle sourceHandle = (OdaDataSourceHandle) setHandle.getDataSource();

        DataSourceAdapter dataSourceAdapter = new DataSourceAdapter();

        // only the local data source can be used.

        if (isSourceChanged
            && sourceHandle != null
            && !sourceHandle.getModuleHandle().isReadOnly()) {
          setHandle.setDataSource(sourceDesign.getName());
          dataSourceAdapter.updateDataSourceHandle(sourceDesign, sourceHandle);
        }

        // if the source is not changed, and it is not in the included
        // library, then we can update it.

        if (!isSourceChanged
            && sourceHandle != null
            && !sourceHandle.getModuleHandle().isReadOnly()
            && !(dataSourceAdapter.isEqualDataSourceDesign(
                dataSourceAdapter.createDataSourceDesign(sourceHandle), sourceDesign))) {
          dataSourceAdapter.updateDataSourceHandle(sourceDesign, sourceHandle);
        }
      } else setHandle.setDataSource(defaultDataSourceName);

      updateDesignerValue(
          setDesign,
          setHandle,
          requestParameters,
          dataParamAdapter.getUserDefinedParams(),
          requestResultSets);

      updateROMMessageFile(sourceDesign, setHandle.getModuleHandle());
    } catch (SemanticException e) {
      stack.rollback();
      throw e;
    }

    stack.commit();
  }