Try using eval as a last resort. A better (smaller, more robust) DSL can be designed around facts and their attributes.<br><br>&quot;||&quot; (and &quot;OR&quot;) can be used, but setting parentheses in order to get the priority right is difficult. In constraints, you may have to resort to &quot;memberof&quot; or &quot;not memberof&quot;.<br>
<br>Your sample isn&#39;t self-contained. But I think that the following DSL and the DSLR might give you some ideas how to proceed.<br><br>[keyword][]check that {conditions}= eval( {conditions} )<br>[keyword][]AND = &amp;&amp;<br>
[keyword][]OR  = ||<br><br>[when][][Tt]here is an? {entity}= {entity}: {entity}()<br>[when][][Tt]here is at least one {entity}= exists {entity}: {entity}()<br><br>[when][]the {entity:\w+}&#39;s {attr:\w+} = {entity}.get{attr}()<br>
<br>[when][]- with a valid {attr} = {attr}: {attr} != null<br>[when][]- with {attr} not equal to {value} = {attr} != {value}<br>[when][]- eval\( {whatever} \)=eval( {whatever} )<br><br>[when][] {attr:\S+} follows pattern {pattern:\S+} =  {attr}.matches( {pattern} )<br>
[when][] {attr:\S+} not equals? {value:\S+} = ! {attr}.equals( {value} )<br>[when][] {attr:\S+} is valid  =  {attr} != null<br> <br>rule &quot;Rule 5&quot;<br>when<br>    There is a Department<br>    There is at least one Person<br>
    - with name not equal to &quot;xxx&quot;<br>    - with a valid subordinate <br>    - check that the Person&#39;s Id is valid AND the Department&#39;s Id follows pattern &quot;I&quot; AND the Department&#39;s HeadOfDpt not equal name<br>
then<br>end<br><br>Notice that &quot;-check that...&quot; must be written as a single line.<br><br>-W<br><br><br><br><br><div class="gmail_quote">2011/1/3 maverik j <span dir="ltr">&lt;<a href="mailto:maverikj348@gmail.com">maverikj348@gmail.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div>Hi,</div>
<div> </div>
<div> We are planning to use DSL/DSRL approach with generic DSL template like say</div>
<div><font size="2">
<p align="left">[condition][]The {object} has valid {field}={object}({field} != null )</p>
<p align="left">[condition][]there is object {<u>obj</u>} that = {<u>obj</u>}()</p>
<p align="left">[condition][]- has {<u>attr</u>} equal {<u>val</u>} = {<u>attr</u>} == {<u>val</u>}</p>
<p align="left">[condition][]- has valid {<u>attr</u>} = {<u>attr</u>} != null</p>
<p>[condition][]- and has {<u>attr</u>} equal {value}= &amp;&amp; {<u>attr</u>} == {value}</p></font></div>
<div> </div>
<div>But there are quite few of requirements like to have DSL rules that can generate expression as follows:</div>
<div>exists Employee(<br>   attribute name not equals &quot;xxx&quot;<br>   &amp;&amp; the attribute subOrdinate is not null<br>   &amp;&amp; eval(<br>   the attribute $dept.getId() is not null   <br>   &amp;&amp; attribute $dept.getId() follows pattern &quot;I&quot; <br>

   &amp;&amp; ( ! (the attribute $dept.getHeadOfDpt() equals name)<br>   )<br>)</div>
<div> </div>
<div>I am not sure if this is possible with DSL. Using &#39;-&#39; operator we cannot really add &#39;&amp;&amp;&#39;, &#39;||&#39; conditions it by-default expands to &#39;,&#39; separated and conditions. And wirtting generic rules with and/or is not really dynamic to allow any number of expressions in evaluation.</div>


<div> </div>
<div>i am struggling to get this run since long time so any help/thoughts on this would be  highly appriciable !!!</div>
<div> </div>
<div>Thanks &amp; Regards,</div>
<div>-Maverik</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>