I suspect you're looking for something a bit like this:
$p : Person( $degrees : degrees )
$d : Degree( name in ("phd", "ms", "jd", "md") )
from $degrees
… apologies for any syntax errors - I haven't tested it. ;)
On 24 Mar 2013, at 21:13, lamenramen <lamenramen(a)gmail.com> wrote:
Hi,
I have read around for an entire day but still can not figure out how to
write the following in DRL syntax:
"When a person has a an advanced degree, print 'person is educated'"
A person has many degrees. So, I have a Person POJO and a Degree POJO.
A Person object has a field callled "degrees", which is nothing more than an
ArrayList<Degree>.
A degree has nothing but a name field, which is a String.
In regular java, it would be:
for (Degree d : person.getDegrees() {
if (d == "phd" || d == "ms" || d == "jd" || d ==
"md") {
System.out.println("person is highly educated");
}
}
I can not do this in the Guvnor either.
I've tried using a contains keyword but I just can't my rule to fire.
Simple rules otherwise fire just fine ,so my plumbing is all wired up
correctly.
--
View this message in context:
http://drools.46999.n3.nabble.com/Example-code-to-test-an-object-that-con...
Sent from the Drools: User forum mailing list archive at
Nabble.com.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users