Class InferenceEngine
java.lang.Object
com.aquima.interactions.rule.inference.InferenceEngine
- All Implemented Interfaces:
IRuleGraph
The inference engine contains the logic to determine a value for an attribute using the inference business rules
defined.
- Since:
- 5.0
- Author:
- O. Kerpershoek
-
Constructor Summary
ConstructorsConstructorDescriptionInferenceEngine
(IRuleGraph graph) Constructs an inference engine using an initialized rule graph. -
Method Summary
Modifier and TypeMethodDescriptionThis method returns an array containing all the entity nodes present in the rule graph.getAttributeNode
(String entity, String attribute) This method returns the IAttributeNodeof the dependency graph for the given attribute.getDMNDecision
(IProfile profile, ValueReference valueReference) Determines the justification information for the DMN decision tree for the specified value.getDMNDecision
(IProfile profile, IExpression expression, String description) Determines the justification information for the DMN decision tree for the specified expressionprotected DMNDecisionTree
getDMNDecision
(InferenceContext context, ValueReference valueReference) This method determines the DMN decision tree for the specified value.getEntityNode
(String entity) This method returns the IEntityNode of the dependency graph for the given entity name.getJustification
(IProfile profile, ValueReference valueReference, JustificationDepth depth) This method determines the justification tree for the specified value.protected JustificationTree
getJustification
(InferenceContext context, ValueReference valueReference, JustificationDepth depth, Map<ValueReference, JustificationTree> coveredJustifications) This method determines the justification tree for the specified value.getRuleGroup
(String name) This method returns the rule group definition for the specified name.sourceAttribute
(IProfile profile, ValueReference valueReference, IRuleListener listener) This method does not check if the profile already contains a value for the given reference, but will always source a value for the attribute.
-
Constructor Details
-
InferenceEngine
Constructs an inference engine using an initialized rule graph.- Parameters:
graph
- The rule graph that should be used by the inference engine.
-
-
Method Details
-
sourceAttribute
public InferenceResult[] sourceAttribute(IProfile profile, ValueReference valueReference, IRuleListener listener) throws AppException This method does not check if the profile already contains a value for the given reference, but will always source a value for the attribute. This method will return an inference result object in the result array for each rule that has been evaluated. Also rules that did not yield a value for the target attribute will be present in this array. The reason to include all inference results is that the dependency information on the failed rules is needed to determine whether the target attribute may need to be inferenced again when one of the dependencies of the failed rules changes.- Parameters:
profile
- The profile that should be used when evaluating the business rules.valueReference
- The attribute whose value should be inferenced.listener
- Optional listener that may be used to intercept events.- Returns:
- Array containing the results of the inference actions that were triggered.
- Throws:
AppException
- This exception is raised when the source action failed due to an unexpected error.
-
getJustification
protected JustificationTree getJustification(InferenceContext context, ValueReference valueReference, JustificationDepth depth, Map<ValueReference, JustificationTree> coveredJustifications) throws AppExceptionThis method determines the justification tree for the specified value.- Parameters:
context
- The profile containing the inferenced values.valueReference
- The value for which the justification tree should be generated.depth
- The depth of the justification tree that should be generated.- Returns:
- The justification tree for the specified value.
- Throws:
AppException
- This exception is thrown when the justification tree could not be determined.
-
getJustification
public JustificationTree getJustification(IProfile profile, ValueReference valueReference, JustificationDepth depth) throws AppException This method determines the justification tree for the specified value.- Parameters:
profile
- The profile containing the inferenced values.valueReference
- The value for which the justification tree should be generated.depth
- The depth of the justification tree that should be generated.- Returns:
- The justification tree for the specified value.
- Throws:
AppException
- This exception is thrown when the justification tree could not be determined.
-
getDMNDecision
protected DMNDecisionTree getDMNDecision(InferenceContext context, ValueReference valueReference) throws AppException This method determines the DMN decision tree for the specified value.- Parameters:
context
- The profile containing the inferenced values.valueReference
- The value for which the DMN decision tree should be generated.- Returns:
- The DMN decision tree for the specified value.
- Throws:
AppException
- This exception is thrown when the DMN decision tree could not be determined.
-
getDMNDecision
Determines the justification information for the DMN decision tree for the specified value.- Parameters:
profile
- The profile containing the inferred values.valueReference
- The value for which the DMN decision tree should be generated.- Returns:
- DMN decision tree for the specified value.
-
getDMNDecision
Determines the justification information for the DMN decision tree for the specified expression- Parameters:
profile
- The profile contained the inferred valuesexpression
- The expression for which the DMN decision tree should be generated- Returns:
- DMN decision tree for the specified expression
-
getAllEntityNodes
Description copied from interface:IRuleGraph
This method returns an array containing all the entity nodes present in the rule graph.- Specified by:
getAllEntityNodes
in interfaceIRuleGraph
- Returns:
- Array containing all the entity nodes of the rule graph.
-
getAttributeNode
public IAttributeNode getAttributeNode(String entity, String attribute) throws UnknownEntityException, UnknownAttributeException Description copied from interface:IRuleGraph
This method returns the IAttributeNodeof the dependency graph for the given attribute. When the attribute is not used by a business rule, this method may return null.- Specified by:
getAttributeNode
in interfaceIRuleGraph
- Parameters:
entity
- The name of the entity that contains the attribute (this does not need to be the name of the entity in which the attribute is defined, but may also be the entity that contains the attribute by inheritance.attribute
- The name of the attribute.- Returns:
- IAttributeNode The attribute node of the dependency graph for the given attribute name, or null when the attribute has no dependencies.
- Throws:
UnknownEntityException
- This exception will be thrown when the provided entity does not exist in the metamodel.UnknownAttributeException
- This exception will be thrown when the provided attribute does not exist in the provided entity.
-
getEntityNode
Description copied from interface:IRuleGraph
This method returns the IEntityNode of the dependency graph for the given entity name.- Specified by:
getEntityNode
in interfaceIRuleGraph
- Parameters:
entity
- The name of the entity.- Returns:
- IEntityNode The entity node of the dependency graph for the given entity name.
- Throws:
UnknownEntityException
- This exception will be thrown when the provided entity does not exist in the metamodel.
-
getRuleGroup
Description copied from interface:IRuleGraph
This method returns the rule group definition for the specified name.- Specified by:
getRuleGroup
in interfaceIRuleGraph
- Parameters:
name
- The name of the requested rule group.- Returns:
- The rule group definition for the specified name.
- Throws:
UnknownRuleGroupException
- This exception is thrown when no rule group is defined with the specified name.
-