use of org.teiid.metadata.MetadataStore in project teiid by teiid.
the class TestVDBStatusChecker method testDataSourceReplaced.
@Test
public void testDataSourceReplaced() throws Exception {
final VDBRepository repo = new VDBRepository();
repo.setSystemFunctionManager(RealMetadataFactory.SFM);
repo.start();
VDBStatusChecker vsc = new VDBStatusChecker() {
@Override
public VDBRepository getVDBRepository() {
return repo;
}
@Override
public Executor getExecutor() {
return null;
}
};
VDBTranslatorMetaData factory = new VDBTranslatorMetaData();
factory.setExecutionFactoryClass(ExecutionFactory.class);
assertFalse(vsc.dataSourceReplaced("x", "1", "y", "z", "t", "dsName"));
MetadataStore metadataStore = RealMetadataFactory.exampleBQTCached().getMetadataStore();
VDBMetaData vdb = TestCompositeVDB.createVDBMetadata(metadataStore, "bqt");
ConnectorManagerRepository cmr = new ConnectorManagerRepository();
cmr.setProvider(new ExecutionFactoryProvider() {
@Override
public ExecutionFactory<Object, Object> getExecutionFactory(String name) throws ConnectorManagerException {
return new ExecutionFactory<Object, Object>();
}
});
ExecutionFactory ef1 = new ExecutionFactory();
ConnectorManager mgr = new ConnectorManager("oracle", "dsName", ef1);
cmr.addConnectorManager("BQT1", mgr);
repo.addVDB(vdb, metadataStore, null, null, cmr);
assertTrue(vsc.dataSourceReplaced("bqt", "1", "BQT1", "BQT1", "oracle", "dsName1"));
ExecutionFactory ef = cmr.getConnectorManager("BQT1").getExecutionFactory();
assertSame(ef, ef1);
assertFalse(vsc.dataSourceReplaced("bqt", "1", "BQT1", "BQT1", "sqlserver", "dsName1"));
ExecutionFactory ef2 = cmr.getConnectorManager("BQT1").getExecutionFactory();
assertNotNull(ef2);
assertNotSame(ef, ef2);
assertTrue(vsc.dataSourceReplaced("bqt", "1", "BQT1", "BQT1", "oracle", "dsName2"));
ef = cmr.getConnectorManager("BQT1").getExecutionFactory();
assertNotNull(ef);
assertNotSame(ef, ef2);
}
use of org.teiid.metadata.MetadataStore in project teiid by teiid.
the class EmbeddedAdminImpl method getSchema.
@Override
public String getSchema(String vdbName, String vdbVersion, String modelName, EnumSet<SchemaObjectType> allowedTypes, String typeNamePattern) throws AdminException {
if (vdbVersion == null) {
vdbVersion = "1";
}
VDBMetaData vdb = checkVDB(vdbName, vdbVersion);
MetadataStore metadataStore = vdb.getAttachment(TransformationMetadata.class).getMetadataStore();
if (modelName != null) {
Schema schema = metadataStore.getSchema(modelName);
return DDLStringVisitor.getDDLString(schema, allowedTypes, typeNamePattern);
} else {
Database db = DatabaseUtil.convert(vdb, metadataStore);
return DDLStringVisitor.getDDLString(db);
}
}
use of org.teiid.metadata.MetadataStore in project teiid by teiid.
the class EmbeddedAdminImpl method restartVDB.
@Override
public void restartVDB(String vdbName, String vdbVersion, String... models) throws AdminException {
VDBMetaData vdb = checkVDB(vdbName, vdbVersion);
synchronized (vdb) {
try {
// need remove model cache first
VDBMetaData currentVdb = this.embeddedServer.repo.removeVDB(vdbName, vdbVersion);
ConnectorManagerRepository cmr = this.embeddedServer.cmr;
UDFMetaData udf = currentVdb.getAttachment(UDFMetaData.class);
// need get the visibilityMap from runtime
LinkedHashMap<String, VDBResources.Resource> visibilityMap = new LinkedHashMap<String, VDBResources.Resource>();
MetadataStore store = new MetadataStore();
this.embeddedServer.repo.addVDB(currentVdb, store, visibilityMap, udf, cmr);
} catch (Exception e) {
throw new AdminProcessingException(RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40135, vdbName, vdbVersion, models), e);
}
}
}
use of org.teiid.metadata.MetadataStore in project teiid by teiid.
the class TestCompositeVDB method testFunctionValidationError.
@Test
public void testFunctionValidationError() throws Exception {
VDBRepository repo = new VDBRepository();
repo.start();
repo.setSystemStore(RealMetadataFactory.example1Cached().getMetadataStore());
repo.setSystemFunctionManager(RealMetadataFactory.SFM);
MetadataStore metadataStore = new MetadataStore();
RealMetadataFactory.createPhysicalModel("x", metadataStore);
FunctionMethod method = MetadataFactory.createFunctionFromMethod("getProperty", System.class.getMethod("getProperty", String.class));
method.setInvocationClass("?");
method.setMethod(null);
metadataStore.getSchema("x").addFunction(method);
VDBMetaData vdb = createVDBMetadata(metadataStore, "bqt");
ConnectorManagerRepository cmr = new ConnectorManagerRepository();
cmr.addConnectorManager("x", new ConnectorManager("y", "z"));
repo.addVDB(vdb, metadataStore, null, null, cmr);
repo.finishDeployment(vdb.getName(), vdb.getVersion());
assertEquals(vdb.getStatus(), Status.FAILED);
}
use of org.teiid.metadata.MetadataStore in project teiid by teiid.
the class TestCompositeVDB method testImportVisibility.
@Test
public void testImportVisibility() throws Exception {
VDBRepository repo = new VDBRepository();
repo.setSystemStore(RealMetadataFactory.example1Cached().getMetadataStore());
repo.setSystemFunctionManager(RealMetadataFactory.SFM);
MetadataStore metadataStore = RealMetadataFactory.exampleBQTCached().getMetadataStore();
VDBMetaData vdb = createVDBMetadata(metadataStore, "bqt");
repo.addVDB(vdb, metadataStore, null, null, new ConnectorManagerRepository());
vdb = createVDBMetadata(RealMetadataFactory.exampleBusObjStore(), "example1");
vdb.addProperty("BQT1.visible", "false");
VDBImportMetadata vdbImport = new VDBImportMetadata();
vdbImport.setName("bqt");
vdbImport.setVersion("1");
vdb.getVDBImports().add(vdbImport);
repo.addVDB(vdb, metadataStore, null, null, new ConnectorManagerRepository());
assertTrue(vdb.isVisible("BQT1"));
vdb = repo.getLiveVDB("example1");
assertFalse(vdb.isVisible("BQT1"));
}
Aggregations