Why XML?
import org.drools.decisiontable.SpreadsheetCompiler;
private void testSpreadsheet(){
File dtf = new File( dtPath );
InputStream is;
try {
is = new FileInputStream( dtf );
SpreadsheetCompiler ssComp = new SpreadsheetCompiler();
String s = ssComp.compile( is, InputType.XLS );
System.out.println( "=== Begin generated DRL ===" );
System.out.println( s );
System.out.println( "=== End generated DRL ===" );
} catch (IOException e) {
e.printStackTrace();
}
}
it converts the spreadsheet to you can see what the resulting DRL is.****
Mantis is right in what the output is – if you don’t merge the condition
column you’ll get a drl as below (If there exists a Condition (c1) such that
its payment > $param(1) AND there exists a Condition (c2) such that its
payment <= $param(2).****
If you merge the condition column the constraints apply to the same
Condition object with the comma being the implicit and (if there exists a
Condition c1 such that its payment > $param(1) AND its payment <= $param(2).
All correct, but the problem with this approach is the necessity of
providing identical values in two places - once as an upper limit and once
as a lower limit. By using the keyword "Sequential true" rules will be made
to fire from top to bottom. Adding a uniform constraint that guarantees that
the value-to-be-set hasn't been set yet (==null), a single constraint using
the value as an upper limit is sufficient.
-W
****
** **
Thomas****
** **
*From:* rules-users-bounces(a)lists.jboss.org [mailto:
rules-users-bounces(a)lists.jboss.org] *On Behalf Of *john@oa
*Sent:* 09 September 2011 16:28
*To:* rules-users(a)lists.jboss.org
*Subject:* Re: [rules-users] Spreadsheet: Rule Compilation error (xxx)
cannot be resolved: Keeping running total****
** **
Thanks Manstis
Actually I found that the issue was caused by me having incorrectly placed
the "RuleTable" statement in the spreadsheet, I believe the CONDITION's in
the columns are by default: AND joined.****
On Fri, Sep 9, 2011 at 3:57 PM, manstis [via Drools] <[hidden
email]<http://user/SendEmail.jtp?type=node&node=3323194&i=0>>
wrote:****
Does your "Condition" span the two columns with the payment $param? e.g.
| Condition |
|-----------------+------------------|
|payment > $param | payment <= $param|
|-----------------+------------------|
Otherwise you are creating rules that check the following:-
when
Condition(payment > )
then
...
when
Condition(payment > 1000)
then
...
Whereas you really require:-
when
Condition(payment >0, payment <= 1000)
then
...
etc****
2011/9/9 john@oa <[hidden
email]<http://user/SendEmail.jtp?type=node&node=3323110&i=0>
>****
Thanks Iaune
That is really helpful. Yes, I need the ranges to be mutually exclusive,
what is the easiest way to do that? Feel a bit cheeky asking another
question, but you seem to know what you are talking about! I have tried
adding two conditions to enforce the range, but that doesn't seem to work -
see below. I still get multiple rules firing. Also can you recommend any
good resources for learning all of this, apart from the online
documentation? Would you know if any of the Drools books are any good?***
*
payment > $param****
payment <= $param****
Payment Greater Than****
Payment Less Than or Equal To****
0****
0****
1500****
1500****
2000****
2000****
3000****
3000****
4000****
** **
On Fri, Sep 9, 2011 at 2:22 PM, laune [via Drools] <[hidden
email]<http://user/SendEmail.jtp?type=node&node=3323074&i=0>>
wrote:****
The error you get is due to the second condition (application:
Application()) not being included in the generated rules. Empty cell means:
the column's snippet is not included in the rule.
Since you don't have a constraint for Application() you can employ a trick:
remove the column and prefix the text application: Application() to the text
in cell C7.
In Rule 1, do you really want to test whether a payment is not greater than
zero?
Do you realize that Rules 2 and 3 would both fire for certain payment
amounts?
You can update a String field. To concatenate, use
x.setString( x.getString() + "whatever" );
-W****
On 9 September 2011 14:08, john@oa <[hidden
email]<http://user/SendEmail.jtp?type=node&node=3322896&i=0>>
wrote:****
Guvnor: guvnor-5.2.0.Final-tomcat-6.0
Hi
I am a Drools Newbie and I have an integer field called score that I need
to
add to when a rule matches in a spreadsheet decision table. i.e. the score
field should hold a running total of all scores that are matched. However,
I can't even update the field in the table. I have attached the
spreadsheet
for review. In this spreadsheet I am simply trying to set the score, and
that is failing with:
DScoringTable] Rule Compilation error application cannot be resolved
My goal is to have different decision tables that will all need to update
the same score, and keep a running total of the total score.
Any help very much appreciated! I hope that I am just missing something
obvious.
http://drools.46999.n3.nabble.com/file/n3322713/demo-score-sheet.xls
demo-score-sheet.xls
In future I may wish to also update a String field and keep concatenating
to
that field, is this possible?
John****
--
View this message in context:
http://drools.46999.n3.nabble.com/Spreadsheet-Rule-Compilation-error-xxx-...
Sent from the Drools: User forum mailing list archive at
Nabble.com.
_______________________________________________
rules-users mailing list****
[hidden email] <
http://user/SendEmail.jtp?type=node&node=3322896&i=1>****
https://lists.jboss.org/mailman/listinfo/rules-users****
_______________________________________________
rules-users mailing list
[hidden email] <
http://user/SendEmail.jtp?type=node&node=3322896&i=2> ****
https://lists.jboss.org/mailman/listinfo/rules-users
****
------------------------------
*If you reply to this email, your message will be added to the discussion
below:*
http://drools.46999.n3.nabble.com/Spreadsheet-Rule-Compilation-error-xxx-...
****
To unsubscribe from Spreadsheet: Rule Compilation error (xxx) cannot be
resolved: Keeping running total, click here. ****
** **
------------------------------
View this message in context: Re: [rules-users] Spreadsheet: Rule
Compilation error (xxx) cannot be resolved: Keeping running
total<http://drools.46999.n3.nabble.com/Spreadsheet-Rule-Compilation-e...
****
Sent from the Drools: User forum mailing list
archive<http://drools.46999.n3.nabble.com/Drools-User-forum-f47000.htm...
Nabble.com.
****
_______________________________________________
rules-users mailing list
[hidden email] <
http://user/SendEmail.jtp?type=node&node=3323110&i=1>
https://lists.jboss.org/mailman/listinfo/rules-users****
_______________________________________________
rules-users mailing list
[hidden email] <
http://user/SendEmail.jtp?type=node&node=3323110&i=2>
https://lists.jboss.org/mailman/listinfo/rules-users
****
------------------------------
*If you reply to this email, your message will be added to the discussion
below:*
http://drools.46999.n3.nabble.com/Spreadsheet-Rule-Compilation-error-xxx-...
****
To unsubscribe from Spreadsheet: Rule Compilation error (xxx) cannot be
resolved: Keeping running total, click here. ****
** **
------------------------------
View this message in context: Re: [rules-users] Spreadsheet: Rule
Compilation error (xxx) cannot be resolved: Keeping running
total<http://drools.46999.n3.nabble.com/Spreadsheet-Rule-Compilation-e...
Sent from the Drools: User forum mailing list
archive<http://drools.46999.n3.nabble.com/Drools-User-forum-f47000.htm...
Nabble.com.
****
------------------------------
**************************************************************************************
This message is confidential and intended only for the addressee. If you
have received this message in error, please immediately notify the
postmaster(a)nds.com and delete it from your system as well as any copies.
The content of e-mails as well as traffic data may be monitored by NDS for
employment and security purposes. To protect the environment please do not
print this e-mail unless necessary.
NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18
4EX, United Kingdom. A company registered in England and Wales. Registered
no. 3080780. VAT no. GB 603 8808 40-00
**************************************************************************************
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users