Search in sources :

Example 66 with MetadataStore

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

Example 67 with MetadataStore

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);
    }
}
Also used : MetadataStore(org.teiid.metadata.MetadataStore) TransformationMetadata(org.teiid.query.metadata.TransformationMetadata) VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) Schema(org.teiid.metadata.Schema) Database(org.teiid.metadata.Database)

Example 68 with MetadataStore

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);
        }
    }
}
Also used : MetadataStore(org.teiid.metadata.MetadataStore) ConnectorManagerRepository(org.teiid.dqp.internal.datamgr.ConnectorManagerRepository) VDBMetaData(org.teiid.adminapi.impl.VDBMetaData) UDFMetaData(org.teiid.deployers.UDFMetaData) VDBResources(org.teiid.query.metadata.VDBResources) TransformerException(javax.xml.transform.TransformerException) TeiidComponentException(org.teiid.core.TeiidComponentException) SessionServiceException(org.teiid.dqp.service.SessionServiceException)

Example 69 with MetadataStore

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

Example 70 with MetadataStore

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"));
}
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)

Aggregations

MetadataStore (org.teiid.metadata.MetadataStore)73 Schema (org.teiid.metadata.Schema)47 Test (org.junit.Test)38 Table (org.teiid.metadata.Table)37 TransformationMetadata (org.teiid.query.metadata.TransformationMetadata)22 QueryNode (org.teiid.query.mapping.relational.QueryNode)19 Column (org.teiid.metadata.Column)17 VDBMetaData (org.teiid.adminapi.impl.VDBMetaData)15 Properties (java.util.Properties)12 MetadataFactory (org.teiid.metadata.MetadataFactory)12 QueryMetadataInterface (org.teiid.query.metadata.QueryMetadataInterface)12 Procedure (org.teiid.metadata.Procedure)11 List (java.util.List)9 ModelMetaData (org.teiid.adminapi.impl.ModelMetaData)9 Connection (java.sql.Connection)8 ConnectorManagerRepository (org.teiid.dqp.internal.datamgr.ConnectorManagerRepository)8 ArrayList (java.util.ArrayList)7 ProcedureParameter (org.teiid.metadata.ProcedureParameter)7 BasicSourceCapabilities (org.teiid.query.optimizer.capabilities.BasicSourceCapabilities)7 TempMetadataStore (org.teiid.query.metadata.TempMetadataStore)6