コード例 #1
0
ファイル: DDLStringVisitor.java プロジェクト: teiid/teiid
  private void appendColumnOptions(BaseColumn column) {
    StringBuilder options = new StringBuilder();
    addCommonOptions(options, column);

    if (!column.getDatatype().isBuiltin()) {
      addOption(
          options,
          UDT,
          column.getDatatype().getName()
              + "("
              + column.getLength()
              + ", "
              + column.getPrecision()
              + ", "
              + column.getScale()
              + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    }

    if (column.getDatatype().getRadix() != 0
        && column.getRadix() != column.getDatatype().getRadix()) {
      addOption(options, RADIX, column.getRadix());
    }

    buildColumnOptions(column, options);

    if (options.length() != 0) {
      append(SPACE).append(OPTIONS).append(SPACE).append(LPAREN).append(options).append(RPAREN);
    }
  }
コード例 #2
0
ファイル: DDLStringVisitor.java プロジェクト: teiid/teiid
  private String buildFunctionOptions(FunctionMethod function) {
    StringBuilder options = new StringBuilder();
    addCommonOptions(options, function);

    if (function.getCategory() != null) {
      addOption(options, CATEGORY, function.getCategory());
    }

    if (!function.getDeterminism().equals(Determinism.DETERMINISTIC)) {
      addOption(options, DETERMINISM, function.getDeterminism().name());
    }

    if (function.getInvocationClass() != null) {
      addOption(options, JAVA_CLASS, function.getInvocationClass());
    }

    if (function.getInvocationMethod() != null) {
      addOption(options, JAVA_METHOD, function.getInvocationMethod());
    }

    if (!function.getProperties().isEmpty()) {
      for (String key : function.getProperties().keySet()) {
        addOption(options, key, function.getProperty(key, false));
      }
    }

    return options.toString();
  }
コード例 #3
0
ファイル: DDLStringVisitor.java プロジェクト: teiid/teiid
 private void addCommonOptions(StringBuilder sb, AbstractMetadataRecord record) {
   if (record.isUUIDSet()
       && record.getUUID() != null
       && !record.getUUID().startsWith("tid:")) { // $NON-NLS-1$
     addOption(sb, UUID, record.getUUID());
   }
   if (record.getAnnotation() != null) {
     addOption(sb, ANNOTATION, record.getAnnotation());
   }
   if (record.getNameInSource() != null) {
     addOption(sb, NAMEINSOURCE, record.getNameInSource());
   }
 }
コード例 #4
0
ファイル: DDLStringVisitor.java プロジェクト: teiid/teiid
  private String buildProcedureOptions(Procedure procedure) {
    StringBuilder options = new StringBuilder();
    addCommonOptions(options, procedure);

    if (procedure.getUpdateCount() != Procedure.AUTO_UPDATECOUNT) {
      addOption(options, UPDATECOUNT, procedure.getUpdateCount());
    }

    if (!procedure.getProperties().isEmpty()) {
      for (String key : procedure.getProperties().keySet()) {
        addOption(options, key, procedure.getProperty(key, false));
      }
    }

    return options.toString();
  }
コード例 #5
0
ファイル: DDLStringVisitor.java プロジェクト: teiid/teiid
 private void buildOptions(AbstractMetadataRecord record, StringBuilder options) {
   if (!record.getProperties().isEmpty()) {
     for (Map.Entry<String, String> entry : record.getProperties().entrySet()) {
       addOption(options, entry.getKey(), entry.getValue());
     }
   }
 }
コード例 #6
0
ファイル: DDLStringVisitor.java プロジェクト: teiid/teiid
  private String buildTableOptions(Table table) {
    StringBuilder options = new StringBuilder();
    addCommonOptions(options, table);

    if (table.isMaterialized()) {
      addOption(options, MATERIALIZED, table.isMaterialized());
      if (table.getMaterializedTable() != null) {
        addOption(options, MATERIALIZED_TABLE, table.getMaterializedTable().getName());
      }
    }
    if (table.supportsUpdate()) {
      addOption(options, UPDATABLE, table.supportsUpdate());
    }
    if (table.getCardinality() != -1) {
      if (table.getCardinality() != table.getCardinalityAsFloat()) {
        addOption(options, CARDINALITY, (long) table.getCardinalityAsFloat());
      } else {
        addOption(options, CARDINALITY, table.getCardinality());
      }
    }
    if (!table.getProperties().isEmpty()) {
      for (String key : table.getProperties().keySet()) {
        addOption(options, key, table.getProperty(key, false));
      }
    }
    return options.toString();
  }
コード例 #7
0
ファイル: DDLStringVisitor.java プロジェクト: teiid/teiid
  private void buildColumnOptions(BaseColumn baseColumn, StringBuilder options) {
    if (baseColumn instanceof Column) {
      Column column = (Column) baseColumn;
      if (!column.isSelectable()) {
        addOption(options, SELECTABLE, column.isSelectable());
      }

      // if table is already updatable, then columns are implicitly updatable.
      if (!column.isUpdatable()
          && column.getParent() instanceof Table
          && ((Table) column.getParent()).supportsUpdate()) {
        addOption(options, UPDATABLE, column.isUpdatable());
      }

      if (column.isCurrency()) {
        addOption(options, CURRENCY, column.isCurrency());
      }

      // only record if not default
      if (!column.isCaseSensitive() && column.getDatatype().isCaseSensitive()) {
        addOption(options, CASE_SENSITIVE, column.isCaseSensitive());
      }

      if (!column.isSigned() && column.getDatatype().isSigned()) {
        addOption(options, SIGNED, column.isSigned());
      }
      if (column.isFixedLength()) {
        addOption(options, FIXED_LENGTH, column.isFixedLength());
      }
      // length and octet length should be same. so this should be never be true.
      // TODO - this is not quite valid since we are dealing with length representing chars in
      // UTF-16, then there should be twice the bytes
      if (column.getCharOctetLength() != 0 && column.getLength() != column.getCharOctetLength()) {
        addOption(options, CHAR_OCTET_LENGTH, column.getCharOctetLength());
      }

      // by default the search type is default data type search, so avoid it.
      if (column.getSearchType() != null
          && (!column.getSearchType().equals(column.getDatatype().getSearchType())
              || column.isSearchTypeSet())) {
        addOption(options, SEARCHABLE, column.getSearchType().name());
      }

      if (column.getMinimumValue() != null) {
        addOption(options, MIN_VALUE, column.getMinimumValue());
      }

      if (column.getMaximumValue() != null) {
        addOption(options, MAX_VALUE, column.getMaximumValue());
      }

      if (column.getNullValues() != -1) {
        addOption(options, NULL_VALUE_COUNT, column.getNullValues());
      }

      if (column.getDistinctValues() != -1) {
        addOption(options, DISTINCT_VALUES, column.getDistinctValues());
      }
    }

    if (baseColumn.getNativeType() != null) {
      addOption(options, NATIVE_TYPE, baseColumn.getNativeType());
    }

    buildOptions(baseColumn, options);
  }