org.apache.stanbol.enhancer.servicesapi.helper
Class ExecutionPlanHelper

java.lang.Object
  extended by org.apache.stanbol.enhancer.servicesapi.helper.ExecutionPlanHelper

public final class ExecutionPlanHelper
extends java.lang.Object


Method Summary
static void addDependend(java.util.Collection<org.apache.clerezza.rdf.core.NonLiteral> collection, org.apache.clerezza.rdf.core.TripleCollection executionPlan, org.apache.clerezza.rdf.core.NonLiteral executionNode)
           
static org.apache.clerezza.rdf.core.Graph calculateExecutionPlan(java.lang.String chainName, java.util.List<EnhancementEngine> availableEngines, java.util.Set<java.lang.String> optional, java.util.Set<java.lang.String> missing)
          Creates an execution plan based on the ServiceProperties.ENHANCEMENT_ENGINE_ORDERING of the parsed EnhancementEngines.
static org.apache.clerezza.rdf.core.NonLiteral createExecutionPlan(org.apache.clerezza.rdf.core.MGraph graph, java.lang.String chainName)
          Creates an ExecutionPlan for the parsed chainName in the parsed Graph
static java.util.List<EnhancementEngine> getActiveEngines(EnhancementEngineManager engineManager, org.apache.clerezza.rdf.core.TripleCollection ep)
          Calculates a sorted list of active EnhancementEngines form the given ExecutinPlan
static java.util.Set<org.apache.clerezza.rdf.core.NonLiteral> getDependend(org.apache.clerezza.rdf.core.TripleCollection executionPlan, org.apache.clerezza.rdf.core.NonLiteral executionNode)
           
static java.lang.String getEngine(org.apache.clerezza.rdf.core.TripleCollection executionPlan, org.apache.clerezza.rdf.core.NonLiteral executionNode)
           
static java.util.Set<org.apache.clerezza.rdf.core.NonLiteral> getExecutable(org.apache.clerezza.rdf.core.TripleCollection executionPlan, java.util.Set<org.apache.clerezza.rdf.core.NonLiteral> executed)
          Evaluates the parsed execution plan and the set of already executed ep:ExecutionNodes to find the next nodes that can be executed.
static java.util.Set<org.apache.clerezza.rdf.core.NonLiteral> getExecutionNodes(org.apache.clerezza.rdf.core.TripleCollection ep, org.apache.clerezza.rdf.core.NonLiteral executionPlanNode)
          Getter for the set of ExecutionNodes part of an execution plan.
static org.apache.clerezza.rdf.core.NonLiteral getExecutionPlan(org.apache.clerezza.rdf.core.TripleCollection graph, java.lang.String chainName)
          Getter for the ExecutionPlan.EXECUTION_PLAN node of an execution plan for the given chainNmame.
static boolean isOptional(org.apache.clerezza.rdf.core.TripleCollection executionPlan, org.apache.clerezza.rdf.core.NonLiteral executionNode)
           
static java.util.Set<java.lang.String> validateExecutionPlan(org.apache.clerezza.rdf.core.TripleCollection executionPlan)
          Utility that checks if the parsed graph contains a valid execution plan.
static org.apache.clerezza.rdf.core.NonLiteral writeExecutionNode(org.apache.clerezza.rdf.core.MGraph graph, org.apache.clerezza.rdf.core.NonLiteral epNode, java.lang.String engineName, boolean optional, java.util.Set<org.apache.clerezza.rdf.core.NonLiteral> dependsOn)
          Writes all triples for an ep:ExecutionNode to the parsed MGraph.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

writeExecutionNode

public static org.apache.clerezza.rdf.core.NonLiteral writeExecutionNode(org.apache.clerezza.rdf.core.MGraph graph,
                                                                         org.apache.clerezza.rdf.core.NonLiteral epNode,
                                                                         java.lang.String engineName,
                                                                         boolean optional,
                                                                         java.util.Set<org.apache.clerezza.rdf.core.NonLiteral> dependsOn)
Writes all triples for an ep:ExecutionNode to the parsed MGraph. An BNode is use for representing the execution node resource.

Parameters:
graph - the graph to write the triples. MUST NOT be empty
epNode - the NonLiteral representing the ep:ExecutionPlan
engineName - the name of the engine. MUST NOT be null nor empty
optional - if the execution of this node is optional or required
dependsOn - other nodes that MUST BE executed before this one. Parse null or an empty set if none.
Returns:
the resource representing the added ep:ExecutionNode.

createExecutionPlan

