[rules-users] How to handle priority in a rule
Maxime
mcatelin at perinfo.com
Fri May 11 11:04:07 EDT 2007
Thanks for your reply but this does not do what I want to do because I
don't want to put more priority to a rule over another one, I want this
rule to fire with the price object that has the highest length field,
considering there are more than one Price objects in the WM.
Any other ideas?? Am I trying something impossible or should I take
another approach?
fakhfakh ismail a écrit :
> you can affect a numero to salience in fact salience is used to give
> a priority to rule and the rule who has the numero of salience more
> priority
> rule "Price Product rule using price length"
> salience 500 ( for exemple )
> when
> $s : Product (length > 0)
> $price : Price($length: length)
> then
> $s.setAmount($s.getAmount() + $price.getAmount());
> $s.setLength($s.getLength() - $length.intValue());
> modify($s);
> end
>
>
> */Maxime <mcatelin at perinfo.com>/* a écrit :
>
> Hello,
>
> I'm trying to find how to manage priority within a rule. Let me
> explain
> the problem. I'll try to be as clear as possible but bear with me
> since
> I am new to rules.
>
> We have two objects, the Product is the object I'm trying to price
> and
> the object Price is the one that knows all the prices. Both
> products and
> prices have fields amount and length. Product amount is
> initialized to
> 0 and prices are going to determine the product amount depending
> on its
> length.
>
> Let's see an example :
>
> Product : P -> length = 5, amount = 0
> Price : P1 -> length = 1, amount = 50
> Price : P2 -> length = 3, amount = 100
>
> With this configuration, after asserting the 3 objects to the WM, the
> amount field of Product P should have a value of 200 ( 1*100 + 2*50)
> because the price with the greatest length should be favored over the
> other ones.
>
> Here is the rule I made :
>
> rule "Price Product rule using price length"
> when
> $s : Product (length > 0)
> $price : Price($length: length)
> then
> $s.setAmount($s.getAmount() + $price.getAmount());
> $s.setLength($s.getLength() - $length.intValue());
> modify($s);
> end
>
> This is obviously wrong because it always takes the first asserted
> price
> object. I don't know how to make a rule which would take the
> amount of
> the price object with the greatest length in priority.
>
> Any help would be very much appreciated.
>
> Cheers,
>
> Max
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
> ------------------------------------------------------------------------
> Découvrez une nouvelle façon d'obtenir des réponses à toutes vos
> questions ! Profitez des connaissances, des opinions et des
> expériences des internautes sur Yahoo! Questions/Réponses
> <http://fr.rd.yahoo.com/evt=42054/*http://fr.answers.yahoo.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.6.8/797 - Release Date: 10/05/2007 17:10
>
More information about the rules-users
mailing list