<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.2180" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=467094722-29112007><FONT face=Arial size=2>Hello all,
</FONT></SPAN></DIV>
<DIV><SPAN class=467094722-29112007><FONT face=Arial
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=467094722-29112007><FONT face=Arial size=2>I am about a day old
to Drools. I have had success in executing the examples in a Windows, JDK1.6
environment. </FONT></SPAN></DIV>
<DIV><SPAN class=467094722-29112007><FONT face=Arial size=2>Based on the success
of the examples, I am trying to put together a sample usecase myself to
understand Drools. I write to you since I havent had much success in that.
</FONT></SPAN></DIV>
<DIV><SPAN class=467094722-29112007><FONT face=Arial size=2>My use case is:
</FONT></SPAN></DIV>
<DIV><SPAN class=467094722-29112007><FONT face=Arial size=2>1) Check the type of
person.</FONT></SPAN></DIV>
<DIV><SPAN class=467094722-29112007><FONT face=Arial size=2>2) If person is an
Employee, then print the Employee ID. </FONT></SPAN></DIV>
<DIV><SPAN class=467094722-29112007><FONT face=Arial size=2>3) If person is a
customer then print the customer first and last name.</FONT></SPAN></DIV>
<DIV><SPAN class=467094722-29112007><FONT face=Arial size=2>4) If the person is
an Employee and the employee id is missing, then throw an exception, so that the
calling API can handle the error.</FONT></SPAN></DIV>
<DIV><SPAN class=467094722-29112007><FONT face=Arial
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=467094722-29112007><FONT face=Arial size=2>To realize this, I
have three interfaces, IPerson, IEmployee extends IPerson and ICustomer extends
IPerson. </FONT></SPAN></DIV>
<DIV><SPAN class=467094722-29112007><FONT face=Arial size=2>IPerson has the
common attribute getters such as; getFirstName, getLastName</FONT></SPAN></DIV>
<DIV><SPAN class=467094722-29112007><FONT face=Arial size=2>IEmployee has the
getter getEmployeeId, while the ICustomer is only a marker interface (at the
moment). </FONT></SPAN></DIV>
<DIV><SPAN class=467094722-29112007><FONT face=Arial
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=467094722-29112007><FONT face=Arial size=2>The DRL file with
the rules contains: </FONT></SPAN></DIV>
<DIV><SPAN class=467094722-29112007><FONT face=Arial
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=467094722-29112007><FONT face=Arial size=2>rule "If no Employee
Number, then print error"<BR>&nbsp;dialect
"java"<BR>&nbsp;when<BR>&nbsp;&nbsp;IPerson( empNumber &lt;= -1
)<BR>&nbsp;then<BR>&nbsp;&nbsp;System.out.println( "Invalid Employee number"
);<BR>end</FONT></SPAN></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV><SPAN class=467094722-29112007>
<DIV><BR><FONT face=Arial size=2>rule "Rule to print the Employee
number"<BR>&nbsp;&nbsp;&nbsp; dialect
"mvel"<BR>&nbsp;when<BR>&nbsp;&nbsp;$person : IPerson( personType ==
IPerson.EMPLOYEE_PERSON_TYPE )<BR>&nbsp;then<BR>&nbsp;&nbsp;System.out.println(
"The Employee Number is "+$person.empNumber);<BR>end</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><BR><FONT face=Arial size=2>rule "Rule to print the first name and last
name if it is a Customer"<BR>&nbsp;&nbsp;&nbsp; dialect
"mvel"<BR>&nbsp;when<BR>&nbsp;&nbsp;$person : IPerson( personType ==
IPerson.CUSTOMER_PERSON_TYPE )<BR>&nbsp;then<BR>&nbsp;&nbsp;System.out.println(
"The Customers' name is "+$person.firstName+" "+$person.lastName
);<BR>end</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><SPAN class=467094722-29112007><FONT face=Arial size=2>The error I get for
the rule is:</FONT></SPAN></DIV>
<DIV><SPAN class=467094722-29112007><FONT face=Arial size=2>Unable to create
Field Extractor for 'empNumber' of '[ClassObjectType
class=com.drools.local.samples.model.IPerson]</FONT></SPAN></DIV>
<DIV><SPAN class=467094722-29112007><FONT face=Arial
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=467094722-29112007><FONT face=Arial size=2>The above error did
suggest that the IPerson doesnot expose any methods to retrieve the empNumber,
such as getEmpNumber. But then, when I do a $person.empNumber, it does print the
empNumber. Hence, the Drools framework must somehow be able to *auto-magically*
cast down the object. This is what is confusing me. </FONT></SPAN></DIV>
<DIV><SPAN class=467094722-29112007><FONT face=Arial
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=467094722-29112007><FONT face=Arial size=2>Could you advice if
my usecase is possible with Drools and if yes, then what am I missing? Is my
rules approach wrong? Also, if there a way to throw exceptions in the then
case?</FONT></SPAN></DIV>
<DIV><SPAN class=467094722-29112007><FONT face=Arial size=2>The JSR-94 provides
mechanism to get the results, is there a similar way in
Drools?</FONT></SPAN></DIV>
<DIV><SPAN class=467094722-29112007><FONT face=Arial
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=467094722-29112007><FONT face=Arial
size=2>Thanks.</FONT></SPAN></DIV>
<DIV><SPAN class=467094722-29112007><FONT face=Arial
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=467094722-29112007><FONT face=Arial
size=2>Cheers</FONT></SPAN></DIV>
<DIV><SPAN class=467094722-29112007><FONT face=Arial size=2>Gautham
Kasinath</FONT></SPAN></DIV>
<DIV><SPAN class=467094722-29112007><FONT face=Arial
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><FONT face=Arial size=2></FONT></SPAN>&nbsp;</DIV></BODY></HTML>

<table><tr><td bgcolor=#ffffff><font color=#000000>*******************************************************<br>
This email message and any attached files may contain <br>
information that is confidential and subject of legal <br>
privilege intended only for use by the individual or <br>
entity to whom they are addressed. If you are not the <br>
intended recipient or the person responsible for <br>
delivering the message to the intended recipient be <br>
advised that you have received this message in error <br>
and that any use, copying, circulation, forwarding, <br>
printing or publication of this message or attached <br>
files is strictly forbidden, as is the disclosure of <br>
the information contained therein. If you have received <br>
this message in error, please notify the sender <br>
immediately and delete it from your Inbox.<br>
*******************************************************<br>
</font></td></tr></table>