RE: [rules-users] Help Needed

2007-02-13 Thread shilpa.raghavendra



Thanks a lot Steve it worked fine.



 I need some more information on Agenda Groups. How we can use and
which scenario we can issue?

  

Thanks  Regards

Shilpa  

 



-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Steven
Williams
Sent: Tuesday, February 13, 2007 9:21 AM
To: Rules Users List
Subject: Re: [rules-users] Help Needed


Hi Shilpa,

You can pass your DAOs (or any other object) into the working memory as
globals and then use them in the consequence of your rules.

cheers
Steve


On 2/13/07, [EMAIL PROTECTED] [EMAIL PROTECTED]
wrote: 

Hi,

 

I am using Drools 3.0 in our business logic. I need help in
the below situation

 

 

I will take the records from the database on daily basis and
each record is fact in the rule engine

 

I will check the fact against some constant value; if it
satisfies the condition then I need to update one field in the database.

 

I am using Ibatis as DAO framework. 

 

How I can connect to database in .drl file?

 

Please help me.

 

Thanks  Regards

Shilpa

 


The information contained in this electronic message and any attachments
to this message are intended for the exclusive use of the addressee(s)
and may contain proprietary, confidential or privileged information. If
you are not the intended recipient, you should not disseminate,
distribute or copy this e-mail. Please notify the sender immediately and
destroy all copies of this message and any attachments. 

WARNING: Computer viruses can be transmitted via email. The recipient
should check this email and any attachments for the presence of viruses.
The company accepts no liability for any damage caused by any virus
transmitted by this email. 

www.wipro.com


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






-- 
Steven Williams

Supervising Consultant

Object Consulting
Office: 8615 4500 Mob: 0439 898 668 Fax: 8615 4501
[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED] 
www.objectconsulting.com.au

consulting | development | training | support
our experience makes the difference 




The information contained in this electronic message and any attachments to 
this message are intended for the exclusive use of the addressee(s) and may 
contain proprietary, confidential or privileged information. If you are not the 
intended recipient, you should not disseminate, distribute or copy this e-mail. 
Please notify the sender immediately and destroy all copies of this message and 
any attachments. 

WARNING: Computer viruses can be transmitted via email. The recipient should 
check this email and any attachments for the presence of viruses. The company 
accepts no liability for any damage caused by any virus transmitted by this 
email.
 
www.wipro.com___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] decision tables and 'default' or 'else' conditions

2007-02-13 Thread Joost de Vries

Hi Edson,

I've abstracted our use case since I gather you don't understand the dutch
legal system. :-)

Given a decision table like this ( I hope you are able to read the HTML post
correctly)













I

A

p

II

B

q

III

C

r

IV

D

s

none of the above

E

t

F

u

none of the above

v

we are looking for a keyword that has a meaning similar to none of the
above

The point of this functionality for us is that the business analyst is only
interested in the values I to IV but possibly there are 20 or more values.

The semantics that we need would be such that this would translate into the
following rules

I and A then p

II and B then q

III and C then r

IV and D then s

not(I) and not(II) and not(III) and not(IV) and E then t

not(I) and not(II) and not(III) and not(IV) and F then u

not(I) and not(II) and not(III) and not(IV) and not(A) and not(B) and not(C)
and not(D) then v

I hope this answers your questions.

We will need this functionality pretty soon.

Can you give an indication what the priority is for you guys for this
functionality?


groetjes uit Nederland,


Joost


2007/2/7, Edson Tirelli  [EMAIL PROTECTED]:



Joost,

Unfortunatelly, there is no feature implemented for that. But we are
discussing, specially the semantics we want to define to such statements
( we call them else and otherwise ).
If you have a real use case and you can describe it for us, it may
help on deciding which way to go, and at the same time fullfil your
needs in the future.

Our biggest questions are:

* should the else/otherwise part be fired only once if no rule is
triggered? or should it fire for each tuple that does not trigger
previous rules? What if rules in the otherwise group use different
tuples to activate?

* should else/otherwise apply to the whole LHS of the rules? Or should
there be a way to specify only part of the LHS (like a tag)?

