Package org.teiid.metadata
Class MetadataFactory
- java.lang.Object
-
- org.teiid.metadata.NamespaceContainer
-
- org.teiid.metadata.MetadataFactory
-
- All Implemented Interfaces:
Serializable
public class MetadataFactory extends NamespaceContainer
Allows connectors to build metadata for use by the engine. TODO: add support for datatype import TODO: add support for unique constraints- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected intcount-
Fields inherited from class org.teiid.metadata.NamespaceContainer
ACCUMULO_PREFIX, COUCHBASE_PREFIX, EXCEL_PREFIX, HBASE_PREFIX, INFINISPAN_PREFIX, JPA_PREFIX, LDAP_PREFIX, MONGO_PREFIX, ODATA_PREFIX, PI_PREFIX, RELATIONAL_PREFIX, REST_PREFIX, SF_PREFIX, SPATIAL_PREFIX, WS_PREFIX
-
-
Constructor Summary
Constructors Constructor Description MetadataFactory()MetadataFactory(String vdbName, Object vdbVersion, String schemaName, Map<String,Datatype> runtimeTypes, Properties modelProperties, String rawMetadata)MetadataFactory(String vdbName, Object vdbVersion, Map<String,Datatype> runtimeTypes, ModelMetaData model)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description KeyRecordaddAccessPattern(String name, List<String> columnNames, Table table)Adds an access pattern to the given table.ColumnaddColumn(String name, String type, ColumnSet<?> table)Adds a column to the table with the given name and type.voidaddColumnPermission(String role, Column resource, Boolean allowCreate, Boolean allowRead, Boolean allowUpdate, String mask, Integer order)Add a permission for aColumnvoidaddColumnPermission(String role, Column resource, Boolean allowCreate, Boolean allowRead, Boolean allowUpdate, String condition, String mask, Integer order)Deprecated.ForeignKeyaddForeignKey(String name, List<String> columnNames, String referenceTable, Table table)Adds a foreign key to the given table.ForeignKeyaddForeignKey(String name, List<String> columnNames, List<String> referencedColumnNames, String referenceTable, Table table)Adds a foreign key to the given table.ForeignKeyaddForiegnKey(String name, List<String> columnNames, String referenceTable, Table table)Deprecated.ForeignKeyaddForiegnKey(String name, List<String> columnNames, List<String> referencedColumnNames, String referenceTable, Table table)Deprecated.FunctionMethodaddFunction(String name)Add a function with the given name to the model.FunctionMethodaddFunction(String name, Method method)Adds a non-pushdown function based upon the givenMethod.FunctionMethodaddFunction(String name, String returnType, String... paramTypes)Add a function with the given name to the model.voidaddFunction(FunctionMethod functionMethod)KeyRecordaddFunctionBasedIndex(String name, List<String> expressions, List<Boolean> nonColumnExpressions, Table table)Adds a function based index on the given expressions.KeyRecordaddIndex(String name, boolean nonUnique, List<String> columnNames, Table table)Adds an index to the given table.voidaddPermission(String role, AbstractMetadataRecord resource, Boolean allowAlter, Boolean allowCreate, Boolean allowRead, Boolean allowUpdate, Boolean allowDelete, Boolean allowExecute)voidaddPermission(String role, AbstractMetadataRecord resource, Boolean allowAlter, Boolean allowCreate, Boolean allowRead, Boolean allowUpdate, Boolean allowDelete, Boolean allowExecute, String condition, Boolean constraint)Deprecated.voidaddPolicy(String role, String policyName, AbstractMetadataRecord resource, String condition, Policy.Operation... operations)KeyRecordaddPrimaryKey(String name, List<String> columnNames, Table table)Adds a primary key to the given table.ProcedureaddProcedure(String name)Add a procedure with the given name to the model.ProcedureParameteraddProcedureParameter(String name, String type, ProcedureParameter.Type parameterType, Procedure procedure)Add a procedure parameter.ColumnaddProcedureResultSetColumn(String name, String type, Procedure procedure)Add a procedure resultset column to the given procedure.voidaddSchemaPermission(String role, Boolean allowAlter, Boolean allowCreate, Boolean allowRead, Boolean allowUpdate, Boolean allowDelete, Boolean allowExecute)Add a permission for the currentSchemawhich will typically act as a default for all child objects.TableaddTable(String name)Add a table with the given name to the model.MetadataStoreasMetadataStore()voidcorrectDatatypes(Map<String,Datatype> dt)To be called if the MetadataFactory is deserialized to set the canonical system type value.static FunctionMethodcreateFunctionFromMethod(String name, Method method)Map<String,Datatype>getDataTypes()get runtime types keyed by runtime name, which is a type name known to the Teiid enginePropertiesgetImportProperties()Deprecated.ModelgetModel()PropertiesgetModelProperties()StringgetName()StringgetNameFormat()ParsergetParser()StringgetRawMetadata()Deprecated.SchemagetSchema()ClassLoadergetVDBClassLoader()StringgetVdbName()Map<String,? extends VDBResource>getVDBResources()StringgetVdbVersion()static Stringhex(long val, int hexLength)booleanisAutoCorrectColumnNames()booleanisImportPushdownFunctions()booleanisRenameAllDuplicates()booleanisRenameDuplicateColumns()booleanisRenameDuplicateTables()voidmergeInto(MetadataStore store)voidparse(Reader ddl)Parses, but does not close, the givenReaderinto thisMetadataFactoryColumnrenameColumn(String oldName, String name, ColumnSet<?> table)ProcedureParameterrenameParameter(String oldName, String name, Procedure procedure)voidsetAutoCorrectColumnNames(boolean autoCorrectColumnNames)Set to false to disable correcting column and other names to be valid Teiid names.static DatatypesetDataType(String type, BaseColumn column, Map<String,Datatype> dataTypes, boolean allowNull)voidsetImportPushdownFunctions(boolean importPushdownFunctions)voidsetModel(ModelMetaData model)voidsetNameFormat(String nameFormat)voidsetParser(Parser parser)voidsetRenameAllDuplicates(boolean renameAllDuplicates)voidsetRenameDuplicateColumns(boolean renameDuplicateColumns)voidsetRenameDuplicateTables(boolean renameDuplicateTables)voidsetSchema(Schema schema)Set theSchemato a different instance.protected voidsetUUID(AbstractMetadataRecord record)voidsetVDBClassLoader(ClassLoader classLoader)voidsetVdbResources(Map<String,? extends VDBResource> vdbResources)-
Methods inherited from class org.teiid.metadata.NamespaceContainer
addNamespace, getLegacyKey, resolvePropertyKey
-
-
-
-
Method Detail
-
hex
public static String hex(long val, int hexLength)
-
getImportProperties
@Deprecated public Properties getImportProperties()
Deprecated.- Returns:
- See Also:
getModelProperties()
-
getModelProperties
public Properties getModelProperties()
-
getRawMetadata
@Deprecated public String getRawMetadata()
Deprecated.Get the metadata text for the first metadata element- Returns:
-
getModel
public Model getModel()
-
setUUID
protected void setUUID(AbstractMetadataRecord record)
-
getName
public String getName()
-
getSchema
public Schema getSchema()
-
addTable
public Table addTable(String name)
Add a table with the given name to the model.- Parameters:
name-- Returns:
- Throws:
MetadataException
-
addColumn
public Column addColumn(String name, String type, ColumnSet<?> table)
Adds a column to the table with the given name and type.- Parameters:
name-type- should be one ofTypeFacility.RUNTIME_NAMEStable-- Returns:
- Throws:
MetadataException
-
renameParameter
public ProcedureParameter renameParameter(String oldName, String name, Procedure procedure)
-
setDataType
public static Datatype setDataType(String type, BaseColumn column, Map<String,Datatype> dataTypes, boolean allowNull)
-
addPrimaryKey
public KeyRecord addPrimaryKey(String name, List<String> columnNames, Table table)
Adds a primary key to the given table. The column names should be in key order.- Parameters:
name-columnNames-table-- Returns:
- Throws:
MetadataException
-
addAccessPattern
public KeyRecord addAccessPattern(String name, List<String> columnNames, Table table)
Adds an access pattern to the given table.- Parameters:
name-columnNames-table-- Returns:
- Throws:
MetadataException
-
addIndex
public KeyRecord addIndex(String name, boolean nonUnique, List<String> columnNames, Table table)
Adds an index to the given table.- Parameters:
name-nonUnique- true indicates that an index is being added.columnNames-table-- Returns:
- Throws:
MetadataException
-
addFunctionBasedIndex
public KeyRecord addFunctionBasedIndex(String name, List<String> expressions, List<Boolean> nonColumnExpressions, Table table)
Adds a function based index on the given expressions.- Parameters:
name-expressions-nonColumnExpressions- a Boolean list indicating when expressions are non-column expressionstable-- Returns:
- Throws:
MetadataException
-
addForeignKey
public ForeignKey addForeignKey(String name, List<String> columnNames, String referenceTable, Table table)
Adds a foreign key to the given table. The referenced primary key must already exist. The column names should be in key order.- Parameters:
name-columnNames-referenceTable- - schema qualified reference table nametable-- Returns:
- Throws:
MetadataException
-
addForiegnKey
@Deprecated public ForeignKey addForiegnKey(String name, List<String> columnNames, String referenceTable, Table table)
Deprecated.
-
addForeignKey
public ForeignKey addForeignKey(String name, List<String> columnNames, List<String> referencedColumnNames, String referenceTable, Table table)
Adds a foreign key to the given table. The referenced key may be automatically created if addUniqueConstraint is true. The column names should be in key order. if reference table is is another schema, they will be resolved during validation.- Parameters:
name-columnNames-referencedColumnNames- may be null to indicate that the primary key should be used.referenceTable- - schema qualified reference table name, can be from another schematable-- Returns:
- Throws:
MetadataException
-
addForiegnKey
@Deprecated public ForeignKey addForiegnKey(String name, List<String> columnNames, List<String> referencedColumnNames, String referenceTable, Table table)
Deprecated.
-
addProcedure
public Procedure addProcedure(String name)
Add a procedure with the given name to the model.- Parameters:
name-- Returns:
- Throws:
MetadataException
-
addProcedureParameter
public ProcedureParameter addProcedureParameter(String name, String type, ProcedureParameter.Type parameterType, Procedure procedure)
Add a procedure parameter.- Parameters:
name-type- should be one ofTypeFacility.RUNTIME_NAMESparameterType- should be one ofProcedureParameter.Typeprocedure-- Returns:
- Throws:
MetadataException
-
addProcedureResultSetColumn
public Column addProcedureResultSetColumn(String name, String type, Procedure procedure)
Add a procedure resultset column to the given procedure.- Parameters:
name-type- should be one ofTypeFacility.RUNTIME_NAMESprocedure-- Returns:
- Throws:
MetadataException
-
addFunction
public FunctionMethod addFunction(String name)
Add a function with the given name to the model.- Parameters:
name-- Returns:
- Throws:
MetadataException
-
addFunction
public FunctionMethod addFunction(String name, String returnType, String... paramTypes)
Add a function with the given name to the model.- Parameters:
name-- Returns:
- Throws:
MetadataException
-
addFunction
public FunctionMethod addFunction(String name, Method method)
Adds a non-pushdown function based upon the givenMethod.- Parameters:
name-method-- Returns:
- Throws:
MetadataException
-
createFunctionFromMethod
public static FunctionMethod createFunctionFromMethod(String name, Method method)
-
setAutoCorrectColumnNames
public void setAutoCorrectColumnNames(boolean autoCorrectColumnNames)
Set to false to disable correcting column and other names to be valid Teiid names.- Parameters:
autoCorrectColumnNames-
-
mergeInto
public void mergeInto(MetadataStore store)
-
asMetadataStore
public MetadataStore asMetadataStore()
-
setSchema
public void setSchema(Schema schema)
Set theSchemato a different instance. This is typically called in special situations where theMetadataFactorylogic is not used to construct theSchema.- Parameters:
schema-
-
getDataTypes
public Map<String,Datatype> getDataTypes()
get runtime types keyed by runtime name, which is a type name known to the Teiid engine- Returns:
-
correctDatatypes
public void correctDatatypes(Map<String,Datatype> dt)
To be called if the MetadataFactory is deserialized to set the canonical system type value.- Parameters:
dt-
-
getVdbName
public String getVdbName()
-
getVdbVersion
public String getVdbVersion()
-
parse
public void parse(Reader ddl) throws MetadataException
Parses, but does not close, the givenReaderinto thisMetadataFactory- Parameters:
ddl-- Throws:
MetadataException
-
setParser
public void setParser(Parser parser)
-
setModel
public void setModel(ModelMetaData model)
-
getParser
public Parser getParser()
-
getVDBResources
public Map<String,? extends VDBResource> getVDBResources()
-
setVdbResources
public void setVdbResources(Map<String,? extends VDBResource> vdbResources)
-
addPermission
@Deprecated public void addPermission(String role, AbstractMetadataRecord resource, Boolean allowAlter, Boolean allowCreate, Boolean allowRead, Boolean allowUpdate, Boolean allowDelete, Boolean allowExecute, String condition, Boolean constraint)
Deprecated.- Parameters:
role-resource-allowAlter-allowCreate-allowRead-allowUpdate-allowDelete-allowExecute-condition-constraint-
-
addPermission
public void addPermission(String role, AbstractMetadataRecord resource, Boolean allowAlter, Boolean allowCreate, Boolean allowRead, Boolean allowUpdate, Boolean allowDelete, Boolean allowExecute)
- Parameters:
role-resource-allowAlter-allowCreate-allowRead-allowUpdate-allowDelete-allowExecute-
-
addSchemaPermission
public void addSchemaPermission(String role, Boolean allowAlter, Boolean allowCreate, Boolean allowRead, Boolean allowUpdate, Boolean allowDelete, Boolean allowExecute)
Add a permission for the currentSchemawhich will typically act as a default for all child objects.- Parameters:
role-allowAlter-allowCreate-allowRead-allowUpdate-allowDelete-allowExecute-
-
addColumnPermission
@Deprecated public void addColumnPermission(String role, Column resource, Boolean allowCreate, Boolean allowRead, Boolean allowUpdate, String condition, String mask, Integer order)
Deprecated.Add a permission for aColumn- Parameters:
role-resource-allowCreate-allowRead-allowUpdate-condition- must be nullmask-order-
-
addColumnPermission
public void addColumnPermission(String role, Column resource, Boolean allowCreate, Boolean allowRead, Boolean allowUpdate, String mask, Integer order)
Add a permission for aColumn- Parameters:
role-resource-allowCreate-allowRead-allowUpdate-mask-order-
-
addPolicy
public void addPolicy(String role, String policyName, AbstractMetadataRecord resource, String condition, Policy.Operation... operations)
- Parameters:
role-resource-condition-operations-
-
addFunction
public void addFunction(FunctionMethod functionMethod)
-
isAutoCorrectColumnNames
@TranslatorProperty(display="Auto-correct Column Names", category=IMPORT, description="If true replace the . character with _ in the Teiid column name, otherwise an exception will be raised.") public boolean isAutoCorrectColumnNames()
-
isRenameAllDuplicates
@TranslatorProperty(display="Rename All Duplicate Names", category=IMPORT, description="Provide a unique Teiid name for all duplicate names (typically due to Teiid\'s case insensitivity).") public boolean isRenameAllDuplicates()
-
isRenameDuplicateColumns
@TranslatorProperty(display="Rename Duplicate Columns", category=IMPORT, description="Provide a unique Teiid name for duplicate column names (typically due to Teiid\'s case insensitivity).") public boolean isRenameDuplicateColumns()
-
isRenameDuplicateTables
@TranslatorProperty(display="Rename Duplicate Tables", category=IMPORT, description="Provide a unique Teiid name for duplicate table names (typically due to Teiid\'s case insensitivity).") public boolean isRenameDuplicateTables()
-
setRenameAllDuplicates
public void setRenameAllDuplicates(boolean renameAllDuplicates)
-
setRenameDuplicateColumns
public void setRenameDuplicateColumns(boolean renameDuplicateColumns)
-
setRenameDuplicateTables
public void setRenameDuplicateTables(boolean renameDuplicateTables)
-
getNameFormat
@TranslatorProperty(display="Name Format", category=IMPORT, description="The Java String Format to manipulate table and procedure names.") public String getNameFormat()
-
setNameFormat
public void setNameFormat(String nameFormat)
-
isImportPushdownFunctions
@TranslatorProperty(display="Import Pushdown Functions", category=IMPORT, description="Expose translator pushdown functions on the source model, so that the functions are known to design environments.") public boolean isImportPushdownFunctions()
-
setImportPushdownFunctions
public void setImportPushdownFunctions(boolean importPushdownFunctions)
-
setVDBClassLoader
public void setVDBClassLoader(ClassLoader classLoader)
-
getVDBClassLoader
public ClassLoader getVDBClassLoader()
-
-