Search in sources :

Example 1 with VDBImportMetadata

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

the class TestVDBMerge method testMergeWithEmptyVDB.

@Test
public void testMergeWithEmptyVDB() throws Exception {
    server.deployVDB("empty", UnitTestUtil.getTestDataPath() + "/empty.vdb");
    this.internalConnection = server.createConnection("jdbc:teiid:empty");
    // $NON-NLS-1$
    execute("select * from sys.tables where schemaname ='BQT1'");
    TestMMDatabaseMetaData.compareResultSet("TestVDBMerge/mergeEmpty.before", this.internalResultSet);
    this.internalConnection.close();
    server.deployVDB(VDB2, UnitTestUtil.getTestDataPath() + "/QT_Ora9DS_1.vdb");
    DeployVDBParameter param = new DeployVDBParameter(null, null);
    VDBImportMetadata vdbImport = new VDBImportMetadata();
    vdbImport.setName(VDB2);
    vdbImport.setVersion("1");
    param.vdbImports = Arrays.asList(vdbImport);
    server.undeployVDB("empty");
    server.deployVDB("empty", UnitTestUtil.getTestDataPath() + "/empty.vdb", param);
    this.internalConnection = server.createConnection("jdbc:teiid:empty");
    // $NON-NLS-1$
    execute("select * from sys.tables where schemaname='BQT1'");
    TestMMDatabaseMetaData.compareResultSet("TestVDBMerge/mergeEmpty.after", this.internalResultSet);
}
Also used : DeployVDBParameter(org.teiid.jdbc.FakeServer.DeployVDBParameter) VDBImportMetadata(org.teiid.adminapi.impl.VDBImportMetadata) Test(org.junit.Test)

Example 2 with VDBImportMetadata

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

the class TestVDBMerge method testMerge.

@Test
public void testMerge() throws Throwable {
    server.deployVDB(VDB1, UnitTestUtil.getTestDataPath() + "/PartsSupplier.vdb");
    this.internalConnection = server.createConnection("jdbc:teiid:" + VDB1);
    // $NON-NLS-1$
    execute("select * from sys.tables where schemaname ='PartsSupplier'");
    TestMMDatabaseMetaData.compareResultSet("TestVDBMerge/merge.test", this.internalResultSet);
    // $NON-NLS-1$
    execute("select * from sys.tables where schemaname='BQT1'");
    TestMMDatabaseMetaData.compareResultSet("TestVDBMerge/merge.before", this.internalResultSet);
    this.internalConnection.close();
    server.deployVDB(VDB2, UnitTestUtil.getTestDataPath() + "/QT_Ora9DS_1.vdb");
    DeployVDBParameter param = new DeployVDBParameter(null, null);
    VDBImportMetadata vdbImport = new VDBImportMetadata();
    vdbImport.setName(VDB2);
    vdbImport.setVersion("1");
    param.vdbImports = Arrays.asList(vdbImport);
    server.removeVDB(VDB1);
    server.deployVDB(VDB1, UnitTestUtil.getTestDataPath() + "/PartsSupplier.vdb", param);
    this.internalConnection = server.createConnection("jdbc:teiid:" + VDB1);
    // $NON-NLS-1$
    execute("select * from sys.tables where schemaname='BQT1' order by name");
    TestMMDatabaseMetaData.compareResultSet("TestVDBMerge/merge.after", this.internalResultSet);
}
Also used : DeployVDBParameter(org.teiid.jdbc.FakeServer.DeployVDBParameter) VDBImportMetadata(org.teiid.adminapi.impl.VDBImportMetadata) Test(org.junit.Test)

Example 3 with VDBImportMetadata

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

the class TestMatViews method testMatViewWithImportedVDB.

@Test
public void testMatViewWithImportedVDB() throws Exception {
    ModelMetaData mmd = new ModelMetaData();
    mmd.setName("phy");
    mmd.setSchemaSourceType("DDL");
    mmd.setSchemaText("CREATE FOREIGN TABLE t1 ( col1 string, col2 integer )");
    mmd.addSourceMapping("phy", "loopback", null);
    ModelMetaData mmd1 = new ModelMetaData();
    mmd1.setName("phy_mv");
    mmd1.setSchemaSourceType("DDL");
    mmd1.setSchemaText("CREATE FOREIGN TABLE t1_mv ( col1 string, col2 integer )" + " create foreign table status (VDBNAME STRING, VDBVERSION STRING, " + " SCHEMANAME STRING, NAME STRING, TARGETSCHEMANAME STRING, TARGETNAME STRING, " + " VALID BOOLEAN, LOADSTATE STRING, CARDINALITY LONG, UPDATED TIMESTAMP, LOADNUMBER LONG, NODENAME STRING, STALECOUNT LONG)");
    mmd1.addSourceMapping("phy_mv", "loopback", null);
    ModelMetaData mmd2 = new ModelMetaData();
    mmd2.setName("view1");
    mmd2.setModelType(Type.VIRTUAL);
    mmd2.setSchemaSourceType("DDL");
    mmd2.setSchemaText("CREATE VIEW v1 ( col1 string, col2 integer ) OPTIONS (MATERIALIZED true, " + "MATERIALIZED_TABLE 'phy_mv.t1_mv', \"teiid_rel:MATVIEW_STATUS_TABLE\" 'phy_mv.status', \"teiid_rel:MATVIEW_LOAD_SCRIPT\" 'select 1') AS select t1.col1, t1.col2 FROM t1");
    server.addTranslator(LoopbackExecutionFactory.class);
    server.deployVDB("base", mmd, mmd1, 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);
}
Also used : VDBImportMetadata(org.teiid.adminapi.impl.VDBImportMetadata) VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) ModelMetaData(org.teiid.adminapi.impl.ModelMetaData) Test(org.junit.Test)

Example 4 with VDBImportMetadata

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

the class DeploymentBasedDatabaseStore method getVDBMetadata.

public VDBMetaData getVDBMetadata(String contents) {
    StringReader reader = new StringReader(contents);
    try {
        startEditing(false);
        this.setMode(Mode.DATABASE_STRUCTURE);
        QueryParser.getQueryParser().parseDDL(this, new BufferedReader(reader));
    } finally {
        reader.close();
        stopEditing();
    }
    Database database = getDatabases().get(0);
    VDBMetaData vdb = DatabaseUtil.convert(database);
    for (ModelMetaData model : vdb.getModelMetaDatas().values()) {
        // $NON-NLS-1$
        model.addSourceMetadata("DDL", null);
    }
    for (VDBImportMetadata vid : this.importedVDBs) {
        vdb.getVDBImports().add(vid);
    }
    vdb.addProperty(VDBMetaData.TEIID_DDL, contents);
    return vdb;
}
Also used : VDBImportMetadata(org.teiid.adminapi.impl.VDBImportMetadata) VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) StringReader(java.io.StringReader) BufferedReader(java.io.BufferedReader) Database(org.teiid.metadata.Database) ModelMetaData(org.teiid.adminapi.impl.ModelMetaData)

Example 5 with VDBImportMetadata

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

the class DeploymentBasedDatabaseStore method importDatabase.

@Override
public void importDatabase(String dbName, String version, boolean importPolicies) {
    if (!assertInEditMode(Mode.DATABASE_STRUCTURE)) {
        return;
    }
    VDBImportMetadata db = new VDBImportMetadata();
    db.setName(dbName);
    db.setVersion(version);
    db.setImportDataPolicies(importPolicies);
    this.importedVDBs.add(db);
}
Also used : VDBImportMetadata(org.teiid.adminapi.impl.VDBImportMetadata)

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