What could be the reason for...<br><br><div class="gmail_quote">On 14 April 2011 11:38, Robert Christenson <span dir="ltr"><<a href="mailto:rac@akc.org">rac@akc.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
We've come across something similar in our project just recently as well.<br>
<br>
We have a requirement to have some rules activate based on a tab-off action but also at a higher level (such as validating an entire event entry in the GUI). I also need these rules to activate if initiated from an external webservice (no GUI at all).<br>
<br>
What we've decided to utilize is a meta identifier in certain rules called FieldsAffected which may contain a delimited list of field identifiers.<br>
<br>
An AgendaFilter implementation is created for GUI side requests and passed to fireAllRules. The filter implementation compares any/all field identifiers passed within the request and keeps only those activations which contain the field identifier in it's metadata field.<br>
</blockquote><div><br>...not using a regular rule condition to ascertain this field match? <br><br>-W <br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
Our RHS creates a validation msg which contains the field identifiers so that the calling GUI can display the proper msgs to the field.<br>
<br>
This allows us to support multiple call scenarios without duplicating the logic in multiple rules just based on context info.<br>
<br>
Hope this helps,<br>
<br>
Bob Christenson<br>
<br>
<br>
> ------------------------------<br>
><br>
> Message: 2<br>
> Date: Thu, 14 Apr 2011 15:23:44 +0800<br>
> From: Benson Fung <<a href="mailto:benson.redhat@gmail.com">benson.redhat@gmail.com</a>><br>
> Subject: Re: [rules-users] execute particular rules programmatically<br>
> and dynamically<br>
> To: Rules Users List <<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>><br>
> Message-ID: <BANLkTi=OGO=<a href="mailto:rWFEnYBHM144GVSt%2BP_KVtQ@mail.gmail.com">rWFEnYBHM144GVSt+P_KVtQ@mail.gmail.com</a>><br>
> Content-Type: text/plain; charset=ISO-8859-1<br>
<div><div></div><div class="h5">><br>
> Thanks Michael, let me think about your solution seriously afterwards.<br>
> Actually, I am using GWT.<br>
> I would like to say that sometimes customer's requirement is picky and<br>
> unexpectable. They really want to have close coupling between UI and<br>
> Rules. haha..... :) Do you think it is helpless as a<br>
> consultant??? :~(<br>
><br>
> If anyone has another idea of this scenario, you are welcome to post<br>
> your idea out there.<br>
><br>
><br>
> Thank you very much<br>
><br>
><br>
><br>
> 2011/4/14 Michael Anstis <<a href="mailto:michael.anstis@gmail.com">michael.anstis@gmail.com</a>>:<br>
>> In my example Rule 1 was shared between "screen1.panel1.editbox1" and<br>
>> "screen1.panel1.editbox2":-<br>
>><br>
>> rule "Rule1"<br>
>> ? salience 1<br>
>> ? dialect "mvel"<br>
>> ??? when<br>
>> ????? ApplicationContext( context in ("screen1.panel1.editbox1",<br>
>> "screen1.panel1.editbox2") )<br>
>> ? ? ? ad : ApplicationData( age == "" || ( ?== null ))<br>
>> ? ? then<br>
>> ? ??? ad.setReturnMsg( "\n age should not be null or empty" );<br>
>> end<br>
>><br>
>> This is an approach and may not be the best available; I was trying to<br>
>> demonstrate how your problem can be solved without having to worry about<br>
>> explicitly executing individual rules.For example, depending on what UI<br>
>> technology you are using (Swing, JSF) you could subclass the UI components<br>
>> and use these as facts - but such close coupling between UI and Rules may be<br>
>> undesirable.<br>
>><br>
>> With kind regards,<br>
>><br>
>> Mike<br>
>><br>
>> On 14 April 2011 03:52, Benson Fung <<a href="mailto:benson.redhat@gmail.com">benson.redhat@gmail.com</a>> wrote:<br>
>>><br>
>>> Good, Michael.<br>
>>><br>
>>> 'context' is used to distinguish which part of the UI which will be<br>
>>> validated, right? ?The customer will ask if they have 10000 rules in<br>
>>> the rulebase. ?And some of them are redundant, so they want to make<br>
>>> some of the rules share with several part of UI, e.g. ?editbox 6,<br>
>>> editbox 7 and editbox 8 these 3 boxes' value range is within 0 and<br>
>>> 600. ?Therefore, Rule3 can be shared for these 3 editbox validation,<br>
>>> right? ?However, for the context variable approach, it seems Rule3<br>
>>> cannot be shared for another editbox with same value range validation.<br>
>>> ?So these could be a key for the BRMS/Drools.<br>
>>><br>
>>><br>
>>> Benson<br>
>>><br>
>>> 2011/4/14 Michael Anstis <<a href="mailto:michael.anstis@gmail.com">michael.anstis@gmail.com</a>>:<br>
>>>> Sure, whenever you copy values from your UI to your model for validation<br>
>>>> you<br>
>>>> also enter a fact representing the "context" of the values.<br>
>>>><br>
>>>> Using your example you have two edit boxes on one screen and your rule<br>
>>>> simply checks for the value of a single edit box; in this case the<br>
>>>> context<br>
>>>> differentiates the two.<br>
>>>><br>
>>>> Walking your example:<br>
>>>><br>
>>>> (1) When editbox 1 looses focus you copy the value from the dropdown and<br>
>>>> edit box 1 into your model, plus you enter a "context" fact stating that<br>
>>>> these values relate to that part of the UI (say<br>
>>>> "screen1.panel1.editbox1").<br>
>>>> You then insert these facts into WM and call fireAllRules. The rules<br>
>>>> check<br>
>>>> the "context" and only execute if the values are for the (rule)<br>
>>>> applicable<br>
>>>> context. (2) Editbox 2 works in a similar way, but has a different<br>
>>>> context<br>
>>>> ((say "screen1.panel1.editbox2").<br>
>>>><br>
>>>> Have a look at Plugtree - I believe they're quite well customed to<br>
>>>> writing<br>
>>>> UIs backed with rules; salaboy or esteban (or IRC #drools) might be able<br>
>>>> to<br>
>>>> offer more practical advice.<br>
>>>><br>
>>>> With kind regards,<br>
>>>><br>
>>>> Mike<br>
>>>><br>
>>>><br>
>>>><br>
>>>> On 13 April 2011 17:48, Benson Fung <<a href="mailto:benson.redhat@gmail.com">benson.redhat@gmail.com</a>> wrote:<br>
>>>>><br>
>>>>> Hi Michael,<br>
>>>>><br>
>>>>> Can you elaborate more for the uses of the ApplicationContext? ?I<br>
>>>>> can't follow its uses.<br>
>>>>><br>
>>>>><br>
>>>>> Thanks<br>
>>>>> Benson<br>
>>>>><br>
>>>>> 2011/4/14 Michael Anstis <<a href="mailto:michael.anstis@gmail.com">michael.anstis@gmail.com</a>>:<br>
>>>>>> Here's a quick (and probably sub-optimal way) ;)<br>
>>>>>><br>
>>>>>> When you copy values from the UI to Facts for validation you also<br>
>>>>>> include<br>
>>>>>> the context of the validation.<br>
>>>>>><br>
>>>>>> I've also removed the inline evals you were using.<br>
>>>>>><br>
>>>>>> rule "Rule1"<br>
>>>>>> ? salience 1<br>
>>>>>> ? dialect "mvel"<br>
>>>>>> ??? when<br>
>>>>>> ????? ApplicationContext( context == "*" )<br>
>>>>>> ? ? ? ad : ApplicationData( age == "" || ( ?== null ))<br>
>>>>>> ? ? then<br>
>>>>>> ? ??? ad.setReturnMsg( "\n age should not be null or empty" );<br>
>>>>>> end<br>
>>>>>><br>
>>>>>> rule "Rule2"<br>
>>>>>> ? dialect "mvel"<br>
>>>>>> ??? when<br>
>>>>>> ? ??? ApplicationContext( context == "screen1.panel1.ed" )<br>
>>>>>> ? ? ? ad : ApplicationData( $age : age != null , age != "" , age < 0<br>
>>>>>> ||<br>
>>>>>>><br>
>>>>>> 100, minIssrdAge == "Years" )<br>
>>>>>> ? ? then<br>
>>>>>> ? ??? ad.setReturnMsg( "\nage is out of the range(i.e. ?< 0 and ><br>
>>>>>> 100)"<br>
>>>>>> );<br>
>>>>>> end<br>
>>>>>><br>
>>>>>> rule "Rule3"<br>
>>>>>> ?? dialect "mvel"<br>
>>>>>> ? ?? when<br>
>>>>>> ? ? ?? ad : ApplicationData( $age : age != null , age != "" , age <0<br>
>>>>>> ||<br>
>>>>>>><br>
>>>>>> 600, minIssrdAge == "Years" )<br>
>>>>>> ? ?? then<br>
>>>>>> ? ? ?? ad.setReturnMsg( "\nage is out of the range(i.e. ?< 0 and ><br>
>>>>>> 600)"<br>
>>>>>> );<br>
>>>>>> end<br>
>>>>>><br>
>>>>>> On 13 April 2011 17:19, Benson Fung <<a href="mailto:benson.redhat@gmail.com">benson.redhat@gmail.com</a>> wrote:<br>
>>>>>>><br>
>>>>>>> Hi,<br>
>>>>>>><br>
>>>>>>> Here is the scenario :<br>
>>>>>>><br>
>>>>>>> If there are 2 edit boxes and 2 dropdown list at the frontend like.<br>
>>>>>>><br>
>>>>>>><br>
>>>>>>> dropdown(minIssrdAge1) ? editbox(age1)<br>
>>>>>>> dropdown(minIssrdAge2) ? editbox(age2)<br>
>>>>>>><br>
>>>>>>> everytime when I lost focus the editbox(age1 or age2), ?the<br>
>>>>>>> editbox(age1 or age2) value will be validated against the following<br>
>>>>>>> rules.<br>
>>>>>>> i.e. ?minIssrdAge1 and age1 will be validated together if lost focus<br>
>>>>>>> the editbox age1.<br>
>>>>>>> ? ? ? minIssrdAge2 and age2 will be validated together if lost focus<br>
>>>>>>> the editbox age2<br>
>>>>>>><br>
>>>>>>> Rule1 is mandatory because both editbox are required field.<br>
>>>>>>> However, editbox(age1) is only valid within the 0 and 100. ?and<br>
>>>>>>> editbox(age2) is only valid within 0 and 600.<br>
>>>>>>><br>
>>>>>>> In other words, editbox(age1) have to be validated against Rule1 +<br>
>>>>>>> Rule2. ?However, editbox(age2) have to validated against Rule1 +<br>
>>>>>>> Rule3.<br>
>>>>>>><br>
>>>>>>> My question, how to design the rule attribute or at the java program<br>
>>>>>>> side so that different editbox can be validated against different<br>
>>>>>>> rule.<br>
>>>>>>><br>
>>>>>>> Please help. ?I can't find any solution by now.<br>
>>>>>>><br>
>>>>>>> rule "Rule1"<br>
>>>>>>> ? ? ? ?salience 1<br>
>>>>>>> ? ? ? ?dialect "mvel"<br>
>>>>>>> ? ? ? ?when<br>
>>>>>>> ? ? ? ? ? ? ? ?ad : ApplicationData( age == "" || ( ?== null ))<br>
>>>>>>> ? ? ? ?then<br>
>>>>>>> ? ? ? ? ? ? ? ?ad.setReturnMsg( "\n age should not be null or empty"<br>
>>>>>>> );<br>
>>>>>>> end<br>
>>>>>>><br>
>>>>>>><br>
>>>>>>> rule "Rule2"<br>
>>>>>>> ? ? ? ?dialect "mvel"<br>
>>>>>>> ? ? ? ?when<br>
>>>>>>> ? ? ? ? ? ? ? ?ad : ApplicationData( $age : age != null , age != ""<br>
>>>>>>> ,<br>
>>>>>>> minIssrdAge<br>
>>>>>>> == "Years" )<br>
>>>>>>> ? ? ? ? ? ? ? ?eval(Integer.parseInt($age) < 0) or<br>
>>>>>>> eval(Integer.parseInt($age) > 100)<br>
>>>>>>> ? ? ? ?then<br>
>>>>>>> ? ? ? ? ? ? ? ?ad.setReturnMsg( "\nage is out of the range(i.e. ?< 0<br>
>>>>>>> and ><br>
>>>>>>> 100)" );<br>
>>>>>>> end<br>
>>>>>>><br>
>>>>>>> rule "Rule3"<br>
>>>>>>> ? ? ? ?dialect "mvel"<br>
>>>>>>> ? ? ? ?when<br>
>>>>>>> ? ? ? ? ? ? ? ?ad : ApplicationData( $age : age != null , age != ""<br>
>>>>>>> ,<br>
>>>>>>> minIssrdAge<br>
>>>>>>> == "Years" )<br>
>>>>>>> ? ? ? ? ? ? ? ?eval(Integer.parseInt($age) < 0) or<br>
>>>>>>> eval(Integer.parseInt($age) > 600)<br>
>>>>>>> ? ? ? ?then<br>
>>>>>>> ? ? ? ? ? ? ? ?ad.setReturnMsg( "\nage is out of the range(i.e. ?< 0<br>
>>>>>>> and ><br>
>>>>>>> 600)" );<br>
>>>>>>> end<br>
>>>>>>> _______________________________________________<br>
>>>>>>> rules-users mailing list<br>
>>>>>>> <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
>>>>>>> <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
>>>>>><br>
>>>>>><br>
>>>>>> _______________________________________________<br>
>>>>>> rules-users mailing list<br>
>>>>>> <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
>>>>>> <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
>>>>>><br>
>>>>>><br>
>>>>><br>
>>>>> _______________________________________________<br>
>>>>> rules-users mailing list<br>
>>>>> <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
>>>>> <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
>>>><br>
>>>><br>
>>>> _______________________________________________<br>
>>>> rules-users mailing list<br>
>>>> <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
>>>> <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
>>>><br>
>>>><br>
>>><br>
>>> _______________________________________________<br>
>>> rules-users mailing list<br>
>>> <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
>>> <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
>><br>
>><br>
>> _______________________________________________<br>
>> rules-users mailing list<br>
>> <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
>> <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
>><br>
>><br>
><br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</div></div></blockquote></div><br>