[rules-users] RE: rules-users Digest, Vol 6, Issue 49

Sikkandar Nawabjan Sikkandar.Nawabjan at ustri.com
Mon May 21 23:14:27 EDT 2007


Hi,
I beleive rule engine is a system which is used in Business Layer,and it is meant to validate the business rules in the application. The data accessing stuff arre related to data layer.
In your situation you cann use the DAO to access the databaseand read the particular employee details and VALIDATE through drools.
connecting drl file to database creating a model problem i guess.
any suggestions Edson?
Thanks and Regs,
Basha
 
 
 
 
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Hi

I am using Drools 3.0 in our business logic. I need help in the below situation
Right now i am done with writing .drl files.but the problem is that my rules should be read from the Database.

For example i have to write rule for a leave application.I am using Drools 3.0 and writing rules.In case if i want to know the joining date of a particular employee,i should be able to read that from the database.


Not only this case but should be able to connect the .drl file to the database and also should be able to prepare a decision table.


I request u to respond to my query as early as possible.Please understand the situation and do the needful



Thanks,
mary

________________________________

From: rules-users-bounces at lists.jboss.org on behalf of rules-users-request at lists.jboss.org
Sent: Mon 5/21/2007 11:18 PM
To: rules-users at lists.jboss.org
Subject: rules-users Digest, Vol 6, Issue 49



Send rules-users mailing list submissions to
        rules-users at lists.jboss.org

To subscribe or unsubscribe via the World Wide Web, visit
        https://lists.jboss.org/mailman/listinfo/rules-users
or, via email, send a message with subject or body 'help' to
        rules-users-request at lists.jboss.org

You can reach the person managing the list at
        rules-users-owner at lists.jboss.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of rules-users digest..."


Today's Topics:

   1. Re: using homemade Date in Drools (Maxime Catelin)
   2. Re: using homemade Date in Drools (Mark Proctor)
   3. Which rules are "passed" by object (Aeternitas)
   4. (no subject) (suma latha)


----------------------------------------------------------------------

Message: 1
Date: Mon, 21 May 2007 18:10:54 +0200
From: Maxime Catelin <mcatelin at perinfo.com>
Subject: Re: [rules-users] using homemade Date in Drools
To: Rules Users List <rules-users at lists.jboss.org>
Message-ID: <4651C48E.7000300 at perinfo.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Thank you all for your insights.  Your explanations are really helpful.

Regards.

