Skip to main content



      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 06:55 Go to next message
Eclipse UserFriend
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 07:35 Go to previous messageGo to next message
Eclipse UserFriend
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 07:49 Go to previous messageGo to next message
Eclipse UserFriend
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 08:09 Go to previous message
Eclipse UserFriend
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: Sun Aug 31 13:48:41 EDT 2025

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

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

Back to the top