Replies: 1 comment 4 replies
-
Grule support facts for array/slice and map. You could construct your slice/array or map and add them into the context. The thing is, there are so many way you can evaluate your fact, process it and be reason with it, element by element or sets by sets. relying on the engine to process/iterate the array element are just not the purpose of the engine. Rule engine should tell you WHAT to do, but NOT HOW to do it. You should implement the logic to handle that array of fact, the logic you can put in the context as well as function, let the engine invoke the function that do your specific logic. For example, You could create a fact of ShoppingCart that contain an array of items you have in the cart. The ShoppingCart may have functions like |
Beta Was this translation helpful? Give feedback.
-
Please correct me if I am wrong, but it appears that, unlike Drools, Grule is incapable of evaluating rules against a set of facts that include multiple instances of the same struct type unless you name each instant something different. But if you name them differently, you can have a rule that will match both instances generically.
DataContext.Add()
takes key as its first parameter. The fact is stored in map keyed by that first parameter. Any facts added to theDataContext
using the same key will overwrite previous facts that use the same key. This seem like a severe limitation (e.g. you can't have a set of facts representing order items associated with an order to compute a total, because you can only insert a single order item while a real order may have many items).If that is the case, it should be clearly mentioned in the documentation.
Beta Was this translation helpful? Give feedback.
All reactions