[QVTO] About ordering collections [message #76874] |
Tue, 18 March 2008 08:29 |
|
Hi QVTO team,
Thanks a lot for your help on my previous issue, everything is working ok
now. Here's a question about your OCL implementation:
I have a collection with repeated objects. They are repeated, in terms
that they are of the same type and their properties have the same value. I
need to remove these repeated objects, so I apply asOrderedSet() on the
collection. According to the OCL specification, this operation should
remove the repeated objects, besides ordering them; however QVTO isn't
doing this right now.
I could implement the removal of duplicates manually, but I'd like to know
if there's a way to do this that I'm missing. Thanks a lot!
-Juan
|
|
|
Re: [QVTO] About ordering collections [message #76906 is a reply to message #76874] |
Tue, 18 March 2008 10:09 |
Sergey Boyko Messages: 171 Registered: July 2009 |
Senior Member |
|
|
Hi Juan,
Operational QVT is built upon OCL and all ocl-related calls are handled
by OCL evaluator. I think behavior you asked is not QVTO but rather OCL
specific.
The reason why "repeated" objects stays unaffected in resulted
collection is that OCL implements OrderedSet by means of LinkedHashSet
java-class. Therefore objects' equality is measured by means of java
equals() operation. EMF-generated implementation doesn't redefines
equals() so default "by-reference" comparison is used.
You can customize EMF-generated sources and provide equals()/hashCode()
methods but I guess that using select()/reject() operation on OCL
collection is more suitable in your case.
Regards,
Sergey.
Juan Jose Cadavid G wrote:
> Hi QVTO team,
>
> Thanks a lot for your help on my previous issue, everything is working
> ok now. Here's a question about your OCL implementation:
>
> I have a collection with repeated objects. They are repeated, in terms
> that they are of the same type and their properties have the same value.
> I need to remove these repeated objects, so I apply asOrderedSet() on
> the collection. According to the OCL specification, this operation
> should remove the repeated objects, besides ordering them; however QVTO
> isn't doing this right now.
>
> I could implement the removal of duplicates manually, but I'd like to
> know if there's a way to do this that I'm missing. Thanks a lot!
>
> -Juan
>
|
|
|
Re: [QVTO] About ordering collections [message #77391 is a reply to message #76874] |
Mon, 24 March 2008 13:51 |
Eclipse User |
|
|
|
Originally posted by: Alexander.Igdalov.borland.com
Hi Juan,
Are you looking at the source collection or the resulting one?
var resColl := srcColl->asOrderedSet();
The new collection - resColl - mustn't contain dups, but srcColl may
contain them since it is not affected by OCL expressions such as the
asOrderedSet operation.
WBR,
Alex.
Juan Jose Cadavid G wrote:
> Hi QVTO team,
>
> Thanks a lot for your help on my previous issue, everything is working
> ok now. Here's a question about your OCL implementation:
>
> I have a collection with repeated objects. They are repeated, in terms
> that they are of the same type and their properties have the same value.
> I need to remove these repeated objects, so I apply asOrderedSet() on
> the collection. According to the OCL specification, this operation
> should remove the repeated objects, besides ordering them; however QVTO
> isn't doing this right now.
>
> I could implement the removal of duplicates manually, but I'd like to
> know if there's a way to do this that I'm missing. Thanks a lot!
>
> -Juan
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.03800 seconds