Exemplo n.º 1
0
  /**
   * @param meta
   * @throws BirtException
   */
  private void addResultSetColumn(DataSetHandle dataSetHandle, IResultMetaData meta)
      throws BirtException {
    if (meta == null || !(dataSetHandle instanceof OdaDataSetHandle)) return;

    Set computedColumnNameSet = new HashSet();
    Iterator computedIter = dataSetHandle.computedColumnsIterator();
    while (computedIter.hasNext()) {
      ComputedColumnHandle handle = (ComputedColumnHandle) computedIter.next();
      computedColumnNameSet.add(handle.getName());
    }

    HashSet orgColumnNameSet = new HashSet();
    HashSet uniqueColumnNameSet = new HashSet();

    PropertyHandle handle = dataSetHandle.getPropertyHandle(DataSetHandle.RESULT_SET_PROP);
    for (int i = 1; i <= meta.getColumnCount(); i++) {
      OdaResultSetColumn rsColumn = new OdaResultSetColumn();

      String uniqueName;

      if (!computedColumnNameSet.contains(meta.getColumnName(i))) {
        uniqueName =
            MetaDataPopulator.getUniqueName(
                orgColumnNameSet, uniqueColumnNameSet, meta.getColumnName(i), i - 1);
        rsColumn.setColumnName(uniqueName);
        if (meta.getColumnType(i) != DataType.ANY_TYPE)
          rsColumn.setDataType(DataAdapterUtil.adapterToModelDataType(meta.getColumnType(i)));
        rsColumn.setNativeName(meta.getColumnName(i));
        rsColumn.setPosition(Integer.valueOf(i));

        handle.addItem(rsColumn);
        uniqueColumnNameSet.add(uniqueName);
      }
    }
  }
Exemplo n.º 2
0
  /**
   * clear unused column hints
   *
   * @throws BirtException
   */
  private final void clearUnusedColumnHints(DataSetHandle dataSetHandle, IResultMetaData metaData)
      throws BirtException {

    PropertyHandle handle = dataSetHandle.getPropertyHandle(DataSetHandle.COLUMN_HINTS_PROP);
    if (handle != null && handle.getListValue() != null) {
      ArrayList list = handle.getListValue();
      int count = list.size();
      for (int n = count - 1; n >= 0; n--) {
        ColumnHint hint = (ColumnHint) list.get(n);
        String columnName =
            (String) hint.getProperty(handle.getModule(), ColumnHint.COLUMN_NAME_MEMBER);
        String alias = (String) hint.getProperty(handle.getModule(), ColumnHint.ALIAS_MEMBER);
        boolean found = false;
        if (!isEmpty(hint, handle.getModule().getModuleHandle())) {
          for (int m = 0; m < metaData.getColumnCount() && !found; m++) {
            String name = metaData.getColumnName(m + 1);
            if (name != null && (name.equals(columnName)) || name.equals(alias)) {
              found = true;
              break;
            }
          }
          if (!found) {
            try {
              // remove the item
              handle.removeItem(hint);
            } catch (PropertyValueException e) {
            }
          }
        }
      }
    }
  }
Exemplo n.º 3
0
  /**
   * 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();
  }
Exemplo n.º 4
0
 /**
  * Removes the filter condition.
  *
  * @param fc the filter condition structure
  * @throws SemanticException if the given condition doesn't exist in the filters
  */
 public void removeFilter(FilterCondition fc) throws SemanticException {
   PropertyHandle propHandle = getPropertyHandle(FILTER_PROP);
   propHandle.removeItem(fc);
 }
Exemplo n.º 5
0
 /**
  * Returns an iterator for the filter list defined on this cube. Each object returned is of type
  * <code>StructureHandle</code>.
  *
  * @return the iterator for <code>FilterCond</code> structure list defined on this cube.
  */
 public Iterator filtersIterator() {
   PropertyHandle propHandle = getPropertyHandle(FILTER_PROP);
   assert propHandle != null;
   return propHandle.iterator();
 }