コード例 #1
0
ファイル: DataSetAdapter.java プロジェクト: GiorgioHuang/birt
  /**
   * 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) {
    }
  }
コード例 #2
0
ファイル: DataSetBasePage.java プロジェクト: lukehan/birt
 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);
 }
コード例 #3
0
ファイル: DataSetAdapter.java プロジェクト: GiorgioHuang/birt
  /**
   * Updates a structure list with the corresponding property handle.
   *
   * @param propHandle the property handle
   * @param structList the structure list
   * @throws SemanticException if any structure has invalid value.
   */
  private void updateROMResultSets(
      OdaDataSetHandle setHandle,
      ResultSetsAdapter tmpAdapter,
      ResultSetDefinition cachedResultDefn)
      throws SemanticException {
    List structList = tmpAdapter.newROMResultSets(cachedResultDefn);

    List columns = new ArrayList();
    List hints = new ArrayList();

    ResultSetColumnInfo.updateResultSetColumnList(structList, columns, hints);

    PropertyHandle propHandle = setHandle.getPropertyHandle(OdaDataSetHandle.RESULT_SET_PROP);
    propHandle.clearValue();

    if (!columns.isEmpty()) {
      for (int i = 0; i < columns.size(); i++) propHandle.addItem(columns.get(i));
    }

    propHandle = setHandle.getPropertyHandle(OdaDataSetHandle.COLUMN_HINTS_PROP);
    propHandle.clearValue();
    if (!hints.isEmpty()) {
      for (int i = 0; i < hints.size(); i++) {
        ColumnHint hint = (ColumnHint) hints.get(i);
        ColumnHintHandle oldHint =
            AdapterUtil.findColumnHint(
                (String) hint.getProperty(null, ColumnHint.COLUMN_NAME_MEMBER),
                setHandle.columnHintsIterator());

        if (oldHint == null) propHandle.addItem(hints.get(i));
        else {
          oldHint.setDisplayName((String) hint.getProperty(null, ColumnHint.DISPLAY_NAME_MEMBER));
          oldHint.setDisplayNameKey(
              (String) hint.getProperty(null, ColumnHint.DISPLAY_NAME_ID_MEMBER));
          oldHint.setHelpText((String) hint.getProperty(null, ColumnHint.HELP_TEXT_MEMBER));
          oldHint.setHelpTextKey((String) hint.getProperty(null, ColumnHint.HELP_TEXT_ID_MEMBER));
          oldHint.setFormat((String) hint.getProperty(null, ColumnHint.FORMAT_MEMBER));
        }
      }
    }

    // add column hints for the computed column

    List hints4ComputedColumn = tmpAdapter.getHintsForComputedColumn();
    for (int i = 0; i < hints4ComputedColumn.size(); i++) {
      propHandle.addItem((ColumnHint) hints4ComputedColumn.get(i));
    }

    // add filter condition for the result set
    tmpAdapter.updateROMFilterCondition();
  }
コード例 #4
0
ファイル: DataSetAdapter.java プロジェクト: GiorgioHuang/birt
  /**
   * @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());
  }
コード例 #5
0
ファイル: ResultSetsAdapter.java プロジェクト: WPCode/birt
  /**
   * The constructor.
   *
   * @param setHandle the data set handle
   * @param setDesign the data set design
   */
  ResultSetsAdapter(OdaDataSetHandle setHandle, DataSetDesign setDesign) {
    this.setHandle = setHandle;
    this.setDesign = setDesign;

    filterAdapter = new ResultSetCriteriaAdapter(setHandle, setDesign);

    Iterator tmpIterator = setHandle.resultSetIterator();
    setDefinedResults = new ArrayList();
    while (tmpIterator.hasNext()) setDefinedResults.add(tmpIterator.next());

    tmpIterator = setHandle.columnHintsIterator();
    setDefinedColumnHints = new ArrayList();
    while (tmpIterator.hasNext()) setDefinedColumnHints.add(tmpIterator.next());

    designFactory = ODADesignFactory.getFactory();
  }