public static org.apache.clerezza.rdf.core.NonLiteral createExecutionPlan(org.apache.clerezza.rdf.core.MGraph graph,
                                                                          java.lang.String chainName)
Creates an ExecutionPlan for the parsed chainName in the parsed Graph

Parameters:
graph - the graph
chainName - the chain name
Returns:
the node representing the ex:ExecutionPlan

getExecutable

public static java.util.Set<org.apache.clerezza.rdf.core.NonLiteral> getExecutable(org.apache.clerezza.rdf.core.TripleCollection executionPlan,
                                                                                   java.util.Set<org.apache.clerezza.rdf.core.NonLiteral> executed)
Evaluates the parsed execution plan and the set of already executed ep:ExecutionNodes to find the next nodes that can be executed.

Parameters:
executionPlan - the execution plan
executed - the already executed nodes or an empty set to determine the nodes to start the execution.
Returns:
the set of nodes that can be executed next or an empty set if there are no more nodes to execute.

calculateExecutionPlan

public static org.apache.clerezza.rdf.core.Graph calculateExecutionPlan(java.lang.String chainName,
                                                                        java.util.List<EnhancementEngine> availableEngines,
                                                                        java.util.Set<java.lang.String> optional,
                                                                        java.util.Set<java.lang.String> missing)
Creates an execution plan based on the ServiceProperties.ENHANCEMENT_ENGINE_ORDERING of the parsed EnhancementEngines. NOTE that the parsed list is modified as it is sroted by using the EnhancementEngineHelper.EXECUTION_ORDER_COMPARATOR.

A second parameter with the set of optional engines can be used to define what ExecutionPlan.EXECUTION_NODE in the execution plan should be marked as ExecutionPlan.OPTIONAL.

Parameters:
chainName - the name of the Chain to build the execution plan for
availableEngines - the list of engines
the - names of optional engines.
Returns:
the execution plan

validateExecutionPlan

public static java.util.Set<java.lang.String> validateExecutionPlan(org.apache.clerezza.rdf.core.TripleCollection executionPlan)
                                                             throws ChainException
Utility that checks if the parsed graph contains a valid execution plan. This method is intended to be used by components that need to ensure that an parsed graph contains a valid execution plan.

This especially checks:


getDependend

public static java.util.Set<org.apache.clerezza.rdf.core.NonLiteral> getDependend(org.apache.clerezza.rdf.core.TripleCollection executionPlan,
                                                                                  org.apache.clerezza.rdf.core.NonLiteral executionNode)

addDependend

public static void addDependend(java.util.Collection<org.apache.clerezza.rdf.core.NonLiteral> collection,
                                org.apache.clerezza.rdf.core.TripleCollection executionPlan,
                                org.apache.clerezza.rdf.core.NonLiteral executionNode)

isOptional

public static boolean isOptional(org.apache.clerezza.rdf.core.TripleCollection executionPlan,
                                 org.apache.clerezza.rdf.core.NonLiteral executionNode)

getEngine

public static java.lang.String getEngine(org.apache.clerezza.rdf.core.TripleCollection executionPlan,
                                         org.apache.clerezza.rdf.core.NonLiteral executionNode)

getActiveEngines

public static java.util.List<EnhancementEngine> getActiveEngines(EnhancementEngineManager engineManager,
                                                                 org.apache.clerezza.rdf.core.TripleCollection ep)
Calculates a sorted list of active EnhancementEngines form the given ExecutinPlan

Parameters:
engineManager - The engine manager (OSGI service or EnginesTracker)
ep - the execution plan
Returns:

getExecutionPlan

public static org.apache.clerezza.rdf.core.NonLiteral getExecutionPlan(org.apache.clerezza.rdf.core.TripleCollection graph,
                                                                       java.lang.String chainName)
Getter for the ExecutionPlan.EXECUTION_PLAN node of an execution plan for the given chainNmame. This method is handy for components that need to get an execution plan for a graph that might potentially contain more than a single execution plan.

Parameters:
graph - the graph
chainName - the chain name
Returns:
the node or null if not found

getExecutionNodes

public static java.util.Set<org.apache.clerezza.rdf.core.NonLiteral> getExecutionNodes(org.apache.clerezza.rdf.core.TripleCollection ep,
                                                                                       org.apache.clerezza.rdf.core.NonLiteral executionPlanNode)
Getter for the set of ExecutionNodes part of an execution plan.

Parameters:
ep - the execution plan graph
executionPlanNode - the execution plan node


Copyright © 2010-2012 The Apache Software Foundation. All Rights Reserved.