Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » resolvetemp and Sequence
resolvetemp and Sequence [message #1809418] Tue, 16 July 2019 03:31 Go to next message
Marshall Charron is currently offline Marshall CharronFriend
Messages: 72
Registered: August 2018
Member
Hi

Given this sample :

rule rule1  {
	from s: MMA!MAModel
	to t : MMA!MAModel(
		objects <- s.objects, -- This is a Sequence of MMA!Object
	)	
}

rule rule2 {
        from s : MMB!Any
	to t : MMA!Object(
		name <- s.anyname
	)
}



I would like to add the target of rule2 i.e MMA!Object in "objects" of rule1, how can I achieve that ?

[Updated on: Tue, 16 July 2019 03:33]

Report message to a moderator

Re: resolvetemp and Sequence [message #1809428 is a reply to message #1809418] Tue, 16 July 2019 06:30 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 589
Registered: September 2012
Location: Belgium
Senior Member

The binding operator '<-' makes this implicit, and your transformation should already work as-is.

Cheers,
Dennis
Re: resolvetemp and Sequence [message #1809463 is a reply to message #1809428] Tue, 16 July 2019 13:37 Go to previous messageGo to next message
Marshall Charron is currently offline Marshall CharronFriend
Messages: 72
Registered: August 2018
Member
It works but it creates MMA!Object outside of MMA!MAModel. I want MMA!Object to be inside MMA!MAModel

[Updated on: Tue, 16 July 2019 13:37]

Report message to a moderator

Re: resolvetemp and Sequence [message #1809529 is a reply to message #1809463] Wed, 17 July 2019 13:51 Go to previous messageGo to next message
Marshall Charron is currently offline Marshall CharronFriend
Messages: 72
Registered: August 2018
Member
Notice that in rule2, I use another metamodel (MMB!Any) in the 'to' part.
Re: resolvetemp and Sequence [message #1809548 is a reply to message #1809529] Thu, 18 July 2019 00:10 Go to previous messageGo to next message
Marshall Charron is currently offline Marshall CharronFriend
Messages: 72
Registered: August 2018
Member
As I said the previous rules create MMA!Object outside of MMA!MAModel. But now I am trying to include it inside 'objects', but still don't figure it out :

rule rule1  {
	from s: MMA!MAModel
	to t : MMA!MAModel(
		objects <-  thisModule.resolveTemp(s.objects, 't') , -- This is a Sequence of MMA!Object
	)	
}

rule rule2 {
        from s : MMB!Any
	to t : MMA!Object(
		name <- s.anyname
	)
}


But I got this error :

org.eclipse.m2m.atl.emftvm.util.VMException: Cannot resolve default trace target 't' for Sequence{X:MMA!Object}


Anyone can help ?

Thanks in advance

[Updated on: Thu, 18 July 2019 02:56]

Report message to a moderator

Re: resolvetemp and Sequence [message #1809683 is a reply to message #1809548] Sat, 20 July 2019 08:18 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 589
Registered: September 2012
Location: Belgium
Senior Member

You'll need to do this:
objects <- s.objects->union(MMB!Any.allInstances())


Cheers,
Dennis
Re: resolvetemp and Sequence [message #1809684 is a reply to message #1809683] Sat, 20 July 2019 08:54 Go to previous messageGo to next message
Marshall Charron is currently offline Marshall CharronFriend
Messages: 72
Registered: August 2018
Member
Thanks so much, it works. I was wondering why you do the union of MMB!Any rather than MMA!Object, as 'objects' is composed of MMA!Object ?

[Updated on: Sat, 20 July 2019 08:54]

Report message to a moderator

Re: resolvetemp and Sequence [message #1809709 is a reply to message #1809684] Sun, 21 July 2019 17:37 Go to previous message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 589
Registered: September 2012
Location: Belgium
Senior Member

s.objects->union(MMB!Any.allInstances())
is a mixed Sequence of MMA!Object and MMB!Any. As soon as this mixed Sequence is passed through the '<-' operator, all source elements in this Sequence are replaced by their default (=first) target element (regardless of the rule by which these elements are generated). This is called the implicit tracing mechanism.


Cheers,
Dennis
Previous Topic:How to refine a model from another ?
Next Topic:Use of refInvokeOperation
Goto Forum:
  


Current Time: Fri Apr 26 10:31:37 GMT 2024

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

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

Back to the top