コード例 #6
0
ファイル: DataSetAdapter.java プロジェクト: GiorgioHuang/birt
  /**
   * @param dataSetHandle
   * @return
   */
  public OdaDesignSession createOdaDesignSession(OdaDataSetHandle dataSetHandle) {
    OdaDesignSession session = designFactory.createOdaDesignSession();
    DataSetDesign setDesign = createDataSetDesign(dataSetHandle);
    DesignSessionRequest request = designFactory.createDesignSessionRequest();
    request.setNewDataAccessDesign(setDesign);
    request.setDesignerState(
        DesignerStateAdapter.createOdaDesignState(dataSetHandle.getDesignerState()));

    session.setRequest(request);
    return session;
  }
コード例 #7
0
ファイル: ResultSetsAdapter.java プロジェクト: WPCode/birt
  /**
   * Creates a ResultSetDefinition with the given ROM ResultSet columns.
   *
   * @return the created ResultSetDefinition
   */
  private ResultSetDefinition newOdaResultSetDefinition() {
    Iterator romSets = setDefinedResults.iterator();
    String name = setHandle.getResultSetName();

    if (!romSets.hasNext()) return null;

    ResultSetDefinition odaSetDefn = null;
    ResultSetColumns odaSetColumns = null;

    if (!StringUtil.isBlank(name)) {
      odaSetDefn = designFactory.createResultSetDefinition();
      odaSetDefn.setName(name);
    }

    while (romSets.hasNext()) {
      if (odaSetDefn == null) odaSetDefn = designFactory.createResultSetDefinition();

      if (odaSetColumns == null) odaSetColumns = designFactory.createResultSetColumns();

      OdaResultSetColumnHandle setColumn = (OdaResultSetColumnHandle) romSets.next();

      // get the colum hint

      ColumnHintHandle hint =
          AdapterUtil.findColumnHint(
              (OdaResultSetColumn) setColumn.getStructure(), setDefinedColumnHints.iterator());

      ColumnDefinition columnDefn = designFactory.createColumnDefinition();

      DataElementAttributes dataAttrs = designFactory.createDataElementAttributes();

      String newName = setColumn.getNativeName();
      dataAttrs.setName(newName);

      Integer position = setColumn.getPosition();
      if (position != null) dataAttrs.setPosition(setColumn.getPosition().intValue());

      Integer nativeDataType = setColumn.getNativeDataType();
      if (nativeDataType != null) dataAttrs.setNativeDataTypeCode(nativeDataType.intValue());

      columnDefn.setAttributes(dataAttrs);
      odaSetColumns.getResultColumnDefinitions().add(columnDefn);

      if (hint == null) continue;

      updateOdaColumnHint(columnDefn, hint);
    }

    if (odaSetDefn != null) odaSetDefn.setResultSetColumns(odaSetColumns);

    return odaSetDefn;
  }
コード例 #8
0
ファイル: Regression_121857.java プロジェクト: cwichoski/birt
  /** @throws Exception */
  public void test_regression_121857() throws Exception {
    SessionHandle session = new DesignEngine(new DesignConfig()).newSessionHandle(ULocale.ENGLISH);
    ReportDesignHandle designHandle = session.createDesign();
    ElementFactory factory = designHandle.getElementFactory();
    OdaDataSourceHandle datasource =
        factory.newOdaDataSource(
            "dsource", //$NON-NLS-1$
            "org.eclipse.birt.report.data.oda.jdbc"); //$NON-NLS-1$
    OdaDataSetHandle dataset =
        factory.newOdaDataSet(
            "dset", //$NON-NLS-1$
            "org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet"); //$NON-NLS-1$
    dataset.setDataSource("dsource"); // $NON-NLS-1$

    designHandle.getDataSources().add(datasource);
    designHandle.getDataSets().add(dataset);

    datasource.drop();
    assertNull(designHandle.findDataSource("dsource")); // $NON-NLS-1$
    assertNull(dataset.getDataSource());
    assertEquals("dsource", dataset.getDataSourceName()); // $NON-NLS-1$
  }
