<div>is there any restriction in terms of using custom function in condition etc. </div>
<div>If I add function evaluation to conditions its messing up with dsl. For pattern matching if I use custom function defined in drl then its not able to parse that properly</div>
<div> </div>
<div>[when][] {attr:\S+} follows pattern {pattern:\S+} = funcToEvalPattern({attr},( {pattern} )<br></div>
<div>in this case it is getting translated to </div>
<div>exists(Person:Person(subordinate != null <font size="2">, funcToEvalPattern( </font><b><font color="#960000" size="2"><font color="#960000" size="2">eval</font></font></b><font size="2">( name, </font><font color="#008000" size="2"><font color="#008000" size="2">"I"</font></font><font size="2"> ) ) )</font></div>
<div>where as I was hoping this to be
<div>exists(Person:Person(subordinate != null <font size="2">, <strong><font color="#960000">eval </font></strong>(funcToEvalPattern</font><font size="2">( name, </font><font color="#008000" size="2"><font color="#008000" size="2">"I"</font></font><font size="2"> ) ) )</font></div>
</div>
<div><br>Regards,</div>
<div>-Maverik</div>
<div> </div>
<div class="gmail_quote">On Tue, Jan 4, 2011 at 12:24 PM, maverik j <span dir="ltr"><<a href="mailto:maverikj348@gmail.com">maverikj348@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div>cool...this was of great help, I will try this out I think it shoudl solve the purpose.</div>
<div> </div>
<div>Thanks once again,</div>
<div>Maverik <br><br></div>
<div class="gmail_quote">2011/1/3 Wolfgang Laun <span dir="ltr"><<a href="mailto:wolfgang.laun@gmail.com" target="_blank">wolfgang.laun@gmail.com</a>></span>
<div>
<div></div>
<div class="h5"><br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Try using eval as a last resort. A better (smaller, more robust) DSL can be designed around facts and their attributes.<br>
<br>"||" (and "OR") can be used, but setting parentheses in order to get the priority right is difficult. In constraints, you may have to resort to "memberof" or "not memberof".<br>
<br>Your sample isn'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 = &&<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+}'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 "Rule 5"<br>when<br> There is a Department<br> There is at least one Person<br>
- with name not equal to "xxx"<br> - with a valid subordinate <br> - check that the Person's Id is valid AND the Department's Id follows pattern "I" AND the Department's HeadOfDpt not equal name<br>
then<br>end<br><br>Notice that "-check that..." 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"><<a href="mailto:maverikj348@gmail.com" target="_blank">maverikj348@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">
<div>
<div></div>
<div>
<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}= && {<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 "xxx"<br> && the attribute subOrdinate is not null<br> && eval(<br> the attribute $dept.getId() is not null <br> && attribute $dept.getId() follows pattern "I" <br>
&& ( ! (the attribute $dept.getHeadOfDpt() equals name)<br> )<br>)</div>
<div> </div>
<div>I am not sure if this is possible with DSL. Using '-' operator we cannot really add '&&', '||' conditions it by-default expands to ',' 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 & Regards,</div>
<div>-Maverik</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></div></div><br></blockquote></div><br>