Wolfang,
thank you very much for your reply.
Your assumptions are correct and your explanation makes sense.
Unfortunately, I cannot understand why this happens.
Let me explain things a bit.
I will use the shorthand notation "IUEcop" to refer to the
"incrementalUpdateOfEconomicOperators" object.
The IUEcop has the following structure (in rough terms)
IUEcop
+- (various objects as properties)
+- list of traderAuthorisation
+- list of warehouseAuthorisation
+- list of temporaryAuthorisation
So in rule "takeTwo" the expression
"$c.Body.IUEcop.traderAuthorisation"
directly refers to the list of traderAuthorisation.
In rule "take3" I was expecting the expression "$i : this.Body.IUEcop"
to
bind the variable $i to the IUEcop object and consequently I was expecting
that the expression "from $i.traderAuthorisation" would refer to the list
of traderAuthorisation from the $i (IUEcop) object.
I do not understand why this is not happening.
A more general issue with my understanding has to do with handling of
deeply nested objects. In my case, the "traderAuthorisation" object has
itself another set of object properties and lists that I would like to
refer to in my rules. Are you aware of any relevant documentation?
Thank you very much for your time,
-Stathis
Wolfgang Laun wrote:
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(a)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(a)lists.jboss.org
>
https://lists.jboss.org/mailman/listinfo/rules-users
>