コード例 #9
0
ファイル: DataSetAdapter.java プロジェクト: GiorgioHuang/birt
  /**
   * @param setHandle
   * @return
   */
  private DataSetParameters getCachedParameters(OdaDataSetHandle setHandle) {
    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();

    return cachedParams;
  }
コード例 #10
0
ファイル: ResultSetsAdapter.java プロジェクト: WPCode/birt
  /** Updates column hints for computed columns. Saved in the field. */
  private void updateHintsForComputedColumn() {
    Iterator columns = setHandle.computedColumnsIterator();
    List<String> columnNames = new ArrayList<String>();
    while (columns.hasNext()) {
      ComputedColumnHandle tmpColumn = (ComputedColumnHandle) columns.next();
      columnNames.add(tmpColumn.getName());
    }

    for (int i = 0; i < columnNames.size(); i++) {
      String columnName = columnNames.get(i);
      ColumnHintHandle hintHandle =
          AdapterUtil.findColumnHint(columnName, setDefinedColumnHints.iterator());
      if (hintHandle == null) continue;

      if (columnHintsForComputedColumns == null)
        columnHintsForComputedColumns = new ArrayList<IStructure>();

      columnHintsForComputedColumns.add(hintHandle.getStructure().copy());
    }
  }
コード例 #11
0
ファイル: DataSetAdapter.java プロジェクト: GiorgioHuang/birt
  public void updateDataSetHandle(
      DataSetDesign setDesign, OdaDataSetHandle setHandle, boolean isSourceChanged)
      throws SemanticException {
    if (setDesign == null || setHandle == null) return;

    // serialize and get the designer values
    DesignValues designerValues = null;
    try {
      designerValues = SerializerImpl.instance().read(setHandle.getDesignerValues());
    } catch (IOException e) {
      e.printStackTrace();
    }

    DataSetParameters requestParameters = null;
    ResultSets requestResultSets = null;
    if (designerValues != null) {
      requestParameters = designerValues.getDataSetParameters();
      requestResultSets = designerValues.getResultSets();
    }

    updateDataSetHandle(
        setDesign, setHandle, isSourceChanged, requestParameters, requestResultSets);
  }