Input welcome.

Edson

Joost de Vries wrote:

 Hi,

 We're using excel decision tables to specify our business rules.
 In one column we enumerate several condition values and describe a
 specific effect.
 We'd like to offer business analysts te possibility of describing
 succinctly what the effect is 'for all other values'.
 That could be described as an 'else' or 'default' rule.

 In other words; we don't want to burden business analysts with the
 necessity to enumerate all other values.

 What is the right way to do that?

 Thanks for you help.

 groetjes,
 Joost



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




--
Edson Tirelli
Software Engineer - JBoss Rules Core Developer
Office: +55 11 3124-6000
Mobile: +55 11 9218-4151
JBoss, a division of Red Hat @ www.jboss.com


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





--
Joost de Vries
06 22375323
werk:  [EMAIL PROTECTED]
privé:  [EMAIL PROTECTED]
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] decision tables and 'default' or 'else' conditions

2007-02-13 Thread Joost de Vries

Ok, I think that HTML tables get mangled. I'll mail it to you directly.

2007/2/13, Joost de Vries [EMAIL PROTECTED]:


Hi Edson,

I've abstracted our use case since I gather you don't understand the dutch
legal system. :-)

Given a decision table like this ( I hope you are able to read the HTML
post correctly)













I

A

p

II

B

q

III

C

r

IV

D

s

none of the above

E

t

F

u

none of the above

v

 we are looking for a keyword that has a meaning similar to none of the
above

The point of this functionality for us is that the business analyst is
only interested in the values I to IV but possibly there are 20 or more
values.

The semantics that we need would be such that this would translate into
the following rules

I and A then p

II and B then q

III and C then r

IV and D then s

not(I) and not(II) and not(III) and not(IV) and E then t

not(I) and not(II) and not(III) and not(IV) and F then u

not(I) and not(II) and not(III) and not(IV) and not(A) and not(B) and
not(C) and not(D) then v

I hope this answers your questions.

We will need this functionality pretty soon.

Can you give an indication what the priority is for you guys for this
functionality?


groetjes uit Nederland,


Joost


2007/2/7, Edson Tirelli  [EMAIL PROTECTED]:


 Joost,

 Unfortunatelly, there is no feature implemented for that. But we are

 discussing, specially the semantics we want to define to such statements
 ( we call them else and otherwise ).
 If you have a real use case and you can describe it for us, it may
 help on deciding which way to go, and at the same time fullfil your
 needs in the future.

 Our biggest questions are:

 * should the else/otherwise part be fired only once if no rule is
 triggered? or should it fire for each tuple that does not trigger
 previous rules? What if rules in the otherwise group use different
 tuples to activate?

 * should else/otherwise apply to the whole LHS of the rules? Or should
 there be a way to specify only part of the LHS (like a tag)?

 Input welcome.

 Edson

 Joost de Vries wrote:

  Hi,
 
  We're using excel decision tables to specify our business rules.
  In one column we enumerate several condition values and describe a
  specific effect.
  We'd like to offer business analysts te possibility of describing
  succinctly what the effect is 'for all other values'.
  That could be described as an 'else' or 'default' rule.
 
  In other words; we don't want to burden business analysts with the
  necessity to enumerate all other values.
 
  What is the right way to do that?
 
  Thanks for you help.
 
  groetjes,
  Joost
 

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


 --
 Edson Tirelli
 Software Engineer - JBoss Rules Core Developer
 Office: +55 11 3124-6000
 Mobile: +55 11 9218-4151
 JBoss, a division of Red Hat @ www.jboss.com


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




--
Joost de Vries
06 22375323
werk:   [EMAIL PROTECTED]
privé:  [EMAIL PROTECTED]





--
Joost de Vries
06 22375323
werk:  [EMAIL PROTECTED]
privé:  [EMAIL PROTECTED]
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Example of contains operator...

2007-02-13 Thread jdepaul

Ok thanks - that worked when partnerList was an ArrayList, how would I code
my contains condition if the parternList was a HashMap!?  


