use of org.teiid.adminapi.impl.ModelMetaData in project teiid by teiid.
the class TestEmbeddedServer method testTempVisibilityToExecuteImmediate.
@Test
public void testTempVisibilityToExecuteImmediate() throws Exception {
EmbeddedConfiguration ec = new EmbeddedConfiguration();
es.start(ec);
ModelMetaData mmd = new ModelMetaData();
mmd.setName("x");
mmd.setModelType(Type.VIRTUAL);
mmd.addSourceMetadata("ddl", "create procedure p () as execute immediate 'select 1' as x integer into #temp;");
es.deployVDB("x", mmd);
Connection c = es.getDriver().connect("jdbc:teiid:x", null);
Statement s = c.createStatement();
s.execute("create local temporary table #temp (x integer)");
s.execute("exec p()");
extractRowCount("select * from #temp", s, 0);
}
use of org.teiid.adminapi.impl.ModelMetaData in project teiid by teiid.
the class TestVisitor method queryMetadataInterface.
private static TransformationMetadata queryMetadataInterface() {
try {
ModelMetaData mmd = new ModelMetaData();
mmd.setName("couchbase");
CouchbaseMetadataProcessor mp = new CouchbaseMetadataProcessor();
MetadataFactory mf = new MetadataFactory("couchbase", 1, SystemMetadata.getInstance().getRuntimeTypeMap(), mmd);
Table customer = createTable(mf, KEYSPACE, "Customer");
mp.scanRow(KEYSPACE, KEYSPACE_SOURCE, formCustomer(), mf, customer, customer.getName(), false, new Dimension());
Table order = createTable(mf, KEYSPACE, "Oder");
mp.scanRow(KEYSPACE, KEYSPACE_SOURCE, formOder(), mf, order, order.getName(), false, new Dimension());
Table t2 = createTable(mf, "T2", "T2");
mp.scanRow("T2", "`T2`", formDataTypeJson(), mf, t2, t2.getName(), false, new Dimension());
Table t3 = createTable(mf, "T3", "T3");
mp.scanRow("T3", "`T3`", nestedJson(), mf, t3, t3.getName(), false, new Dimension());
mp.scanRow("T3", "`T3`", nestedArray(), mf, t3, t3.getName(), false, new Dimension());
mp.addProcedures(mf, null);
TransformationMetadata tm = RealMetadataFactory.createTransformationMetadata(mf.asMetadataStore(), "x");
ValidatorReport report = new MetadataValidator().validate(tm.getVdbMetaData(), tm.getMetadataStore());
if (report.hasItems()) {
throw new RuntimeException(report.getFailureMessage());
}
return tm;
} catch (MetadataException e) {
throw new RuntimeException(e);
}
}
use of org.teiid.adminapi.impl.ModelMetaData in project teiid by teiid.
the class CachedFinder method findCapabilities.
/**
* Find capabilities used the cache if possible, otherwise do the lookup.
*/
public SourceCapabilities findCapabilities(String modelName) throws TeiidComponentException {
SourceCapabilities caps = userCache.get(modelName);
if (caps != null) {
return caps;
}
ModelMetaData model = vdb.getModel(modelName);
List<String> sourceNames = model.getSourceNames();
if (sourceNames.isEmpty()) {
throw new TeiidRuntimeException(QueryPlugin.Event.TEIID30499, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30499, modelName));
}
TeiidException cause = null;
for (String sourceName : sourceNames) {
// TOOD: in multi-source mode it may be necessary to compute minimal capabilities across the sources
ConnectorManager mgr = this.connectorRepo.getConnectorManager(sourceName);
if (mgr == null) {
throw new TeiidComponentException(QueryPlugin.Event.TEIID30497, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30497, sourceName, modelName, sourceName));
}
try {
caps = mgr.getCapabilities();
break;
} catch (TeiidException e) {
cause = e;
// $NON-NLS-1$
LogManager.logDetail(LogConstants.CTX_DQP, e, "Could not obtain capabilities for" + sourceName);
}
}
if (caps == null) {
InvalidCaps ic = new InvalidCaps();
ic.setSourceProperty(Capability.INVALID_EXCEPTION, cause);
caps = ic;
}
userCache.put(modelName, caps);
return caps;
}
use of org.teiid.adminapi.impl.ModelMetaData in project teiid by teiid.
the class MultiSourceMetadataWrapper method getMultiSourceModels.
public static Map<String, String> getMultiSourceModels(VDBMetaData vdb) {
HashMap<String, String> result = new HashMap<String, String>();
for (ModelMetaData mmd : vdb.getModelMetaDatas().values()) {
if (!mmd.isSupportsMultiSourceBindings()) {
continue;
}
String columnName = mmd.getPropertyValue(MULTISOURCE_COLUMN_NAME);
if (columnName == null) {
columnName = MultiSourceElement.DEFAULT_MULTI_SOURCE_ELEMENT_NAME;
}
result.put(mmd.getName(), columnName);
}
return result;
}
use of org.teiid.adminapi.impl.ModelMetaData in project teiid by teiid.
the class TestPhoenixUtil method queryMetadataInterface.
public static TransformationMetadata queryMetadataInterface() {
try {
ModelMetaData mmd = new ModelMetaData();
mmd.setName("HBaseModel");
MetadataFactory mf = new MetadataFactory("hbase", 1, SystemMetadata.getInstance().getRuntimeTypeMap(), mmd);
mf.setParser(new QueryParser());
mf.parse(new FileReader(UnitTestUtil.getTestDataFile("customer.ddl")));
TransformationMetadata tm = RealMetadataFactory.createTransformationMetadata(mf.asMetadataStore(), "x");
ValidatorReport report = new MetadataValidator().validate(tm.getVdbMetaData(), tm.getMetadataStore());
if (report.hasItems()) {
throw new RuntimeException(report.getFailureMessage());
}
return tm;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
Aggregations