[rules-users] Calling a method in when part

Wolfgang Laun wolfgang.laun at gmail.com
Wed Aug 10 05:31:17 EDT 2011


If you don't show your code we can't tell you what is wrong with it. So I
think what you may have to do is

when
   $someObj: SomeClass()  # matches each WME of SomeClass
   eval( $someObj.getValueBoolean("abc"))
then

There is not much to be gained by using a DRL function; it would have to be
called like
   eval( someFunction( $someObj, "abc" ) )

-W


On 10 August 2011 11:05, Sumeet Karawal <sumeet.karawal at tcs.com> wrote:

>
> Hi,
>
> I have a requirement where there is a customized Java class having a method
> that returns some value.
> like:
>
> getValueBoolean("Some String")
>
> { //some calculation
>   // returns a boolean value
> }
>
> The default getters and setters are not being used in the Application. The
> value that is being returned by the method needs to be checked in the .drl
> file.
> There are different Java classes with these kind of methods. Where the
> string and integer value is also returned. I have gone through the
> documentation for Drools-Expert but have only found the implementation for
> the method in the consequence part, i.e., the then part.
>
> This is how I tried:
>
> importing the class
>
> in when
> binding the a variable to the Class name suppose $c
> eval ($c.getValueBoolean("abc"))
> then
> System.out.println("the value is true")
>
>
> It didn't work this way.
> I tried by another way like :
>
> creating a function in the .drl itself that calls the method of that class
> and returns a value
> then calling this drl function in the when part and carrying on.
>
> It would be very helpful if some body could let me know how to do this in
> the .drl.
>
>
> Thanks & Regards,
> Sumeet Karawal
> Mailto: sumeet.karawal at tcs.com
>
> =====-----=====-----=====
> Notice: The information contained in this e-mail
> message and/or attachments to it may contain
> confidential or privileged information. If you are
> not the intended recipient, any dissemination, use,
> review, distribution, printing or copying of the
> information contained in this e-mail message
> and/or attachments to it are strictly prohibited. If
> you have received this communication in error,
> please notify us by reply e-mail or telephone and
> immediately and permanently delete the message
> and any attachments. Thank you
>
>
>
> _______________________________________________
> 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/20110810/56543c92/attachment.html 


More information about the rules-users mailing list