Michael Neale wrote:
 
 contains works on the Collection interface. So if parnerList is a
 ArrayList
 of String, then you could do:  parnerList contains 2900
 

-- 
View this message in context: 
http://www.nabble.com/Example-of-contains-operator...-tf3202978.html#a8944919
Sent from the drools - user mailing list archive at Nabble.com.

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


RE: [rules-users] fact tuples selection - what are the principles - a bit confused?

2007-02-13 Thread Olenin, Vladimir (MOH)
No, I'm not concerned with the order in this particular case - just trying
to figure out what I should be taking into account or rely on when doing the
design. Thanks for taking the time to go through (now that I scrolled
through it myself :-) ) this quite lengthy email.

 

Vlad

 

  _  

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Michael Neale
Sent: 12 February 2007 23:53
To: Rules Users List
Subject: Re: [rules-users] fact tuples selection - what are the principles -
a bit confused?

 

that sounds correct.

No you can't really depend on things happening in a certain order. of course
it will be consistent between executions for the same data, but you can't
count on that. It would mostly be effected by the order in which you assert
facts. 

I guess the question is why are you concerned in what order it does things?

Michael

On 2/13/07, Olenin, Vladimir (MOH)  mailto:[EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:

Hi,

I was trying to find more detailed explanation on how the fact tuples for 
activations are being selected based on the constraints, but couldn't find
much. So, I guess I just want to assert my understanding of this process is
correct.

Assuming I have the following set of 'Accounts' with the fields: 

ID  | Province   | City| Type| Balance

1  | ON | Toronto | Checking| 1000
2  | BC | Vancouver   | Checking| 100 
3  | ON | Toronto | Visa| 2000
4  | ON | Toronto | Checking|-100
5  | BC | Vancouver   | Checking| 100
6  | BC | Vancouver   | Visa| 150 
7  | AB | Calgary | Checking| 100
7  | AB | Toronto | Checking| 300

I have two rules to process:

1) within each province, the sum of balances on Visa accounts should less 
then 10 times the sum of balances on Checking accounts (within the same
province)
2) within each province, the sum of balances on Checking accounts should be
a positive number
3) within each province and within each city, the number of visa accounts 
should be no more than 2 times the number of checking accounts

If I model my business objects like this:

1) Account  (id, province, city, type, balance)
2) Province (province)
3) City (province, city) 


And WorkingMemory will be initialized (for the data above) with:
- 7 Account instances (ids 1 through 7)
- 3 Province instances (ON, AB, BC)
- 3 City instances (Toronto, Vancouver, Calgary) 


Then the rules containing 'within province' would read like:
-
Rule '1'
When
Province($prov: province)
$a: Account(province == $prov)
Then
// accumulate sums on Checking and Visa accounts as Edson showed in 
previous emails
End
-


The rule containing 'within province, within city' would have then:
-
Rule '3'
When
Province($prov: province)
  City($city: city, province = $prov) 
$a: Account(province = $prov, city = $city)
Then
// accumulate sums on Checking and Visa accounts as Edson showed in
previous emails
-


Is this correct business object model to achieve the goal? Do I understand 
correctly that the LHS statement:


Province($prov: province)
  City($city: city, province = $prov)
$a: Account(province = $prov, city = $city)


Can be read as:

For each province 
For each city within the province
For each account for the given city and province



What 'guides' the order in which fact tuples are selected from the set of 
all facts in the WorkingMemory? Can any particular sequence be guaranteed?

Thanks!

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


Re: [rules-users] Example of contains operator...

2007-02-13 Thread Marcus Ilgner

On 2/13/07, jdepaul [EMAIL PROTECTED] wrote:


Ok thanks - that worked when partnerList was an ArrayList, how would I code
my contains condition if the parternList was a HashMap!?


You could write an accessor in your model called getPartnerListKeys()
which returns getPartnerList().keySet() and then use (partnerListKeys
contains 2900) in your rule.
I'm not 100% sure (started with JBoss Rules only a couple of days
ago), but I'm pretty confident that this should work.

hth
Marcus


