[rules-users] FW: Decision Tables

Hehl, Thomas Thomas.Hehl at acs-inc.com
Wed Aug 29 13:23:07 EDT 2007


Got that. How do I code the action so it calls the setAnswer() method on my
BooleanAnswer object?

 

  _____  

From: rules-users-bounces at lists.jboss.org
[mailto:rules-users-bounces at lists.jboss.org] On Behalf Of Mark Proctor
Sent: Wednesday, August 29, 2007 12:59 PM
To: Rules Users List
Subject: Re: [rules-users] FW: Decision Tables

 

This isn't bug, you aren't using drools correctly. Only valid java can be
used in an Action. anAnswer:BooleanAnswer is not valid java and shows up in
your generated code:
anAnswer: BooleanAnswer.anAnswer.setAnswer(true);;

Hehl, Thomas wrote: 

The problem appears to be that the rule being generated is just flat wrong.
I'm starting to think this is a bug in decision tables for 4.0 GA.

 

The following entry:

 


 

 


ACTION

 


anAnswer: BooleanAnswer

 


anAnswer.setAnswer($param);

 


Allowed

 


TRUE

 


 


 


 


 


TRUE

 


 


 


 


 

 

 

Generates this rule:

 

rule "postponePart_10"

      

      when

            PoolInfo(courtLocation == "101", statusCode >= 0, statusCode <=
2, numberFta < 1, numberOfDeferralsPosted < 2, daysBeforeSummons>= 1,
daysBeforeSummons<= 1)

      then

            anAnswer: BooleanAnswer.anAnswer.setAnswer(true);;

end

 

This doesn't seem right at all. What I'm trying to do is to call the
setAnswer method on the object I passed in with:

 

            StatelessSession session =
participantRuleBase.newStatelessSession();

            

            //now create some test data

            PoolInfo pool = part.getActivePool();

            BooleanAnswer answer = new BooleanAnswer();

            

            Object[] rules = new Object[]{pool, answer};

            session.execute(rules);

            

            return answer.isTrue();

 

 

Advice?

 

Thanks.

 

 

 

  _____  

From: Hehl, Thomas 
Sent: Tuesday, August 28, 2007 4:10 PM
To: 'rules-users at lists.jboss.org <mailto:rules-users at lists.jboss.org> '
Subject: Decision Tables

 

I'm having trouble figuring out the ACTION section of a decision table.
Everything else appears to be working.

 

My rules result in a simple True/False condition. To do this in a decision
table, I've created a class called BooleanAnswer that looks like:

 

public class BooleanAnswer {

            

            private boolean   answer;

            

            

            /**

             * no-arg constructor

             */

            public BooleanAnswer(){

            }

            

 

            /**

             * create your own default answer

             * @param answer the answer to set

             */

            public BooleanAnswer(boolean answer){

                        setAnswer(answer);

            }

            

 

            /**

             * @return the answer

             */

            public boolean isTrue() {

                        return answer;

            }

            

 

            /**

             * @param answer the answer to set

             */

            public void setAnswer(boolean answer) {

                        this.answer = answer;

            }

}

 

 

Then I create a decision table with the following ACTION in it:

 


ACTION

 


answer: BooleanAnswer

 


answer.setAnswer($param);

 


Allowed

 


TRUE

 


 


 


 


 

 

This generates the following errors:

 

...

Caused by: org.drools.rule.InvalidRulePackage: Rule Compilation error :
[Rule name=postponePart_15, agendaGroup=MAIN, salience=0, no-loop=false]

            participantPostponementRules/Rule_postponePart_15_0.java (8:343)
: The field BooleanAnswer.answer is not visible

Rule Compilation error : [Rule name=postponePart_13, agendaGroup=MAIN,
salience=0, no-loop=false]

            participantPostponementRules/Rule_postponePart_13_0.java (8:343)
: The field BooleanAnswer.answer is not visible

Rule Compilation error : [Rule name=postponePart_14, agendaGroup=MAIN,
salience=0, no-loop=false]

            participantPostponementRules/Rule_postponePart_14_0.java (8:343)
