Search in sources :

Example 16 with EnhancementEngine

use of org.apache.stanbol.enhancer.servicesapi.EnhancementEngine in project stanbol by apache.

the class AllActiveEnginesChain method update.

private void update() throws ChainException {
    Set<String> activeEngineNames = new HashSet<String>(tracker.getActiveEngineNames());
    if (activeEngineNames.isEmpty()) {
        throw new ChainException("Currently there are no active EnhancementEngines available");
    }
    List<EnhancementEngine> activeEngines = new ArrayList<EnhancementEngine>(activeEngineNames.size());
    Iterator<String> names = activeEngineNames.iterator();
    while (names.hasNext()) {
        String name = names.next();
        EnhancementEngine engine = tracker.getEngine(name);
        if (engine != null) {
            activeEngines.add(engine);
        } else {
            //looks like the config has changed in the meantime
            names.remove();
        }
    }
    Set<String> emptySet = Collections.emptySet();
    executionPlan = calculateExecutionPlan(getName(), activeEngines, //this Chain does not support optional engines
    emptySet, //only active meaning that no engines are missing
    emptySet);
    engineNames = Collections.unmodifiableSet(activeEngineNames);
}
Also used : ArrayList(java.util.ArrayList) EnhancementEngine(org.apache.stanbol.enhancer.servicesapi.EnhancementEngine) ChainException(org.apache.stanbol.enhancer.servicesapi.ChainException) HashSet(java.util.HashSet)

Aggregations

EnhancementEngine (org.apache.stanbol.enhancer.servicesapi.EnhancementEngine)16 Test (org.junit.Test)8 HashMap (java.util.HashMap)6 Map (java.util.Map)6 HashSet (java.util.HashSet)4 ArrayList (java.util.ArrayList)3 Collection (java.util.Collection)3 BlankNodeOrIRI (org.apache.clerezza.commons.rdf.BlankNodeOrIRI)2 EnhancementEngineHelper.getString (org.apache.stanbol.enhancer.servicesapi.helper.EnhancementEngineHelper.getString)2 ServiceReference (org.osgi.framework.ServiceReference)2 Entry (java.util.Map.Entry)1 Graph (org.apache.clerezza.commons.rdf.Graph)1 IRI (org.apache.clerezza.commons.rdf.IRI)1 ImmutableGraph (org.apache.clerezza.commons.rdf.ImmutableGraph)1 PlainLiteralImpl (org.apache.clerezza.commons.rdf.impl.utils.PlainLiteralImpl)1 TripleImpl (org.apache.clerezza.commons.rdf.impl.utils.TripleImpl)1 IndexedGraph (org.apache.stanbol.commons.indexedgraph.IndexedGraph)1 ChainException (org.apache.stanbol.enhancer.servicesapi.ChainException)1 EngineException (org.apache.stanbol.enhancer.servicesapi.EngineException)1