Michael Neale wrote:

 contains works on the Collection interface. So if parnerList is a
 ArrayList
 of String, then you could do:  parnerList contains 2900



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


Re: [rules-users] Example of contains operator...

2007-02-13 Thread jdepaul

That worked just fine - thanks very much for clarification - I'm starting to
understand how that works now... example is worth a thousand lines of
documentation text... :)


Marcus Ilgner wrote:
 
 You could write an accessor in your model called getPartnerListKeys()
 which returns getPartnerList().keySet() and then use (partnerListKeys
 contains 2900) in your rule.
 

-- 
View this message in context: 
http://www.nabble.com/Example-of-contains-operator...-tf3202978.html#a8947081
Sent from the drools - user mailing list archive at Nabble.com.

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


Re: [rules-users] Roll Back Rule / Rule Transactions?

2007-02-13 Thread Michael Suzio

Anytime you modify a object, candidate rules are going to be re-examined.
You may need some state variables in addition to this (to control when rules
fire, avoid loops, etc), but the basic rules could be:

rule AddVcr
when
 $c: Cart(contents contains TV, contents excludes free VCR)
then
$c.add(free VCR);
modify($c);
end

rule RemoveVcr
when
$c: Cart(contents excludes TV)
then
$c.remove(free VCR);
modify($c);
end

You can fill in the rest.  Like I said, you probably need some state
variables so things don't loop, need to exclude the case where a non-free
VCR is legitimately in the cart, etc.  But your basic question should be
answered with this approach.  Don't think procedurally, think in terms of a
living system when the changes in objects trigger somewhat asynchronous
cascades of matching rules.  Calling modify() on a fact is like restarting
the whole matching algorithm for any rules that had that fact included in
their (possible candidate) constraints.

On 2/13/07, Matt Johnston [EMAIL PROTECTED] wrote:


I am working on rules for an online shopping cart. Depending on the
products in the cart, the customer may get certain discounts.

If cart contains a TV, add a free VCR.

I can apply these rules, but what about rolling them back?

So in the example above, the rule automatically added a free VCR because
the cart contained a TV. If the customer removes the TV, I need to roll
back the VCR rule and also remove the VCR from the cart.

Does anyone know how to do this? Is it possible?

Matt Johnston
Manager of Internet Content
Publishing Group of America
p: 615-468-6053
f: 615-468-6153

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

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


[rules-users] Short-circuit rules by group?!

2007-02-13 Thread jdepaul

I have several rules defined in groups by Customer, so I have number of rules
for Walmart, some rules for NIKE, more rules for SomeCustomer...  When one
of the rules matches for a given customer I need to send an event
notification.  I need to make sure that I send only ONE event notification
per Customer (regardless of how many rules were matched), thus after finding
the very first match in the Walmart group, I'd like to activate a rule, and
then short-circuit and Skip to the next group of rules for NIKE - to see
if any of the matches are found in the next group.  

I've implemented this functionality using a Match object, which I assert
into WorkingMemory whenever I find a match for customer, then all my rules
check for absence of Match for given customer...

This works, but I wonder if there is a better way to do it - using Agenda
Groups, maybe - once I find ONE match for Walmart, skip to the next Agenda
Group?!  Could someone comment on this?

THanks,
James
-- 
View this message in context: 
http://www.nabble.com/Short-circuit-rules-by-group-%21-tf3222142.html#a8949165
Sent from the drools - user mailing list archive at Nabble.com.

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


RE: [rules-users] Roll Back Rule / Rule Transactions?

2007-02-13 Thread Olenin, Vladimir (MOH)
NOTE: I'm not a DROOL expert. Keeping this in mind, I'd say


You'd need a separate rule which states:

 - if a cart does NOT contain TV, remove any free VCR from the cart if any

Once you retract the 'TV' fact from WorkingMemory and refire the rules (or
they will automatically refire?), this new rule will be activate and remove
the free VCR from the cart.

Just my 2c...

Vlad

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Matt Johnston
Sent: 13 February 2007 11:21
To: rules-users@lists.jboss.org
Subject: [rules-users] Roll Back Rule / Rule Transactions?

