Is carton used on the left hand side of
the rule? All actions can only take place against an instance that was referred
to on the LHS.
From:
rules-users-bounces@lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] On
Behalf Of Costello, Robert
Sent: Friday, January 16, 2009
10:52 AM
To:
Subject: RE: [rules-users] How to
access data after rule fires
The next issue I’m running into is
referencing a method in another class for the action. In this case, we
get a compile error “Carton.carton cannot be resolved”
I have both objects in the import
statement. Is the syntax incorrect?
|
RuleTable |
|
|
CONDITION |
ACTION |
|
product: Product |
carton: Carton |
|
brand: brand |
carton.isGood($param); |
Cases |
hoover match case |
|
Brand Check |
hoover |
TRUE |
Bad Brand |
walmart |
FALSE |
Robert Costello
Lead Systems Engineer
IMA Performance
E3- 279A
847.286.0910
-----Original Message-----
From:
rules-users-bounces@lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] On
Behalf Of Costello, Robert
Sent: Tuesday, January 13, 2009
12:34 PM
To:
Subject: RE: [rules-users] How to
access data after rule fires
So, ultimately this
helped. One other thing I needed to get this working was a variable for
my object, like you said below (brand.setGoodBrand). Once I changed that,
it fired. The suggestion to use parameters was also good as it allows for
more rule flexibility. When I used the setGoodBrand(true), it only
worked if there was some sort of value in the action column for the rule, even
an ‘x’, as Steven suggested. And I am able to get the
changed values either by direct reference to the object or by getting the
object from the session.
Thanks to Edson and
Steven for the fast replies!
|
RuleTable |
|
|
CONDITION |
ACTION |
|
product: Product |
|
|
brand: brand |
product.setGoodBrand($param); |
Cases |
hoover match case |
|
Brand Check |
hoover |
TRUE |
Bad Brand |
walmart |
FALSE |
Robert Costello
-----Original Message-----
From:
rules-users-bounces@lists.jboss.org [mailto:rules-users-bounces@lists.jboss.org]
On Behalf Of Steven Williams
Sent: Monday, January 12, 2009
6:26 PM
To:
Subject: Re: [rules-users] How to
access data after rule fires
If you put an X or something in the cell (i.e. just
don't leave it empty) it should also work.
On Tue, Jan 13, 2009 at 10:57 AM, Edson Tirelli <tirelli@post.com> wrote:
The action is not being executed. I don't use decision
tables frequently, but I think that it ignores empty cells and is generating an
empty consequence for your rule. Usually, you would place the method call on
the header prototype and the parameter in the cell. So your cell would be:
| hoover | true |
| xyz | false |
The method prototype would be something like (please
check the correct syntax in the manual):
brand.setGoodBrand( $param );
Where the engine would replace $param by the value you
write in the cell.
[]s
Edson
2009/1/12 Costello, Robert <rcost10@searshc.com>
I tried that and it
returned false, which doesn't make sense to me since the rule firing is to set
the value to true, and in the execution the rule does fire.
StatefulKnowledgeSession session = kbase.newStatefulKnowledgeSession();
Product p = new Product();
p.setBrand("hoover");
session.insert( p );
int u = session.fireAllRules();
System.out.println(u + " many rules fired");
System.out.println("is brand good? " + p.isGoodBrand());
Here's a snippet
of the rule (decision table)
|
CONDITION |
ACTION |
|
Product |
|
|
brand |
setGoodBrand(true); |
Cases |
hoover
match case |
|
Brand Check |
hoover |
|
And the console returns:
1 many rules
fired
is brand good?
false
Robert Costello
Lead Systems Engineer
IMA Performance
E3- 279A
847.286.0910
-----Original Message-----
From: rules-users-bounces@lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org]
On Behalf Of Edson Tirelli
Sent: Monday, January 12, 2009
4:16 PM
To:
Subject: Re: [rules-users] How to
access data after rule fires
Can't you keep the reference to your object while firing the
rules?
MyObject x = ...
ksession.insert( x );
ksession.fireAllRules();
boolean result = x.getBooleanAttribute();
[]s
Edson
2009/1/12 Costello, Robert <rcost10@searshc.com>
So, how do I access data after the rules fire?
If one has a rule which modifies a field on an object (a boolean, for
example), and you want to return the object after the rules are
complete, how do you do it?
I tried this using a StatefulKnowledgeSession, getting an object
collection after the rules fire, but I don't see that this works.
Also googled the heck out of this and looked in all the documentation.
I must be missing something, because the docs generally are pretty good.
Any hints?
Thanks in advance,
Robert Costello
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
--
Edson Tirelli
JBoss Drools Core Development
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
--
Edson Tirelli
JBoss Drools Core Development
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
--
Steven Williams
Supervising Consultant
Object Consulting
Office: 8615 4500 Mob: 0439 898 668 Fax: 8615 4501
steven.williams@objectconsulting.com.au
www.objectconsulting.com.au
consulting | development | training | support
our experience makes the difference