business-rulesrule-engineilogjrules

How to pass a collection from a rule to a java method


I have a collection of Type Cars which I need to pass from the ILOG Jrules to my Java evaluation method. My Java evaluation method can accept an Object, so a collection can be accepted. I need to process the collection of cars in my Java XOM and then return some output to ILOG. But how do I create a collection of cars from my ILOG JRules? And for DVS testing, how do I pass the collection of cars from my DVS Scenario Excel sheet?


Solution

  • To clarify Tito's comment on the first answer: Well, it depends what you want to do. Without any input, it is hard to tell.

    Yes, you can send a collection as an InputParameter easily. BUT, if your business users want to author rules against the items of the collection then use [concept.insert(Object) ish to insert all your items in the working memory]. (if you want to write "if the code of the item is.." without having to say: "definitions set item to an item in the items of the shopping cart" first, for instance), and DO NOT use any loop in the rule flow. This is overkilling the perfs.

    You can send to JRules a complex structured object if you wish. It is then up to you to manage how you will author rules and split the model, if needed, using pointers to objects, like a ruleset parameter being the collection "items" of your main object "shoppingCart" makes sense?