>
>    Yes, Shahad's suggestion shall work, but answering your first
> question, a predicate would be like:
>
> rule XXX
> when
>    obj1 : A( $date1: mydate)
>    obj2 : A( $date2: mydate -> ( $date1.isBefore($date2) ) )
> then
>    // something
>    obj1.doSomething();
> End
>
>    Remember that predicates and evals use plain java code inside it.
>
>    []s
>    Edson
>
>
> 2007/5/21, Shahad Ahmed < shahad.ahmed2 at gmail.com
> <mailto:shahad.ahmed2 at gmail.com>>:
>
>     How about a slight modification on Mike's solution:
>     
>     rule XXX
>     when
>        obj1 : A( $date1: mydate)
>        obj2 : A( $date2: mydate)
>        eval($date1.isBefore($date2))
>     then
>        // something
>        obj1.doSomething();
>     End
>
>     I think eval allows you access to the methods in your custom Date
>     class so you can call isBefore in there after binding $date1 and
>     $date 2 to any custom date objects. I still new to Drools, so this
>     may not be correct.
>     
>     Regards
>     Shahad
>
>     
>     On 5/21/07, *Maxime Catelin* <mcatelin at perinfo.com
>     <mailto:mcatelin at perinfo.com>> wrote:
>
>         Thanks for your input. That seems to involve some
>         modifications,  on our
>         Date class and all the classes that have Date members.  That's
>         not
>         exactly what i thought of doing but maybe that's the only way.
>
>         What I meant was to to find a way to compare those dates
>         eventually
>         using the date methods we have (isAfter() or isBefore() for
>         exemple) and
>         to "keep" only the object with the latest date.  So if there
>         are several
>         A objects in the working memory, we will only fire the one
>         with the
>         latest date.
>
>         rule XXX
>
>         when
>            obj : A( $date : mydate)
>            not A( $date.isBefore(mydate)) // does not work but that
>         what i was thinking
>         then
>            // something
>            obj.doSomething();
>         end
>
>
>
>         Anstis, Michael (M.) a écrit :
>         > The simplest way could be to have your Date expose a "Time"
>         type member
>         > (like java.util.Date.getTime()) that represents the number of
>         > seconds\milliseconds etc since a given point in time ("your
>         absolute
>         > zero" for example; being day * month * year * H * M * s *
>         ms). This
>         > could then be used as a simple predicate condition:-
>         >
>         > rule XXX
>         > when
>         >     obj1 : A( $time : myTime)
>         >     obj2 : A( myTime < $time )
>         > then
>         >     // something
>         >     obj.doSomething();
>         > End
>         >
>         > Thanks,
>         >
>         > Mike
>         >
>         > -----Original Message-----
>         > From: rules-users-bounces at lists.jboss.org
>         <mailto:rules-users-bounces at lists.jboss.org>
>         > [mailto:rules-users-bounces at lists.jboss.org
>         <mailto:rules-users-bounces at lists.jboss.org> ] On Behalf Of
>         Maxime Catelin
>         > Sent: 21 May 2007 14:34
>         > To: Rules Users List
>         > Subject: [rules-users] using homemade Date in Drools
>         >
>         > Hi,
>         >
>         > We are using a lot of Dates in our application but we use a
>         homemade
>         > Date class for that.  Therefore, we cannot use > and <
>         provided by
>         > Drools.  I looked through the mailing list but could not find
>         any
>         > examples using Dates in Drools other than in the
>         documentation.  What
>         > interested me in particular in the documentation was "If more
>         control is
>         >
>         > required, use the predicate constraint."
>         >
>         > Could someone give some examples of using predicate
>         constraint with
>         > dates?
>         >
>         > Something I would like to do, for example, is the following :
>         >
>         > If there is an obj1 of class A with field of type Date d1 and
>         another
>         > obj2 of class A with field Date d2, where d1 is before d2,
>         obj2 should
>         > be used to fire something.
>         >
>         > rule XXX
>         > when
>         >     obj : A( $date : mydate)
>         >     // do not know how to use constraint on date here.
>         > then
>         >     // something
>         >     obj.doSomething();
>         > end
>         >
>         > Thanks for your input.
>         > _______________________________________________
>         > rules-users mailing list
>         > rules-users at lists.jboss.org <mailto:rules-users at lists.jboss.org>
>         > https://lists.jboss.org/mailman/listinfo/rules-users
>         <https://lists.jboss.org/mailman/listinfo/rules-users>
>         >
>         > _______________________________________________
>         > rules-users mailing list
>         > rules-users at lists.jboss.org <mailto:rules-users at lists.jboss.org>
>         > https://lists.jboss.org/mailman/listinfo/rules-users
>         <https://lists.jboss.org/mailman/listinfo/rules-users>
>         >
>         >
>         >
>         _______________________________________________
>         rules-users mailing list
>         rules-users at lists.jboss.org <mailto:rules-users at lists.jboss.org>
>         https://lists.jboss.org/mailman/listinfo/rules-users
>         <https://lists.jboss.org/mailman/listinfo/rules-users>
>
>
>
>     _______________________________________________
>     rules-users mailing list
>     rules-users at lists.jboss.org <mailto:rules-users at lists.jboss.org>
>     https://lists.jboss.org/mailman/listinfo/rules-users
>
>
>
>
> --
>   Edson Tirelli
>   Software Engineer - JBoss Rules Core Developer
>   Office: +55 11 3529-6000
>   Mobile: +55 11 9287-5646
>   JBoss, a division of Red Hat @ www.jboss.com <http://www.jboss.com>
> ------------------------------------------------------------------------
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>  
> ------------------------------------------------------------------------
>
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.467 / Virus Database: 269.7.6/813 - Release Date: 20/05/2007 07:54
>  


------------------------------

