Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » remove duplications in sequence
remove duplications in sequence [message #72056] Wed, 16 January 2008 10:57 Go to next message
wong is currently offline wongFriend
Messages: 54
Registered: July 2009
Member
Hello,

I used 'union' joined several Sequence, then used asSet() converted it to
a Set. A problem is duplications are not be removed.

Thanks for any help.

Wong.
[ATL] Re: remove duplications in sequence [message #72166 is a reply to message #72056] Wed, 16 January 2008 16:04 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: quentin.glineur.obeo.fr

This is a multi-part message in MIME format.
--------------090608040205070804030409
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit

Hello,

First, please prefix the subject of you ATL related post with [ATL] as I
did for the answer. Thanks.

Then ATL sets are implemented by java hash set. The only way I see for
duplications no to be removed is that they are not *completely* equal
(by the equals() method of their implementation class).

What is the type of the elements of your sequence ?

Quentin

wong a
Re: [ATL] Re: remove duplications in sequence [message #72202 is a reply to message #72166] Wed, 16 January 2008 17:23 Go to previous messageGo to next message
wong is currently offline wongFriend
Messages: 54
Registered: July 2009
Member
Hello,

Sorry about the prefix of the subject. Thank you for your reply.

The elements of the sequence is a 'ConceptRelationship' class ecore model:
<eClassifiers xsi:type="ecore:EClass" name="ConceptRelationship">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="label"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="type"
eType="#//RelationshipType"
defaultValueLiteral=""/>
<eStructuralFeatures xsi:type="ecore:EReference" name="source"
eType="#//Concept"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="target"
eType="#//Concept"/>
</eClassifiers>


inside the container class is :
<eStructuralFeatures xsi:type="ecore:EReference"
name="conceptRelations" upperBound="-1"
eType="#//ConceptRelationship" containment="true"/>


and I also got error when I tried to print out the label value.

Thanks for any help.

Wong.
Re: [ATL] Re: remove duplications in sequence [message #72305 is a reply to message #72202] Thu, 17 January 2008 11:12 Go to previous messageGo to next message
wong is currently offline wongFriend
Messages: 54
Registered: July 2009
Member
Hello,

I used iterate and still can not remove the duplication.

->iterate(e; fin: Sequence(Education!ConceptRelationship)=Sequence{} |
if e.label = 'include' then
fin->append(e)
else
fin->append(e)
endif


Then I want compare the label value to remove the duplication manually. I
can get the size of the sequence, but can not retrive the label value????

rdfs.conceptRelations.size().debug('ConceptRelationship total');
rdfs.conceptRelations.debug('conceptRelations');
rdfs.conceptRelations ->first().label.debug('tttt')

erroe message:

[am3.atl] INFO: ConceptRelationship total: 4
[am3.atl] INFO: conceptRelations: Sequence {OUT!<unnamed>,
OUT!<unnamed>, OUT!<unnamed>, OUT!<unnamed>}
[am3.atl] INFO: tttt: OclUndefined

Any help, please.

Thanks in advance.

Wong.
Re: [ATL] Re: remove duplications in sequence [message #72393 is a reply to message #72305] Thu, 17 January 2008 16:19 Go to previous messageGo to next message
wong is currently offline wongFriend
Messages: 54
Registered: July 2009
Member
Hello,

I initialzed a sequence as a attribute of a class in 'to' section of a
rule. Then I tried delete some elements in the sequence in 'do' section
of the rule, but this not work.

Wong: a man who hate ATL.
Re: [ATL] Re: remove duplications in sequence [message #72412 is a reply to message #72393] Thu, 17 January 2008 17:28 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: quentin.glineur.obeo.fr

This is a multi-part message in MIME format.
--------------000302050105010908050608
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit

Hi Wong,

OK, I think I understood your need. You want to consider one attribute
as a key. This one should work :

let relations = rdfs.conceptRelations in
relations->select(cr | not relations
->subSequence(1, relations->indexOf(cr))
->collect(cr2 | cr2.label)->includes(cr.label)
)

The idea is to keep, in a sequence, all the elements for which another
element with the same label does not exist before.

Your idea about the iterate is also good but I noticed that you append
the element in both alternative of your if test. You should do this
instead :

->iterate(e; fin: Sequence(Education!ConceptRelationship)=Sequence{} |
if fin->collect(cr | cr.label)->includes(e.label) then
fin
else
fin->append(e)
endif

Any way, it will only keep elements whose label is 'include' and the
will not remove duplications.

Quentin: another man who tries to help people to like good things ;)

wong a
Re: [ATL] Re: remove duplications in sequence [message #72556 is a reply to message #72412] Fri, 18 January 2008 13:19 Go to previous messageGo to next message
wong is currently offline wongFriend
Messages: 54
Registered: July 2009
Member
Hello, Quentin,

Thank you for your help. I got your code working. This is still different
from what I want.

I have a 'ConceptRelationship' class has labe, soure, target 3 attributes.
I want delete same initialized instances which have same label, and swaped
soures and targets.

My code looks like following:
->iterate(e; fin: Sequence(Education!ConceptRelationship)=Sequence{} |
if fin->select(cr | cr.label = e.label and cr.source=e.target and
cr.target =e.source )->isEmpty() or fin.isEmpty()
then
fin->append(e)
else
fin
endif
)

The select statement seem not working, and I got Oclundefined message when
I put debug after the cr.label.

Thank you,
Wong.
Re: [ATL] Re: remove duplications in sequence [message #72682 is a reply to message #72556] Fri, 18 January 2008 15:56 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: quentin.glineur.obeo.fr

This is a multi-part message in MIME format.
--------------060500030908070004080506
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit

wong a
Re: [ATL] Re: remove duplications in sequence [message #72729 is a reply to message #72682] Fri, 18 January 2008 16:48 Go to previous messageGo to next message
wong is currently offline wongFriend
Messages: 54
Registered: July 2009
Member
Hello, Quentin,

I have worked on this several days. It is very strange.

I used the resolveTemp to assign all relationships to a container.
Everything works fine, but I can not retrieve the value of
attribute(label) of relationship to compare.

XML!Element.allInstancesFrom('IN')->select(e|e.name='skos:subject')- >collect(e|thisModule.resolveTemp(e,
'infRelSub'))
-----------------------
Then I used distinct to assign all relationships to the container, I can
retrieve the value of all attributes and compare, but the container does
not change after I deleted some elements in 'do' section of the rule.

conceptRelations <- allre),

allre: distinct CAVIAr!ConceptRelationship foreach (i in b)(
label<-'include',
source<-i.parent,
target<- if ........

Thank you very much.
Wong.
Re: [ATL] Re: remove duplications in sequence [message #72915 is a reply to message #72729] Mon, 21 January 2008 08:56 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: quentin.glineur.obeo.fr

This is a multi-part message in MIME format.
--------------080005010104040907040705
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit

Hi Wong,

Actually, the problem comes from the declarative part.
Once the attribute is set in the declarative part, one cannot make any
removal in the imperative part.
This post explains this:
http://dev.eclipse.org/newslists/news.eclipse.modeling.m2m/m sg01788.html

As a consequence, prefer using an OCL expression (even though it is more
complex) to set your property in the declarative style.

Regards,
Quentin

wong a
Re: [ATL] Re: remove duplications in sequence [message #73011 is a reply to message #72915] Mon, 21 January 2008 12:09 Go to previous message
wong is currently offline wongFriend
Messages: 54
Registered: July 2009
Member
Hello Quentin,

I understood its a bug of ATL. Appreciate your help.

Wong: A man starts introduce ATL to friends.
Previous Topic:Problem with for
Next Topic:[ATL] Difference between IBM MTF and ATL
Goto Forum:
  


Current Time: Sat Apr 10 14:26:09 GMT 2021

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

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

Back to the top