Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo 3] Intersection on 2 list return string, and not the objects [Solved]
[Acceleo 3] Intersection on 2 list return string, and not the objects [Solved] [message #547777] Mon, 19 July 2010 15:23 Go to next message
Laviale Benoit is currently offline Laviale Benoit
Messages: 25
Registered: April 2010
Location: Paris
Junior Member
Hello

I would filter two lists of objects.
One of this lists is a Set(Operation), and the other list a Set(MessagesOccurenceSpecification).

To do that, I build 3 queries :
The first one get the operations
[query public getAllOpeFromInteraction(l : Interaction) : Set(Operation) = l.lifeline.represents.type.ownedElement /]



The second one to get the messages
[query public getAllMessFromInteraction(l : Interaction) : Set(MessageOccurrenceSpecification) = l.fragment->select(
 mess | 
 	mess.oclAsType(MessageOccurrenceSpecification).event.eClass().name = 'ReceiveOperationEvent'
 		and (
 			mess.oclAsType(MessageOccurrenceSpecification).message.messageSort.toString().equalsIgnoreCase('synchCall')   or
 			mess.oclAsType(MessageOccurrenceSpecification).message.messageSort.toString().equalsIgnoreCase('asynchCall')
 			)
 		
 ) /]



The last one must compare the two lists. it must drop the duplicates entries, and drop the unused operations ( who are not in the Messages list)
[query public compareMessOpe( ListMess : Set(MessageOccurrenceSpecification), ListOpe : Set(Operation))
	 : Set(Operation) = 
	 ListOpe.name->intersection(ListMess.oclAsType(MessageOccurrenceSpecification).message.name)->asSet()
/]



The first and the second queries are good. The third gives me good values ( with no duplicates and no unused operations) but in string format...

How can I have operation object and not just the string object?

Thanks for the help

regards

Benoit


Trainee
Thales Communications France

[Updated on: Tue, 20 July 2010 09:41]

Report message to a moderator

Re: [Acceleo 3] Intersection on 2 list return string, and not the objects [message #547939 is a reply to message #547777] Tue, 20 July 2010 08:48 Go to previous messageGo to next message
Stephane Begaudeau is currently offline Stephane Begaudeau
Messages: 413
Registered: April 2010
Location: Nantes (France)
Senior Member

Hi,

The result is normal because "mySet.name" equals mySet->collect(elem | elem.name) and thus "ListOpe.name->" is a Set of String and its intersection with another set of String is a Set of String.

To achieve what you want, you'll need to try something different. In order to be sure that I give you a valid solution, I tested it so here is a nice screenshot (it's faster for me to explain with a screenshot than with sentences Very Happy ) The key element here is to use select with an OCL expression which returns a boolean.

http://img835.imageshack.us/img835/8950/acceleo3select.png

You can see there that I use "o.name" which is a shorter version of "o->collect(ope | ope.name)" to obtain a set with the name of all the operations. Since I'm collecting all the name in a Set, all duplicates are suppress. By the way, "select" is an OCL operation, if you need some documentation :

If you need the list of all OCL operations : http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse. acceleo.doc/doc/html/ocl_operation_reference.html
Or the list of all Acceleo operations : http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse. acceleo.doc/doc/html/acceleo_operation_reference.html

You can access the documentation online, or with the help menu in Eclipse.

Stephane Begaudeau, Obeo



[Updated on: Tue, 20 July 2010 09:00]

Report message to a moderator

Re: [Acceleo 3] Intersection on 2 list return string, and not the objects [message #547949 is a reply to message #547777] Tue, 20 July 2010 09:05 Go to previous message
Laviale Benoit is currently offline Laviale Benoit
Messages: 25
Registered: April 2010
Location: Paris
Junior Member
You do and did a very very good job! Wink
Thank you very much !


[Solved]



Trainee
Thales Communications France

[Updated on: Tue, 20 July 2010 09:05]

Report message to a moderator

Previous Topic:[JET]How to compile JET templates headless using ANT
Next Topic:[Acceleo] Modules recompilation
Goto Forum:
  


Current Time: Thu Oct 23 21:21:42 GMT 2014

Powered by FUDForum. Page generated in 0.08142 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software