<div dir="ltr">Obviously I can.<br>Thank you very much David for you motivation to help.<br><br><br>Here is the relevant set of rules as it&#39;s looks in My Drools3 .drl file: (Please see comments after the drl).<br><br>&quot;&quot;&quot;<br>
rule &quot;4&quot; // Campaign Age Range Groups<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; no-loop<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; when<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $f : FilteringStateConnector(connectorIndex == 4,<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $campaignId : campaignId, $subscriberId : subscriberId)<br>
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; eval ($f.getCampaign().getAgeRangeGroups().size() &gt; 0)<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $subscriber : DynaSubscriber(id == $subscriberId,<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; age != null, <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $subscriberAge : age<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; )<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; eval(com.ml.common.utils.BooleanLogging.trace(log,&nbsp; &quot;common.drl R:4 **** DynaSubscriber()&nbsp; &quot; + $subscriber))<br>
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // Locate age group(s) subscriber is categorized within.<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $ageGroup : AgeGroup(lowValue &lt;= $subscriberAge, highValue &gt;= $subscriberAge, <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $ageGroupCode : code<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; )<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; eval(com.ml.common.utils.BooleanLogging.trace(log,&nbsp; &quot;common.drl R:4 ******** AgeGroup()&nbsp; &quot; + $ageGroup))<br>
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // Check if campaign contains this AgeRange Group.&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; DynaCampaign(<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; code == $campaignId,<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ageRangeGroups contains $ageGroupCode<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; )<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; eval(com.ml.common.utils.BooleanLogging.trace(log,&nbsp; &quot;common.drl R:4 AgeGroup verified for Subscriber: &quot; + $subscriberId + &quot; at Campaign: &quot; + $campaignId))<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; then<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $f.setPassedRuleRecord(&quot;4&quot;);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $f.setConnectorIndex(500);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; modify($f);<br>end<br><br>rule &quot;[XOR NO COUNTING RULE] 4&quot; // Campaign AgeGroup<br>
&nbsp;&nbsp;&nbsp; when<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $f : FilteringStateConnector(connectorIndex == 4,<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $campaignId : campaignId, $subscriberId : subscriberId)<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; eval ($f.getCampaign().getAgeRangeGroups().size() == 0)<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; eval(com.ml.common.utils.BooleanLogging.trace(log,&nbsp; &quot;common.drl R:4 AgeGroup NOT CHECKED for Subscriber: &quot; + $subscriberId + &quot; at Campaign: &quot; + $campaignId))<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; then<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $f.setPassedRuleRecord(&quot;4&quot;);<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $f.setConnectorIndex(500);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; modify($f);<br>end<br>&quot;&quot;&quot;<br><br>What I&#39;m trying to do with these 2 rules is check if I need to verify age ranges for subscriber, if so [rule &quot;4&quot;] is firing, I already know the campaign I&#39;m checking so I would like to first locate it, then fetch it&#39;s ageRangeGroups and only then check of each of the groups if it matches by it&#39;s ranges to the subscriber age range - 1 match is enough to stop the search.<br>
<br>What I&#39;m doing now is first location all the AgeGroup objects that match the subscriber and then check (for each) of the groups is it matches the campaign collection.<br><br>Please again note that I&#39;m using Drools 3, we&#39;re considering here Drools4 but for now It&#39;s hard core 3.<br>
<br><br>Thank you,<br>Maxim.<br><br><div class="gmail_quote">On Wed, Dec 31, 2008 at 7:05 PM, David Sinclair <span dir="ltr">&lt;<a href="mailto:dsinclair@chariotsolutions.com">dsinclair@chariotsolutions.com</a>&gt;</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;">I&#39;m not quite sure if I understand your question. Could you write out the rule(even pseudo-code if necessary), or the something as to try and clarify what you are trying doing? <br>
<div><div></div><div class="Wj3C7c"><br><div class="gmail_quote">On Wed, Dec 31, 2008 at 11:38 AM, Maxim Veksler <span dir="ltr">&lt;<a href="mailto:maxim.veksler@gmail.com" target="_blank">maxim.veksler@gmail.com</a>&gt;</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;"><div dir="ltr">Hello Again David / List,<br><br><br>I should have probably mentioned that I&#39;m working with Drools 3, I&#39;m not sure how or &quot;if&quot; this can be implemented in Drools 3 syntax. I&#39;ve tried to search Drools 3 documentation and googled for this. <br>


<br>Currently I&#39;m using contains with first finds the age groups then follows to find the matching Campaing but as I already know what campaign I&#39;m checking and my intention is to check if this campaign can accept this age group I would like to reverese the search order...<br>


