Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » Create multiple from one(Create multiple elements in output model based on one element from source model)
Create multiple from one [message #1799496] Fri, 07 December 2018 17:33 Go to next message
Cesar Bernabe is currently offline Cesar BernabeFriend
Messages: 13
Registered: December 2016
Junior Member
Hi,

I need to instantiate a given element in the target model from an attribute in a source model. For example:

Source Model:
Element1 {
name,
references -> Element2
}

Element2 {
name
}


Target Model:
Element1 {
name
}

Element2 {
name
}

Element3 { (created from source model Element1 references)
source <- Element1
target <- Element2
}

I tried to use lazy rules but I could not assign the values of source and target on Element3. Can someone please help me with this?

Thanks.
Re: Create multiple from one [message #1799533 is a reply to message #1799496] Sat, 08 December 2018 19:51 Go to previous messageGo to next message
Cesar Bernabe is currently offline Cesar BernabeFriend
Messages: 13
Registered: December 2016
Junior Member
Oh, I forgot to mention that the "references" variable in the first module is an array and therefore refers to several elements. It would then be necessary to create one "Element3" (in the second model) for each array index of the first model.
Re: Create multiple from one [message #1799559 is a reply to message #1799533] Mon, 10 December 2018 09:53 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 581
Registered: September 2012
Location: Belgium
Senior Member

Like so:
-- @atlcompiler emftvm
-- @path ONE=/ATLMultipleFromOne/metamodels/One.ecore
-- @path MULTIPLE=/ATLMultipleFromOne/metamodels/Multiple.ecore
module MultipleFromOne;
create OUT: MULTIPLE from IN: ONE;

rule Element1 {
	from
		s: ONE!Element1
	to
		t: MULTIPLE!Element1
	do {
		for (r in s.references) {
			thisModule.Element3(s, r);
		}
	}
}

rule Element2 {
	from
		s: ONE!Element2
	to
		t: MULTIPLE!Element2
}

unique lazy rule Element3 {
	from
		e1: ONE!Element1,
		e2: ONE!Element2
	to
		t: MULTIPLE!Element3 (
			source <- e1,
			target <- e2
		)
}


See example Eclipse project in attachment.


Cheers,
Dennis
Re: Create multiple from one [message #1802255 is a reply to message #1799559] Tue, 05 February 2019 12:32 Go to previous message
Cesar Bernabe is currently offline Cesar BernabeFriend
Messages: 13
Registered: December 2016
Junior Member
Thank you so much!
Previous Topic:[ATL] Matching in a called rule
Next Topic:Problem to reference to an existing model
Goto Forum:
  


Current Time: Sat Nov 11 08:20:04 GMT 2023

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

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

Back to the top