Search in sources :

Example 11 with VDBImportMetadata

use of org.teiid.adminapi.impl.VDBImportMetadata in project teiid by teiid.

the class TestMatViews method testImportedMatView.

@Test
public void testImportedMatView() throws Exception {
    ModelMetaData mmd2 = new ModelMetaData();
    mmd2.setName("view1");
    mmd2.setModelType(Type.PHYSICAL);
    mmd2.setSchemaSourceType("DDL");
    mmd2.setSchemaText("create foreign table x (col integer); CREATE VIEW v1 ( col1 string ) OPTIONS (MATERIALIZED true) AS select current_database() from x");
    mmd2.addSourceMapping("a", "a", null);
    HardCodedExecutionFactory hcef = new HardCodedExecutionFactory();
    hcef.addData("SELECT x.col FROM x", Arrays.asList(Collections.singletonList(1)));
    server.addTranslator("a", hcef);
    server.deployVDB("base", mmd2);
    VDBMetaData vdbMetaData = new VDBMetaData();
    vdbMetaData.setXmlDeployment(true);
    VDBImportMetadata importVDB = new VDBImportMetadata();
    importVDB.setName("base");
    importVDB.setVersion("1");
    vdbMetaData.getVDBImports().add(importVDB);
    vdbMetaData.setName("importing");
    server.deployVDB(vdbMetaData);
    Connection c = server.getDriver().connect("jdbc:teiid:importing", null);
    Statement s = c.createStatement();
    ResultSet rs = s.executeQuery("select * from v1");
    rs.next();
    assertEquals("base", rs.getString(1));
}
Also used : VDBImportMetadata(org.teiid.adminapi.impl.VDBImportMetadata) Statement(java.sql.Statement) CallableStatement(java.sql.CallableStatement) VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) HardCodedExecutionFactory(org.teiid.runtime.HardCodedExecutionFactory) ModelMetaData(org.teiid.adminapi.impl.ModelMetaData) Test(org.junit.Test)

Aggregations

VDBImportMetadata (org.teiid.adminapi.impl.VDBImportMetadata)11 Test (org.junit.Test)8 VDBMetaData (org.teiid.adminapi.impl.VDBMetaData)8 ModelMetaData (org.teiid.adminapi.impl.ModelMetaData)4 ConnectorManagerRepository (org.teiid.dqp.internal.datamgr.ConnectorManagerRepository)4 MetadataStore (org.teiid.metadata.MetadataStore)4 ConnectorManager (org.teiid.dqp.internal.datamgr.ConnectorManager)2 DeployVDBParameter (org.teiid.jdbc.FakeServer.DeployVDBParameter)2 BufferedReader (java.io.BufferedReader)1 IOException (java.io.IOException)1 StringReader (java.io.StringReader)1 CallableStatement (java.sql.CallableStatement)1 Connection (java.sql.Connection)1 ResultSet (java.sql.ResultSet)1 Statement (java.sql.Statement)1 Collection (java.util.Collection)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 DataPolicyMetadata (org.teiid.adminapi.impl.DataPolicyMetadata)1