There was an almost identical posting not long ago...<br><br>Repeating: As
you present this code, it doesn't make any sense. The condition is a
join of two objects, and all parameters are literals - very unlikely.<br>
<br>Providing an object to collect results is one reasonable way of doing it.<br><br>But the syntax of modify is incorrect. This would be correct:<br> modify ($projRes) { setResult("Drools project") }<br><br>
Most likely, this rule will loop. Either check that field "result" in $projRes is still unset or use rule attribute no-loop true.<br><br>-W<br><br><br><br><div class="gmail_quote">On 11 August 2011 00:15, Dibya <span dir="ltr"><<a href="mailto:dibya.tcs@gmail.com">dibya.tcs@gmail.com</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;">I have the below two requirement for Drools implementation.<br>
<br>
1. To use a java method(with single argument) of my application class in the<br>
'LHS' of the rule .<br>
2. To pass the object set in 'RHS' of the rule back to my application.<br>
<br>
Is it possible to implement point 1 and point 2 as below ?<br>
<br>
Example :<br>
<br>
Application class is defined as :<br>
<br>
//Class for getting various types from my application<br>
<br>
package application.custom;<br>
<br>
public class Project<br>
{<br>
public string getStringValue(String name) {<br>
<Logic of the application><br>
return ;<br>
}<br>
}<br>
<br>
//Class 2 for setting the rule result<br>
<br>
package application.customresults;<br>
<br>
public class ProjectResults<br>
{<br>
public void setResult(String name) {<br>
<Logic of the application><br>
<br>
}}<br>
<br>
===========================================================================<br>
Drl file like :<br>
<br>
package application.rules<br>
<br>
#I shall set the object 'projRes' in my appl using setGlobal<br>
global application.customresults.ProjectResults projRes ;<br>
<br>
import application.custom.Project;<br>
<br>
rule "project-1.option1"<br>
<br>
when<br>
<br>
$proj : application.custom.Project();<br>
<br>
eval ($proj.getStringValue("Drools") .equals ("ABC")) # Logic specific to my<br>
application<br>
<br>
then<br>
#Requirement is to set and make use of the object 'projRes' in my<br>
application<br>
<br>
modify (projRes) {projRes.setResult("Drools project"); }<br>
end<br>
<br>
rule "project-1.option2"<br>
<br>
when<br>
<br>
$proj : application.custom.Project();<br>
$projRes : application.customresults.ProjectResults();<br>
<br>
eval ($proj.getStringValue("Java") .equals ("DEF")) # Logic specific to my<br>
application<br>
<br>
then<br>
#Requirement is to set and make use of the object 'projRes' in my<br>
application<br>
<br>
modify (projRes) {projRes.setResult("Java project");<br>
}<br>
end<br>
<br>
<br>
Please let me know if the above way of writing the drl would suffice both<br>
the requirements (or) is there a better way to implement it.<br>
<br>
Thanks<br>
Dibya<br>
<font color="#888888"><br>
--<br>
View this message in context: <a href="http://drools.46999.n3.nabble.com/Drools-Queries-with-relation-to-the-LHS-and-RHS-syntax-of-the-rule-tp3244097p3244097.html" target="_blank">http://drools.46999.n3.nabble.com/Drools-Queries-with-relation-to-the-LHS-and-RHS-syntax-of-the-rule-tp3244097p3244097.html</a><br>
Sent from the Drools: User forum mailing list archive at Nabble.com.<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>
</font></blockquote></div><br>