Search in sources :

Example 26 with VDBTranslatorMetaData

use of org.teiid.adminapi.impl.VDBTranslatorMetaData 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 27 with VDBTranslatorMetaData

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

the class EmbeddedAdminImpl method getTranslatorPropertyDefinitions.

@Override
public Collection<? extends PropertyDefinition> getTranslatorPropertyDefinitions(String translatorName, TranlatorPropertyType type) throws AdminException {
    List<PropertyDefinition> list = new ArrayList<PropertyDefinition>();
    VDBTranslatorMetaData translator = this.embeddedServer.getTranslatorRepository().getTranslatorMetaData(translatorName);
    TranlatorPropertyType translatorPropertyType = TranlatorPropertyType.valueOf(type.toString().toUpperCase());
    if (translator != null) {
        ExtendedPropertyMetadataList properties = translator.getAttachment(ExtendedPropertyMetadataList.class);
        if (translatorPropertyType.equals(TranlatorPropertyType.ALL)) {
            for (ExtendedPropertyMetadata epm : properties) {
                list.add(buildNode(epm));
            }
        } else {
            PropertyType propType = PropertyType.valueOf(type.toString().toUpperCase());
            for (ExtendedPropertyMetadata epm : properties) {
                if (PropertyType.valueOf(epm.category()).equals(propType)) {
                    list.add(buildNode(epm));
                }
            }
        }
    }
    return list;
}
Also used : ExtendedPropertyMetadataList(org.teiid.deployers.ExtendedPropertyMetadataList) ExtendedPropertyMetadata(org.teiid.deployers.ExtendedPropertyMetadata) PropertyType(org.teiid.translator.TranslatorProperty.PropertyType) VDBTranslatorMetaData(org.teiid.adminapi.impl.VDBTranslatorMetaData)

Aggregations

VDBTranslatorMetaData (org.teiid.adminapi.impl.VDBTranslatorMetaData)27 Test (org.junit.Test)13 VDBMetaData (org.teiid.adminapi.impl.VDBMetaData)6 ExecutionFactory (org.teiid.translator.ExecutionFactory)6 ModelNode (org.jboss.dmr.ModelNode)4 Translator (org.teiid.adminapi.Translator)4 ArrayList (java.util.ArrayList)3 ModelMetaData (org.teiid.adminapi.impl.ModelMetaData)3 ConnectorManagerRepository (org.teiid.dqp.internal.datamgr.ConnectorManagerRepository)3 ConnectorManagerException (org.teiid.dqp.internal.datamgr.ConnectorManagerRepository.ConnectorManagerException)3 TranslatorException (org.teiid.translator.TranslatorException)3 Properties (java.util.Properties)2 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)2 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)2 Module (org.jboss.modules.Module)2 ServiceTarget (org.jboss.msc.service.ServiceTarget)2 TeiidException (org.teiid.core.TeiidException)2 UDFMetaData (org.teiid.deployers.UDFMetaData)2 TeiidConstants.asString (org.teiid.jboss.TeiidConstants.asString)2 IndexMetadataRepository (org.teiid.metadata.index.IndexMetadataRepository)2