Function call in LHS

View: New views
6 Messages — Rating Filter:   Alert me  

Function call in LHS

by BINET JEAN-BAPTISTE :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Function call in LHS

Hello,

I am new to Drools. I have downloaded and installed Drools 4.0.7.
After having read the documentation, I saw that it is possible to create function in the .drl file.
I succeed in creating a function, calling it in the LHS with eval() instruction or in the RHS.
But, is it possible to call a function in the LHS out of an eval() ? For example, I would like to use
a pattern such as :
$tmp : MyClass( name == MyFunction() )

Thanks in advance.

Regards.

JB


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

Re: Function call in LHS

by Mark Proctor :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

only inside an eval or return value.

Mark
BINET JEAN-BAPTISTE wrote:
Function call in LHS

Hello,

I am new to Drools. I have downloaded and installed Drools 4.0.7.
After having read the documentation, I saw that it is possible to create function in the .drl file.
I succeed in creating a function, calling it in the LHS with eval() instruction or in the RHS.
But, is it possible to call a function in the LHS out of an eval() ? For example, I would like to use
a pattern such as :
$tmp : MyClass( name == MyFunction() )

Thanks in advance.

Regards.

JB


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


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

LHS Conditional Syntax for drl - date comparison with objects

by Costello, Robert :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
Function call in LHS

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@...
https://lists.jboss.org/mailman/listinfo/rules-users

Re: LHS Conditional Syntax for drl - date comparison with objects

by Scott Reed-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

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:
Function call in LHS

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@... https://lists.jboss.org/mailman/listinfo/rules-users


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

Re: LHS Conditional Syntax for drl - date comparison with objects

by Scott Reed-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
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:
Function call in LHS

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@... https://lists.jboss.org/mailman/listinfo/rules-users



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

RE: LHS Conditional Syntax for drl - date comparisonwith objects

by Costello, Robert :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
Function call in LHS

Wonderful!  Thanks very much for your learned response.  Java syntax, then, is more reserved for the right hand side of the rule, which makes sense, else we would see semi-colons in the LHS. 

 

Thanks again!

 

Robert Costello

Lead Systems Engineer

IMA Performance

E3- 279A

847.286.0910

 

 

-----Original Message-----
From: rules-users-bounces@... [mailto:rules-users-bounces@...] On Behalf Of Scott Reed
Sent: Monday, July 14, 2008 10:02 AM
To: Rules Users List
Subject: Re: [rules-users] LHS Conditional Syntax for drl - date comparisonwith objects

 

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@...
https://lists.jboss.org/mailman/listinfo/rules-users
  

 

 


_______________________________________________
rules-users mailing list
rules-users@...
https://lists.jboss.org/mailman/listinfo/rules-users
LightInTheBox - Buy quality products at wholesale price