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;
}
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;
}
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;
}
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));
}
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");
}
Aggregations