Message: 2
Date: Mon, 21 May 2007 17:24:34 +0100
From: Mark Proctor <mproctor at codehaus.org>
Subject: Re: [rules-users] using homemade Date in Drools
To: Rules Users List <rules-users at lists.jboss.org>
Message-ID: <4651C7C2.309 at codehaus.org>
Content-Type: text/plain; charset="iso-8859-1"

Why not just make your class implement Comparable, and then it will work
with > and <.

Mark
Edson Tirelli wrote:
>
>    Yes, Shahad's suggestion shall work, but answering your first
> question, a predicate would be like:
>
> rule XXX
> when
>    obj1 : A( $date1: mydate)
>    obj2 : A( $date2: mydate -> ( $date1.isBefore($date2) ) )
> then
>    // something
>    obj1.doSomething();
> End
>
>    Remember that predicates and evals use plain java code inside it.
>
>    []s
>    Edson
>
>
> 2007/5/21, Shahad Ahmed < shahad.ahmed2 at gmail.com
> <mailto:shahad.ahmed2 at gmail.com>>:
>
>     How about a slight modification on Mike's solution:
>     
>     rule XXX
>     when
>        obj1 : A( $date1: mydate)
>        obj2 : A( $date2: mydate)
>        eval($date1.isBefore($date2))
>     then
>        // something
>        obj1.doSomething();
>     End
>
>     I think eval allows you access to the methods in your custom Date
>     class so you can call isBefore in there after binding $date1 and
>     $date 2 to any custom date objects. I still new to Drools, so this
>     may not be correct.
>     
>     Regards
>     Shahad
>
>     
>     On 5/21/07, *Maxime Catelin* <mcatelin at perinfo.com
>     <mailto:mcatelin at perinfo.com>> wrote:
>
>         Thanks for your input. That seems to involve some
>         modifications,  on our
>         Date class and all the classes that have Date members.  That's
>         not
>         exactly what i thought of doing but maybe that's the only way.
>
>         What I meant was to to find a way to compare those dates
>         eventually
>         using the date methods we have (isAfter() or isBefore() for
>         exemple) and
>         to "keep" only the object with the latest date.  So if there
>         are several
>         A objects in the working memory, we will only fire the one
>         with the
>         latest date.
>
>         rule XXX
>
>         when
>            obj : A( $date : mydate)
>            not A( $date.isBefore(mydate)) // does not work but that
>         what i was thinking
>         then
>            // something
>            obj.doSomething();
>         end
>
>
>
>         Anstis, Michael (M.) a écrit :
>         > The simplest way could be to have your Date expose a "Time"
>         type member
>         > (like java.util.Date.getTime()) that represents the number of
>         > seconds\milliseconds etc since a given point in time ("your
>         absolute
>         > zero" for example; being day * month * year * H * M * s *
>         ms). This
>         > could then be used as a simple predicate condition:-
>         >
>         > rule XXX
>         > when
>         >     obj1 : A( $time : myTime)
>         >     obj2 : A( myTime < $time )
>         > then
>         >     // something
>         >     obj.doSomething();
>         > End
>         >
>         > Thanks,
>         >
>         > Mike
>         >
>         > -----Original Message-----
>         > From: rules-users-bounces at lists.jboss.org
>         <mailto:rules-users-bounces at lists.jboss.org>
>         > [mailto:rules-users-bounces at lists.jboss.org
>         <mailto:rules-users-bounces at lists.jboss.org> ] On Behalf Of
>         Maxime Catelin
>         > Sent: 21 May 2007 14:34
>         > To: Rules Users List
>         > Subject: [rules-users] using homemade Date in Drools
>         >
>         > Hi,
>         >
>         > We are using a lot of Dates in our application but we use a
>         homemade
>         > Date class for that.  Therefore, we cannot use > and <
>         provided by
>         > Drools.  I looked through the mailing list but could not find
>         any
>         > examples using Dates in Drools other than in the
>         documentation.  What
>         > interested me in particular in the documentation was "If more
>         control is
>         >
>         > required, use the predicate constraint."
>         >
>         > Could someone give some examples of using predicate
>         constraint with
>         > dates?
>         >
>         > Something I would like to do, for example, is the following :
>         >
>         > If there is an obj1 of class A with field of type Date d1 and
>         another
>         > obj2 of class A with field Date d2, where d1 is before d2,
>         obj2 should
>         > be used to fire something.
>         >
>         > rule XXX
>         > when
>         >     obj : A( $date : mydate)
>         >     // do not know how to use constraint on date here.
>         > then
>         >     // something
>         >     obj.doSomething();
>         > end
>         >
>         > Thanks for your input.
>         > _______________________________________________
>         > rules-users mailing list
>         > rules-users at lists.jboss.org <mailto:rules-users at lists.jboss.org>
>         > https://lists.jboss.org/mailman/listinfo/rules-users
>         <https://lists.jboss.org/mailman/listinfo/rules-users>
>         >
>         > _______________________________________________
>         > rules-users mailing list
>         > rules-users at lists.jboss.org <mailto:rules-users at lists.jboss.org>
>         > https://lists.jboss.org/mailman/listinfo/rules-users
>         <https://lists.jboss.org/mailman/listinfo/rules-users>
>         >
>         >
>         >
>         _______________________________________________
>         rules-users mailing list
>         rules-users at lists.jboss.org <mailto:rules-users at lists.jboss.org>
>         https://lists.jboss.org/mailman/listinfo/rules-users
>         <https://lists.jboss.org/mailman/listinfo/rules-users>
>
>
>
>     _______________________________________________
>     rules-users mailing list
>     rules-users at lists.jboss.org <mailto:rules-users at lists.jboss.org>
>     https://lists.jboss.org/mailman/listinfo/rules-users
>
>
>
>
> --
>   Edson Tirelli
>   Software Engineer - JBoss Rules Core Developer
>   Office: +55 11 3529-6000
>   Mobile: +55 11 9287-5646
>   JBoss, a division of Red Hat @ www.jboss.com <http://www.jboss.com>
> ------------------------------------------------------------------------
>
> _______________________________________________
> 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/20070521/3bbb2ef5/attachment-0001.html

