Search in sources :

Example 26 with VDBMetaData

use of org.teiid.adminapi.impl.VDBMetaData in project teiid by teiid.

the class VDBService method start.

@Override
public void start(final StartContext context) throws StartException {
    ConnectorManagerRepository cmr = new ConnectorManagerRepository();
    TranslatorRepository repo = new TranslatorRepository();
    this.vdb.addAttchment(TranslatorRepository.class, repo);
    // check if this is a VDB with index files, if there are then build the TransformationMetadata
    UDFMetaData udf = this.vdb.getAttachment(UDFMetaData.class);
    // add required connector managers; if they are not already there
    for (Translator t : this.vdb.getOverrideTranslators()) {
        VDBTranslatorMetaData data = (VDBTranslatorMetaData) t;
        String type = data.getType();
        VDBTranslatorMetaData parent = getTranslatorRepository().getTranslatorMetaData(type);
        data.setModuleName(parent.getModuleName());
        data.addAttchment(ClassLoader.class, parent.getAttachment(ClassLoader.class));
        data.setParent(parent);
        repo.addTranslatorMetadata(data.getName(), data);
    }
    createConnectorManagers(cmr, repo, this.vdb);
    final ServiceBuilder<Void> vdbService = addVDBFinishedService(context);
    this.vdbListener = new VDBLifeCycleListener() {

        @Override
        public void added(String name, CompositeVDB cvdb) {
        }

        @Override
        public void beforeRemove(String name, CompositeVDB cvdb) {
        }

        @Override
        public void removed(String name, CompositeVDB cvdb) {
        }

        @Override
        public void finishedDeployment(String name, CompositeVDB cvdb) {
            if (!VDBService.this.vdbKey.equals(cvdb.getVDBKey())) {
                return;
            }
            // clear out the indexmetadatarepository as it holds state that is no longer necessary
            // $NON-NLS-1$
            repositories.put("index", new IndexMetadataRepository());
            VDBMetaData vdbInstance = cvdb.getVDB();
            if (vdbInstance.getStatus().equals(Status.ACTIVE)) {
                vdbService.install();
            }
        }
    };
    getVDBRepository().addListener(this.vdbListener);
    MetadataStore store = new MetadataStore();
    try {
        // check to see if there is an index file.  if there is then we assume
        // that index is the default metadata repo
        MetadataRepository<?, ?> defaultRepo = null;
        for (String s : this.vdbResources.getEntriesPlusVisibilities().keySet()) {
            if (s.endsWith(VDBResources.INDEX_EXT)) {
                // $NON-NLS-1$
                defaultRepo = super.getMetadataRepository("index");
                break;
            }
        }
        this.assignMetadataRepositories(vdb, defaultRepo);
        // add transformation metadata to the repository.
        getVDBRepository().addVDB(this.vdb, store, vdbResources.getEntriesPlusVisibilities(), udf, cmr);
    } catch (VirtualDatabaseException e) {
        cleanup(context);
        throw new StartException(e);
    }
    this.vdb.removeAttachment(UDFMetaData.class);
    try {
        loadMetadata(this.vdb, cmr, store, this.vdbResources);
    } catch (TranslatorException e) {
        cleanup(context);
        throw new StartException(e);
    }
    this.runtimeVDB = buildRuntimeVDB(this.vdb, context.getController().getServiceContainer());
}
Also used : ConnectorManagerRepository(org.teiid.dqp.internal.datamgr.ConnectorManagerRepository) CompositeVDB(org.teiid.deployers.CompositeVDB) UDFMetaData(org.teiid.deployers.UDFMetaData) TranslatorRepository(org.teiid.dqp.internal.datamgr.TranslatorRepository) IndexMetadataRepository(org.teiid.metadata.index.IndexMetadataRepository) MetadataStore(org.teiid.metadata.MetadataStore) Translator(org.teiid.adminapi.Translator) VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) VDBLifeCycleListener(org.teiid.deployers.VDBLifeCycleListener) StartException(org.jboss.msc.service.StartException) TranslatorException(org.teiid.translator.TranslatorException) VirtualDatabaseException(org.teiid.deployers.VirtualDatabaseException) VDBTranslatorMetaData(org.teiid.adminapi.impl.VDBTranslatorMetaData)

Example 27 with VDBMetaData

use of org.teiid.adminapi.impl.VDBMetaData in project teiid by teiid.

the class TestVDBMetaData method testMarshellUnmarshellDirectParsing.

@Test
public void testMarshellUnmarshellDirectParsing() throws Exception {
    VDBMetaData vdb = TestVDBUtility.buildVDB();
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    VDBMetadataParser.marshell(vdb, out);
    // System.out.println(new String(out.toByteArray()));
    // UnMarshell
    vdb = VDBMetadataParser.unmarshell(new ByteArrayInputStream(out.toByteArray()));
    TestVDBUtility.validateVDB(vdb);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.junit.Test)

Example 28 with VDBMetaData

use of org.teiid.adminapi.impl.VDBMetaData in project teiid by teiid.

the class TestVDBMetaData method testAdminMOCreation.

@Test
public void testAdminMOCreation() {
    VDBMetaData vdb = new VDBMetaData();
    PropertiesUtils.setBeanProperty(vdb, "name", "x");
    assertEquals("x", vdb.getName());
}
Also used : VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) Test(org.junit.Test)

Example 29 with VDBMetaData

use of org.teiid.adminapi.impl.VDBMetaData in project teiid by teiid.

the class TestVDBMetaData method testVDBMetaDataMapper.

@Test
public void testVDBMetaDataMapper() {
    VDBMetaData vdb = TestVDBUtility.buildVDB();
    ModelNode node = VDBMetadataMapper.INSTANCE.wrap(vdb, new ModelNode());
    vdb = VDBMetadataMapper.INSTANCE.unwrap(node);
    TestVDBUtility.validateVDB(vdb);
}
Also used : VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) ModelNode(org.jboss.dmr.ModelNode) Test(org.junit.Test)

Example 30 with VDBMetaData

use of org.teiid.adminapi.impl.VDBMetaData in project teiid by teiid.

the class TestVDBMetaData method testClone.

@Test
public void testClone() {
    VDBMetaData vdb = TestVDBUtility.buildVDB();
    vdb.setXmlDeployment(true);
    VDBMetaData clone = vdb.clone();
    assertTrue(clone.isXmlDeployment());
    assertEquals(1, vdb.getVDBImports().size());
    assertNotSame(clone.getModelMetaDatas(), vdb.getModelMetaDatas());
// assertNotSame(clone.getDataPolicyMap(), vdb.getDataPolicyMap());
}
Also used : VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) Test(org.junit.Test)

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