コード例 #12
0
ファイル: DataSetAdapter.java プロジェクト: GiorgioHuang/birt
  /**
   * @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());
  }
コード例 #13
0
ファイル: DataSetAdapter.java プロジェクト: GiorgioHuang/birt
  /**
   * 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();
  }
コード例 #14
0
ファイル: DataSetAdapter.java プロジェクト: GiorgioHuang/birt
  /**
   * Copies values of <code>setDesign</code> to <code>setHandle</code>. Values in <code>setDesign
   * </code> are validated before maps to values in OdaDataSetHandle.
   *
   * @param setDesign the ODA data set design
   * @param setHandle the Model handle
   * @throws SemanticException if any value is invalid.
   */
  private void adaptDataSetDesign(DataSetDesign setDesign, OdaDataSetHandle setHandle)
      throws SemanticException {

    Object value = null;

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

    value = setDesign.getName();
    PropertyValueValidationUtil.validateProperty(setHandle, OdaDataSetHandle.NAME_PROP, value);
    setHandle.getElement().setName(setDesign.getName());

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

    value = setDesign.getDisplayName();
    PropertyValueValidationUtil.validateProperty(
        setHandle, OdaDataSetHandle.DISPLAY_NAME_PROP, value);
    setHandle.getElement().setProperty(OdaDataSetHandle.DISPLAY_NAME_PROP, value);

    value = setDesign.getDisplayNameKey();
    PropertyValueValidationUtil.validateProperty(
        setHandle, OdaDataSetHandle.DISPLAY_NAME_ID_PROP, value);
    setHandle.getElement().setProperty(OdaDataSetHandle.DISPLAY_NAME_ID_PROP, value);

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

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

    // set null or empty list if the return list is empty.

    value = newROMPrivateProperties(setDesign.getPrivateProperties());
    PropertyValueValidationUtil.validateProperty(
        setHandle, OdaDataSetHandle.PRIVATE_DRIVER_PROPERTIES_PROP, value);
    setHandle.getElement().setProperty(OdaDataSetHandle.PRIVATE_DRIVER_PROPERTIES_PROP, value);

    updateROMPublicProperties(setDesign.getPublicProperties(), setHandle);

    DataSourceDesign sourceDesign = setDesign.getDataSourceDesign();
    String dataSourceName = null;
    if (sourceDesign != null) {
      dataSourceName = sourceDesign.getName();
      ModuleHandle moduleHandle = setHandle.getModuleHandle();
      DataSourceHandle sourceHandle = null;
      if (isLinkedParameter) {
        sourceHandle =
            moduleHandle
                .getElementFactory()
                .newOdaDataSource(dataSourceName, sourceDesign.getOdaExtensionDataSourceId());
        moduleHandle.getDataSources().add(sourceHandle);
      } else sourceHandle = moduleHandle.findDataSource(dataSourceName);
      if (sourceHandle != null && sourceHandle instanceof OdaDataSourceHandle) {
        new DataSourceAdapter()
            .updateDataSourceHandle(sourceDesign, (OdaDataSourceHandle) sourceHandle);
        dataSourceName = sourceHandle.getName();
      }
    } else dataSourceName = defaultDataSourceName;

    setHandle
        .getElement()
        .setProperty(
            OdaDataSetHandle.DATA_SOURCE_PROP,
            PropertyValueValidationUtil.validateProperty(
                setHandle, OdaDataSetHandle.DATA_SOURCE_PROP, dataSourceName));

    // set the data set parameter list.

    setHandle.getElement().clearProperty(OdaDataSetHandle.PARAMETERS_PROP);

    List dataSetParams = new DataSetParameterAdapter(setHandle, setDesign).newROMSetParams(null);
    PropertyValueValidationUtil.validateProperty(
        setHandle, OdaDataSetHandle.PARAMETERS_PROP, dataSetParams);
    setHandle.getElement().setProperty(OdaDataSetHandle.PARAMETERS_PROP, dataSetParams);

    // set the result sets

    ResultSetsAdapter tmpAdapter = new ResultSetsAdapter(setHandle, setDesign);
    List resultRetColumns = tmpAdapter.newROMResultSets(null);
    // add filter condition for the result set
    tmpAdapter.updateROMFilterCondition();

    List columns = null;
    List hints = null;

    // if the return value is null, do not create an empty list.

    if (resultRetColumns != null) {
      columns = new ArrayList();
      hints = new ArrayList();

      ResultSetColumnInfo.updateResultSetColumnList(resultRetColumns, columns, hints);
      if (hints.isEmpty()) hints = null;

      PropertyValueValidationUtil.validateProperty(
          setHandle, OdaDataSetHandle.RESULT_SET_PROP, columns);
      PropertyValueValidationUtil.validateProperty(
          setHandle, OdaDataSetHandle.COLUMN_HINTS_PROP, hints);
    }
    setHandle.getElement().setProperty(OdaDataSetHandle.COLUMN_HINTS_PROP, hints);
    setHandle.getElement().setProperty(OdaDataSetHandle.RESULT_SET_PROP, columns);

    // set the query text.

    String queryText = setDesign.getQueryText();
    PropertyValueValidationUtil.validateProperty(
        setHandle, OdaDataSetHandle.QUERY_TEXT_PROP, queryText);
    setHandle.getElement().setProperty(OdaDataSetHandle.QUERY_TEXT_PROP, queryText);

    // set the result name

    String resultSetName = setDesign.getPrimaryResultSetName();
    PropertyValueValidationUtil.validateProperty(
        setHandle, OdaDataSetHandle.RESULT_SET_NAME_PROP, queryText);
    setHandle.getElement().setProperty(OdaDataSetHandle.RESULT_SET_NAME_PROP, resultSetName);

    // convert data set paramters and result set columns first. Then update
    // designer values.

    String odaValues = serializeOdaValues(setDesign);
    PropertyValueValidationUtil.validateProperty(
        setHandle, OdaDataSetHandle.DESIGNER_VALUES_PROP, odaValues);
    setHandle.getElement().setProperty(OdaDataSetHandle.DESIGNER_VALUES_PROP, odaValues);

    updateROMMessageFile(setDesign.getDataSourceDesign(), setHandle.getModuleHandle());
  }
