[rules-users] Using memberOf in Decision Tables
Mike Love
mike.love at symbiotics.co.za
Mon Mar 17 17:31:40 EDT 2008
Hi,
I have the following rules that I am trying to implement in a decision table
rule "Payment greater 5m"
agenda-group "txnPricing"
salience 5
when
payment : Collection() from bc.getPaymentTransactionTypes()
t : Transaction(customer == c,
transactionType memberOf payment,
transactionAmount >= 5000000)
then
t.setBaseFee(36.00);
t.setFeeDiscount(0.00);
end
rule "Payment less 5m"
agenda-group "txnPricing"
salience 5
when
payment : Collection() from bc.getPaymentTransactionTypes()
t : Transaction(customer == c,
transactionType memberOf payment,
transactionAmount < 5000000)
then
t.setBaseFee(60.00);
t.setFeeDiscount(0.00);
end
I have attached the Decision Table for reference. Basically, I have two
condition columns representing the 2 conditions respectively. When the
xls is processed the generated DSL has the two statements reversed as
indicated below, and hence the exceptions.
package za.co.fnb.billing;
#generated from Decision Table
import java.util.Collection;
import za.co.fnb.billing.Customer;
import za.co.fnb.billing.Transaction;
import za.co.fnb.billing.BillingConstraints;
global Customer c;
global BillingConstraints bc;
#From row number: 12
rule "Payments_12"
when
t: Transaction(customer == c, t.transactionAmount >= 0,
t.transactionAmount <5000000, transactionType memberOf $payments)
$payment : Collection() from
bc.getTransactionTypesForGroup("Payments")
then
t.setBaseFee(60.00);
t.setFeeDiscount(0.00);
end
#From row number: 13
rule "Payments_13"
when
t: Transaction(customer == c, t.transactionAmount >= 5000000,
t.transactionAmount <9999999999, transactionType memberOf $payments)
$payment : Collection() from
bc.getTransactionTypesForGroup("Payments")
then
t.setBaseFee(36.00);
t.setFeeDiscount(0.00);
end
org.drools.rule.InvalidRulePackage: Unable to return Declaration for
identifier '$payments' : [Rule name=Payments_12, agendaGroup=MAIN,
salience=0, no-loop=false]
Unable to create restriction '[VariableRestriction: memberOf $payments
]' for field 'transactionType' in the rule 'Payments_12' : [Rule
name=Payments_12, agendaGroup=MAIN, salience=0, no-loop=false]
Unable to return Declaration for identifier '$payments' : [Rule
name=Payments_13, agendaGroup=MAIN, salience=0, no-loop=false]
Unable to create restriction '[VariableRestriction: memberOf $payments
]' for field 'transactionType' in the rule 'Payments_13' : [Rule
name=Payments_13, agendaGroup=MAIN, salience=0, no-loop=false]
at org.drools.rule.Package.checkValidity(Package.java:424)
at
org.drools.common.AbstractRuleBase.addPackage(AbstractRuleBase.java:384)
at
za.co.fnb.billing.TxnVolDecisionTableTest.readDecisionTable(TxnVolDecisionTableTest.java:164)
at
za.co.fnb.billing.TxnVolDecisionTableTest.executeExample(TxnVolDecisionTableTest.java:62)
at
za.co.fnb.billing.TxnVolDecisionTableTest.main(TxnVolDecisionTableTest.java:33)
Thanks,
Mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: TxnPricing.xls
Type: application/octet-stream
Size: 76288 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/rules-users/attachments/20080317/86fadbd5/attachment.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mike_love.vcf
Type: text/x-vcard
Size: 295 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/rules-users/attachments/20080317/86fadbd5/attachment.vcf
More information about the rules-users
mailing list