Class RuleEngine

java.lang.Object
com.aquima.interactions.rule.impl.RuleEngine
All Implemented Interfaces:
IRuleEngine

public class RuleEngine extends Object implements 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 Details

    • RuleEngine

      public RuleEngine(IProject project, IMetaModel model, IRuleFactory factory, IValidatorFactory validators, IConnectionManager connectionManager, IRuleEngineDS datasource)
      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

      public IRuleGraph 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 interface IRuleEngine
      Returns:
      Structure containing information about the rules present in the rule engine.
    • getExpressionParser

      public IExpressionParser getExpressionParser()
      Description copied from interface: IRuleEngine
      This method returns a parser which can be used to parse expressions.
      Specified by:
      getExpressionParser in interface IRuleEngine
      Returns:
      a parser which can be used to parse expressions.
    • getParserFactory

      public IParserFactory 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 interface IRuleEngine
      Returns:
      A parser which can be used to create expression parsers for specific listeners.
    • sourceAttribute

      public InferenceResult[] sourceAttribute(IProfile profile, ValueReference valueReference, IRuleListener listener)
      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 interface IRuleEngine
      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.
    • getJustification

      public JustificationTree getJustification(IProfile profile, ValueReference valueReference, JustificationDepth depth)
      Description copied from interface: IRuleEngine
      This method determines the justification tree for the specified value.
      Specified by:
      getJustification in interface IRuleEngine
      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.
    • getDMNDecisionTree

      public DMNDecisionTree getDMNDecisionTree(IProfile profile, ValueReference valueReference)
      Description copied from interface: IRuleEngine
      This method determines the decision tree for the specified value.
      Specified by:
      getDMNDecisionTree in interface IRuleEngine
      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.
    • getDMNDecisionTree

      public DMNDecisionTree getDMNDecisionTree(IProfile profile, IExpression expression, String description)
      Description copied from interface: IRuleEngine
      This method determines the decision tree for the specified expression.
      Specified by:
      getDMNDecisionTree in interface IRuleEngine
      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.
    • determineDomain

      public IPrimitiveValue[] determineDomain(IProfile context, ValueReference valueReference, IDomainDefinition domain)
      Description copied from interface: IRuleEngine
      This method will determine the set of valid values for the specified attribute.
      Specified by:
      determineDomain in interface IRuleEngine
      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.
    • validateAttribute

      public IValidationResult validateAttribute(IProfile profile, ValueReference reference)
      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 interface IRuleEngine
      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.
    • getValidator

      public IValidator getValidator(String name)
      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 interface IRuleEngine
      Parameters:
      name - The validator type name for which an implementation is requested.
      Returns:
      Validator implementation of the requested type.