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

Wolfgang Laun wolfgang.laun at gmail.com
Sat Jan 30 11:46:25 EST 2010


Guessing that Body.incrementalUpdateOfEconomicOperators.traderAuthorisation is
a List<TraderAuthorisationType>, I'd say that binding a List<X> results in the
bound variable ($i in take3) being declared as an untyped List<?> in the code
compiled from the .drl file.

-W


On Fri, Jan 29, 2010 at 8:46 PM,  <rouvas at di.uoa.gr> wrote:
> 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
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>




More information about the rules-users mailing list