Search in sources :

Example 6 with MetadataRepository

use of org.teiid.metadata.MetadataRepository in project teiid by teiid.

the class AbstractVDBDeployer method assignMetadataRepositories.

protected void assignMetadataRepositories(VDBMetaData deployment, MetadataRepository<?, ?> defaultRepo) throws VirtualDatabaseException {
    for (ModelMetaData model : deployment.getModelMetaDatas().values()) {
        if (model.getModelType() != Type.OTHER && (model.getName() == null || model.getName().indexOf('.') >= 0) || model.getName().equalsIgnoreCase(CoreConstants.SYSTEM_MODEL) || model.getName().equalsIgnoreCase(CoreConstants.SYSTEM_ADMIN_MODEL) || model.getName().equalsIgnoreCase(CoreConstants.ODBC_MODEL)) {
            throw new VirtualDatabaseException(RuntimePlugin.Event.TEIID40121, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40121, model.getName(), deployment.getName(), deployment.getVersion()));
        }
        if (model.isSource() && model.getSourceNames().isEmpty()) {
            throw new VirtualDatabaseException(RuntimePlugin.Event.TEIID40093, RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40093, model.getName(), deployment.getName(), deployment.getVersion()));
        }
        if (model.getModelType() == Type.FUNCTION || model.getModelType() == Type.OTHER) {
            continue;
        }
        MetadataRepository<?, ?> repo = getMetadataRepository(deployment, model, defaultRepo);
        // handle multi-source column creation
        if (model.isSupportsMultiSourceBindings() && Boolean.valueOf(model.getPropertyValue("multisource.addColumn"))) {
            // $NON-NLS-1$
            List<MetadataRepository<?, ?>> repos = new ArrayList<MetadataRepository<?, ?>>(2);
            repos.add(repo);
            String columnName = model.getPropertyValue(MultiSourceMetadataWrapper.MULTISOURCE_COLUMN_NAME);
            repos.add(new MultiSourceMetadataRepository(columnName == null ? MultiSourceElement.DEFAULT_MULTI_SOURCE_ELEMENT_NAME : columnName));
            repo = new ChainingMetadataRepository(repos);
        }
        model.addAttchment(MetadataRepository.class, repo);
    }
}
Also used : MetadataRepository(org.teiid.metadata.MetadataRepository) ArrayList(java.util.ArrayList) VirtualDatabaseException(org.teiid.deployers.VirtualDatabaseException) ModelMetaData(org.teiid.adminapi.impl.ModelMetaData)

Aggregations

MetadataRepository (org.teiid.metadata.MetadataRepository)6 VirtualDatabaseException (org.teiid.deployers.VirtualDatabaseException)4 ArrayList (java.util.ArrayList)3 ModelMetaData (org.teiid.adminapi.impl.ModelMetaData)3 StringReader (java.io.StringReader)2 Database (org.teiid.metadata.Database)2 MetadataFactory (org.teiid.metadata.MetadataFactory)2 DeploymentBasedDatabaseStore (org.teiid.metadatastore.DeploymentBasedDatabaseStore)2 ExecutionFactory (org.teiid.translator.ExecutionFactory)2 TranslatorException (org.teiid.translator.TranslatorException)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 List (java.util.List)1 Map (java.util.Map)1 StringTokenizer (java.util.StringTokenizer)1 ConcurrentSkipListMap (java.util.concurrent.ConcurrentSkipListMap)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 OperationFailedException (org.jboss.as.controller.OperationFailedException)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1 ConnectorManager (org.teiid.dqp.internal.datamgr.ConnectorManager)1