- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Create one rule per element from a list provider?
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
05-02-2012 05:29 AM - edited 05-02-2012 05:32 AM
Hi
I have a template:
*Value holder VH-A for custom database list provider A, which lets the user select a value
*Value holder VH-B for custom database list logical provider B, which is based on dynamic override from A, and lists the child nodes of the element selected in A. Count is set to "All - No Selectionl".
I want to automatically create one rule per element in VH-B, when the user select a single value in VH-A.
Is this possible?
Solved! Go to Solution.
Re: Create one rule per element from a list provider?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Not the Solution
- Email to a Friend
- Report Inappropriate Content
05-02-2012 04:10 PM
Hi,
I have tried many ways to accomplish what you are asking but have not yet accomplished it yet (I was trying to do something similar just today).
It sounds like the rules for the nodes in VH-B are "fixed" since you just want to generate them and the RMA user will not interact with those rules. If that is so, let me know and I can show you a way to accomplish it using a function template and another value holder.
Tom Sheckells
Business Rules Consulting, Inc.
Re: Create one rule per element from a list provider?
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Accept as Solution
- Email to a Friend
- Report Inappropriate Content
05-03-2012 03:41 AM - edited 05-03-2012 07:43 AM
Hi Tas
Thank you for the input. In the scenario I suggested, the VH-B have a dynamic override argument (an ID) to limit the set of nodes to "children" of VH-A.
Currently I have opted for a workaround that builds the complete hierarchy of every possible element of VH-A in a single function through inserting child-parent relations in an association instead of generating one rule per level in the hierarchy.
For doing lookups in the generated code I then have to do recursive lookups in a function through that association, as compared to using rule chaining for looking up the hierarchy.
However using association for "large" input gives a considerable performance penalty (700 inserts in a int->int association takes around 2000 milliseconds on my machine), so it's not a good workaround. I ended up using a helper class with IDictionary instead, which uses 60ms for the same task.
I would very much like to see your suggested way to get around the problem.
Re: Create one rule per element from a list provider?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Accept as Solution
- Email to a Friend
- Report Inappropriate Content
05-03-2012 08:05 AM
I am doing this from memory, so I may miss a piece so bear with me. Since you have a Value Holder that essentially holds exaclty the items you want to evaluate, the idea is to build a function template and let it use the value holder you have. So, create a function template inside the ruleset template you already have (we'll get to the content in a moment). In the ruleset create a value holder that references the function template with a count of "Exactly 1". This means that each time the ruleset gets instantiated it will also create one of these functions. If you want a different function for each "rule", then move the value holder to the rule. One thing to keep in mind is that the name of the function (not the template, the function it generates) is going to have to use some other value holders to make the name unique which ever way you do it.
Next, in the function template, set the function name (at least in part using a value holder from the rule or ruleset to make it unique), the return type and any parameters. In the function body, use the little yellow circular arrow to insert a "template loop". When the dialog comes up, select VH-B as the value holder to "loop" on (the one with the "No Selection". Inside of the loop, put your if statements with a value holder that you created the loop with. For each iteration of the loop across all of the items in the value holder array it will create an "if" statement (or whatever you coded inside the loop).
Have fun.
Tom Sheckells
Business Rules Consulting, Inc.
Re: Create one rule per element from a list provider?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Accept as Solution
- Email to a Friend
- Report Inappropriate Content
05-03-2012 11:47 AM
Yes I see, it's basically a workaround creating the rules for each ruleset as if-statements in a function template.
After reviewing some performance issues we decided we have to create caching for the recursive lookups, so the rule chaining I was going for would not be optimal anyway in this case, but thank you for the input.

