Package org.teiid.metadata

Examples of org.teiid.metadata.Datatype


  }

  private TransformationMetadata exampleTransformationMetadata()
      throws TranslatorException {
    Map<String, Datatype> datatypes = new HashMap<String, Datatype>();
        datatypes.put(DataTypeManager.DefaultDataTypes.STRING, new Datatype());
    MetadataFactory mf = new MetadataFactory("x", datatypes, new Properties()); //$NON-NLS-1$
    mf.addProcedure("y"); //$NON-NLS-1$
   
    Table t = mf.addTable("foo");
    mf.addColumn("col", DataTypeManager.DefaultDataTypes.STRING, t);
View Full Code Here


    return model;
  }
 
  @Test public void testAmbiguousTableWithPrivateModel() throws Exception {
    Map<String, Datatype> datatypes = new HashMap<String, Datatype>();
        datatypes.put(DataTypeManager.DefaultDataTypes.STRING, new Datatype());
    MetadataFactory mf = new MetadataFactory("x", datatypes, new Properties()); //$NON-NLS-1$
    mf.addTable("y"); //$NON-NLS-1$
    MetadataFactory mf1 = new MetadataFactory("x1", datatypes, new Properties()); //$NON-NLS-1$
    mf1.addTable("y"); //$NON-NLS-1$
    CompositeMetadataStore cms = new CompositeMetadataStore(Arrays.asList(mf.getMetadataStore(), mf1.getMetadataStore()));
View Full Code Here

    /**
     * @see org.teiid.query.metadata.QueryMetadataInterface#getModeledBaseType(java.lang.Object)
     * @since 5.0
     */
    public String getModeledBaseType(final Object elementID) throws TeiidComponentException, QueryMetadataException {
        Datatype record = getDatatypeRecord(elementID);
        if (record != null) {
            return record.getBasetypeID();
        }
        return null;
    }
View Full Code Here

    /**
     * @see org.teiid.query.metadata.QueryMetadataInterface#getModeledPrimitiveType(java.lang.Object)
     * @since 5.0
     */
    public String getModeledPrimitiveType(final Object elementID) throws TeiidComponentException, QueryMetadataException {
        Datatype record = getDatatypeRecord(elementID);
        if (record != null) {
            return record.getPrimitiveTypeID();
        }
        return null;
    }
View Full Code Here

     * Create a DatatypeRecord instance from the specified index record
     */
    public Datatype createDatatypeRecord(final char[] record) {
        final String str = new String(record);
        final List<String> tokens = getStrings(str, IndexConstants.RECORD_STRING.RECORD_DELIMITER);
        final Datatype dt = new Datatype();

        // Extract the index version information from the record
        int indexVersion = getIndexVersion(record);
       
        // The tokens are the standard header values
        int tokenIndex = 0;

        // Set the record type
        tokenIndex++;

        // Set the datatype and basetype identifiers
        dt.setDatatypeID(getObjectValue(tokens.get(tokenIndex++)));
        dt.setBasetypeID(getObjectValue(tokens.get(tokenIndex++)));

        // Set the fullName/objectID/nameInSource
        String fullName = tokens.get(tokenIndex++);
        int indx = fullName.lastIndexOf(Datatype.URI_REFERENCE_DELIMITER);
        if (indx > -1) {
            fullName = new String(fullName.substring(indx+1));
        } else {
          indx = fullName.lastIndexOf(AbstractMetadataRecord.NAME_DELIM_CHAR);
          if (indx > -1) {
            fullName = new String(fullName.substring(indx+1));
          }
        }
        dt.setName(fullName);
        dt.setUUID(getObjectValue(tokens.get(tokenIndex++)));
        dt.setNameInSource(getObjectValue(tokens.get(tokenIndex++)));
       
        // Set the variety type and its properties
        dt.setVarietyType(Variety.values()[Short.parseShort(tokens.get(tokenIndex++))]);
        tokenIndex++;
       
        // Set the runtime and java class names
        dt.setRuntimeTypeName(getObjectValue(tokens.get(tokenIndex++)));
        dt.setJavaClassName(getObjectValue(tokens.get(tokenIndex++)));
       
        // Set the datatype type
        dt.setType(Datatype.Type.values()[Short.parseShort(tokens.get(tokenIndex++))]);
       
        // Set the search type
        dt.setSearchType(SearchType.values()[3 - Integer.parseInt(tokens.get(tokenIndex++))]);
       
        // Set the null type
        dt.setNullType(NullType.values()[Integer.parseInt(tokens.get(tokenIndex++))]);
        // Set the boolean flags
        char[] booleanValues = (tokens.get(tokenIndex++)).toCharArray();
        dt.setSigned(getBooleanValue(booleanValues[0]));
        dt.setAutoIncrement(getBooleanValue(booleanValues[1]));
        dt.setCaseSensitive(getBooleanValue(booleanValues[2]));
       
        // Append the length
        dt.setLength( Integer.parseInt(tokens.get(tokenIndex++)) );
       
        // Append the precision length
        dt.setPrecisionLength( Integer.parseInt(tokens.get(tokenIndex++)) );
       
        // Append the scale
        dt.setScale( Integer.parseInt(tokens.get(tokenIndex++)) );
       
        // Append the radix
        dt.setRadix( Integer.parseInt(tokens.get(tokenIndex++)) );

        // Set the primitive type identifier
        if (includePrimitiveTypeIdValue(indexVersion)) {
            // The next token is the primitive type identifier
            dt.setPrimitiveTypeID(getObjectValue(tokens.get(tokenIndex++)));
        }

    // The next tokens are footer values
    setRecordFooterValues(dt, tokens, tokenIndex);      
       
View Full Code Here

    /**
     * @see org.teiid.query.metadata.QueryMetadataInterface#getModeledType(java.lang.Object)
     * @since 5.0
     */
    public String getModeledType(final Object elementID) throws TeiidComponentException, QueryMetadataException {
        Datatype record = getDatatypeRecord(elementID);
        if (record != null) {
            return record.getDatatypeID();
        }
        return null;
    }
View Full Code Here

        break;
      case PROCEDUREPARAMS:
        for (Schema schema : getVisibleSchemas(vdb, metadata)) {
          for (Procedure proc : schema.getProcedures().values()) {
            for (ProcedureParameter param : proc.getParameters()) {
              Datatype dt = param.getDatatype();
              rows.add(Arrays.asList(vdbName, proc.getParent().getName(), proc.getName(), param.getName(), dt!=null?dt.getRuntimeTypeName():null, param.getPosition(), param.getType().toString(), param.isOptional(),
                  param.getPrecision(), param.getLength(), param.getScale(), param.getRadix(), param.getNullType().toString(), param.getUUID(), param.getAnnotation(), oid++));
            }
            if (proc.getResultSet() != null) {
              for (Column param : proc.getResultSet().getColumns()) {
                Datatype dt = param.getDatatype();
                rows.add(Arrays.asList(vdbName, proc.getParent().getName(), proc.getName(), param.getName(), dt!=null?dt.getRuntimeTypeName():null, param.getPosition(), "ResultSet", false, //$NON-NLS-1$
                    param.getPrecision(), param.getLength(), param.getScale(), param.getRadix(), param.getNullType().toString(), param.getUUID(), param.getAnnotation(), oid++));
              }
            }
          }
        }
        break;
      case PROPERTIES: //TODO: consider storing separately in the metadatastore
        Collection<AbstractMetadataRecord> records = getAllPropertiedObjects(metadata, getVisibleSchemas(vdb, metadata));
        for (AbstractMetadataRecord record : records) {
          for (Map.Entry<String, String> entry : record.getProperties().entrySet()) {
            String value = entry.getValue();
            Clob clobValue = null;
            if (value != null) {
              try {
                clobValue = new ClobType(new SerialClob(value.toCharArray()));
              } catch (SQLException e) {
                throw new TeiidProcessingException(e);
              }
            }
            rows.add(Arrays.asList(entry.getKey(), entry.getValue(), record.getUUID(), oid++, clobValue));
          }
        }
        break;
      default:
        for (Schema schema : getVisibleSchemas(vdb, metadata)) {
          for (Table table : schema.getTables().values()) {
            switch (sysTable) {
            case TABLES:
              rows.add(Arrays.asList(vdbName, schema.getName(), table.getName(), table.getTableType().toString(), table.getNameInSource(),
                  table.isPhysical(), table.supportsUpdate(), table.getUUID(), table.getCardinality(), table.getAnnotation(), table.isSystem(), table.isMaterialized(), oid++));
              break;
            case COLUMNS:
              for (Column column : table.getColumns()) {
                Datatype dt = column.getDatatype();
                rows.add(Arrays.asList(vdbName, schema.getName(), table.getName(), column.getName(), column.getPosition(), column.getNameInSource(),
                    dt!=null?dt.getRuntimeTypeName():null, column.getScale(), column.getLength(), column.isFixedLength(), column.isSelectable(), column.isUpdatable(),
                    column.isCaseSensitive(), column.isSigned(), column.isCurrency(), column.isAutoIncremented(), column.getNullType().toString(), column.getMinimumValue(),
                    column.getMaximumValue(), column.getDistinctValues(), column.getNullValues(), column.getSearchType().toString(), column.getFormat(),
                    column.getDefaultValue(), dt!=null?dt.getJavaClassName():null, column.getPrecision(),
                    column.getCharOctetLength(), column.getRadix(), column.getUUID(), column.getAnnotation(), oid++));
              }
              break;
            case KEYS:
              for (KeyRecord key : table.getAllKeys()) {
View Full Code Here

TOP

Related Classes of org.teiid.metadata.Datatype

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.