Class RuleEngine
java.lang.Object
com.aquima.interactions.rule.impl.RuleEngine
- All Implemented Interfaces:
IRuleEngine
This class combines the various engines to implement the rule engine methods as defined in the IRuleEngine interface.
- Since:
- 5.0
- Author:
- O. Kerpershoek
-
Constructor Summary
ConstructorsConstructorDescriptionRuleEngine
(IProject project, IMetaModel model, IRuleFactory factory, IValidatorFactory validators, IConnectionManager connectionManager, IRuleEngineDS datasource) Constructs a rule engine using the provided data source. -
Method Summary
Modifier and TypeMethodDescriptiondetermineDomain
(IProfile context, ValueReference valueReference, IDomainDefinition domain) This method will determine the set of valid values for the specified attribute.getDMNDecisionTree
(IProfile profile, ValueReference valueReference) This method determines the decision tree for the specified value.getDMNDecisionTree
(IProfile profile, IExpression expression, String description) This method determines the decision tree for the specified expression.This method returns a parser which can be used to parse expressions.getJustification
(IProfile profile, ValueReference valueReference, JustificationDepth depth) This method determines the justification tree for the specified value.This method returns a parser factory which can be used to create expression parsers with a context listener.This method returns an object containing an internal structure representation of all the business rules that are present in the rule engine.getValidator
(String name) This method returns a (custom) validator implementation for the specified type, using the provided parameters to initialize it.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.validateAttribute
(IProfile profile, ValueReference reference) This method will validate the value of the specified attribute, and return a result containing information about all the validation rules that were processed with their result.
-
Constructor Details
-
RuleEngine
public RuleEngine(IProject project, IMetaModel model, IRuleFactory factory, IValidatorFactory validators, IConnectionManager connectionManager, IRuleEngineDS datasource) throws InitializationException Constructs a rule engine using the provided data source.- Parameters:
project
- The project containing various global definitions.model
- The meta model of the module.factory
- Factory that should be used to load custom rule implementations.validators
- Factory that can provide validator implementations.connectionManager
- The connection manager that can be used to initialize data rules.datasource
- The data source providing the information needed to initialize the rule engine.- Throws:
InitializationException
- This exception is thrown when the rule engine could not be initialized with the provided parameters.
-
-
Method Details
-
getRuleGraph
Description copied from interface:IRuleEngine
This method returns an object containing an internal structure representation of all the business rules that are present in the rule engine.- Specified by:
getRuleGraph
in interfaceIRuleEngine
- Returns:
- Structure containing information about the rules present in the rule engine.
-
getExpressionParser
Description copied from interface:IRuleEngine
This method returns a parser which can be used to parse expressions.- Specified by:
getExpressionParser
in interfaceIRuleEngine
- Returns:
- a parser which can be used to parse expressions.
-
getParserFactory
Description copied from interface:IRuleEngine
This method returns a parser factory which can be used to create expression parsers with a context listener.- Specified by:
getParserFactory
in interfaceIRuleEngine
- Returns:
- A parser which can be used to create expression parsers for specific listeners.
-
sourceAttribute
public InferenceResult[] sourceAttribute(IProfile profile, ValueReference valueReference, IRuleListener listener) throws AppException Description copied from interface:IRuleEngine
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.- Specified by:
sourceAttribute
in interfaceIRuleEngine
- 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
public JustificationTree getJustification(IProfile profile, ValueReference valueReference, JustificationDepth depth) throws AppException Description copied from interface:IRuleEngine
This method determines the justification tree for the specified value.- Specified by:
getJustification
in interfaceIRuleEngine
- 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.
-
getDMNDecisionTree
public DMNDecisionTree getDMNDecisionTree(IProfile profile, ValueReference valueReference) throws AppException Description copied from interface:IRuleEngine
This method determines the decision tree for the specified value.- Specified by:
getDMNDecisionTree
in interfaceIRuleEngine
- Parameters:
profile
- The profile containing the inferred 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.
-
getDMNDecisionTree
public DMNDecisionTree getDMNDecisionTree(IProfile profile, IExpression expression, String description) throws AppException Description copied from interface:IRuleEngine
This method determines the decision tree for the specified expression.- Specified by:
getDMNDecisionTree
in interfaceIRuleEngine
- Parameters:
profile
- The profile contained the inferred values.expression
- The value for which the DMN decision tree should be generated.description
- A description for the expression- Returns:
- The DMN decision tree for the specified value.
- Throws:
AppException
- This exception is thrown when the DMN decision tree could not be determined.
-
determineDomain
public IPrimitiveValue[] determineDomain(IProfile context, ValueReference valueReference, IDomainDefinition domain) throws AppException Description copied from interface:IRuleEngine
This method will determine the set of valid values for the specified attribute.- Specified by:
determineDomain
in interfaceIRuleEngine
- Parameters:
context
- The profile that should be used when evaluating the constraints.valueReference
- Reference to the attribute for which the valid set of values should be determined.domain
- The domain definition of the attribute for which the constrains should be evaluated.- Returns:
- Array containing all the valid values for the specified attribute.
- Throws:
AppException
- This exception is raised when the constraint action failed due to an unexpected error.
-
validateAttribute
public IValidationResult validateAttribute(IProfile profile, ValueReference reference) throws AppException Description copied from interface:IRuleEngine
This method will validate the value of the specified attribute, and return a result containing information about all the validation rules that were processed with their result.- Specified by:
validateAttribute
in interfaceIRuleEngine
- Parameters:
profile
- The profile that contains the value(s) to be validated.reference
- Reference to the attribute whose value should be validated.- Returns:
- Object containing the results of the validation action.
- Throws:
AppException
- This exception is raised when the validation action failed due to an unexpected error.
-
getValidator
Description copied from interface:IRuleEngine
This method returns a (custom) validator implementation for the specified type, using the provided parameters to initialize it.- Specified by:
getValidator
in interfaceIRuleEngine
- Parameters:
name
- The validator type name for which an implementation is requested.- Returns:
- Validator implementation of the requested type.
- Throws:
UnknownValidatorException
- This exception is thrown when the validator type is unknown.
-