Assert is an action type that can be used to provide new information (as objects) to the rule engine to examine and verify if a rule is satisfied.
Assert :: any Java method returning an object
The engine examines the returned object obtained by executing the method. Assert can also be used to provide multiple objects for examination simultaneously.
If the return type of the method is java.util.Collection, java.util.Iterator, or java.util.Enumerator, the object examined is not the collection, iterator, or enumerator, but all the objects returned by iterating over them. That is, the objects asserted are the ones obtained by iterating over the elements of the same.
If it is required that the asserted object should be returned to the application code calling the invokeRuleset method, select the Add Asserted Object to Return List option. There is a true/false toggle for Add Asserted Object to Return List
Assert::Order.getOrderItems
If Order has a method
public List getOrderItems() {
...
}
If this method returns objects of the type OrderItem, then the engine examines all the OrderItem objects.
A business object has a one-to-one or one-to-many relationship with the other business objects and those are required for processing rules. You might want to create a dummy rule that has a condition which is always true and the action of the dummy rule causes the related business objects to be examined.
If |
|
(1 = 1) |
|
Then |
|
Assert::CustomerHome.findCustomersWhoHave BoughtGoodsMoreThan(10000 |
Example
Finder methods in Home interface of EJBeans that return multiple remote interfaces are an ideal case here. If you want finder methods to be used this way, the EJB home interface should have been in the list passed to the invokeRuleset method of com.sap.qrules.engine.RuleEngine.
In cases of optimization, where you are finding the best match or first match which satisfies the rules among the many possible cases. The strategy could be to take an object, verify if it satisfies the match criteria, and then stop, otherwise get the next object.
Example
If |
|
(session object does not satisfy criteria) |
|
Then |
|
Assert::SolutionFactory.CreateNewSolution |
SolutionFactory.CreateNewSolution is a static method that creates a new solution object with the parameters passed to the method for initialization. This rule will usually be a lower priority rule so that higher rules can check if the solution is acceptable.