Ejemplo n.º 1
0
 private DataSetHandle createDataSet(String dataSetType) throws SemanticException {
   DataSourceHandle source = getSelectedDataSource();
   if (source instanceof OdaDataSourceHandle) {
     OdaDataSetHandle dsHandle = Utility.newOdaDataSet(getDataSetName().trim(), dataSetType);
     dsHandle.setDataSource(source.getQualifiedName());
     dsHandle.setQueryText(""); // $NON-NLS-1$ //Need a empty query in the dataset.
     return dsHandle;
   } else if (source instanceof ScriptDataSourceHandle) {
     ScriptDataSetHandle dsHandle = Utility.newScriptDataSet(getDataSetName());
     dsHandle.setDataSource(source.getName());
     return dsHandle;
   } else return helper.createDataSet(getDataSetName().trim(), dataSetType);
 }
Ejemplo n.º 2
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();
  }