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