[rules-users] newbie, Expressing a rule in different ways

rouvas at di.uoa.gr rouvas at di.uoa.gr
Fri Jan 29 14:46:24 EST 2010


Can you please explain why the second form of the same (as it seems to me)
rule does not work?

This works:

rule "takeTwo"
  when
    $c : CD713AType(
Body.incrementalUpdateOfEconomicOperators.traderAuthorisation.size !=
0 )
    $t : TraderAuthorisationType ( $t.OperatorRole.size == 0) from
$c.Body.incrementalUpdateOfEconomicOperators.traderAuthorisation
  then
    stdout(drools.getRule().getName()+"
"+$c.getHeader().getMessageIdentifier());
end

and this fails to compile:

rule "take3"
  when
    $c : CD713AType( $i : this.Body.incrementalUpdateOfEconomicOperators )
    $t : TraderAuthorisationType ( $t.OperatorRole.size !=0 ) from
$i.traderAuthorisation
  then
    stdout(drools.getRule().getName()+"
"+$c.getHeader().getMessageIdentifier());
end

with the message:

Unable to build expression for 'from' : Failed to compile: 1 compilation
error(s):
 - (1,22) unqualified type in strict mode for: traderAuthorisation
'$i.traderAuthorisation' : [Rule name='take3']

Pretty new to Drools and try to figure out how things work.
In the second form of the rule I am trying to use the $i variable as a
shortcut for the "Body.incrementalUpdateOfEconomicOperators" locator.

"stdout" is just a function that print to System.out

Thank you for your time,
-Stathis




More information about the rules-users mailing list