[rules-users] Drools Queries with relation to the LHS and RHS syntax of the rule

Wolfgang Laun wolfgang.laun at gmail.com
Thu Aug 11 03:45:17 EDT 2011


There was an almost identical posting not long ago...

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.

Providing an object to collect results is one reasonable way of doing it.

But the syntax of modify is incorrect. This would be correct:
    modify ($projRes) {  setResult("Drools project")  }

Most likely, this rule will loop. Either check that field "result" in
$projRes is still unset or use rule attribute no-loop true.

-W



On 11 August 2011 00:15, Dibya <dibya.tcs at gmail.com> wrote:

> I have the below two requirement for Drools implementation.
>
> 1. To use a java method(with single argument) of my application class in
> the
> 'LHS' of the rule .
> 2. To pass the object set in 'RHS' of the rule back to my application.
>
> Is it possible to implement point 1 and point 2 as below ?
>
> Example :
>
> Application class is defined as :
>
> //Class for getting various types from my application
>
> package application.custom;
>
> public class Project
> {
>    public string getStringValue(String name) {
>                <Logic of the application>
>                return ;
>        }
> }
>
> //Class 2 for setting the rule result
>
> package application.customresults;
>
> public class ProjectResults
> {
>    public void setResult(String name) {
>                <Logic of the application>
>
>        }}
>
> ===========================================================================
> Drl file like :
>
> package application.rules
>
> #I shall set the object 'projRes'  in my appl using setGlobal
> global application.customresults.ProjectResults  projRes ;
>
> import application.custom.Project;
>
> rule "project-1.option1"
>
> when
>
> $proj : application.custom.Project();
>
> eval ($proj.getStringValue("Drools") .equals ("ABC")) # Logic specific to
> my
> application
>
> then
> #Requirement is to set and make use of the object 'projRes' in my
> application
>
> modify (projRes) {projRes.setResult("Drools project");  }
> end
>
> rule "project-1.option2"
>
> when
>
> $proj : application.custom.Project();
> $projRes : application.customresults.ProjectResults();
>
> eval ($proj.getStringValue("Java") .equals ("DEF")) # Logic specific to my
> application
>
> then
> #Requirement is to set and make use of the object 'projRes' in my
> application
>
> modify (projRes) {projRes.setResult("Java project");
>  }
> end
>
>
> Please let me know if the above way of writing the drl would suffice both
> the requirements (or) is there a better way to implement it.
>
> Thanks
> Dibya
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Drools-Queries-with-relation-to-the-LHS-and-RHS-syntax-of-the-rule-tp3244097p3244097.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20110811/d37b5e04/attachment.html 


More information about the rules-users mailing list