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