I am working on rules for an online shopping cart. Depending on the
products in the cart, the customer may get certain discounts.

If cart contains a TV, add a free VCR.

I can apply these rules, but what about rolling them back? 

So in the example above, the rule automatically added a free VCR because
the cart contained a TV. If the customer removes the TV, I need to roll
back the VCR rule and also remove the VCR from the cart.

Does anyone know how to do this? Is it possible?

Matt Johnston
Manager of Internet Content
Publishing Group of America
p: 615-468-6053
f: 615-468-6153

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


Re: [rules-users] Roll Back Rule / Rule Transactions?

2007-02-13 Thread Mark Proctor
You could use truth maintenance, this won't remove something from a 
list, but it will remove a fact from the working memory when a rule is 
no longer true.


Mark
Michael Suzio wrote:
Anytime you modify a object, candidate rules are going to be 
re-examined.  You may need some state variables in addition to this 
(to control when rules fire, avoid loops, etc), but the basic rules 
could be:


rule AddVcr
when
  $c: Cart(contents contains TV, contents excludes free VCR)
then
 $c.add(free VCR);
 modify($c);
end

rule RemoveVcr
when
 $c: Cart(contents excludes TV)
then
 $c.remove(free VCR);
 modify($c);
end

You can fill in the rest.  Like I said, you probably need some state 
variables so things don't loop, need to exclude the case where a 
non-free VCR is legitimately in the cart, etc.  But your basic 
question should be answered with this approach.  Don't think 
procedurally, think in terms of a living system when the changes in 
objects trigger somewhat asynchronous cascades of matching rules.  
Calling modify() on a fact is like restarting the whole matching 
algorithm for any rules that had that fact included in their (possible 
candidate) constraints.


On 2/13/07, *Matt Johnston* [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED] wrote:


I am working on rules for an online shopping cart. Depending on the
products in the cart, the customer may get certain discounts.

If cart contains a TV, add a free VCR.

I can apply these rules, but what about rolling them back?

So in the example above, the rule automatically added a free VCR
because
the cart contained a TV. If the customer removes the TV, I need to
roll
back the VCR rule and also remove the VCR from the cart.

Does anyone know how to do this? Is it possible?

Matt Johnston
Manager of Internet Content
Publishing Group of America
p: 615-468-6053
f: 615-468-6153

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


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


RE: [rules-users] calls to 'Helper' classes in LHS - are they all owed?

2007-02-13 Thread Olenin, Vladimir (MOH)
Thanks, Mark. Are there any plans on making return value, predicate and eval
expressions indexable (in case it is possible at all)? Would it be included
in 3.2 release? I understand that DROOLS can not guarantee that helper
method will return the same value each time and probably that's why excludes
such cases from index, but the same goes for 'getters' of the fact objects -
DROOLS can't guarantee the getter will return the same value each time, so
it just have to assume it (and it is outlined in the documentation).

 

There are a few use case that might need this kind of functionality, eg to
cache the results of 'associative' lookup. Especially for the 'Decision
Tables'. The problem I'm facing right now is I need to 'expand' the list of
codes based on some id and use those codes as constraint:

 

MyObject(field = LookupMap.getCodes($param))

 

Where $param is a value from Decision Table data. In this particular case a
set of, say 100 codes, can be described with a simple ID. For more complex
cases a pseudo 'set select' expression can be passed as a parameter (eg,
LookupMap.getCodes(groupId_1 - grouperId_2), which should return the
intersection of codes in groupId_1 and groupId_2). In any case, the key,
value pairs returned by LookupMap class would remain the same.

 

Vlad

 

  _  

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Mark Proctor
Sent: 12 February 2007 19:16
To: Rules Users List
Subject: Re: [rules-users] calls to 'Helper' classes in LHS - are they
allowed?

 

