[rules-users] LHS Conditional Syntax for drl - date comparison with objects

Scott Reed sreed at avacoda.com
Mon Jul 14 11:02:21 EDT 2008


Oops, try this:

*rule* "Your First Rule"

   

      *when*

          Date1( $end1: endDate )

          Date2( beginDate > $end1 )

      *then*

            #actions

            System.out.println("do something");

*end*


Scott Reed wrote:
>
> *Try this:
> *
>
> *rule* "Your First Rule"
>
>    
>
>       *when*
>
>       $d1 : Date1( $end1: endDate )    
>
>       $d2 : Date2()
>
>       $d2 : Date2( beginDate > $end1 )
>
>       *then*
>
>             #actions
>
>             System.out.println("do something");
>
> *end*
>
>
>
> Costello, Robert wrote:
>>
>> I'm having a hard time understanding the syntax in the conditional or 
>> left hand side of the DRL.  Is it acceptable to use dot notation in 
>> the LHS?  Is there a better way to compare fields on different objects?
>>
>>  
>>
>> In the example below, I get an error "Unable to find class $d1.  What 
>> limitations are there syntactically on the left hand side?  Any help 
>> would be greatly appreciated.  I have looked at all the examples and 
>> have googled the problem and don't seem to find the answer.
>>
>>  
>>
>> *package* com.rules
>>
>>  
>>
>> #list any import classes here.
>>
>> *import* com.validate.Date1
>>
>> *import* com.validate.Date2
>>
>> *import* java.util.Date
>>
>>  
>>
>> #declare any global variables here
>>
>>  
>>
>> *rule* "Your First Rule"
>>
>>    
>>
>>       *when*
>>
>>       $d1 : Date1()    
>>
>>       $d2 : Date2()
>>
>>       $d2 : Date2(beginDate > $d1.getEndDate)
>>
>>       *then*
>>
>>             #actions
>>
>>             System.out.println("do something");
>>
>> *end*
>>
>>  
>>
>> Best regards,
>>
>>  
>>
>> Robert Costello
>>
>>  
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> 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/20080714/40b18db5/attachment.html 


More information about the rules-users mailing list