use of org.teiid.adminapi.impl.VDBImportMetadata in project teiid by teiid.
the class TestCompositeVDB method testRoleInherit.
@Test
public void testRoleInherit() throws Exception {
VDBRepository repo = new VDBRepository();
repo.setSystemStore(RealMetadataFactory.example1Cached().getMetadataStore());
repo.setSystemFunctionManager(RealMetadataFactory.SFM);
MetadataStore metadataStore = new MetadataStore();
RealMetadataFactory.createPhysicalModel("x", metadataStore);
VDBMetaData vdb = createVDBMetadata(metadataStore, "bqt");
DataPolicyMetadata dpm = new DataPolicyMetadata();
dpm.setName("x");
dpm.setGrantAll(true);
vdb.addDataPolicy(dpm);
ConnectorManagerRepository cmr = new ConnectorManagerRepository();
cmr.addConnectorManager("x", new ConnectorManager("y", "z"));
repo.addVDB(vdb, metadataStore, null, null, cmr);
metadataStore = new MetadataStore();
RealMetadataFactory.createPhysicalModel("y", metadataStore);
vdb = createVDBMetadata(metadataStore, "ex");
VDBImportMetadata vdbImport = new VDBImportMetadata();
vdbImport.setName("bqt");
vdbImport.setVersion("1");
vdbImport.setImportDataPolicies(true);
vdb.getVDBImports().add(vdbImport);
repo.addVDB(vdb, metadataStore, null, null, new ConnectorManagerRepository());
vdb = repo.getLiveVDB("ex");
assertEquals(1, vdb.getDataPolicyMap().get("x").getSchemas().size());
}
use of org.teiid.adminapi.impl.VDBImportMetadata in project teiid by teiid.
the class TestCompositeVDB method testDeepNesting.
@Test
public void testDeepNesting() throws Exception {
VDBRepository repo = new VDBRepository();
repo.setSystemStore(RealMetadataFactory.example1Cached().getMetadataStore());
repo.setSystemFunctionManager(RealMetadataFactory.SFM);
MetadataStore metadataStore = new MetadataStore();
RealMetadataFactory.createPhysicalModel("x", metadataStore);
VDBMetaData vdb = createVDBMetadata(metadataStore, "bqt");
ConnectorManagerRepository cmr = new ConnectorManagerRepository();
cmr.addConnectorManager("x", new ConnectorManager("y", "z"));
repo.addVDB(vdb, metadataStore, null, null, cmr);
metadataStore = new MetadataStore();
RealMetadataFactory.createPhysicalModel("y", metadataStore);
vdb = createVDBMetadata(metadataStore, "ex");
VDBImportMetadata vdbImport = new VDBImportMetadata();
vdbImport.setName("bqt");
vdbImport.setVersion("1");
vdb.getVDBImports().add(vdbImport);
repo.addVDB(vdb, metadataStore, null, null, new ConnectorManagerRepository());
VDBMetaData vdbInstance = repo.getVDB("ex", "1");
assertTrue(!vdbInstance.getAttachment(ConnectorManagerRepository.class).getConnectorManagers().isEmpty());
metadataStore = new MetadataStore();
RealMetadataFactory.createPhysicalModel("z", metadataStore);
vdb = createVDBMetadata(metadataStore, "ex1");
vdbImport = new VDBImportMetadata();
vdbImport.setName("ex");
vdbImport.setVersion("1");
vdb.getVDBImports().add(vdbImport);
repo.addVDB(vdb, metadataStore, null, null, new ConnectorManagerRepository());
vdbInstance = repo.getVDB("ex1", "1");
assertTrue(!vdbInstance.getAttachment(ConnectorManagerRepository.class).getConnectorManagers().isEmpty());
}
use of org.teiid.adminapi.impl.VDBImportMetadata in project teiid by teiid.
the class TestCompositeVDB method testImportErrors.
@Test(expected = VirtualDatabaseException.class)
public void testImportErrors() 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(metadataStore, "bqt1");
VDBImportMetadata vdbImport = new VDBImportMetadata();
vdbImport.setName("foo");
vdb.getVDBImports().add(vdbImport);
try {
// foo does not exist
repo.addVDB(vdb, metadataStore, null, null, new ConnectorManagerRepository());
fail();
} catch (VirtualDatabaseException e) {
}
vdb = createVDBMetadata(metadataStore, "bqt1");
vdbImport.setName("bqt");
vdb.getVDBImports().add(vdbImport);
// model conflict
repo.addVDB(vdb, metadataStore, null, null, new ConnectorManagerRepository());
}
use of org.teiid.adminapi.impl.VDBImportMetadata 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"));
}
use of org.teiid.adminapi.impl.VDBImportMetadata in project teiid by teiid.
the class FakeServer method deployVDB.
public void deployVDB(String vdbName, MetadataStore metadata, DeployVDBParameter parameterObject) {
VDBMetaData vdbMetaData = null;
try {
if (parameterObject.vdbResources != null && parameterObject.useVdbXml) {
VDBResource resource = parameterObject.vdbResources.get("/META-INF/vdb.xml");
if (resource != null) {
vdbMetaData = VDBMetadataParser.unmarshell(resource.openStream());
}
}
if (vdbMetaData == null) {
vdbMetaData = new VDBMetaData();
vdbMetaData.setName(vdbName);
for (Schema schema : metadata.getSchemas().values()) {
ModelMetaData model = addModel(vdbMetaData, schema);
if (parameterObject.metadataRepo != null) {
model.addAttchment(MetadataRepository.class, parameterObject.metadataRepo);
// fakeserver does not load through the repository framework, so call load after the fact here.
MetadataFactory mf = createMetadataFactory(vdbMetaData, metadata, model, parameterObject.vdbResources);
mf.setSchema(schema);
try {
parameterObject.metadataRepo.loadMetadata(mf, null, null);
} catch (TranslatorException e) {
throw new TeiidRuntimeException(e);
}
}
}
} else {
if (!parameterObject.useDataRoles) {
vdbMetaData.setDataPolicies(Collections.EMPTY_LIST);
}
cmr.createConnectorManagers(vdbMetaData, this);
}
UDFMetaData udfMetaData = null;
if (parameterObject.udfs != null) {
udfMetaData = new UDFMetaData();
for (Map.Entry<String, Collection<FunctionMethod>> entry : parameterObject.udfs.entrySet()) {
udfMetaData.addFunctions(entry.getKey(), entry.getValue());
}
}
if (parameterObject.vdbImports != null) {
for (VDBImportMetadata vdbImport : parameterObject.vdbImports) {
vdbMetaData.getVDBImports().add(vdbImport);
}
}
vdbMetaData.setStatus(VDB.Status.ACTIVE);
this.repo.addVDB(vdbMetaData, metadata, parameterObject.vdbResources, udfMetaData, cmr);
this.repo.finishDeployment(vdbMetaData.getName(), vdbMetaData.getVersion());
this.repo.getLiveVDB(vdbMetaData.getName(), vdbMetaData.getVersion()).setStatus(VDB.Status.ACTIVE);
} catch (VirtualDatabaseException e) {
throw new RuntimeException(e);
} catch (ConnectorManagerException e) {
throw new RuntimeException(e);
} catch (XMLStreamException e) {
throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
Aggregations