Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo] How to traduct s.Fields ->collect(field|field.name='toto').notEmpty()
[Acceleo] How to traduct s.Fields ->collect(field|field.name='toto').notEmpty() [message #632631] Wed, 13 October 2010 12:14 Go to next message
poltrox  is currently offline poltrox
Messages: 16
Registered: June 2010
Junior Member
Hi,

I don't undurstand how to know if a collection contains a specifics elements.

I want to traduct this ATL fonction in Acceleo :
s.Fields ->collect(field|field.name='toto').notEmpty()

Thanks
Re: [Acceleo] How to traduct s.Fields ->collect(field|field.name='toto').notEmpty() [message #632741 is a reply to message #632631] Thu, 14 October 2010 02:59 Go to previous messageGo to next message
Stephane Begaudeau is currently offline Stephane Begaudeau
Messages: 406
Registered: April 2010
Location: Nantes (France)
Senior Member

Hi,

You should try something like this:
s.Fields.name->includes('toto')

which is exactly the same as:
s.Fields->collect(f | f.name)->includes('toto')

Stephane Begaudeau, Obeo



Re: [Acceleo] How to traduct s.Fields ->collect(field|field.name='toto').notEmpty() [message #632746 is a reply to message #632631] Thu, 14 October 2010 03:02 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent Goubet
Messages: 1625
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------040701010005030008010105
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Hi,

This is an OCL question rather than an Acceleo one.

"know if a collection contains a specific element" is not made through
"collect" in OCL ... and I am surprised your function works at all with ATL.

- s.Fields <= retrieve all fiels contained by "s"
- s.Fields->collect(field|field.name='toto') <= if a field's name is
"toto", add "true" to the collection, otherwise add "false" to it. If
you have fields named "tata", "toto", "titi", you then get a collection
containing "false", "true", "false" (the result of "field.name='toto'".
This is true in both ATL and Acceleo as it is basic OCL.
- s.Fields->collect(field|field.name='toto').notEmpty() <= returns true
if "s" contains at least one field, false otherwise, whatever the result
of "collect" as it does not alter the collection size.

"Testing if a collection contains a specific element" is done with
"exists", not "collect". You need to use :

- s.Fields->exists(field.name='toto')

where "exists(expression)" means "return true if at least one of the
elements in the collection validates 'expression'".

See also the OCL documentation we provide with Acceleo :
http://help.eclipse.org/helios/topic/org.eclipse.acceleo.doc /doc/html/ocl_operation_reference.html
..

Laurent Goubet
Obeo

poltrox wrote:
> Hi,
>
> I don't undurstand how to know if a collection contains a specifics
> elements.
>
> I want to traduct this ATL fonction in Acceleo :
> s.Fields ->collect(field|field.name='toto').notEmpty()
>
> Thanks


--------------040701010005030008010105
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=
--------------040701010005030008010105--
Re: [Acceleo] How to traduct s.Fields ->collect(field|field.name='toto').notEmpty() [message #632775 is a reply to message #632746] Thu, 14 October 2010 05:02 Go to previous messageGo to next message
poltrox  is currently offline poltrox
Messages: 16
Registered: June 2010
Junior Member
Sorry , but my question is how to traduct because in my acceleo template I can't use there ocl action on my object Fields.

Autocompletion do not take me exist() or collect() or includes() propositions. I have only acces at econtains, econtents .... and i dont find in this list an equivalent to exists.

s.fields is in my model a list of 0 * reference of Field.


Is it possible in a template to write an expression like s.Fields->exists(field.name='toto') ?

Re: [Acceleo] How to traduct s.Fields ->collect(field|field.name='toto').notEmpty() [message #632778 is a reply to message #632631] Thu, 14 October 2010 05:05 Go to previous message
poltrox  is currently offline poltrox
Messages: 16
Registered: June 2010
Junior Member
I have find.


I haven't see before today as operating -> is works in template . I always use .


Thanks for your response.

[Updated on: Thu, 14 October 2010 05:10]

Report message to a moderator

Previous Topic:[XPAND] Workflow problem
Next Topic:[Xpand] problem to launch a workflow from another one
Goto Forum:
  


Current Time: Fri Aug 22 02:00:45 EDT 2014

Powered by FUDForum. Page generated in 0.03984 seconds