Exemple #1
0
 public String getScriptDataSourceName(DataSourceHandle dataSourceHandle) {
   if (dataSourceHandle instanceof ScriptDataSourceHandle) {
     if (dataSourceHandle.getProperty(DataUIConstants.SCRIPT_TYPE) != null
         && dataSourceHandle
             .getProperty(DataUIConstants.SCRIPT_TYPE)
             .equals(DataUIConstants.CASSANDRA_DATA_SOURCE_VALUE)) {
       return CASSANDRA_DATASOURCE_NAME;
     } else return SCRIPT_DATASOURCE_NAME;
   }
   return null;
 }
Exemple #2
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);
 }
Exemple #3
0
  protected boolean isLeafMatch(Viewer viewer, Object element) {

    String text;
    if (element instanceof DataSourceType) {
      return false;
    } else if (element instanceof DataSourceHandle) {
      DataSourceHandle node = (DataSourceHandle) element;
      text = node.getName();

      if (wordMatches(text)) {
        return true;
      }
    }
    return false;
  }
 DataSetAdapter(DataSourceHandle defaultDataSource) {
   super();
   if (defaultDataSource != null) {
     defaultDataSourceName = defaultDataSource.getName();
     isLinkedParameter = true;
   }
 }
  /**
   * 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());
  }