<br>&nbsp;&nbsp; Another option is to use &#39;from&#39;. I didn&#39;t tested that, but it should work fine in trunk.<br><br>There is a Person<br>Whose address areaCode equals &#39;415&#39;<br><br>&nbsp;&nbsp;&nbsp; Would be mapped to:<br><br>when
<br>&nbsp; p: Person()<br>&nbsp; a: Address( areaCode == &#39;415&#39; ) from p.addresses<br>then<br>&nbsp; ...<br>end<br><br>&nbsp;&nbsp;&nbsp; Note that the kind of flexibility you are trying to achieve is not simple by nature do to in a template engine (like DSL). 
<br><br>&nbsp;&nbsp;&nbsp; Good luck and let us know plz how it goes.<br><br>&nbsp;&nbsp;&nbsp; Regards,<br>&nbsp;&nbsp;&nbsp;&nbsp; Edson<br><br><div><span class="gmail_quote">2007/6/29, Michael Neale &lt;<a href="mailto:michael.neale@gmail.com">michael.neale@gmail.com</a>
&gt;:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi Matt. <br><br>yeah mapping deep hierarchies in a way that anyone can understand is not that easy. You can have helper methods on your objects to give you functionality. eg if you don&#39;t care which address you are talking about, then you could do something like:
<br><br>Person ( .... , (hasAddress(&quot;blah&quot;)) )<br><br>assuming there is a hasAddress method on Person - which then iterates through for you. Or you have a function to do it for you. <br><br>You can do things like
<br><br>There is a Person<br>&nbsp; - has an address of &#39;blah&#39;<br><br>where -has an address of &#39;{blah}&#39;==(checkAddress(this, &quot;{blah}&quot;) )<br>that will use a function checkAddress, and apply it to the fact (which is the Person). So you can span lines that way rather then coming up with combinations. 
<div><span class="e" id="q_113766a4baf741c0_1"><br><br><br><br><br><div><span class="gmail_quote">On 6/26/07, <b class="gmail_sendername">Matt Geis</b> &lt;<a href="mailto:mgeis@yahoo.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
mgeis@yahoo.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br>I&#39;m encountering some conceptual issues trying to get something done with JBossRules.<br><br>What I&#39;d like to do is to create a DSL that allows our non-technical users to have some very flexible options for accessing nested properties in an object.
<br><br>Ideally I&#39;d like to allow them to....<br><br>1.&nbsp;&nbsp;Access certain cryptically named properties by easy-to-understand aliases.<br>2.&nbsp;&nbsp;Use boolean operators such as and/or<br>3.&nbsp;&nbsp;Use comparators such as ==, &gt;, &lt;, etc.
<br>4.&nbsp;&nbsp;Use the above in nested clauses (see below).<br><br>For example, take a Person, which has the following properties...<br><br>String name<br>Date birthdate<br>Address[] addresses<br>Phone[] phones<br><br>Address has the following properties:
<br>String street, city, state, zip;<br><br>Phone has...<br>String areaCode, exchange, line:<br><br>Most frequently, the rules will operate to find out if a given object<br>in a nested collection meets certain property criteria, and if so, to
<br>identify the first object that does and call out that fact in the THEN<br>clause of the rule.<br><br>Here&#39;s a sample use case.&nbsp;&nbsp;If the user has one or more phones with an area code of &quot;415&quot;, print &quot;San Francisco&quot;.
<br><br>Pseudo-code...<br><br>rule<br>&nbsp;&nbsp;&nbsp;&nbsp;when<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;There is a person with a phone with area code equals &#39;415&#39;<br>&nbsp;&nbsp;&nbsp;&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Output &quot;San Francisco&quot;<br>end<br><br>So, &quot;there is a person&quot; clearly equates to something like p:Person()...
<br><br>but where I&#39;m getting stuck is the rest of it.&nbsp;&nbsp;I dont&#39; want to come up with ALL possible permutations of the object&#39;s properties, so having<br>something like p:Person(phone[0].areaCode == &#39;415&#39;) is not an option.&nbsp;&nbsp;Not only does it fail to address ALL the phones, it&#39;s hard-coded.
<br><br>I couldn&#39;t find any documentation on using the &#39;contains&#39; operator for anything other than Collections of Strings ($shop.cheeses contains &#39;stilton&#39;).&nbsp;&nbsp;I could imagine something like...<br><br>
in DRL: p:Person(phones contains 
phone.areaCode == &#39;415&#39;)&nbsp;&nbsp;(yes, very pseudocode, I know)<br><br>Other thoughts I&#39;ve had, but I have no experience with them, are whether MVEL projections or accumulator functions would be of use.&nbsp;&nbsp;I could see ways where I could find out if a nested item met certain criteria (project all area codes for phones into a collection, then see if that collection &#39;contains&#39; the desired value, or use an accumulator function to examine all objects and capture the index of the first one that matches).&nbsp;&nbsp;Although that might work (as I said, not sure here), I&#39;m still not seeing how to do this and still keep the end user flexibility I&#39;m hoping for.
<br><br>I&#39;d like to have a list of names, like &#39;area code&#39;&nbsp;&nbsp;maps to &#39;areaCode&#39; and &#39;street address&#39; maps to &#39;street&#39;, and the user could plug them in on their own, so they could just as easily also write (with no changes to the DSL)...
<br><br>There is a person with an address with state equals &#39;MA&#39;<br><br>I&#39;ve thought about somehow using an eval() call, but I can&#39;t capture the entire criteria string and pass it to a function in a global helper (the DSL doesn&#39;t expand it, and just sends the String literal &quot;{criteria}&quot;
<br>Even if that did work, I don&#39;t like the idea of circumventing the declarative nature of the rules language.<br><br>I&#39;d LOVE to be able to express this all in one rule, as it&#39;s business users who will be working with the DSL.&nbsp;&nbsp;If it were programmers, I&#39;d probably be ok with asking them to assert the Phone[], and have some other rule act on that, but I don&#39;t think that will work for me.
<br><br>On a side note, is there documentation or examples anywhere for getting nested properties and using MVEL?<br><br>Any help and suggestions greatly appreciated.<br><br>Thanks,<br>Matt<br><br><br><br><br><br>____________________________________________________________________________________Ready for the edge of your seat?
<br>Check out tonight&#39;s top picks on Yahoo! TV.<br><a href="http://tv.yahoo.com/" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://tv.yahoo.com/</a><br>_______________________________________________
<br>rules-users mailing list<br><a href="mailto:rules-users@lists.jboss.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
rules-users@lists.jboss.org</a><br><a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">https://lists.jboss.org/mailman/listinfo/rules-users
</a><br></blockquote></div><br>
</span></div><br>_______________________________________________<br>rules-users mailing list<br><a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org
</a><br><a onclick="return top.js.OpenExtLink(window,event,this)" 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>&nbsp;&nbsp;Edson Tirelli<br>&nbsp;&nbsp;Software Engineer - JBoss Rules Core Developer<br>&nbsp;&nbsp;Office: +55 11 3529-6000<br>&nbsp;&nbsp;Mobile: +55 11 9287-5646<br>&nbsp;&nbsp;JBoss, a division of Red Hat @ <a href="http://www.jboss.com">
www.jboss.com</a>