Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] remove elements
[ATL] remove elements [message #758770] Thu, 24 November 2011 14:07 Go to next message
Fy Za is currently offline Fy ZaFriend
Messages: 245
Registered: March 2010
Senior Member
Hi All,
I have a problem with this simple transformation
that generate the result and also inappropriate elements (adresses of persons that person.age > 26)

rule Person2Student{
from 
	person : PersonMM!Person(person.age < 26)
to
	student : StudentMM!Student(
		name <- person.name --attribute
                has_adress <-person.has_adress -- reference  Person ----- 1..* : has_adress ----> Home 
        )
}
rule Home2Adress{){
from 
	home : PersonMM!Home 
to
	adress : StudentMM!Adress(
		adress <- home.adress
	)
}


So plz, How remove these elements from my output model
I want to express : remove Adresses of persons which are not transformed to Student
Thanks

[Updated on: Thu, 24 November 2011 14:27]

Report message to a moderator

Re: [ATL] remove elements [message #758786 is a reply to message #758770] Thu, 24 November 2011 14:45 Go to previous messageGo to next message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARDFriend
Messages: 556
Registered: July 2009
Senior Member
Imho the best solution for filters is to use helpers.
helper context PersonMM!Person def : filter : Boolean =
self.age < 26;

helper context PersonMM!Home def : filter : Boolean =
PersonMM!Person.allInstances()->select(e | e.filter)->exists(e |e.has_adress = self);

rule Person2Student{
from 
	person : PersonMM!Person(person.filter)

rule Home2Adress{
from 
	home : PersonMM!Home (home.filter)

That way, if the filter on a person changes, then the filter on home will adjust automatically.
Re: [ATL] remove elements [message #758796 is a reply to message #758786] Thu, 24 November 2011 15:22 Go to previous message
Fy Za is currently offline Fy ZaFriend
Messages: 245
Registered: March 2010
Senior Member
Thank you Sylvain,
it works with a simple modification Wink :

helper context PersonMM!Home def : filter : Boolean =
PersonMM!Person.allInstances()->select(e | e.filter)->exists(e |e.has_adress->includes(self));

because has_adress is an 1..* reference

[Updated on: Thu, 24 November 2011 15:23]

Report message to a moderator

Previous Topic:[ATL] Referenced part does not exist yet: org.eclipse.jdt.ui.PackageExplorer.
Next Topic:[ATL] Invoking an ATL transformation on a part of a model, not on a whole model
Goto Forum:
  


Current Time: Tue Dec 03 21:09:37 GMT 2024

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

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

Back to the top