com.hammurapi.reasoning.impl
Class ReasoningNodeBase<F>
java.lang.Object
com.hammurapi.reasoning.impl.ReasoningNodeBase<F>
- Type Parameters:
F - Fact type.
- All Implemented Interfaces:
- FlowElement, Node<List<?>,Integer,KnowledgeBase<F>,com.hammurapi.reasoning.impl.InferenceToken<F>>
- Direct Known Subclasses:
- ConditionNode, InferenceMethodNode, ReasoningPassThroughNode
public abstract class ReasoningNodeBase<F>
- extends Object
- implements Node<List<?>,Integer,KnowledgeBase<F>,com.hammurapi.reasoning.impl.InferenceToken<F>>
Base class for reasoning nodes
- Author:
- Pavel Vlasov
|
Method Summary |
void |
addPin(String pinName,
List<?> pinConfig)
|
void |
afterConnect()
|
void |
beforeConnect()
|
protected ArrayList<com.hammurapi.reasoning.impl.PinEntry<F>> |
getInputPins()
|
Invocable<KnowledgeBase<F>,com.hammurapi.reasoning.impl.InferenceToken<F>> |
getInvocable(String pinName,
Integer connectKey)
|
Invoker<KnowledgeBase<F>,com.hammurapi.reasoning.impl.InferenceToken<F>> |
getInvoker(String pinName,
Integer connectKey)
|
int |
getPriority()
|
protected Collection<Future<?>> |
invoke(KnowledgeBase<F> flowState,
com.hammurapi.reasoning.impl.InferenceToken<F>[] args,
com.hammurapi.reasoning.impl.PinEntry<F> pe,
PropertySet properties,
Context context,
List<ProcessingPathElement> processingPath)
Ivocations come here. |
protected boolean |
partialJoin(List<com.hammurapi.reasoning.impl.InferenceToken<F>>[] inputs,
int index)
Validates already joined inputs. |
protected abstract Collection<Future<?>> |
process(KnowledgeBase<F> flowState,
List<com.hammurapi.reasoning.impl.InferenceToken<F>>[] inputs,
PropertySet properties,
Context context,
List<ProcessingPathElement> processingPath,
Joiner.InputConsumer consumer,
int activator)
Processes inputs. |
void |
setKnowledgeBase(KnowledgeBase<F> knowledgeBase)
|
void |
setMethodName(String methodName)
|
void |
setParameterTypes(List<Class<?>> parameterTypes)
|
void |
setPriority(int priority)
|
void |
setRuleDescription(String ruleDescription)
|
void |
setRuleIndex(int ruleIndex)
|
void |
setRuleName(String ruleName)
|
void |
setRules(List<?> rules)
|
protected void |
sortInputs()
This implementation does nothing. |
String |
toString()
|
logger
protected final Logger logger
isFine
protected final boolean isFine
rule
protected Object rule
knowledgeBase
protected KnowledgeBase<F> knowledgeBase
method
protected Method method
parameterTypes
protected Class<?>[] parameterTypes
pins
protected List<com.hammurapi.reasoning.impl.PinEntry<F>> pins
methodName
protected String methodName
ruleName
protected String ruleName
ruleDescription
protected String ruleDescription
ReasoningNodeBase
public ReasoningNodeBase()
setParameterTypes
public void setParameterTypes(List<Class<?>> parameterTypes)
toString
public String toString()
- Overrides:
toString in class Object
setRuleIndex
public void setRuleIndex(int ruleIndex)
setRules
public void setRules(List<?> rules)
throws ConfigurationException
- Throws:
ConfigurationException
setKnowledgeBase
public void setKnowledgeBase(KnowledgeBase<F> knowledgeBase)
getInputPins
protected ArrayList<com.hammurapi.reasoning.impl.PinEntry<F>> getInputPins()
beforeConnect
public void beforeConnect()
throws ConfigurationException
- Specified by:
beforeConnect in interface FlowElement
- Throws:
ConfigurationException
afterConnect
public void afterConnect()
throws ConfigurationException
- Specified by:
afterConnect in interface FlowElement
- Throws:
ConfigurationException
sortInputs
protected void sortInputs()
- This implementation does nothing.
Condition nodes can override this method to sort input pins to optimize inference by
moving pins participating in condition to first places and evaluating conditions
as soon as possible in partialJoin() method.
- Parameters:
inputPins - Input pins to sort.
partialJoin
protected boolean partialJoin(List<com.hammurapi.reasoning.impl.InferenceToken<F>>[] inputs,
int index)
throws Exception
- Validates already joined inputs.
- Parameters:
inputs - Inputsindex - Index of last already joined input.
- Returns:
-
- Throws:
Exception
addPin
public void addPin(String pinName,
List<?> pinConfig)
- Specified by:
addPin in interface Node<List<?>,Integer,KnowledgeBase<F>,com.hammurapi.reasoning.impl.InferenceToken<F>>
getInvocable
public Invocable<KnowledgeBase<F>,com.hammurapi.reasoning.impl.InferenceToken<F>> getInvocable(String pinName,
Integer connectKey)
throws ConfigurationException
- Specified by:
getInvocable in interface Node<List<?>,Integer,KnowledgeBase<F>,com.hammurapi.reasoning.impl.InferenceToken<F>>
- Throws:
ConfigurationException
invoke
protected Collection<Future<?>> invoke(KnowledgeBase<F> flowState,
com.hammurapi.reasoning.impl.InferenceToken<F>[] args,
com.hammurapi.reasoning.impl.PinEntry<F> pe,
PropertySet properties,
Context context,
List<ProcessingPathElement> processingPath)
throws Exception
- Ivocations come here. Depending on whether joiner is null or not, do direct call to join or through
joiner.
- Parameters:
pe - properties - context - processingPath - args -
- Throws:
Exception
process
protected abstract Collection<Future<?>> process(KnowledgeBase<F> flowState,
List<com.hammurapi.reasoning.impl.InferenceToken<F>>[] inputs,
PropertySet properties,
Context context,
List<ProcessingPathElement> processingPath,
Joiner.InputConsumer consumer,
int activator)
throws Exception
- Processes inputs.
- Parameters:
properties - Properties.context - Context.processingPath - Processing path.inputs - Inputs.consumer - Input consumer.
- Returns:
- Collection of future results.
- Throws:
Exception - If anything goes wrong.
getInvoker
public Invoker<KnowledgeBase<F>,com.hammurapi.reasoning.impl.InferenceToken<F>> getInvoker(String pinName,
Integer connectKey)
throws ConfigurationException
- Specified by:
getInvoker in interface Node<List<?>,Integer,KnowledgeBase<F>,com.hammurapi.reasoning.impl.InferenceToken<F>>
- Throws:
ConfigurationException
setMethodName
public void setMethodName(String methodName)
getPriority
public int getPriority()
setPriority
public void setPriority(int priority)
setRuleName
public void setRuleName(String ruleName)
setRuleDescription
public void setRuleDescription(String ruleDescription)