Search in sources :

Example 1 with DelegatingExecutionFactory

use of org.teiid.translator.DelegatingExecutionFactory in project teiid by teiid.

the class TranslatorUtil method getExecutionFactory.

@SuppressWarnings({ "rawtypes", "unchecked" })
public static ExecutionFactory<Object, Object> getExecutionFactory(String name, TranslatorRepository vdbRepo, TranslatorRepository repo, VDBMetaData deployment, IdentityHashMap<Translator, ExecutionFactory<Object, Object>> map, HashSet<String> building) throws ConnectorManagerException {
    if (!building.add(name)) {
        throw new ConnectorManagerException(RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40138, building));
    }
    VDBTranslatorMetaData translator = vdbRepo.getTranslatorMetaData(name);
    if (translator == null) {
        translator = repo.getTranslatorMetaData(name);
    }
    if (translator == null) {
        return null;
    }
    ExecutionFactory<Object, Object> ef = map.get(translator);
    if (ef == null) {
        try {
            ef = TranslatorUtil.buildExecutionFactory(translator);
        } catch (TeiidException e) {
            throw new ConnectorManagerException(e);
        }
        if (ef instanceof DelegatingExecutionFactory) {
            DelegatingExecutionFactory delegator = (DelegatingExecutionFactory) ef;
            String delegateName = delegator.getDelegateName();
            if (delegateName != null) {
                ExecutionFactory<Object, Object> delegate = getExecutionFactory(delegateName, vdbRepo, repo, deployment, map, building);
                if (delegate == null) {
                    if (deployment != null) {
                        throw new ConnectorManagerException(QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31146, deployment.getName(), deployment.getVersion(), delegateName));
                    }
                    throw new ConnectorManagerException(RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40136, delegateName));
                }
                ((DelegatingExecutionFactory<Object, Object>) ef).setDelegate(delegate);
            }
        }
        map.put(translator, ef);
    }
    return ef;
}
Also used : ConnectorManagerException(org.teiid.dqp.internal.datamgr.ConnectorManagerRepository.ConnectorManagerException) DelegatingExecutionFactory(org.teiid.translator.DelegatingExecutionFactory) VDBTranslatorMetaData(org.teiid.adminapi.impl.VDBTranslatorMetaData) TeiidException(org.teiid.core.TeiidException)

Example 2 with DelegatingExecutionFactory

use of org.teiid.translator.DelegatingExecutionFactory in project teiid by teiid.

the class TranslatorUtil method buildDelegateAwareExecutionFactory.

public static ExecutionFactory<Object, Object> buildDelegateAwareExecutionFactory(VDBTranslatorMetaData translator, ExecutionFactoryProvider provider) throws ConnectorManagerException {
    ExecutionFactory<Object, Object> ef = null;
    try {
        ef = buildExecutionFactory(translator);
    } catch (TeiidException e) {
        throw new ConnectorManagerException(e);
    }
    if (ef instanceof DelegatingExecutionFactory) {
        DelegatingExecutionFactory delegator = (DelegatingExecutionFactory) ef;
        String delegateName = delegator.getDelegateName();
        if (delegateName != null) {
            ExecutionFactory<Object, Object> delegate = provider.getExecutionFactory(delegateName);
            if (delegate == null) {
                throw new ConnectorManagerException(RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40155, delegateName));
            }
            ((DelegatingExecutionFactory<Object, Object>) ef).setDelegate(delegate);
        }
    }
    return ef;
}
Also used : ConnectorManagerException(org.teiid.dqp.internal.datamgr.ConnectorManagerRepository.ConnectorManagerException) DelegatingExecutionFactory(org.teiid.translator.DelegatingExecutionFactory) TeiidException(org.teiid.core.TeiidException)

Aggregations

TeiidException (org.teiid.core.TeiidException)2 ConnectorManagerException (org.teiid.dqp.internal.datamgr.ConnectorManagerRepository.ConnectorManagerException)2 DelegatingExecutionFactory (org.teiid.translator.DelegatingExecutionFactory)2 VDBTranslatorMetaData (org.teiid.adminapi.impl.VDBTranslatorMetaData)1