Package org.teiid.metadata
Class MetadataFactory
- java.lang.Object
-
- org.teiid.metadata.NamespaceContainer
-
- org.teiid.metadata.MetadataFactory
-
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
PgCatalogMetadataStore
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 int
count
-
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, PARQUET_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 KeyRecord
addAccessPattern(String name, List<String> columnNames, Table table)
Adds an access pattern to the given table.Column
addColumn(String name, String type, ColumnSet<?> table)
Adds a column to the table with the given name and type.void
addColumnPermission(String role, Column resource, Boolean allowCreate, Boolean allowRead, Boolean allowUpdate, String mask, Integer order)
Add a permission for aColumn
void
addColumnPermission(String role, Column resource, Boolean allowCreate, Boolean allowRead, Boolean allowUpdate, String condition, String mask, Integer order)
Deprecated.ForeignKey
addForeignKey(String name, List<String> columnNames, String referenceTable, Table table)
Adds a foreign key to the given table.ForeignKey
addForeignKey(String name, List<String> columnNames, List<String> referencedColumnNames, String referenceTable, Table table)
Adds a foreign key to the given table.ForeignKey
addForiegnKey(String name, List<String> columnNames, String referenceTable, Table table)
Deprecated.ForeignKey
addForiegnKey(String name, List<String> columnNames, List<String> referencedColumnNames, String referenceTable, Table table)
Deprecated.FunctionMethod
addFunction(String name)
Add a function with the given name to the model.FunctionMethod
addFunction(String name, Method method)
Adds a non-pushdown function based upon the givenMethod
.FunctionMethod
addFunction(String name, String returnType, String... paramTypes)
Add a function with the given name to the model.void
addFunction(FunctionMethod functionMethod)
KeyRecord
addFunctionBasedIndex(String name, List<String> expressions, List<Boolean> nonColumnExpressions, Table table)
Adds a function based index on the given expressions.KeyRecord
addIndex(String name, boolean nonUnique, List<String> columnNames, Table table)
Adds an index to the given table.void
addPermission(String role, AbstractMetadataRecord resource, Boolean allowAlter, Boolean allowCreate, Boolean allowRead, Boolean allowUpdate, Boolean allowDelete, Boolean allowExecute)
void
addPermission(String role, AbstractMetadataRecord resource, Boolean allowAlter, Boolean allowCreate, Boolean allowRead, Boolean allowUpdate, Boolean allowDelete, Boolean allowExecute, String condition, Boolean constraint)
Deprecated.void
addPolicy(String role, String policyName, AbstractMetadataRecord resource, String condition, Policy.Operation... operations)
KeyRecord
addPrimaryKey(String name, List<String> columnNames, Table table)
Adds a primary key to the given table.Procedure
addProcedure(String name)
Add a procedure with the given name to the model.ProcedureParameter
addProcedureParameter(String name, String type, ProcedureParameter.Type parameterType, Procedure procedure)
Add a procedure parameter.Column
addProcedureResultSetColumn(String name, String type, Procedure procedure)
Add a procedure resultset column to the given procedure.void
addSchemaPermission(String role, Boolean allowAlter, Boolean allowCreate, Boolean allowRead, Boolean allowUpdate, Boolean allowDelete, Boolean allowExecute)
Add a permission for the currentSchema
which will typically act as a default for all child objects.Table
addTable(String name)
Add a table with the given name to the model.MetadataStore
asMetadataStore()
void
correctDatatypes(Map<String,Datatype> dt)
To be called if the MetadataFactory is deserialized to set the canonical system type value.static FunctionMethod
createFunctionFromMethod(String name, Method method)
Map<String,Datatype>
getDataTypes()
get runtime types keyed by runtime name, which is a type name known to the Teiid engineProperties
getImportProperties()
Deprecated.Model
getModel()
Properties
getModelProperties()
String
getName()
String
getNameFormat()
Parser
getParser()
String
getRawMetadata()
Deprecated.Schema
getSchema()
ClassLoader
getVDBClassLoader()
String
getVdbName()
Map<String,? extends VDBResource>
getVDBResources()
String
getVdbVersion()
static String
hex(long val, int hexLength)
boolean
isAutoCorrectColumnNames()
boolean
isImportPushdownFunctions()
boolean
isRenameAllDuplicates()
boolean
isRenameDuplicateColumns()
boolean
isRenameDuplicateTables()
void
mergeInto(MetadataStore store)
void
parse(Reader ddl)
Parses, but does not close, the givenReader
into thisMetadataFactory
Column
renameColumn(String oldName, String name, ColumnSet<?> table)
ProcedureParameter
renameParameter(String oldName, String name, Procedure procedure)
void
setAutoCorrectColumnNames(boolean autoCorrectColumnNames)
Set to false to disable correcting column and other names to be valid Teiid names.static Datatype
setDataType(String type, BaseColumn column, Map<String,Datatype> dataTypes, boolean allowNull)
void
setImportPushdownFunctions(boolean importPushdownFunctions)
void
setModel(ModelMetaData model)
void
setNameFormat(String nameFormat)
void
setParser(Parser parser)
void
setRenameAllDuplicates(boolean renameAllDuplicates)
void
setRenameDuplicateColumns(boolean renameDuplicateColumns)
void
setRenameDuplicateTables(boolean renameDuplicateTables)
void
setSchema(Schema schema)
Set theSchema
to a different instance.protected void
setUUID(AbstractMetadataRecord record)
void
setVDBClassLoader(ClassLoader classLoader)
void
setVdbResources(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_NAMES
table
-- 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_NAMES
parameterType
- should be one ofProcedureParameter.Type
procedure
-- 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_NAMES
procedure
-- 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 theSchema
to a different instance. This is typically called in special situations where theMetadataFactory
logic 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 givenReader
into 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 currentSchema
which 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()
-
-