Search in sources :

Example 56 with VDBMetaData

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());
}
Also used : MetadataStore(org.teiid.metadata.MetadataStore) VDBImportMetadata(org.teiid.adminapi.impl.VDBImportMetadata) ConnectorManagerRepository(org.teiid.dqp.internal.datamgr.ConnectorManagerRepository) VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) ConnectorManager(org.teiid.dqp.internal.datamgr.ConnectorManager) Test(org.junit.Test)

Example 57 with VDBMetaData

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());
}
Also used : MetadataStore(org.teiid.metadata.MetadataStore) VDBImportMetadata(org.teiid.adminapi.impl.VDBImportMetadata) ConnectorManagerRepository(org.teiid.dqp.internal.datamgr.ConnectorManagerRepository) VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) Test(org.junit.Test)

Example 58 with VDBMetaData

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;
}
Also used : RequestMessage(org.teiid.client.RequestMessage) AtomicRequestMessage(org.teiid.dqp.message.AtomicRequestMessage) VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) TeiidComponentException(org.teiid.core.TeiidComponentException) AtomicRequestMessage(org.teiid.dqp.message.AtomicRequestMessage) ModelMetaData(org.teiid.adminapi.impl.ModelMetaData)

Example 59 with VDBMetaData

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;
}
Also used : TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) GlobalTableStore(org.teiid.query.tempdata.GlobalTableStore) VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) Schema(org.teiid.metadata.Schema) TempMetadataID(org.teiid.query.metadata.TempMetadataID) DataModifiable(org.teiid.metadata.AbstractMetadataRecord.DataModifiable) Modifiable(org.teiid.metadata.AbstractMetadataRecord.Modifiable)

Example 60 with VDBMetaData

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;
}
Also used : VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) VDBTranslatorMetaData(org.teiid.adminapi.impl.VDBTranslatorMetaData) ModelMetaData(org.teiid.adminapi.impl.ModelMetaData)

Aggregations

VDBMetaData (org.teiid.adminapi.impl.VDBMetaData)121 Test (org.junit.Test)48 ModelMetaData (org.teiid.adminapi.impl.ModelMetaData)36 TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)16 MetadataStore (org.teiid.metadata.MetadataStore)15 ConnectorManagerRepository (org.teiid.dqp.internal.datamgr.ConnectorManagerRepository)14 VDBRepository (org.teiid.deployers.VDBRepository)12 ArrayList (java.util.ArrayList)10 IOException (java.io.IOException)9 ConnectorManager (org.teiid.dqp.internal.datamgr.ConnectorManager)9 Properties (java.util.Properties)8 XMLStreamException (javax.xml.stream.XMLStreamException)8 VDBImportMetadata (org.teiid.adminapi.impl.VDBImportMetadata)8 DataPolicyMetadata (org.teiid.adminapi.impl.DataPolicyMetadata)7 TeiidComponentException (org.teiid.core.TeiidComponentException)7 VDBKey (org.teiid.vdb.runtime.VDBKey)7 ByteArrayInputStream (java.io.ByteArrayInputStream)6 VDBTranslatorMetaData (org.teiid.adminapi.impl.VDBTranslatorMetaData)6 Schema (org.teiid.metadata.Schema)6 SessionMetadata (org.teiid.adminapi.impl.SessionMetadata)5