logo       

Re: [drools-user] Three Important Doubts: msg#00147

java.drools.user

Subject: Re: [drools-user] Three Important Doubts

Hi Joj,

1) and 2)
In this case it is appropriate to use the declarations (bound variable) for your properties of the class Student, and the eval complementary element for column (read the drools manual http://labs.jboss.com/portal/jbossrules/docs). Drools doesn't allow you to operate with class properties in columns, as you suggest in your example, but it offers you an alternative: the declarations.

s : Student( m1:mark1, m2:mark2  )
eval ( m1.intValue() + m2.intValue() >= 100)

eval (m1.intValue() > m2.intValue())

3) Here is a simple example about the use of accessors for bean objects.

   rule "EvalWithFunction_1"

    when
        $e:Employee($name:employeeName == "Fred")
        e val($e.getExtraHours() >= 8)
        eval($e.getCurrencyName() == "EURO")
    then
        System.out.println($name+" has worked at least 8 extra hours");
end

$e is a fact declaration , and $name is a field declaration.
getExtraHours() - is a getter for extraHours field. 

Eval can contain any predicate _expression_ as long it returns a primitive boolean.  It is usually used to refer variable that were bound previously in the LHS of the rule, and functions with parameters in the rule package. In the LHS structure, the eval element(s) should be the last. An eval element will be checked each time if all the conditions in the rule are met.

Best regards,
                     Oana.


Joj <jojpm@yaho o.com> wrote:

hi,

my doubts are:

1)
cant we check an _expression_ against a single value in the condition part?
i mean like this:
s : Student( mark1 + mark2 >= 100 )
(where mark1 and mark2 are the properties of Student)

is there any way to do it?

2)
cant we use properties on both sides of a condition?
for ex:
s : Student ( mark1 > mark2 )

3)
how can we use global variable (set and get)?
plz illustrate using a simple example.


plz reply A.S.A.P.
thanx in advance
joj

--
View this message in context: http://www.nabble.com/Three-Important-Doubts-tf2863748.html#a8002872
Sent from the drools - user mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email


__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise