Search in sources :

Example 16 with Table

use of org.teiid.metadata.Table in project teiid by teiid.

the class CassandraMetadataProcessor method addTable.

/**
 * Adds table.
 * @param columnFamily
 */
private void addTable(MetadataFactory factory, TableMetadata columnFamily) {
    Table table = factory.addTable(columnFamily.getName());
    addColumnsToTable(factory, table, columnFamily);
    addPrimaryKey(factory, table, columnFamily);
    for (IndexMetadata index : columnFamily.getIndexes()) {
        Column c = table.getColumnByName(index.getTarget());
        if (c != null) {
            c.setSearchType(SearchType.Searchable);
            factory.addIndex(index.getName(), false, Arrays.asList(index.getTarget()), table);
        }
    }
    table.setSupportsUpdate(true);
}
Also used : Table(org.teiid.metadata.Table) Column(org.teiid.metadata.Column) IndexMetadata(com.datastax.driver.core.IndexMetadata)

Example 17 with Table

use of org.teiid.metadata.Table in project teiid by teiid.

the class TestTeiidLanguageToCQL method createFakeMetadata.

private void createFakeMetadata(MetadataFactory factory) {
    Table person = factory.addTable("Person");
    factory.addColumn("id", TypeFacility.RUNTIME_NAMES.INTEGER, person);
    factory.addColumn("name", TypeFacility.RUNTIME_NAMES.STRING, person);
    factory.addColumn("age", TypeFacility.RUNTIME_NAMES.INTEGER, person);
    factory.addColumn("bday", TypeFacility.RUNTIME_NAMES.TIMESTAMP, person);
    factory.addColumn("employed", TypeFacility.RUNTIME_NAMES.BOOLEAN, person);
    factory.addColumn("custom", TypeFacility.RUNTIME_NAMES.VARBINARY, person);
    factory.addColumn("custom1", TypeFacility.RUNTIME_NAMES.BLOB, person);
    Properties pros = factory.getModelProperties();
    for (Object key : pros.keySet()) {
        person.setProperty(key.toString(), pros.getProperty(key.toString()));
    }
}
Also used : Table(org.teiid.metadata.Table) Properties(java.util.Properties)

Example 18 with Table

use of org.teiid.metadata.Table in project teiid by teiid.

the class CompositeMetadataStore method assignOids.

private void assignOids(Schema schema, TreeMap<String, RecordHolder> map) {
    addOid(schema, map);
    for (Table table : schema.getTables().values()) {
        addOid(table, map);
        addOids(table.getColumns(), map);
        addOids(table.getAllKeys(), map);
    }
    for (Procedure proc : schema.getProcedures().values()) {
        addOid(proc, map);
        addOids(proc.getParameters(), map);
        if (proc.getResultSet() != null) {
            addOids(proc.getResultSet().getColumns(), map);
        }
    }
    for (FunctionMethod func : schema.getFunctions().values()) {
        addOid(func, map);
        addOids(func.getInputParameters(), map);
        addOid(func.getOutputParameter(), map);
    }
}
Also used : Table(org.teiid.metadata.Table) Procedure(org.teiid.metadata.Procedure) FunctionMethod(org.teiid.metadata.FunctionMethod)

Example 19 with Table

use of org.teiid.metadata.Table in project teiid by teiid.

the class CompositeMetadataStore method getXMLTempGroups.

/*
	 * The next method is a hold over from XML/UUID resolving and will perform poorly
	 */
public Collection<Table> getXMLTempGroups(Table tableRecord) {
    ArrayList<Table> results = new ArrayList<Table>();
    String namePrefix = tableRecord.getName() + TransformationMetadata.DELIMITER_STRING;
    for (Table table : tableRecord.getParent().getTables().values()) {
        if (table.getTableType() == Type.XmlStagingTable && table.getName().startsWith(namePrefix)) {
            results.add(table);
        }
    }
    return results;
}
Also used : Table(org.teiid.metadata.Table) ArrayList(java.util.ArrayList)

Example 20 with Table

use of org.teiid.metadata.Table in project teiid by teiid.

the class MaterializationMetadataRepository method loadMetadata.

// Status table column names
// VDBName, VDBVersion, SchemaName, Name, TargetSchemaName, TargetName, Valid, LoadState, Updated, Cardinality, LoadNumber
@Override
public void loadMetadata(MetadataFactory factory, ExecutionFactory executionFactory, Object connectionFactory) throws TranslatorException {
    for (Table table : factory.getSchema().getTables().values()) {
        if (table.isMaterialized()) {
            // external materialization
            if (table.getMaterializedTable() != null) {
                String manage = table.getProperty(ALLOW_MATVIEW_MANAGEMENT, false);
                if (!Boolean.valueOf(manage)) {
                    continue;
                }
                fixScript(ON_VDB_START_SCRIPT, table);
                fixScript(ON_VDB_DROP_SCRIPT, table);
                fixScript(MATVIEW_BEFORE_LOAD_SCRIPT, table);
                fixScript(MATVIEW_AFTER_LOAD_SCRIPT, table);
                fixScript(MATVIEW_LOAD_SCRIPT, table);
            } else {
            // internal materialization
            }
        }
    }
}
Also used : Table(org.teiid.metadata.Table)

Aggregations

Table (org.teiid.metadata.Table)239 Test (org.junit.Test)82 Column (org.teiid.metadata.Column)72 MetadataFactory (org.teiid.metadata.MetadataFactory)59 Properties (java.util.Properties)45 MetadataStore (org.teiid.metadata.MetadataStore)37 Schema (org.teiid.metadata.Schema)35 TranslatorException (org.teiid.translator.TranslatorException)30 ArrayList (java.util.ArrayList)27 TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)27 RealMetadataFactory (org.teiid.query.unittest.RealMetadataFactory)23 List (java.util.List)22 ForeignKey (org.teiid.metadata.ForeignKey)22 Connection (java.sql.Connection)15 QueryNode (org.teiid.query.mapping.relational.QueryNode)15 BasicSourceCapabilities (org.teiid.query.optimizer.capabilities.BasicSourceCapabilities)15 KeyRecord (org.teiid.metadata.KeyRecord)14 Dimension (org.teiid.translator.couchbase.CouchbaseMetadataProcessor.Dimension)14 CouchbaseMetadataProcessor (org.teiid.translator.couchbase.CouchbaseMetadataProcessor)13 CouchbaseProperties (org.teiid.translator.couchbase.CouchbaseProperties)13