Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » Inter-Model Refenrence, How do I do it correctly?
Inter-Model Refenrence, How do I do it correctly? [message #990799] Fri, 14 December 2012 10:18 Go to next message
Tim Winkelmann is currently offline Tim WinkelmannFriend
Messages: 2
Registered: December 2012
Junior Member
I made an example and replicated the error. So let me explain the Models first.
I want to transform my "source model" into my "target model".
My "source model" references an Object from a "core model".
"Allow inter-model reference" is active, when i do the transformation.
But when I debug the transformation, the references from "source model" to the "core model" are all unknown. I see the reference to the object "core" (<unknown>!<unnamed>),
and his attribute "name". The content of the attribute is "OclUndefined".
The content of the Attribute should be: "CoreName"
So my Questions is: Why arent the references between this models sloved correctly?
Or what did I do wrong?
I hope you can help me with this example. If you need more information, i am happy to provide them.

regards

Tim

The ATL file:
module source2target;
create OUT : tar from IN : src;

helper def : getModel(): tar!TargetModel = tar!TargetModel->allInstances()->first();

rule m2m {
	from srcModel : src!SourceModel
	to
		model : tar!TargetModel()
}

rule c2c {
	from sourceClass : src!SourceClass
	using{
		model : tar!TargetModel = thisModule.getModel();	
	}
	to
		tar : tar!Target (name <- sourceClass.core.name)
	do{
		model.target <- tar;
	}
}
Re: Inter-Model Refenrence, How do I do it correctly? [message #990878 is a reply to message #990799] Fri, 14 December 2012 15:57 Go to previous messageGo to next message
Hugo Bruneliere is currently offline Hugo BruneliereFriend
Messages: 674
Registered: July 2009
Senior Member
Hello,

It seems that you are trying several times (in the helper or in a rule) to navigate the target model, which should not be done since you cannot know at runtime which elements are/are going to be created by the transformation (as ATL is declarative and not imperative).
In ATL, only the source model has to be navigated within helpers or rules.
Then you have to let the ATL automated resolution mechanism matching the source elements (you are navigating) with the corresponding created target elements.
It should rather look something like this:

module source2target;
create OUT : tar from IN : src;

helper def : myModel : tar!TargetModel = OclUndefined;

rule m2m {
	from 
                srcModel : src!SourceModel
	to
		model : tar!TargetModel(
                     target <- srcModel.getAccessThe-SourceClass-CreatingTheSearched-Target() 
                )
        do {
               thisModule.myModel <- model;
        }
}

rule c2c {
	from 
                sourceClass : src!SourceClass
	to
		tar : tar!Target (
                     name <- sourceClass.core.name
                )
}

I hope this helps.

Hugo


--------------------------------------------------------
Hugo Bruneliere, PhD
NaoMod team (IMT Atlantique & LS2N-CNRS)
Nantes - France
--------------------------------------------------------
Re: Inter-Model Refenrence, How do I do it correctly? [message #991075 is a reply to message #990878] Mon, 17 December 2012 09:56 Go to previous messageGo to next message
Tim Winkelmann is currently offline Tim WinkelmannFriend
Messages: 2
Registered: December 2012
Junior Member
Ok, your info helped to wright better ATL code.
But...
The Problem is the same.
If I transform my source model to my target model the "name" attribute is empty.
(If this would be a List or an Object it would be empty. And that is the real Problem, since I need those information to do a proper transformation.)
module source2target;
create OUT : tar from IN : src;

rule c2c {
	from sourceClass : src!SourceClass
	to
--the sourceClass.core.name can not be found!
		tar : tar!Target (name <- sourceClass.core.name)
}

rule m2m {
	from srcModel : src!SourceModel
	to
		model : tar!TargetModel(target <- tar!Target->allInstances()->first())
}



When I look at the variables in the debugging view, the core reference is "unknown" and the attribute name is "OclUndefined", which should be "CoreName".

So my guess is, that something went wrong with solving the refenrences to the "core model". But I have no Idea where I should start looking.

Hope you can help me with this too.

Tim
Re: Inter-Model Refenrence, How do I do it correctly? [message #991202 is a reply to message #991075] Mon, 17 December 2012 17:43 Go to previous message
Hugo Bruneliere is currently offline Hugo BruneliereFriend
Messages: 674
Registered: July 2009
Senior Member
Hello,

In that case, I cannot see immediately why elements from the Core model are not accessible.
Have you tried to also load this Core model as input of your transformation (even if you actually refer only to the Source model in the rules)?

Hugo


--------------------------------------------------------
Hugo Bruneliere, PhD
NaoMod team (IMT Atlantique & LS2N-CNRS)
Nantes - France
--------------------------------------------------------
Previous Topic:Exception during invocation of operation applyStereotype
Next Topic:HighOrderTransformation: From Model to Text
Goto Forum:
  


Current Time: Tue Apr 16 21:06:09 GMT 2024

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

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

Back to the top