Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] Target model should have a reference to the source model
[ATL] Target model should have a reference to the source model [message #658654] Wed, 09 March 2011 11:55 Go to next message
ModelingNewbie is currently offline ModelingNewbieFriend
Messages: 7
Registered: August 2010
Junior Member
Hi,

I have a simple question regarding ATL transformations. My purpose is to transform a source model into a target model where the elements in the target model should have a refernce to the corresponding element in the source model.

For this purpose I wrote the following ATL rule:

rule model {
	from 
		i : SOURCE!ClassA
	to
		o : TARGET!ClassB(
			name <-  i.name,
                        sourceRef <- i
		)


If I execute the transformation I get a ClassCastException with the message the ClassBImpl can not be cast to ClassB.

How I have to change the part of the transformation rule about sourceRef?
Re: [ATL] Target model should have a reference to the source model [message #658664 is a reply to message #658654] Wed, 09 March 2011 12:35 Go to previous messageGo to next message
Ronan B is currently offline Ronan BFriend
Messages: 273
Registered: July 2009
Senior Member
Hi,
In your code there you are assigning an instance of A to a property on B. I assume you want to assign the type A to the property on B? i.oclType() will assign type A to the property on B.

If you do want to assign an instance to the property on B then you will to set it to an appropriate type.

Regards,
Ronan
Re: [ATL] Target model should have a reference to the source model [message #658667 is a reply to message #658664] Wed, 09 March 2011 12:49 Go to previous messageGo to next message
ModelingNewbie is currently offline ModelingNewbieFriend
Messages: 7
Registered: August 2010
Junior Member
Hi,

Thank you for your answer.
I don't want to assign the type of A to B. In the metamodel sourceRef is a non-containment eReference to A. Hence, the newly created element of B should reference the input element of A by assigning:

B.sourceRef = A

Hope, this helps to answer my question.

Thanks
Re: [ATL] Target model should have a reference to the source model [message #658677 is a reply to message #658654] Wed, 09 March 2011 13:09 Go to previous message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARDFriend
Messages: 556
Registered: July 2009
Senior Member
ATL has a resolve mechanism that links each input element to the first output element.
So when you have the binding sourceRef <- i, in the end, "i" will be replaced by o.

You could maybe try the refining mode.
You'll then have :
rule model {
	from 
		i : SOURCE!ClassA
	to
		k : SOURCE!ClassA(),
		o : TARGET!ClassB(
			name <-  i.name,
                        sourceRef <- k
		)
Previous Topic:[ATL] Refining mode usage with UML Profile
Next Topic:the ' in an ATL transformation
Goto Forum:
  


Current Time: Sat Apr 27 04:02:47 GMT 2024

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

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

Back to the top