コード例 #15
0
  /**
   * Updates a ROM result set definition. To make sure that convertNativeTypeToROMDataType() will be
   * called. So that can verify blob conversion.
   *
   * @param param
   */
  private void updateResultSetDefinition2(OdaDataSetHandle setHandle) throws SemanticException {
    Iterator iter1 = setHandle.resultSetIterator();
    OdaResultSetColumnHandle column = (OdaResultSetColumnHandle) iter1.next();

    column.setNativeDataType(new Integer(10));
  }
コード例 #16
0
  /**
   * Adapts a model oda data set handle
   *
   * @param modelDataSet model handle
   * @param propBindingScope Javascript scope in which to evaluate property binding expressions. If
   *     null, property binding is not resolved
   * @throws BirtException
   */
  public OdaDataSetAdapter(
      OdaDataSetHandle modelDataSet,
      Scriptable propBindingScope,
      ModelAdapter adapter,
      DataEngineContext dtContext)
      throws BirtException {
    super(modelDataSet.getQualifiedName());

    // TODO: event handler

    // Adapt base class properties
    DataAdapterUtil.adaptBaseDataSet(modelDataSet, this, adapter);

    // Adapt extended data set elements

    // Set query text; if binding exists, use its result; otherwise
    // use static design
    Expression expression = modelDataSet.getPropertyBindingExpression(OdaDataSet.QUERY_TEXT_PROP);
    org.eclipse.birt.data.engine.api.querydefn.ScriptExpression script =
        adapter.adaptExpression(expression);

    if (propBindingScope != null
        && script != null
        && DataSessionContext.MODE_UPDATE != dtContext.getMode()) {
      String queryText =
          JavascriptEvalUtil.evaluateScript(
                  null, propBindingScope, script.getText(), ScriptExpression.defaultID, 0)
              .toString();
      setQueryText(queryText);
    } else {
      setQueryText(modelDataSet.getQueryText());
    }

    // type of extended data set
    setExtensionID(modelDataSet.getExtensionID());

    // result set name
    setPrimaryResultSetName(modelDataSet.getResultSetName());

    if (modelDataSet.getPropertyHandle(IOdaDataSetModel.RESULT_SET_NUMBER_PROP).isSet())
      setPrimaryResultSetNumber(modelDataSet.getResultSetNumber());
    // static ROM properties defined by the ODA driver extension
    Map staticProps =
        DataAdapterUtil.getExtensionProperties(
            modelDataSet, modelDataSet.getExtensionPropertyDefinitionList());
    if (staticProps != null && !staticProps.isEmpty()) {
      Iterator propNamesItr = staticProps.keySet().iterator();
      while (propNamesItr.hasNext()) {
        String propName = (String) propNamesItr.next();
        assert (propName != null);
        String propValue;
        String bindingExpr = modelDataSet.getPropertyBinding(propName);
        if (propBindingScope != null && bindingExpr != null && bindingExpr.length() > 0) {
          propValue =
              JavascriptEvalUtil.evaluateScript(
                      null, propBindingScope, bindingExpr, ScriptExpression.defaultID, 0)
                  .toString();
        } else {
          propValue = (String) staticProps.get(propName);
        }
        addPublicProperty((String) propName, propValue);
      }
    }

    // private driver properties / private runtime data
    Iterator elmtIter = modelDataSet.privateDriverPropertiesIterator();
    if (elmtIter != null) {
      while (elmtIter.hasNext()) {
        ExtendedPropertyHandle modelProp = (ExtendedPropertyHandle) elmtIter.next();
        addPrivateProperty(modelProp.getName(), modelProp.getValue());
      }
    }
  }