Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo] Removing duplicate in collection(How to remove duplicate descriptions of collections)
[Acceleo] Removing duplicate in collection [message #897655] Tue, 24 July 2012 23:13 Go to next message
Wagner de Andrade Perin is currently offline Wagner de Andrade PerinFriend
Messages: 2
Registered: July 2012
Junior Member
Hi.

I am a beginner in Acceleo and have a "simple" problem.

I write this code:
primeiraOrdem(Conceito, Consulta) :-
[for (elemento : Componentes | aMapaConceitual.elementos->sortedBy(descricao))]
	[if (elemento.oclIsTypeOf(Relacao))]
	[elemento.descricao/](Conceito, Consulta),
	[/if]
[/for]

And i get this results:
primeiraOrdem(Conceito, Consulta) :-
	e(Conceito, Consulta),
	podeestar(Conceito, Consulta),
	podeser(Conceito, Consulta),
	quandoesta(Conceito, Consulta),
	quandoesta(Conceito, Consulta),
	tem(Conceito, Consulta),
	tem(Conceito, Consulta).


My question is: "How can I remove the lines that are worded "duplicate" (case of 'quandoesta' and 'tem')?"

I tried everything I could think but not got successful.

Excuse my poor English.

Thank you already.
Re: [Acceleo] Removing duplicate in collection [message #897671 is a reply to message #897655] Wed, 25 July 2012 05:06 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Set is the usual way to force uniqueness, with isUnique() helpful in
more complicated scenarios.

You can just change to loop over your names reduced to a set of their values

[for (descricao: String|
aMapaConceitual.elementos->select(oclIsTypeOf(Relacao)).descricao->asSet()->sortedBy(descricao
| descricao))]
[descricao/](Conceito, Consulta),
[/for]

oclIsKindOf is generally better than oclIsTypeOf, in which case filter()
would be better. (In Juno OCL adds selectByType and selectByKind as well).

Regards

Ed Willink

On 25/07/2012 00:13, Wagner de Andrade Perin wrote:
> Hi.
>
> I am a beginner in Acceleo and have a "simple" problem.
>
> I write this code:
>
> primeiraOrdem(Conceito, Consulta) :-
> [for (elemento : Componentes |
> aMapaConceitual.elementos->sortedBy(descricao))]
> [if (elemento.oclIsTypeOf(Relacao))]
> [elemento.descricao/](Conceito, Consulta),
> [/if]
> [/for]
>
> And i get this results:
> primeiraOrdem(Conceito, Consulta) :-
> e(Conceito, Consulta),
> podeestar(Conceito, Consulta),
> podeser(Conceito, Consulta),
> quandoesta(Conceito, Consulta),
> quandoesta(Conceito, Consulta),
> tem(Conceito, Consulta),
> tem(Conceito, Consulta).
>
> My question is: "How can I remove the lines that are worded
> "duplicate" (case of 'quandoesta' and 'tem')?"
>
> I tried everything I could think but not got successful.
>
> Excuse my poor English.
>
> Thank you already.
icon14.gif  Re: [Acceleo] Removing duplicate in collection [message #897993 is a reply to message #897671] Wed, 25 July 2012 15:07 Go to previous messageGo to next message
Wagner de Andrade Perin is currently offline Wagner de Andrade PerinFriend
Messages: 2
Registered: July 2012
Junior Member
Thank you so much.

It worked perfectly.

I tried using the "asSet" but with a collection of "Relacao" and not their "descricao".

Now I understand how to use it.

I'm very grateful for your help!
How to Remove Duplicates Using Advance Filter? [message #1624972 is a reply to message #897655] Fri, 20 February 2015 04:27 Go to previous message
Gangyada Krishna is currently offline Gangyada KrishnaFriend
Messages: 2
Registered: February 2015
Junior Member
Removing duplicates is one of the important tasks, when we work with database in excel. Many times you encounter a situation where you need to remove duplicate records/data. In the following article we tried explaining you 'How to remove duplicates using Advanced Filter', hope this articles helps you!

1 Data before removing duplicates.

2 Data after removing duplicates.

Let us follow step by step process for removing duplicates using Advanced Filter.

1 Select a cell in your data set and choose Data from menu.

2 Select Filter and select Advanced from Sort and Filter group.

3 Advanced Filter dialogue box appears.

4 Enter the range of data containing duplicates in the box provided for List range.
Here the List range is '$B$3:$C$16'.

5 Check the box Unique Records Only and click OK.
Previous Topic:How to Remove Duplicates Using Advance Filter?
Next Topic:Acceleo Builder error encountered during build: java.util.ConcurrentModificationException
Goto Forum:
  


Current Time: Fri Apr 19 09:20:26 GMT 2024

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

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

Back to the top