|
[ATL] Re: remove duplications in sequence [message #72166 is a reply to message #72056] |
Wed, 16 January 2008 16:04   |
Eclipse User |
|
|
|
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 #72412 is a reply to message #72393] |
Thu, 17 January 2008 17:28   |
Eclipse User |
|
|
|
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 #72729 is a reply to message #72682] |
Fri, 18 January 2008 16:48   |
wong 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   |
Eclipse User |
|
|
|
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
|
|
|
|
Powered by
FUDForum. Page generated in 0.02726 seconds