[Acceleo]Collections of Collections on Queries [message #500602] |
Fri, 27 November 2009 02:44 |
Andre Messages: 29 Registered: November 2009 Location: Brazil |
Junior Member |
|
|
Hi
Is it possible to use collections of collections as return of a query? i've tried the code below, but the type 'Sequence(Sequente(T))' is Invalid.
[query public packages2(input : MetaComponent) : Sequence(Sequence(T)) =
input.properties->iterate(item : Property; res : Sequence(Sequence(String)) = Sequence{Sequence{}} | res->append(
item.type.ancestors(Package)->iterate(pack : Package; retur : Sequence(String) = Sequence{} | retur->append(pack.name))
)) /]
And what about the initialization of a collection of collection? i've tried 'Sequence{Sequence{}}', but i dont know if it is right.
thanks
Andre Silva
Natal-RN
Brazil
[Updated on: Fri, 27 November 2009 13:58] Report message to a moderator
|
|
|
Re: Collections of Collections on Queries [message #500640 is a reply to message #500602] |
Fri, 27 November 2009 09:33 |
|
This is a multi-part message in MIME format.
--------------020008040900020608000409
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Hi Andre,
You can initialize sequences containing Sequence like you described here
: "Sequence{Sequence{'a', 'b'}, Sequence{'c'}}" is perfectly legal.
However, the current implementation of OCL will prevent you from using
Sequences typed with Sequences : "Sequence(Sequence(String))" is
illegal. That means you cannot define Acceleo queries returning such
sequences, and you cannot cast to them either "Sequence{Sequence{'a',
'b'}, Sequence{'c'}}.oclAsType(Sequence(Sequence(String)))" will fail in
compilation error.
Laurent Goubet
Obeo
Andre wrote:
> Hi
>
> Is it possible to use collections of collections as return of a query?
> i've tried the code below, but the type 'Sequence(Sequente(T))' is Invalid.
>
> [query public packages2(input : MetaComponent) : Sequence(Sequence(T)) =
> input.properties->iterate(item : Property; res :
> Sequence(Sequence(String)) = Sequence{Sequence{}} | res->append(
> item.type.ancestors(Package)->iterate(pack : Package; retur :
> Sequence(String) = Sequence{} | retur->append(pack.name))
> )) /]
>
>
> And what about the initialization of a collection of collection? i've
> tried 'Sequence{Sequence{}}', but i dont know if it is right.
>
> thanks
>
--------------020008040900020608000409
Content-Type: text/x-vcard; charset=utf-8;
name="laurent_goubet.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="laurent_goubet.vcf"
YmVnaW46dmNhcmQNCmZuOkxhdXJlbnQgR291YmV0DQpuOkdvdWJldDtMYXVy ZW50DQpvcmc6
PGEgaHJlZj0iaHR0cDovL3d3dy5vYmVvLmZyIj5PYmVvPC9hPg0KZW1haWw7 aW50ZXJuZXQ6
bGF1cmVudC5nb3ViZXRAb2Jlby5mcg0KdXJsOmh0dHA6Ly93d3cub2Jlby5m cg0KdmVyc2lv
bjoyLjENCmVuZDp2Y2FyZA0KDQo=
--------------020008040900020608000409--
|
|
|
|
Re: Collections of Collections on Queries [message #500696 is a reply to message #500687] |
Fri, 27 November 2009 14:41 |
|
This is a multi-part message in MIME format.
--------------060204080005070409050606
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Andre,
This is possible, and should work as you did. The only potential
explanation I see is that the compiler mixes up a custom "String"
classifier you have in your metamodel (or the UML "String" for that
matter) with the OCL String.
In this :
"queryA(s : String)" if you ctrl+click on "String", does it open the
"oclstdlib.ecore" model on "String"?
and same question on
"item.toString()" : which "toString()" is called? Is its return type the
same "String" as just above?
If none of what I say makes sense to you, could you provide us with the
module that fails to compile?
Laurent Goubet
Obeo
Andre wrote:
> Hi Laurent
>
> is it possible to call a query A inside of a query B?
>
> something like:
> [query queryA(s : String) : String = s.concat(';') /]
> [query queryB(s : Sequence(T) ) : Sequence(T) = s->iterate( item :
> String; ret : Sequence(String) = Sequence{} | ret->append (
> queryA(item.toString()) )) /]
>
> When i do this, an error occours on query B: Invalid Operation Signature
> (queryA(String))
>
> thanks
>
--------------060204080005070409050606
Content-Type: text/x-vcard; charset=utf-8;
name="laurent_goubet.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="laurent_goubet.vcf"
YmVnaW46dmNhcmQNCmZuOkxhdXJlbnQgR291YmV0DQpuOkdvdWJldDtMYXVy ZW50DQpvcmc6
PGEgaHJlZj0iaHR0cDovL3d3dy5vYmVvLmZyIj5PYmVvPC9hPg0KZW1haWw7 aW50ZXJuZXQ6
bGF1cmVudC5nb3ViZXRAb2Jlby5mcg0KdXJsOmh0dHA6Ly93d3cub2Jlby5m cg0KdmVyc2lv
bjoyLjENCmVuZDp2Y2FyZA0KDQo=
--------------060204080005070409050606--
|
|
|
|
Re: Collections of Collections on Queries [message #500794 is a reply to message #500789] |
Sat, 28 November 2009 19:53 |
Andre Messages: 29 Registered: November 2009 Location: Brazil |
Junior Member |
|
|
Hi
Based on this problem and other tests, i've concluded that on queries like these, when a query calls another, the error message is always 'Invalid Operation Signature', even when there is another type of error subsequent on the query. So, the developer thinks that the problem is on the call to the other query, when it isn't.
Andre Silva
Natal-RN
Brazil
|
|
|
Powered by
FUDForum. Page generated in 0.04176 seconds