<br>Ideas are very welcome.<br><br><br><br>Happy new year everyone !<br><br><br><br><br><div class="gmail_quote">On Sun, Dec 21, 2008 at 10:20 PM, David Sinclair <span dir="ltr">&lt;<a href="mailto:dsinclair@chariotsolutions.com" target="_blank">dsinclair@chariotsolutions.com</a>&gt;</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;">u almost had it. This should do it.<div><br>&nbsp;<br>Subscriber($age : age)<br>Campaign($campaignAgeRangs : listOfAgeRangeCodes)<br>




</div>
AgeRange(minAge &lt;= $age, max &gt;= $age, code memberOf $campaignAgeRangs)<br><br>As far as performance, i would think the former would be faster. This
one will look at all campaigns regardless if they have an AgeRange that
matches. The former just looks for an AgeRange, then joins back to the
Campaign.<br><br>dave<div><div></div><div><br><br><div class="gmail_quote">On Sun, Dec 21, 2008 at 2:18 PM, Maxim Veksler <span dir="ltr">&lt;<a href="mailto:maxim.veksler@gmail.com" target="_blank">maxim.veksler@gmail.com</a>&gt;</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;">
<div dir="ltr">Thank you very much for the fast and accurate reply David,<br><br><br>Is it also possible to use the opposite positioning?, something like:<br><br>Subscriber($age : age)<br>Campaign($campaignAgeRangs : listOfAgeRangeCodes)<br>






AgeRange(minAge &lt;= $age, max &gt;= $age, $campaignAgeRangs contains code)<br><br><br>Please don&#39;t try the above as this tries to create a field extractor for $campaignAgeRangs on the AgeRange object which fails for obvious reasons..<br>






<br>I would like to to filter first by Subscriber, then by Campaign and last by age range. This is obviously a simplification of the actual filtering rules.<div><div></div><div><br><br><br><div class="gmail_quote">
On Sun, Dec 21, 2008 at 7:28 PM, David Sinclair <span dir="ltr">&lt;<a href="mailto:dsinclair@chariotsolutions.com" target="_blank">dsinclair@chariotsolutions.com</a>&gt;</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;">Subscriber($age : age)<br>AgeRange(minAge &lt;= $age, max &gt;= $age, $code : code)<br>Campaign(listOfAgeRangeCodes contains $code)<br>






<br><div class="gmail_quote"><div><div></div><div>On Sun, Dec 21, 2008 at 12:17 PM, Maxim Veksler <span dir="ltr">&lt;<a href="mailto:maxim.veksler@gmail.com" target="_blank">maxim.veksler@gmail.com</a>&gt;</span> wrote:<br>







</div></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div><div dir="ltr">Hello,<br><br><br>The dataModel is as following:<br>






<br>class AgeRange() {<br>
Integer code;<br>int minAge;<br>int maxAge;<br>}<br><br>Campaign() {<br>List&lt;Integer&gt; listOfAgeRangeCodes;<br>}<br><br>Subscriber() {<br>
int age;<br>}<br><br>AgeRange()&#39;s and Campaign()&#39;s are pre-populated into the WM.<br>Subscriber() is asserted right before fireAllRules is called.<br><br>I need a rule that would allow me to check if Subscriber() is within one of the defined on the Campaign() AgeRange()&#39;s.<br>








<br>What would be the most efficient way to enforce this constraint? <br>The other possibility I see is to store the list of AgeRange()&#39;s in each Campaign() and then use eval() to iterate over the list...<br><br><br>







Advice and ideas are appreciated.<br>
<br><br>Thank you,<br>Maxim.<br>-- <br>Cheers, <br>Maxim Veksler<br><br>&quot;Free as in Freedom&quot; - Do u GNU ?<br>
</div>
<br></div></div>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">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></blockquote></div><br>
<br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">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></blockquote></div><br><br clear="all"><br>-- <br>Cheers, <br>Maxim Veksler<br><br>&quot;Free as in Freedom&quot; - Do u GNU ?<br>
</div></div></div>
<br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">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></blockquote></div><br>
</div></div><br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">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></blockquote></div><br><br clear="all"><br>-- <br>Cheers, <br>Maxim Veksler<br><br>&quot;Free as in Freedom&quot; - Do u GNU ?<br>
</div>
<br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">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></blockquote></div><br>
</div></div><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></blockquote></div><br><br clear="all"><br>-- <br>Cheers, <br>Maxim Veksler<br><br>&quot;Free as in Freedom&quot; - Do u GNU ?<br>
</div>