use of org.teiid.adminapi.impl.VDBMetaData 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.VDBMetaData 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.VDBMetaData in project teiid by teiid.
the class DataTierManagerImpl method createRequest.
private AtomicRequestMessage createRequest(RequestWorkItem workItem, Command command, String modelName, String connectorBindingId, int nodeID) throws TeiidComponentException {
RequestMessage request = workItem.requestMsg;
// build the atomic request based on original request + context info
AtomicRequestMessage aqr = new AtomicRequestMessage(request, workItem.getDqpWorkContext(), nodeID);
aqr.setCommand(command);
aqr.setModelName(modelName);
aqr.setMaxResultRows(requestMgr.getMaxSourceRows());
aqr.setExceptionOnMaxRows(requestMgr.isExceptionOnMaxSourceRows());
aqr.setPartialResults(request.supportsPartialResults());
aqr.setSerial(requestMgr.getUserRequestSourceConcurrency() == 1);
aqr.setTransactionContext(workItem.getTransactionContext());
aqr.setBufferManager(this.getBufferManager());
if (connectorBindingId == null) {
VDBMetaData vdb = workItem.getDqpWorkContext().getVDB();
ModelMetaData model = vdb.getModel(modelName);
List<String> bindings = model.getSourceNames();
if (bindings == null || bindings.size() != 1) {
// this should not happen, but it did occur when setting up the SystemAdmin models
throw new TeiidComponentException(QueryPlugin.Event.TEIID30554, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30554, modelName, workItem.getDqpWorkContext().getVdbName(), workItem.getDqpWorkContext().getVdbVersion()));
}
connectorBindingId = bindings.get(0);
// $NON-NLS-1$
Assertion.isNotNull(connectorBindingId, "could not obtain connector id");
}
aqr.setConnectorName(connectorBindingId);
return aqr;
}
use of org.teiid.adminapi.impl.VDBMetaData in project teiid by teiid.
the class AccessInfo method restore.
/**
* Restore reconnects to the live metadata objects
* @throws TeiidComponentException
* @throws TeiidProcessingException
*/
void restore() throws TeiidComponentException, TeiidProcessingException {
if (this.objectsAccessed != null) {
return;
}
VDBMetaData vdb = DQPWorkContext.getWorkContext().getVDB();
TransformationMetadata tm = vdb.getAttachment(TransformationMetadata.class);
GlobalTableStore globalStore = vdb.getAttachment(GlobalTableStore.class);
if (!externalNames.isEmpty()) {
this.objectsAccessed = new HashSet<Object>(externalNames.size());
for (List<String> key : this.externalNames) {
if (key.size() == 1) {
String matTableName = key.get(0);
TempMetadataID id = globalStore.getGlobalTempTableMetadataId(matTableName);
if (id == null) {
// if the id is null, then create a local instance
String viewFullName = matTableName.substring(RelationalPlanner.MAT_PREFIX.length());
id = globalStore.getGlobalTempTableMetadataId(tm.getGroupID(viewFullName));
}
this.objectsAccessed.add(id);
} else {
Schema s = tm.getMetadataStore().getSchema(key.get(0));
Modifiable m = s.getTables().get(key.get(1));
if (m == null) {
m = s.getProcedures().get(key.get(1));
}
if (m != null) {
this.objectsAccessed.add(m);
}
}
}
} else {
this.objectsAccessed = Collections.emptySet();
}
this.externalNames = null;
}
use of org.teiid.adminapi.impl.VDBMetaData in project teiid by teiid.
the class DatabaseUtil method convert.
public static VDBMetaData convert(Database database) {
VDBMetaData vdb = new VDBMetaData();
vdb.setName(database.getName());
vdb.setVersion(database.getVersion());
vdb.setDescription(database.getAnnotation());
if (database.getProperty("connection-type", false) != null) {
vdb.setConnectionType(VDB.ConnectionType.valueOf(database.getProperty("connection-type", false)));
}
vdb.getPropertiesMap().putAll(database.getProperties());
String domainDDLString = DDLStringVisitor.getDomainDDLString(database);
if (!domainDDLString.isEmpty()) {
vdb.addProperty(VDBMetaData.TEIID_DOMAINS, domainDDLString);
}
// translators
for (DataWrapper dw : database.getDataWrappers()) {
if (dw.getType() == null) {
// we only care about the override types in the VDB
continue;
}
VDBTranslatorMetaData translator = new VDBTranslatorMetaData();
translator.setName(dw.getName());
translator.setType(dw.getType());
translator.setDescription(dw.getAnnotation());
translator.getPropertiesMap().putAll(dw.getProperties());
vdb.addOverideTranslator(translator);
}
for (Schema schema : database.getSchemas()) {
ModelMetaData mmd = new ModelMetaData();
mmd.setName(schema.getName());
mmd.setDescription(schema.getAnnotation());
mmd.setVisible(Boolean.valueOf(schema.isVisible()));
mmd.getPropertiesMap().putAll(schema.getProperties());
if (schema.isPhysical()) {
mmd.setModelType(Model.Type.PHYSICAL);
for (Server server : schema.getServers()) {
// if there are more properties to create DS they will be lost in this translation
String connectionName = server.getJndiName();
if (connectionName == null) {
connectionName = server.getName();
}
mmd.addSourceMapping(server.getName(), server.getDataWrapper(), connectionName);
}
} else {
mmd.setModelType(Model.Type.VIRTUAL);
}
vdb.addModel(mmd);
}
copyDatabaseGrantsAndRoles(database, vdb);
return vdb;
}
Aggregations