Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » Input Model with references
Input Model with references [message #1754594] Mon, 20 February 2017 16:03 Go to next message
Thibault beziers la fosse is currently offline Thibault beziers la fosseFriend
Messages: 10
Registered: February 2017
Junior Member
Hello everyone, I'm having a small issue with my ATL transformation. Here's the header:

-- @atlcompiler emftvm
-- @nsURI MM=http://www.eclipse.org/MoDisco/Java/0.2.incubation/java
-- @nsURI MM2=http://www.eclipse.org/MoDisco/Java/Composition/0.1.incubation/javaApplication
-- @path MM1=/model2test/resources/testmetamodel.ecore


module transfo;
create OUT: MM1 from IN: MM, IN2: MM2;


The input model with the MM2 metamodel has references to other models in the same folder (with the same meta model) :

  <javaapplication:Java2Directory>
    <javaPackage href="../Model_java.xmi#//@ownedElements.0/@ownedPackages.0/@ownedPackages.0"/>
    <directory href="../Model_kdm.xmi#//@model.0/@inventoryElement.0/@inventoryElement.9/@inventoryElement.0/@inventoryElement.0/@inventoryElement.0/@inventoryElement.0/@inventoryElement.0"/>
    <parent href="../Model_java2kdm.xmi#/"/>
    <java2FileChildren href="com.tblf.Business_java2kdm.xmi#/"/>
  </javaapplication:Java2Directory>
  <javaapplication:Java2Directory>
    <javaPackage href="../Model_java.xmi#//@ownedElements.0/@ownedPackages.0/@ownedPackages.1"/>
    <directory href="../Model_kdm.xmi#//@model.0/@inventoryElement.0/@inventoryElement.9/@inventoryElement.0/@inventoryElement.0/@inventoryElement.0/@inventoryElement.0/@inventoryElement.1"/>
    <parent href="../Model_java2kdm.xmi#/"/>
    <java2FileChildren href="com.tblf.Model_java2kdm.xmi#/0"/>
    <java2FileChildren href="com.tblf.Model_java2kdm.xmi#/1"/>
    <java2FileChildren href="com.tblf.Model_java2kdm.xmi#/2"/>
    <java2FileChildren href="com.tblf.Model_java2kdm.xmi#/3"/>
    <java2FileChildren href="com.tblf.Model_java2kdm.xmi#/4"/>
  </javaapplication:Java2Directory>


When I'm doing MM2!JavaNodeSourceRegion.allInstances(), if I use the previous model, I won't get any results, but if I use the referenced model "com.tblf.Model_java2kdm.xmi", or the "com.tblf.Business_java2kdm.xmi" I'll get a part of the instances of the NodeSourceRegion :


I would like to get all the instances from the referenced input models, by loading the "root" one. How can I do ?

Thank you for your answer(s) Smile

T.



Re: Input Model with references [message #1754596 is a reply to message #1754594] Mon, 20 February 2017 16:37 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 589
Registered: September 2012
Location: Belgium
Senior Member

ATL traverses only the models you specify in the launch configuration (= Resources in EMF). You have to add all referenced models explicitly to your launch configuration (Run... -> ...); you don't necessarily have to specify them in the transformation module itself.

Cheers,
Dennis
Re: Input Model with references [message #1754630 is a reply to message #1754596] Tue, 21 February 2017 08:08 Go to previous messageGo to next message
Thibault beziers la fosse is currently offline Thibault beziers la fosseFriend
Messages: 10
Registered: February 2017
Junior Member
Hello,
It worked by adding all the xmi models as inputs, in the run configuration, thank you very much.

T.
Re: Input Model with references [message #1754665 is a reply to message #1754630] Tue, 21 February 2017 11:58 Go to previous messageGo to next message
Thibault beziers la fosse is currently offline Thibault beziers la fosseFriend
Messages: 10
Registered: February 2017
Junior Member
The transformation works well when I'm launching it with the EMFTVM Eclipse Run Configuration, but I'm having some issues when launching it programmatically, with Java.
I've this helper:

helper context MM!Statement def: lineNumber: Integer =
	-- might need some optimization
	let allNodes: Sequence(MM2!JavaNodeSourceRegion) =
		MM2!JavaNodeSourceRegion.allInstances() -> asSequence()
	in
		if (allNodes -> select(node | node.node.debug() = self).size() > 0)
		then
			allNodes -> select(node | node.node = self).first().startLine.debug()
		else
			-1
		endif
	;


The debug() method will print lines as:
121f7d04:MM!ExpressionStatement
with the emftvm launch configuration.
When running the transformation programmatically, the debug() method prints
6e11dd6c:ECORE!EObject
instead.

I'm loading the metamodels and the models in this order:
MM: http://www.eclipse.org/MoDisco/Java/0.2.incubation/java
MM2: http://www.eclipse.org/MoDisco/Java/Composition/0.1.incubation/javaApplication
MM1: /.../resources/testmetamodel.ecore
IN
all the java2kdm.xmi models
IN2

To load the Meta Models I use the following Java code:
		Metamodel inMetamodel = EmftvmFactory.eINSTANCE.createMetamodel();
		inMetamodel.setResource(resourceSet.getResource(URI.createURI(MMUri), true));
		execEnv.registerMetaModel(name, inMetamodel);



To load the input models I use the following Java Code :
		Model model = EmftvmFactory.eINSTANCE.createModel();
		model.setAllowInterModelReferences(true);
		model.setResource(resourceSet.getResource(URI.createURI(modelUri), true));
		execEnv.registerInputModel(name, model);


And the output model:
		Model model = EmftvmFactory.eINSTANCE.createModel();
		model.setAllowInterModelReferences(true);		
		model.setResource(resourceSet.createResource(URI.createURI(modelUri)));
		execEnv.registerOutputModel(name, model);


I have no error message in the standard output, and the transformation is completed, except the part using my helper.

Maybe I'm not clear enough. Tell me if you need more informations, or code sample.

If you have an idea, that would be very helpful.

T.

[Updated on: Tue, 21 February 2017 12:02]

Report message to a moderator

Re: Input Model with references [message #1755028 is a reply to message #1754665] Mon, 27 February 2017 08:03 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 589
Registered: September 2012
Location: Belgium
Senior Member

I see you're using multiple debug() calls: it's better to add a string parameter to debug() to see which debug() call is triggering (e.g. debug('first call')).

As for the actual problem: in which part of the Java meta model does ExpressionStatement reside? Is that part loaded properly?


Cheers,
Dennis
Re: Input Model with references [message #1756389 is a reply to message #1755028] Thu, 16 March 2017 10:16 Go to previous message
Thibault beziers la fosse is currently offline Thibault beziers la fosseFriend
Messages: 10
Registered: February 2017
Junior Member
Hello Dennis, I just noticed your answer.
I managed to resolve my problem though.

If I remember well, the models with the MetaModel http://www.eclipse.org/MoDisco/Java/Composition/0.1.incubation/javaApplication were located inside a folder.
After the model transformation, the eProxyUri couldn't be resolved, and that's why I had EObjects instead of ExpressionStatement.

Finally the *trick* I did was to get the resource corresponding to my Model with the http://www.eclipse.org/MoDisco/Java/0.2.incubation/java metamodel,
and then to add ../ at the start of its URI before registering it in the emftvm execEnv.

After that the eProxyUris were able to be resolved.

Thank for for the tip about the debug() method, I didn't know we could add string parameters, it will be very useful.


Previous Topic:Create a new element in the target model
Next Topic:[to delete]
Goto Forum:
  


Current Time: Fri Mar 29 12:23:29 GMT 2024

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

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

Back to the top