Interface BusinessRulesEngine


@RemoteInterface public interface BusinessRulesEngine
The business rules engine will execute the validation of each business rule in order as defined by the execution plan set in the business rule set. Identifies the set of BusinessRulesEngine methods that are invokable only from classes running in the method server. The following information is required to obtain a business rule set from the system:
  1. The key of the business rule set
  2. Container reference on which the rules should be evaluated
Alternatively, more than one business rule set and target collection relationship key can be specified to generate an accumulation of results. When using this technique the container reference is not needed. The rule set will instead be evaluated by the containers of the objects in the target collection. The business rules engine will be responsible for acquiring the appropriate business rule set from the Windchill services. The business rule set will be discovered using a hierarchical container lookup. Business rule sets that are not enabled will be ignored. The generation of the execution plan of a business rule set may evolve in the future depending on performance criteria and/or profiles. Initially the execution plan will involve:
  1. Creation of a RuleValidation instance based on the ruleKey defined in the rule.
  2. The RuleValidation instance will use the configuration from the persisted rule to determine if it is valid using the isConfigurationValid method.
    • If the configuration is not valid, the engine will immediately return a validation result set with a result failure and error will be logged.
  3. Initializing each rule validation with the following items:
    • Collection of objects that rules are to evaluate
    • Context specific criteria (such as the container reference) that may be used by a rule validation to configure its execution.
  4. The rule validation instance is added to the execution plan.
The rule validation prepareForValidate method will be provided with the entire set of the objects that will be validated. This is to allow any collection-based pre-validation to occur within the Windchill server (example might be retrieving the life cycle template which would be common to many of the items). This method will not be considered thread-safe. The instantiation of the RuleValidation will be based on the ruleKey defined in the business rule. Application services will be used to lookup the implementing class for the defined ruleKey. If no implementing class is defined, or the class fails to be instantiated an error will be logged. Since the business rule set is persisted and does support loading via IXB loaders, it is possible that the current system does not have a properly configured business rule key entry.

For each object in the collection of seed objects the RuleValidation#performValidation method will be called for each rule in the plan and return a validation result:
  1. A RuleValidationObject will be created for each seed object
    • If the seed object is a link object and the rule validation handles links then the RuleValidationObject#getTargetObjectLink should be used.
    • If the rule validation cannot handle links then the validation should use the RuleValidationObject#getTargetObject
  2. If the rule validation does not support target object or target object link class type on the RuleValidationObject, the rule will be skipped for the unsupported object.


Supported API: true

Extendable: false
  • Method Summary

    Modifier and Type
    Method
    Description
    execute(Object primaryBusinessObject, BusinessRuleSetBean[] ruleSetBeans)
    Given a primary business object and business rule set beans executes all business rule sets and return an accumulation of the validation results.
    execute(String ruleSetKey, RuleValidationCriteria criteria)
    Given a collection of target objects specified in the RuleValidationCriteria executes all business rules in the business rule set in the container that is specified in the criteria.
    boolean
    Given a business rule object, Checks if the rule has a registered validator and is properly configured.
  • Method Details

    • execute

      RuleValidationResultSet execute(String ruleSetKey, RuleValidationCriteria criteria)
      Given a collection of target objects specified in the RuleValidationCriteria executes all business rules in the business rule set in the container that is specified in the criteria. If the container is null then the engine will try to use the container of the target objects to look up the business rule set to execute. This method will bypass access control in order to execute rules the user does not have access to.

      Supported API: true
      Parameters:
      ruleSetKey -
      criteria -
      Returns:
      validation result set
    • execute

      RuleValidationResultSet execute(Object primaryBusinessObject, BusinessRuleSetBean[] ruleSetBeans)
      Given a primary business object and business rule set beans executes all business rule sets and return an accumulation of the validation results. The target collection is generated for the given primary business object and the relationship specified on the business rule set bean. The target collection is then organized into one or more target collections based on the container that the objects in the target collection belong to. The specific business rule set will be looked up using the container of the target objects. If the target objects do not have a container then the engine will try to use the container of the primary business object to look up the business rule set. This method will bypass access control in order to execute rules the user does not have access to.

      Supported API: true
      Parameters:
      primaryBusinessObject -
      ruleSetBeans -
      Returns:
      validation results for all configured business rule sets.
      See Also:
    • isBusinessRuleValid

      boolean isBusinessRuleValid(RuleValidationKey ruleKey)
      Given a business rule object, Checks if the rule has a registered validator and is properly configured.
      Parameters:
      ruleKey -
      Returns:
      true if rule has a registered validator and is properly configured. Returns false otherwise

      Supported API: true