------------------------------

Message: 3
Date: Mon, 21 May 2007 00:26:27 -0700 (PDT)
From: Aeternitas <gotischerose at yahoo.de>
Subject: [rules-users] Which rules are "passed" by object
To: rules-users at lists.jboss.org
Message-ID: <10714262.post at talk.nabble.com>
Content-Type: text/plain; charset=us-ascii


Hello,

I have collection of objects. I fire all rules for then and after this I
want to know which rules were passed (or were not passed). I can't throw an
Exception in rule's body, because in this case I will know only the first
passed rule, and only for first object which passed it.
Another solution I found - to add one more field, which will show what I
need... But maybe there is better solution. Does Drools provide such kind of
information?

Thanks,
Max
--
View this message in context: http://www.nabble.com/Which-rules-are-%22passed%22-by-object-tf3788713.html#a10714262
Sent from the drools - user mailing list archive at Nabble.com.



------------------------------

Message: 4
Date: Mon, 21 May 2007 20:20:33 +0530 (IST)
From: suma latha <suma_shallin at yahoo.co.in>
Subject: [rules-users] (no subject)
To: rules-users at lists.jboss.org
Message-ID: <128057.6833.qm at web8510.mail.in.yahoo.com>
Content-Type: text/plain; charset="us-ascii"

Hi

I am using Drools 3.0 in our business logic. I need help in the below situation
Right now i am done with writing .drl files.but the problem is that my rules should be read from the Database.

For example i have to write rule for a leave application.I am using Drools 3.0 and writing rules.In case if i want to know the joining date of a particular employee,i should be able to read that from the database.


Not only this case but should be able to connect the .drl file to the database and also should be able to prepare a decision table.


I request u to respond to my query as early as possible.Please understand the situation and do the needful



Thanks,
mary


               
__________________________________________________________
Yahoo! India Answers: Share what you know. Learn something new
http://in.answers.yahoo.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20070521/a1376657/attachment.html

------------------------------

_______________________________________________
rules-users mailing list
rules-users at lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


End of rules-users Digest, Vol 6, Issue 49
******************************************


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/ms-tnef
Size: 36328 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/rules-users/attachments/20070522/aef9aadd/attachment.bin 


More information about the rules-users mailing list