Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [QVTO] About ordering collections
[QVTO] About ordering collections [message #76874] Tue, 18 March 2008 08:29 Go to next message
Juan Cadavid is currently offline Juan CadavidFriend
Messages: 59
Registered: July 2009
Location: Paris, France
Member

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 Go to previous messageGo to next message
Sergey Boyko is currently offline Sergey BoykoFriend
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 Go to previous messageGo to next message
Eclipse UserFriend
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
>
Re: [QVTO] About ordering collections [message #77406 is a reply to message #77391] Mon, 24 March 2008 19:16 Go to previous message
Juan Cadavid is currently offline Juan CadavidFriend
Messages: 59
Registered: July 2009
Location: Paris, France
Member

Thanks a lot Alexander. As you said, I just had to understand that OCL is
declarative and doesn't modify the source objects of operations.

If it's possible for you, I'd really appreciate your help on my other
issue at
http://www.eclipse.org/newsportal/article.php?id=2387&gr oup=eclipse.modeling.m2m#2387
about adding custom operations to the OCL primitive data types, since I
need a split() operation for strings.

Thanks again!

-Juan
Previous Topic:[ATL] Model Inferencing
Next Topic:ATL cannot find local helper?
Goto Forum:
  


Current Time: Thu Apr 25 01:00:52 GMT 2024

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

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

Back to the top