[Acceleo 3] Intersection on 2 list return string, and not the objects [Solved] [message #547777] |
Mon, 19 July 2010 15:23 |
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 |
|
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 ) The key element here is to use select with an OCL expression which returns a boolean.
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
|
|
|
|
Powered by
FUDForum. Page generated in 0.03355 seconds