use word boundaries, i.e. \b to denote "words"<br><br>\bassistant\b <br><br><div class="gmail_quote">On Wed, Mar 4, 2009 at 5:56 AM, D1vy@@Ind1@ <span dir="ltr"><<a href="mailto:divya.rajendranath@gmail.com">divya.rajendranath@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;"><br>
Thanks every one, I found a solution to this. I created an utility class used<br>
it in setGlobal of the drools session. Thus, I could call even non static<br>
methods from the utility class.<br>
<br>
Could any one help me with regular expressions in Drools.<br>
<br>
I want to check the existance of any one of the keywords 'assistant',<br>
'temp', 'intern' in a position field of an object. To be more clear I wanted<br>
to get the correct match if these keywords exist as a subword of its own and<br>
not as a part of a word. For eg., intern exists in internship and Systems :<br>
Intern, here I should get a successful match only for the second one. How<br>
can I achieve that ?<br>
<br>
My sampl drl file looks like:<br>
<br>
rule "Form the "<br>
salience 20<br>
no-loop true<br>
when<br>
$s:Form(details.position matches "^.*[_-:/](assistant|intern|temp)$");<br>
then<br>
<br>
$s.setRecipients((ArrayList)utilities.toArrayList((String)myRecipientsMap.get("Recipients")));<br>
update($s);<br>
end<br>
<br>
If would be very helpful if anyone could help me solve this.<br>
<br>
thanks<br>
-D<br>
<br>
<br>
<br>
<br>
<br>
D1vy@@Ind1@ wrote:<br>
><br>
> I have still not found a solution to the problem.<br>
><br>
> The problem is that I have a non static function in my service class and i<br>
> have to call thhat from my drools rule file.<br>
><br>
> The function basically accepts a mail id and if a mailing list returns an<br>
> arraylist of the individual mail ids in the mailing list.<br>
><br>
> my drl file looks like this:<br>
><br>
> ========================================================<br>
> package com.test.ams.rule<br>
><br>
> dialect "java"<br>
><br>
> import java.util.ArrayList;<br>
> import org.json.JSONArray;<br>
> import java.net.HttpURLConnection;<br>
> import java.net.URL;<br>
> import java.io.InputStream;<br>
> import java.io.InputStreamReader;<br>
> import java.io.BufferedReader;<br>
><br>
> import com.test.domobjects.StaffingForm;<br>
> import com.test.domobjects.StaffingFormOfferDetails;<br>
> import com.test.domobjects.OfferResponseType;<br>
> import function<br>
> com.test.serviceImpl.StaffingFormMailingServiceImpl.expandTheMailingList;<br>
><br>
> global java.util.HashMap myOSFRecipientsMap;<br>
><br>
> rule "Part A"<br>
> salience 20<br>
> no-loop true<br>
> when<br>
> $s:StaffingForm(staffingFormOfferDetails.offerValue== true &&<br>
> staffingFormOfferDetails.offerResponseType.offerResponseTypeName ==<br>
> "Accepted")<br>
> then<br>
><br>
> $s.setPartARecipients((ArrayList<String>)expandTheMailingList((String)myOSFRecipientsMap.get("PART_A_EXEC_COMMITTEE")));<br>
><br>
> $s.setPartARecipients((String)myOSFRecipientsMap.get("PART_A_CONFIDENTIAL"));<br>
> $s.setPartARecipients((String)myOSFRecipientsMap.get("PART_A_PAYROLL"));<br>
> update($s);<br>
> end<br>
> ========================================================<br>
><br>
><br>
> This gives me an exception -- java.lang.RuntimeException: Unable to<br>
> compile "the.drl".<br>
><br>
> Please let me know what is the problem here.<br>
><br>
><br>
> Thanks<br>
> -D<br>
><br>
><br>
><br>
> D1vy@@Ind1@ wrote:<br>
>><br>
>> A couple of more questions,<br>
>><br>
>> I am calling my rules engine from a service and into the session i am<br>
>> inserting the business object.<br>
>><br>
>> In my service class, I have a few helper functions, which I need to call<br>
>> from my drl file.<br>
>><br>
>> How can I do that ?<br>
>><br>
>> Thanks<br>
>> -D<br>
>><br>
>><br>
>><br>
>> Corneil du Plessis wrote:<br>
>>><br>
>>> You should initialise your globals and then pass them into the session.<br>
>>> Your rule file will have:<br>
>>><br>
>>> global java.lang.String recipients<br>
>>> global java.lang.String to<br>
>>> global java.lang.String cc<br>
>>><br>
>>><br>
>>> On Mon, 2009-02-23 at 06:23 -0800, D1vy@@Ind1@ wrote:<br>
>>><br>
>>>> Thanks for your help , Sudhir,<br>
>>>><br>
>>>> I used<br>
>>>><br>
>>>> rule<br>
>>>> when $a:A(b.z.s=="test");<br>
>>>> then<br>
>>>> end<br>
>>>><br>
>>>> And that solved my problem.<br>
>>>><br>
>>>> But I would like to know one more information about global variables.<br>
>>>><br>
>>>> package...<br>
>>>> dialect java<br>
>>>> import ..,<br>
>>>><br>
>>>> global java.lang.String recipients="<a href="mailto:divya@gmail.com">divya@gmail.com</a>"<br>
>>>> global java.lang.String to="<a href="mailto:xyz@yahoo.com">xyz@yahoo.com</a>"<br>
>>>> global java.lang.String cc="<a href="mailto:abc@gmail.com">abc@gmail.com</a>"<br>
>>>><br>
>>>> rule<br>
>>>> when when $a:A(b.z.s=="divya");<br>
>>>> then<br>
>>>> $a.setRecipients(recipients);<br>
>>>> $a.setTo(to);<br>
>>>> $a.setCC(cc);<br>
>>>> update($a)<br>
>>>> end<br>
>>>><br>
>>>> Is this feasible with Drools. I get<br>
>>>><br>
>>>> unable to comile myfile.drl file<br>
>>>> [9,40]: unknown:9:40 mismatched token: [@49,201:201='=',<71>,9:40];<br>
>>>> E<br>
>>>><br>
>>>> exception. Could you please help me with this too.<br>
>>>><br>
>>>><br>
>>>> Thanks<br>
>>>> -D<br>
>>>><br>
>>>><br>
>>>><br>
>>>><br>
>>>><br>
>>>><br>
>>>><br>
>>>><br>
>>>> Sudhir M-2 wrote:<br>
>>>> ><br>
>>>> > Hi D,<br>
>>>> > I don't know which version of drools are you using. If u are using<br>
>>>> drools<br>
>>>> > 4<br>
>>>> > or higher you can use 'from' to write rules on nested objects. All u<br>
>>>> need<br>
>>>> > to do is insert the root pbject in the working memory<br>
>>>> ><br>
>>>> > Regards,<br>
>>>> > sudhir.<br>
>>>> ><br>
>>>> > On Mon, Feb 23, 2009 at 2:56 PM, Divya Rajendranath <<br>
>>>> > <a href="mailto:divya.rajendranath@gmail.com">divya.rajendranath@gmail.com</a>> wrote:<br>
>>>> ><br>
>>>> >> Hi,<br>
>>>> >><br>
>>>> >> I am planning to use Drools - JBoss Rules Engine. My requirement is<br>
>>>> to<br>
>>>> >> disburse mails from my application to different groups based on<br>
>>>> various<br>
>>>> >> criteria. I want to use Drools here.<br>
>>>> >><br>
>>>> >> My object structure is as follows:<br>
>>>> >><br>
>>>> >> class A{<br>
>>>> >><br>
>>>> >> String B = "";<br>
>>>> >><br>
>>>> >> B b;<br>
>>>> >><br>
>>>> >> C c;<br>
>>>> >> }<br>
>>>> >><br>
>>>> >> Hence Obj A has embedded objects within it, and obj B and C further<br>
>>>> has<br>
>>>> >> embedded objects.<br>
>>>> >><br>
>>>> >> class B {<br>
>>>> >><br>
>>>> >> String X;<br>
>>>> >><br>
>>>> >> Z z;<br>
>>>> >><br>
>>>> >> }<br>
>>>> >><br>
>>>> >> class Z{<br>
>>>> >><br>
>>>> >> String t;<br>
>>>> >><br>
>>>> >> String s;<br>
>>>> >><br>
>>>> >> }<br>
>>>> >><br>
>>>> >> The decision on sending the mails based on the fields in embedded<br>
>>>> objects<br>
>>>> >> of A. I pass instance of A to Drools<br>
>>>> >><br>
>>>> >> Format of drl file:<br>
>>>> >><br>
>>>> >> package...;<br>
>>>> >><br>
>>>> >> import ..;<br>
>>>> >><br>
>>>> >> rule "Test"<br>
>>>> >><br>
>>>> >> when $a:A(B(Z(s == "testvalue")))<br>
>>>> >><br>
>>>> >> then<br>
>>>> >><br>
>>>> >> $a.setSomething();<br>
>>>> >><br>
>>>> >> update($a);<br>
>>>> >><br>
>>>> >> end<br>
>>>> >><br>
>>>> >> I wanted to know if this (accessing fields in embedded/child object)<br>
>>>> is<br>
>>>> >> feasible with Drools.<br>
>>>> >><br>
>>>> >> I get an error saying "UNable to compile myfile.drl when i try to fo<br>
>>>> >> this.<br>
>>>> >><br>
>>>> >> Could some one look into this issue and let me know the reason for<br>
>>>> this ?<br>
>>>> >><br>
>>>> >><br>
>>>> >><br>
>>>> >> Thanks<br>
>>>> >><br>
>>>> >> -D<br>
>>>> >><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>
>>>> >><br>
>>>> >><br>
>>>> ><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>
>>>> ><br>
>>>> ><br>
>>>><br>
>>><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>
>>><br>
>>><br>
>><br>
>><br>
><br>
><br>
<font color="#888888"><br>
--<br>
View this message in context: <a href="http://www.nabble.com/Help-on-using-Drools-with-embedded-objects-tp22158087p22327495.html" target="_blank">http://www.nabble.com/Help-on-using-Drools-with-embedded-objects-tp22158087p22327495.html</a><br>
Sent from the drools - user mailing list archive at Nabble.com.<br>
<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>