: The field BooleanAnswer.answer is not visible

Rule Compilation error : [Rule name=postponePart_16, agendaGroup=MAIN,
salience=0, no-loop=false]

            participantPostponementRules/Rule_postponePart_16_0.java (8:343)
: The field BooleanAnswer.answer is not visible

Rule Compilation error : [Rule name=postponePart_17, agendaGroup=MAIN,
salience=0, no-loop=false]

            participantPostponementRules/Rule_postponePart_17_0.java (8:343)
: The field BooleanAnswer.answer is not visible

Rule Compilation error : [Rule name=postponePart_10, agendaGroup=MAIN,
salience=0, no-loop=false]

            participantPostponementRules/Rule_postponePart_10_0.java (8:343)
: The field BooleanAnswer.answer is not visible

Rule Compilation error : [Rule name=postponePart_11, agendaGroup=MAIN,
salience=0, no-loop=false]

            participantPostponementRules/Rule_postponePart_11_0.java (8:343)
: The field BooleanAnswer.answer is not visible

Rule Compilation error : [Rule name=postponePart_18, agendaGroup=MAIN,
salience=0, no-loop=false]

            participantPostponementRules/Rule_postponePart_18_0.java (8:343)
: The field BooleanAnswer.answer is not visible

Rule Compilation error : [Rule name=postponePart_19, agendaGroup=MAIN,
salience=0, no-loop=false]

            participantPostponementRules/Rule_postponePart_19_0.java (8:343)
: The field BooleanAnswer.answer is not visible

Rule Compilation error : [Rule name=postponePart_12, agendaGroup=MAIN,
salience=0, no-loop=false]

            participantPostponementRules/Rule_postponePart_12_0.java (8:343)
: The field BooleanAnswer.answer is not visible

 

            at org.drools.rule.Package.checkValidity(Package.java:408)

            at
org.drools.common.AbstractRuleBase.addPackage(AbstractRuleBase.java:288)

            at
com.acs.gs.juror.bizstrategy.PostponementStrategy.init(PostponementStrategy.
java:129)

            ... 14 more

)

            at junit.framework.Assert.fail(Assert.java:47)

            at junit.framework.TestSuite$1.runTest(TestSuite.java:263)

            at junit.framework.TestCase.runBare(TestCase.java:127)

            at junit.framework.TestResult$1.protect(TestResult.java:106)

            at junit.framework.TestResult.runProtected(TestResult.java:124)

            at junit.framework.TestResult.run(TestResult.java:109)

            at junit.framework.TestCase.run(TestCase.java:118)

            at junit.framework.TestSuite.runTest(TestSuite.java:208)

            at junit.framework.TestSuite.run(TestSuite.java:203)

            at
org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3T
estReference.java:128)

            at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:3
8)

            at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRu
nner.java:460)

            at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRu
nner.java:673)

            at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.
java:386)

            at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner
.java:196)

 

 

Help for a newbie, please?

 

Thanks.

Thom Hehl
Sr. eJuror Architect

* Office (859) 277-8800 x 144

* Thomas.Hehl at acs-inc.com <mailto:Thomas.Hehl at acs-inc.com>  
ACS, Inc.

Government Solutions

1733 Harrodsburg Road
Lexington, KY 40504-3617

This e-mail message, including any attachments, is for the sole use of the
intended recipient(s) and may contain confidential and privileged
information. Any unauthorized review, use, disclosure or distribution is
prohibited. If you are not the intended recipient, please contact the sender
by reply e-mail and destroy all copies of the original message and notify
sender via e-mail at Thomas.Hehl at acs-inc.com
<mailto:Thomas.Hehl at acs-inc.com>  or by telephone at 859-277-8800 ext. 144.
Thank you.

 

 





  _____  



 
_______________________________________________
rules-users mailing list
rules-users at lists.jboss.org <mailto:rules-users at lists.jboss.org> 
https://lists.jboss.org/mailman/listinfo/rules-users
<https://lists.jboss.org/mailman/listinfo/rules-users> 
  

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20070829/f5c223c4/attachment.html 


More information about the rules-users mailing list