We were hoping the community would work with us and improve the
documentation over the last year - to date we have had zip :( We will have
another documentation drive once we get to the candidate release stage for
the current development cycle. We simply don't have the cycles to work on a
book, with any luck after we spend 3 to 4 weeks on documentation during hte
candidate release stage it should get better, and maybe one day  the manual
can form the basis of a book. Some ideas for the  community to work include
the examples in drools-examples, they can even use what I did for drools 2.x
as a starting basis, or to provide a really good tutorial on the basics of
pattern matching, you can look the public domain clips manual for pointers
here. It's not money we need, its time, YOUR time :)

If you want to use a helper class it must be in a return value, predicate or
eval - none of which are currently indexed. return value and predicate must
also be time constant, eval does not have to be.

Mark
Michael Suzio wrote: 

I see this in the docs:

A d0e1997Predicate constraint can use any valid Java expression as long as
it evaluated to a primitive boolean - avoid using any Drools keywords as
Declaration identifiers. Previously bound declarations can be used in the
expression. Functions used in a Predicate Constraint must return time
constant results.

and under the discussion of 'eval':

Evals cannot be indexed and thus are not as optimal as using Field
Constraints.

and this in general discussion of constraints and accessors of your objects
used in them:

Do please make sure that you are accessing methods that take no parameters,
and are in-fact accessors (as in, they don't change the state of the
object in a way that may effect the rules - remember that the rule engine
effectively caches the results of its matching inbetween invocations to make
it faster).

So, if invoking a helper method is like an eval, I'm thinking Drools
computes the match, but then throws it away because it knows this is not a
constant expression.  Whereas, if it were just a match of an accessor's
value vs. a constant String, it could cache that. 

I'm wildly speculating, only because I want to understand fully what is
happening, so I'm throwing stuff out there so the Drools team will have to
correct my misapprehensions before I confuse the whole list (*g*).
Sometimes reading the Drools documentation is like a Talmudic scholar trying
to find the deeper meaning of the sacred words...  as much as I want the 3.2
milestone, I want real documentation even more (and *hint hint* -- would
probably be willing to pay for it, guys!  Can we get an O'Reilly book?)

  --- Michael



On 2/12/07, Steven Williams [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]  wrote: 

I believe there is a caveat on functions and helper methods called from the
LHS that they need to be constant over time (or at least over the life of
the working memory) which then allows matches to be computed as per normal. 

Steve 

 

On 2/13/07, Michael Suzio  mailto:[EMAIL PROTECTED]  [EMAIL PROTECTED]
wrote: 

The JBoss guys can correct me if I'm wrong, but although I think that works,
what you've just done is eliminate any chance to precompute matches and trim
down the checks that need to happen to find a rule match.  Since the engine
can't know that Helper.transform(value) returns a constant value, it has
to re-run that every time and it has to reject for matches to the rule

Re: [rules-users] Roll Back Rule / Rule Transactions?

2007-02-13 Thread Andrew Thompson
Probably you want to make sure you understand the difference between assert() 
and assertLogical() and see if that will meet your needs.
 
--
Andrew Thompson

- Original Message 
From: Matt Johnston [EMAIL PROTECTED]
To: rules-users@lists.jboss.org
Sent: Tuesday, February 13, 2007 11:20:35 AM
Subject: [rules-users] Roll Back Rule / Rule Transactions?

I am working on rules for an online shopping cart. Depending on the
products in the cart, the customer may get certain discounts.

If cart contains a TV, add a free VCR.

I can apply these rules, but what about rolling them back? 

So in the example above, the rule automatically added a free VCR because
the cart contained a TV. If the customer removes the TV, I need to roll
back the VCR rule and also remove the VCR from the cart.

Does anyone know how to do this? Is it possible?

Matt Johnston
Manager of Internet Content
Publishing Group of America
p: 615-468-6053
f: 615-468-6153

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





 

Sucker-punch spam with award-winning protection. 
Try the free Yahoo! Mail Beta.
http://advision.webevents.yahoo.com/mailbeta/features_spam.html

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


Re: [rules-users] calls to 'Helper' classes in LHS - are they all owed?

2007-02-13 Thread Mark Proctor
In theory they can be indexed, but we havne't done it yet, no idea when 
we'll get time. Patches welcome :)


Mark
Olenin, Vladimir (MOH) wrote:


Thanks, Mark. Are there any plans on making return value, predicate 
and eval expressions indexable (in case it is possible at all)? Would 
it be included in 3.2 release? I understand that DROOLS can not 
guarantee that helper method will return the same value each time and 
probably that's why excludes such cases from index, but the same goes 
for 'getters' of the fact objects -- DROOLS can't guarantee the getter 
will return the same value each time, so it just have to assume it 
(and it is outlined in the documentation).


 

There are a few use case that might need this kind of functionality, 
eg to cache the results of 'associative' lookup. Especially for the 
'Decision Tables'. The problem I'm facing right now is I need to 
'expand' the list of codes based on some id and use those codes as 
constraint:


 


MyObject(field = LookupMap.getCodes($param))

 

Where $param is a value from Decision Table data. In this particular 
case a set of, say 100 codes, can be described with a simple ID. For 
more complex cases a pseudo 'set select' expression can be passed as a 
parameter (eg, LookupMap.getCodes(groupId_1 -- grouperId_2), which 
should return the intersection of codes in groupId_1 and groupId_2). 
In any case, the key, value pairs returned by LookupMap class would 
remain the same.


 


Vlad

 




*From:* [EMAIL PROTECTED] 
[mailto:[EMAIL PROTECTED] *On Behalf Of *Mark Proctor

*Sent:* 12 February 2007 19:16
*To:* Rules Users List
*Subject:* Re: [rules-users] calls to 'Helper' classes in LHS - are 
they allowed?


 

We were hoping the community would work with us and improve the 
documentation over the last year - to date we have had zip :( We will 
have another documentation drive once we get to the candidate release 
stage for the current development cycle. We simply don't have the 
cycles to work on a book, with any luck after we spend 3 to 4 weeks on 
documentation during hte candidate release stage it should get better, 
and maybe one day  the manual can form the basis of a book. Some ideas 
for the  community to work include the examples in drools-examples, 
they can even use what I did for drools 2.x as a starting basis, or to 
provide a really good tutorial on the basics of pattern matching, you 
can look the public domain clips manual for pointers here. It's not 
money we need, its time, YOUR time :)


If you want to use a helper class it must be in a return value, 
predicate or eval - none of which are currently indexed. return value 
and predicate must also be time constant, eval does not have to be.


Mark
Michael Suzio wrote:

I see this in the docs:

A Predicate constraint can use any valid Java expression as long as 
it evaluated to a primitive boolean - avoid using any Drools keywords 
as Declaration identifiers. Previously bound declarations can be used 
in the expression. Functions used in a Predicate Constraint must 
return time constant results.


and under the discussion of 'eval':

Evals cannot be indexed and thus are not as optimal as using Field 
Constraints.


and this in general discussion of constraints and accessors of your 
objects used in them:


Do please make sure that you are accessing methods that take no 
parameters, and are in-fact accessors (as in, they don't change the 
state of the object in a way that may effect the rules - remember that 
the rule engine effectively caches the results of its matching 
inbetween invocations to make it faster).


So, if invoking a helper method is like an eval, I'm thinking Drools 
computes the match, but then throws it away because it knows this is 
not a constant expression.  Whereas, if it were just a match of an 
accessor's value vs. a constant String, it could cache that.


I'm wildly speculating, only because I want to understand fully what 
is happening, so I'm throwing stuff out there so the Drools team will 
have to correct my misapprehensions before I confuse the whole list 
(*g*).  Sometimes reading the Drools documentation is like a Talmudic 
scholar trying to find the deeper meaning of the sacred words...  as 
much as I want the 3.2 milestone, I want real documentation even more 
(and *hint hint* -- would probably be willing to pay for it, guys!  
Can we get an O'Reilly book?)


  --- Michael

On 2/12/07, *Steven Williams* [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED] wrote:


I believe there is a caveat on functions and helper methods called 
from the LHS that they need to be constant over time (or at least over 
the life of the working memory) which then allows matches to be 
computed as per normal.


Steve

 

On 2/13/07, *Michael Suzio*  [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED] wrote:


The JBoss guys can correct me if I'm wrong, but although I think that 
works, what you've just