Search in sources :

Example 1 with Schema

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

the class CompositeMetadataStore method getStoredProcedure.

public Collection<Procedure> getStoredProcedure(String name) throws TeiidComponentException, QueryMetadataException {
    List<Procedure> result = new LinkedList<Procedure>();
    int index = name.indexOf(TransformationMetadata.DELIMITER_STRING);
    if (index > -1) {
        String schemaName = name.substring(0, index);
        Schema schema = getSchema(schemaName);
        if (schema != null) {
            Procedure proc = schema.getProcedures().get(name.substring(index + 1));
            if (proc != null) {
                result.add(proc);
                return result;
            }
        }
    }
    // assume it's a partial name
    for (Schema schema : getSchemas().values()) {
        for (Procedure p : schema.getProcedures().values()) {
            if (matchesPartialName(name, p.getName(), schema)) {
                result.add(p);
            }
        }
    }
    return result;
}
Also used : Schema(org.teiid.metadata.Schema) Procedure(org.teiid.metadata.Procedure) LinkedList(java.util.LinkedList)

Example 2 with Schema

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

the class CompositeMetadataStore method getOids.

public TreeMap<String, RecordHolder> getOids() {
    if (oids == null) {
        synchronized (this) {
            if (oids == null) {
                TreeMap<String, RecordHolder> map = new TreeMap<String, RecordHolder>(String.CASE_INSENSITIVE_ORDER);
                addOids(this.getDatatypesExcludingAliases().values(), map);
                for (Schema s : getSchemaList()) {
                    assignOids(s, map);
                }
                oids = map;
            }
        }
    }
    return oids;
}
Also used : Schema(org.teiid.metadata.Schema) TreeMap(java.util.TreeMap)

Example 3 with Schema

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

the class CompositeMetadataStore method findGroup.

public Table findGroup(String fullName) throws QueryMetadataException {
    int index = fullName.indexOf(TransformationMetadata.DELIMITER_STRING);
    if (index == -1) {
        throw new QueryMetadataException(QueryPlugin.Event.TEIID30353, fullName + TransformationMetadata.NOT_EXISTS_MESSAGE);
    }
    String schemaName = fullName.substring(0, index);
    Schema schema = getSchema(schemaName);
    if (schema == null) {
        throw new QueryMetadataException(QueryPlugin.Event.TEIID30352, fullName + TransformationMetadata.NOT_EXISTS_MESSAGE);
    }
    Table result = schema.getTables().get(fullName.substring(index + 1));
    if (result == null) {
        throw new QueryMetadataException(QueryPlugin.Event.TEIID30354, fullName + TransformationMetadata.NOT_EXISTS_MESSAGE);
    }
    return result;
}
Also used : Table(org.teiid.metadata.Table) Schema(org.teiid.metadata.Schema) QueryMetadataException(org.teiid.api.exception.query.QueryMetadataException)

Example 4 with Schema

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

the class TestSessionAwareCache method testTtl.

@Test
public void testTtl() {
    SessionAwareCache<Cachable> cache = new SessionAwareCache<Cachable>("resultset", DefaultCacheFactory.INSTANCE, SessionAwareCache.Type.RESULTSET, 0);
    CacheID id = new CacheID(buildWorkContext(), new ParseInfo(), "SELECT * FROM FOO");
    Cachable result = Mockito.mock(Cachable.class);
    // make sure defaults are returned
    assertNull(cache.computeTtl(id, result, null));
    assertEquals(Long.valueOf(1), cache.computeTtl(id, result, 1l));
    AccessInfo ai = new AccessInfo();
    Mockito.stub(result.getAccessInfo()).toReturn(ai);
    Table t = new Table();
    t.setProperty(DataModifiable.DATA_TTL, "2");
    ai.addAccessedObject(t);
    assertEquals(Long.valueOf(2), cache.computeTtl(id, result, null));
    Table t1 = new Table();
    Schema s = new Schema();
    t1.setParent(s);
    s.setProperty(DataModifiable.DATA_TTL, "0");
    ai.addAccessedObject(t1);
    // ensure that the min and the parent are used
    assertEquals(Long.valueOf(0), cache.computeTtl(id, result, null));
}
Also used : Table(org.teiid.metadata.Table) CacheID(org.teiid.dqp.internal.process.SessionAwareCache.CacheID) Schema(org.teiid.metadata.Schema) ParseInfo(org.teiid.query.parser.ParseInfo) Cachable(org.teiid.cache.Cachable) Test(org.junit.Test)

Example 5 with Schema

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

the class TestMetaDataProcessor method examplePrivatePhysicalModel.

public static TransformationMetadata examplePrivatePhysicalModel() {
    MetadataStore metadataStore = new MetadataStore();
    // Create models
    // $NON-NLS-1$
    Schema pm1 = RealMetadataFactory.createPhysicalModel("pm1", metadataStore);
    // $NON-NLS-1$
    Schema vm1 = RealMetadataFactory.createVirtualModel("vm1", metadataStore);
    // Create physical groups
    // $NON-NLS-1$
    Table pm1g1 = RealMetadataFactory.createPhysicalGroup("g1", pm1);
    // $NON-NLS-1$ //$NON-NLS-2$
    QueryNode vm1g1n1 = new QueryNode("SELECT * FROM pm1.g1");
    // $NON-NLS-1$
    Table vm1g1 = RealMetadataFactory.createVirtualGroup("g1", vm1, vm1g1n1);
    // $NON-NLS-1$
    Table pm1g2 = RealMetadataFactory.createPhysicalGroup("g2", pm1);
    // Create physical elements
    RealMetadataFactory.createElements(pm1g1, // $NON-NLS-1$
    new String[] { "e1" }, new String[] { DataTypeManager.DefaultDataTypes.SHORT });
    // Create physical elements
    List<Column> pm1g2e = RealMetadataFactory.createElements(pm1g2, // $NON-NLS-1$
    new String[] { "e1" }, new String[] { DataTypeManager.DefaultDataTypes.BIG_DECIMAL });
    Column e1 = pm1g2e.get(0);
    e1.setPrecision(19);
    e1.setLength(21);
    e1.setScale(4);
    RealMetadataFactory.createElements(vm1g1, // $NON-NLS-1$
    new String[] { "e1" }, new String[] { DataTypeManager.DefaultDataTypes.STRING });
    // Create the facade from the store
    return RealMetadataFactory.createTransformationMetadata(metadataStore, "example");
}
Also used : MetadataStore(org.teiid.metadata.MetadataStore) Table(org.teiid.metadata.Table) Column(org.teiid.metadata.Column) QueryNode(org.teiid.query.mapping.relational.QueryNode) Schema(org.teiid.metadata.Schema)

Aggregations

Schema (org.teiid.metadata.Schema)92 MetadataStore (org.teiid.metadata.MetadataStore)47 TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)37 Table (org.teiid.metadata.Table)35 Test (org.junit.Test)34 QueryNode (org.teiid.query.mapping.relational.QueryNode)20 FakeCapabilitiesFinder (org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder)19 Column (org.teiid.metadata.Column)18 BasicSourceCapabilities (org.teiid.query.optimizer.capabilities.BasicSourceCapabilities)18 Procedure (org.teiid.metadata.Procedure)16 QueryMetadataInterface (org.teiid.query.metadata.QueryMetadataInterface)11 List (java.util.List)10 ArrayList (java.util.ArrayList)9 VDBMetaData (org.teiid.adminapi.impl.VDBMetaData)8 ProcedureParameter (org.teiid.metadata.ProcedureParameter)8 ModelMetaData (org.teiid.adminapi.impl.ModelMetaData)7 FunctionMethod (org.teiid.metadata.FunctionMethod)6 TempMetadataStore (org.teiid.query.metadata.TempMetadataStore)6 CompositeMetadataStore (org.teiid.query.metadata.CompositeMetadataStore)5 DefaultCapabilitiesFinder (org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder)5