Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] announce of a Java DSL for ATL transformations execution.
[ATL] announce of a Java DSL for ATL transformations execution. [message #510039] Tue, 26 January 2010 05:22 Go to next message
Guillaume Hillairet is currently offline Guillaume Hillairet
Messages: 81
Registered: July 2009
Member
Hi all,

I have made a simple library to simplify the coding of ATL transformations execution in Java. It makes my life easier when i want to launch ATL from Java code, so i tought that some of you may want to give it a try.
It's available at this address http://code.google.com/p/atl-commons/.
Any comments and feedback are welcome.

BRs
Guillaume
Re: [ATL] announce of a Java DSL for ATL transformations execution. [message #529585 is a reply to message #510039] Mon, 26 April 2010 09:43 Go to previous messageGo to next message
Elhamlaoui Mahmoud is currently offline Elhamlaoui Mahmoud
Messages: 248
Registered: March 2010
Senior Member


Hi,

plz ,How can i use this library?

Re: [ATL] announce of a Java DSL for ATL transformations execution. [message #529629 is a reply to message #529585] Mon, 26 April 2010 11:16 Go to previous messageGo to next message
Guillaume Hillairet is currently offline Guillaume Hillairet
Messages: 81
Registered: July 2009
Member
Hi,

Installation is done via an update site [1], that is now up and running. User guide can be found in wiki pages.

BRs,
Guillaume


[1] http://atl-commons.googlecode.com/hg/atl-commons/

[Updated on: Mon, 26 April 2010 11:43]

Report message to a moderator

Re: [ATL] announce of a Java DSL for ATL transformations execution. [message #529645 is a reply to message #529629] Mon, 26 April 2010 11:49 Go to previous messageGo to next message
Elhamlaoui Mahmoud is currently offline Elhamlaoui Mahmoud
Messages: 248
Registered: March 2010
Senior Member


thanks for the reply,

because i tried abd i had the folloxin problem :
rg.eclipse.emf.ecore.resource.Resource$IOWrappedException: Package with uri 'http://www.ensias.com/Books' not found. (file:D:/input.xml, 2, 128)
its a book2 publication example.

any ideas why i have this problem

thanks
mahmoud
Re: [ATL] announce of a Java DSL for ATL transformations execution. [message #529654 is a reply to message #529645] Mon, 26 April 2010 12:15 Go to previous messageGo to next message
Guillaume Hillairet is currently offline Guillaume Hillairet
Messages: 81
Registered: July 2009
Member

You should provide more information, like a log or an idea of what code you try ti execute. Nevertheless, it seems that you haven't register the Books metamodel.
Re: [ATL] announce of a Java DSL for ATL transformations execution. [message #529668 is a reply to message #529654] Mon, 26 April 2010 12:48 Go to previous messageGo to next message
Elhamlaoui Mahmoud is currently offline Elhamlaoui Mahmoud
Messages: 248
Registered: March 2010
Senior Member
hi ,

this the code that i reuse :
Quote:

* Copyright (c) 2009 Guillaume Hillairet
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html.
*
*/
package com.atl.common.tests;
import static com.atl.common.trans.Transformations.transform;

import java.util.Set;

import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.m2m.atl.core.emf.EMFModel;
import org.eclipse.m2m.atl.engine.emfvm.ASM;
import org.junit.Test;

import com.atl.common.models.Models;
import com.atl.common.trans.ATLModel2ASM;
import com.atl.common.trans.Transformation;
import com.atl.common.trans.Transformations;
import static com.atl.common.models.Models.*;

public class TransformationTest {

@Test public void HOTTest() {

Resource model = Models.resource(" file:D:/dsltk/workspace/com.atl.common/test/com/atl/common/t ests/models/input.xml ");
register(model);
EMFModel m = Models.inject( model,ATL_URI);

ASM asm = transform(m, new ATLModel2ASM());

assert asm != null;
}

@Test public void testBuilder() {
long start = System.currentTimeMillis();
Transformation<Set<EMFModel>, EMFModel> t = new Transformations.Builder()
.asm(TransformationTest.class.getResource("models/bookpubli.asm "))
.in(Models.ecore(), "IN1", "ecore")
.in(Models.ecore(), "IN2", "ecore")
.out(Models.ecore(), "OUT", "ecore")
.buildMultiInOneOut();

Resource in1 = Models.resource(" file:D:/dsltk/workspace/com.atl.common/test/com/atl/common/t ests/models/Books.ecore ");
Resource in2 = Models.resource(" file:D:/dsltk/workspace/com.atl.common/test/com/atl/common/t ests/models/Publication.ecore ");
Set<EMFModel> set = Models.setOf(Models.inject(in1, Models.ECORE_URI), Models.inject(in2, Models.ECORE_URI));


EMFModel mo = transform(set, t);
Models.extract(mo, System.out);
System.out.println((System.currentTimeMillis() - start) / 1000.);
mo = null;
mo = transform(set, t);
Models.extract(mo, System.out);
}

public static void main(String[] args) {
TransformationTest t =new TransformationTest();
t.HOTTest();
t.testBuilder();

}
}



i try to transform a book to publication the exmaple works fine without using simple ATL

mahmoud
Re: [ATL] announce of a Java DSL for ATL transformations execution. [message #529784 is a reply to message #529668] Tue, 27 April 2010 04:35 Go to previous messageGo to next message
Guillaume Hillairet is currently offline Guillaume Hillairet
Messages: 81
Registered: July 2009
Member
Hi,

You are using code defined for other purposes (test generation of high order transformations). The example for the definition of transformations is given here http://code.google.com/p/atl-commons/wiki/Transformations and it is much simpler.

In your case, the code should look like this:

register( resource(" file:D:/dsltk/workspace/com.atl.common/test/com/atl/common/t ests/models/Books.ecore ", true) );
register( resource(" file:D:/dsltk/workspace/com.atl.common/test/com/atl/common/t ests/models/Publication.ecore ", true) );

// considering that your transformation header is
// module Books2Publication
// create OUT:Publication from IN:Books

Transformation<EMFModel, EMFModel> Books2Publication= new Transformations.Builder()
.asm("Books2Publication.asm")
.in(get("Books Package URI"), "IN", "Books") // you need to set EPackages URIs
.out(get("Publication URI"), "OUT", "Publication")
.buildOneInOneOut();

Resource model = resource(" file:D:/dsltk/workspace/com.atl.common/test/com/atl/common/t ests/models/input.xml ");
EMFModel out = transform(inject(model, get("Books URI")), Books2Publication);

where out is the transformation output model.

BRs
Guillaume

[Updated on: Tue, 27 April 2010 08:47]

Report message to a moderator

Re: [ATL] announce of a Java DSL for ATL transformations execution. [message #529816 is a reply to message #510039] Tue, 27 April 2010 07:05 Go to previous messageGo to next message
zoro  is currently offline zoro
Messages: 26
Registered: April 2010
Junior Member
"Page "Transformations," Not Found"
Re: [ATL] announce of a Java DSL for ATL transformations execution. [message #529818 is a reply to message #529784] Tue, 27 April 2010 07:15 Go to previous messageGo to next message
Elhamlaoui Mahmoud is currently offline Elhamlaoui Mahmoud
Messages: 248
Registered: March 2010
Senior Member



Hi, Guillaume,

thanks for the reply, one more question plz,
in the EPackages URIs i write:.
in(get("http://www.ensias.ma/Books"), "IN", "Books") but i got an IO error :
java.io.FileNotFoundException: http://www.ensias.ma/Books

thanks a lot
mahmoud
Re: [ATL] announce of a Java DSL for ATL transformations execution. [message #529820 is a reply to message #529818] Tue, 27 April 2010 07:16 Go to previous messageGo to next message
Elhamlaoui Mahmoud is currently offline Elhamlaoui Mahmoud
Messages: 248
Registered: March 2010
Senior Member


Hi zoro,

perhaps you have to open the page in an other navigator, im using chrome and its working
Re: [ATL] announce of a Java DSL for ATL transformations execution. [message #529825 is a reply to message #529820] Tue, 27 April 2010 07:36 Go to previous messageGo to next message
Guillaume Hillairet is currently offline Guillaume Hillairet
Messages: 81
Registered: July 2009
Member

There was simply an unwanted comma in the URL (fix now).

Quote:

thanks for the reply, one more question plz,
in the EPackages URIs i write:.
in(get("http://www.ensias.ma/Books"), "IN", "Books") but i got an IO error :
java.io.FileNotFoundException: http://www.ensias.ma/Books



What version are you using? If it is not 0.5.6 try to update or try ti use file location uri in get().
Re: [ATL] announce of a Java DSL for ATL transformations execution. [message #529828 is a reply to message #529825] Tue, 27 April 2010 07:48 Go to previous messageGo to next message
Elhamlaoui Mahmoud is currently offline Elhamlaoui Mahmoud
Messages: 248
Registered: March 2010
Senior Member



hi ,
i use the file location uri, at least i have atl problems instead java satndard ones:

exception in thread "main"

org.eclipse.m2m.atl.engine.emfvm.VMException: Could not find model MM

sorry for disturbance
Re: [ATL] announce of a Java DSL for ATL transformations execution. [message #529845 is a reply to message #529828] Tue, 27 April 2010 09:05 Go to previous messageGo to next message
Guillaume Hillairet is currently offline Guillaume Hillairet
Messages: 81
Registered: July 2009
Member
First, note that i corrected the code i had given previously.
If you are using the latest version, you should had a Boolean parameter to the resource() method. If the Boolean is true then the resource will be loaded (default is false).

register( resource(" file:D:/dsltk/workspace/com.atl.common/test/com/atl/common/t ests/models/Books.ecore ", true) );


Quote:

exception in thread "main"

org.eclipse.m2m.atl.engine.emfvm.VMException: Could not find model MM



Now, for this error, what is your transformation header? According to the code you give it should be something like

module Books2Publication
create OUT:Publication from IN:Books

It seems that you are trying to execure this transformation http://eclipse.org/m2m/atl/atlTransformations/#Book2Publicat ion is that right?
In this case what is your input model? It should be the file modelBook.ecore, not the xml file.

[Updated on: Tue, 27 April 2010 09:06]

Report message to a moderator

Re: [ATL] announce of a Java DSL for ATL transformations execution. [message #530404 is a reply to message #529845] Thu, 29 April 2010 11:08 Go to previous messageGo to next message
Elhamlaoui Mahmoud is currently offline Elhamlaoui Mahmoud
Messages: 248
Registered: March 2010
Senior Member


hi Guillaume,


Could you please tell th e modification you maid and so i ca make the i mine because ihavent the permisssion to download with the prescence of the administrator


for the project, its the same exmaple, ive just given a diifent name for the input and output model.

mahmoud
Re: [ATL] announce of a Java DSL for ATL transformations execution. [message #530584 is a reply to message #530404] Fri, 30 April 2010 04:55 Go to previous messageGo to next message
Guillaume Hillairet is currently offline Guillaume Hillairet
Messages: 81
Registered: July 2009
Member
Hi,

I put an project example here (made with Book2Publication transformation) http://code.google.com/p/atl-commons/downloads/list
You will find 2 Java classes, each one uses the same transformation, but the second shows you how to set up transformations to work with XML files as in/output.

BRs,
Guillaume
Re: [ATL] announce of a Java DSL for ATL transformations execution. [message #530602 is a reply to message #510039] Fri, 30 April 2010 05:55 Go to previous messageGo to next message
Christophe  is currently offline Christophe
Messages: 9
Registered: April 2010
Junior Member
Hi,

I have a problem using your library ( maybe i'm missing something ... )

Here is my Java Class that calls my ATL file ( using directly my ATL file, the transformation works well ) but i need to write a Java Class for tests purposes.

Java Class containing just a main :

/********************* *
* IMPORTS
**********************/
import static com.atl.common.models.Models.ecore;
import static com.atl.common.models.Models.get;
import static com.atl.common.models.Models.inject;
import static com.atl.common.models.Models.register;
import static com.atl.common.models.Models.resource;
import static com.atl.common.trans.Transformations.compose;
import static com.atl.common.trans.Transformations.transform;

import java.io.IOException;
import java.util.Collections;

import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EcorePackage;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.m2m.atl.core.emf.EMFModel;

import com.atl.common.trans.Transformation;
import com.atl.common.trans.Transformations;

/*****************
* MAIN
*****************/

public static void main(String[] args) {

Resource myMetamodel = resource(" fr.cea.paprika.numerical2ecore/Model/paprika_numerical.ecore ");

register(EcorePackage.eINSTANCE.eResource());
register(myMetamodel);

Transformation<EMFModel, EMFModel> numerical2ecore = new Transformations.Builder()
.asm(" file:D:/Projets/Paprika/plugins/fr.cea.paprika.numerical2eco re/Transformation/numerical2ecore.asm ")
.in(get("http://paprika_numerical/1.0"), "IN", "numerical")
.out(ecore(), "OUT", "ecore")
.buildOneInOneOut();

EMFModel out = transform( inject(resource(" fr.cea.paprika.numerical2ecore/Examples/castesttransformatio n.numerical ")
, get("http://paprika_numerical/1.0"))
, numerical2ecore );

out.getResource().setURI(URI.createURI(" fr.cea.paprika.numerical2ecore/Examples/castesttransformatio n.numerical.out.ecore "));
try {
out.getResource().save(Collections.EMPTY_MAP);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}


/******************
* EXECUTION
******************/

While running my Class as a java application, i got the following error :

Exception in thread "main" org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1Diagnos ticWrappedException: java.net.UnknownHostException: paprika_numerical
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.handleDe mandLoadException(ResourceSetImpl.java:315)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:274)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:397)
at com.atl.common.models.Models$ModelsFactory.get(Models.java:4 16)
at com.atl.common.models.Models.get(Models.java:277)
at fr.cea.paprika.numerical2ecore.transformation.Numerical2Ecor eMain.main(Numerical2EcoreMain.java:32)
Caused by: java.net.UnknownHostException: paprika_numerical
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:177)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:525)
at java.net.Socket.connect(Socket.java:475)
at sun.net.NetworkClient.doConnect(NetworkClient.java:163)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:394)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:529)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:233)
at sun.net.www.http.HttpClient.New(HttpClient.java:306)
at sun.net.www.http.HttpClient.New(HttpClient.java:323)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient (HttpURLConnection.java:860)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Htt pURLConnection.java:801)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLC onnection.java:726)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(H ttpURLConnection.java:1049)
at org.eclipse.emf.ecore.resource.impl.URIHandlerImpl.createInp utStream(URIHandlerImpl.java:178)
at org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterIm pl.createInputStream(ExtensibleURIConverterImpl.java:301)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1254)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:255)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:270)
... 4 more

/****************** END *********************/

Error is highlighted with line :

.in(get("http://paprika_numerical/1.0"), "IN", "numerical")

Maybe that's because i give the URI of my package directly instead of using a method like toNS_URI(String) if it exists..

Help will be very much appreciated =)

Thanks.


Re: [ATL] announce of a Java DSL for ATL transformations execution. [message #530610 is a reply to message #530602] Fri, 30 April 2010 06:23 Go to previous messageGo to next message
Guillaume Hillairet is currently offline Guillaume Hillairet
Messages: 81
Registered: July 2009
Member
Hi,

Have you set the NsURI of the EPackage in paprika_numerical.ecore. This error typically happen when NsURIs are not set.

Otherwise you can try something like that

register("http://paprika_numerical/1.0", (EPackage)myMetamodel.getContents().get(0)); // IF you have one root EPackage

[Updated on: Fri, 30 April 2010 06:23]

Report message to a moderator

Re: [ATL] announce of a Java DSL for ATL transformations execution. [message #530643 is a reply to message #510039] Fri, 30 April 2010 08:30 Go to previous messageGo to next message
Christophe  is currently offline Christophe
Messages: 9
Registered: April 2010
Junior Member
Hi.

Thanks for answering so quiclky.

Replacing the registration of my model by register("http://paprika_numerical/1.0", (EPackage)myMetamodel.getContents().get(0));

generates a

org.eclipse.emf.common.util.BasicEList$BasicIndexOutOfBounds Exception: index=0, size=0

because using debug mode, after stepping the line

Resource myMetamodel = resource(" file:D:/Projets/Paprika/plugins/fr.cea.paprika.numerical2eco re/Model/paprika_numerical.ecore ");

the "contents" variable of myMetamodel is "null" ...

I think it's also the reason why i have the error detailed in my previous message.

Hope you could help.

Regards,

Chris.

Re: [ATL] announce of a Java DSL for ATL transformations execution. [message #530649 is a reply to message #530643] Fri, 30 April 2010 08:43 Go to previous messageGo to next message
Guillaume Hillairet is currently offline Guillaume Hillairet
Messages: 81
Registered: July 2009
Member

I see the problem. The resource is not loaded.

Just change metamodel registration by:

Resource myMetamodel = resource(" file:D:/Projets/Paprika/plugins/fr.cea.paprika.numerical2eco re/Model/paprika_numerical.ecore", true);

The boolean parameter will enable the loading process. It is the same as writing:

Resource myMetamodel = ...
myMetamodel.load(null);
Re: [ATL] announce of a Java DSL for ATL transformations execution. [message #530650 is a reply to message #510039] Fri, 30 April 2010 08:44 Go to previous messageGo to next message
Christophe  is currently offline Christophe
Messages: 9
Registered: April 2010
Junior Member
It works ! Thanks for all =)
I just specified the metamodel relative path (using workspace) but now i use your previous reply and "file:<absolute file path>" and it works ! My last problem is generating the output test case because using :

out.getResource().save(Collections.EMPTY_MAP);

generates a :

java.net.UnknownServiceException: protocol doesn't support output


... I'm going to search unless you have any suggestion but i wanted to thank you for your library, it's very usefull, even if a fully functional example (to be downloaded from the website and uses as-is) should be very appreciated.

Chris.
Re: [ATL] announce of a Java DSL for ATL transformations execution. [message #530653 is a reply to message #510039] Fri, 30 April 2010 08:48 Go to previous messageGo to next message
Christophe  is currently offline Christophe
Messages: 9
Registered: April 2010
Junior Member
Effectively, i add "true" parameter (because it was done like that in your examples) and it worked =) A big thank to you. Just remains the

(EMFModel)out.save(Collections.EMPTY_MAP);

problem...
Re: [ATL] announce of a Java DSL for ATL transformations execution. [message #530654 is a reply to message #530653] Fri, 30 April 2010 08:53 Go to previous messageGo to next message
Guillaume Hillairet is currently offline Guillaume Hillairet
Messages: 81
Registered: July 2009
Member
You need to set up the URI of the output model,
like this:

out.getResource().setURI(URI.createURI(" uri "));
out.getResource().save(null);



Re: [ATL] announce of a Java DSL for ATL transformations execution. [message #530658 is a reply to message #510039] Fri, 30 April 2010 09:03 Go to previous messageGo to next message
Christophe  is currently offline Christophe
Messages: 9
Registered: April 2010
Junior Member
Unforunately, that's what i've done... using :

out.getResource().setURI(URI.createURI(" file:D:/Projets/Paprika/plugins/fr.cea.paprika.numerical2eco re/Output/castesttransformation.numerical.out.ecore "));
out.getResource().save(null);

and when the second line is executed ( save action ), exception is raised :

Exception in thread "main" java.net.UnknownServiceException: protocol doesn't support output
at java.net.URLConnection.getOutputStream(URLConnection.java:79 2)
at org.eclipse.emf.ecore.resource.impl.URIHandlerImpl.createOut putStream(URIHandlerImpl.java:137)
at org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterIm pl.createOutputStream(ExtensibleURIConverterImpl.java:290)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(Resour ceImpl.java:990)
at fr.cea.paprika.numerical2ecore.transformation.Numerical2Ecor eMain.main(Numerical2EcoreMain.java:47)

If you have any idea.. Because debugging there is pointless..
Re: [ATL] announce of a Java DSL for ATL transformations execution. [message #530688 is a reply to message #510039] Fri, 30 April 2010 10:22 Go to previous messageGo to next message
Christophe  is currently offline Christophe
Messages: 9
Registered: April 2010
Junior Member
Please, just one last question, you know, while using atl files directly, in run configuration options of eclipse, atl application, advanced, there is a checkbox called "allow inter-model references" that enables both input model to have the same metamodel ( ecore there ). This enable the user to share types like EString, EInt, and so on...

I'd like to say whether it was possible or not to specify such an option, and if so, how ?

Thanks a lot for your help,

Chris.
Re: [ATL] announce of a Java DSL for ATL transformations execution. [message #530749 is a reply to message #530688] Fri, 30 April 2010 13:09 Go to previous messageGo to next message
Elhamlaoui Mahmoud is currently offline Elhamlaoui Mahmoud
Messages: 248
Registered: March 2010
Senior Member


Hi,

first thanks a lot for your Book2publication example, it enables me to go on.
i have a problem that i wish that your plug-in enable to do :
in my target metamodel, i have a UML so i write :
Quote:

register(resource("http://www.eclipse.org/uml2/2.1.0/UML", true));



but i got this error like it try to bring the the uml ecore from internet :
Quote:

java.net.ConnectException: Connection timed out: connect


i try to bring the UMl.ecore but it need also other MM like the ecore.ecore,..


mahmoud

Re: [ATL] announce of a Java DSL for ATL transformations execution. [message #530859 is a reply to message #530749] Sat, 01 May 2010 20:03 Go to previous messageGo to next message
Christophe  is currently offline Christophe
Messages: 9
Registered: April 2010
Junior Member
I had same error but corrected using function ecore( ) instead of typing directly the ecore URI. Try using this :

register(resource(ecore( ), true));

It should work fine.

Chris.
Re: [ATL] announce of a Java DSL for ATL transformations execution. [message #530860 is a reply to message #510039] Sat, 01 May 2010 20:12 Go to previous messageGo to next message
Christophe  is currently offline Christophe
Messages: 9
Registered: April 2010
Junior Member
Sorry for my previous answer, this works for ecore metamodel only. For your model, please use URI.createUri( http .... )

I also corrected my last problem.

Resources need to be saved, to use URI.createFileURI method and absolute file path instead of createURI method.


Regards,

Chris.
Re: [ATL] announce of a Java DSL for ATL transformations execution. [message #531805 is a reply to message #530860] Thu, 06 May 2010 05:20 Go to previous messageGo to next message
Elhamlaoui Mahmoud is currently offline Elhamlaoui Mahmoud
Messages: 248
Registered: March 2010
Senior Member


Hi, itried but i dodnt succeed, itry to make :

Quote:

OneInOneOutTransformation trans = new Transformations.Builder()
.asm("file:D:/tr.asm")
.in(get("http://www.eclipse.org/MetaModel"), "IN", "DSLMetaModel")
//.out(get("http://www.eclipse.org/uml2/2.1.0/UML"), "OUT", "uml")

.out(get(URI.createURI("http://www.eclipse.org/uml2/2.1.0/UML").toString()),"OUT", "uml")
.buildOneInOneOut();



any ideas?
Re: [ATL] announce of a Java DSL for ATL transformations execution. [message #531821 is a reply to message #531805] Thu, 06 May 2010 05:49 Go to previous messageGo to next message
Guillaume Hillairet is currently offline Guillaume Hillairet
Messages: 81
Registered: July 2009
Member
Hi,

The get() method cannot find EPackage if they have not been registered using the register method. In the case of UML, the solution is given in the wiki pages. (http://code.google.com/p/atl-commons/wiki/Transformations) . That is, you have to register the UML Package like this

register (UMLPackage.eINSTANCE.eResource())
then you can call get(UMLPackage.eNS_URI)

and of course your project need dependencies to the uml plugins.


BRs,
Guillaume

[Updated on: Thu, 06 May 2010 06:14]

Report message to a moderator

Re: [ATL] announce of a Java DSL for ATL transformations execution. [message #531833 is a reply to message #531821] Thu, 06 May 2010 06:24 Go to previous messageGo to next message
Elhamlaoui Mahmoud is currently offline Elhamlaoui Mahmoud
Messages: 248
Registered: March 2010
Senior Member


Hi,

thanks its working,Razz , i forget to add the uml dependencies so he couldnt fine eNS_URI.

one last question, if i got MultiInOneOutTransformation what are the paraeter of the function transform(...)

thanks
mahmoud
Re: [ATL] announce of a Java DSL for ATL transformations execution. [message #531841 is a reply to message #531833] Thu, 06 May 2010 06:58 Go to previous messageGo to next message
Elhamlaoui Mahmoud is currently offline Elhamlaoui Mahmoud
Messages: 248
Registered: March 2010
Senior Member

Hi,

the idea is that i have some steriotype that i need to make in the input, and they are taken into consideration in my transformation i just need to make refencethem in java
Re: [ATL] announce of a Java DSL for ATL transformations execution. [message #531892 is a reply to message #531841] Thu, 06 May 2010 09:41 Go to previous messageGo to next message
Guillaume Hillairet is currently offline Guillaume Hillairet
Messages: 81
Registered: July 2009
Member

You need to pass a Set of EMFModel as input.
You can use the Models.setOf() method for that.
Re: [ATL] announce of a Java DSL for ATL transformations execution. [message #531940 is a reply to message #531892] Thu, 06 May 2010 10:44 Go to previous messageGo to next message
Elhamlaoui Mahmoud is currently offline Elhamlaoui Mahmoud
Messages: 248
Registered: March 2010
Senior Member
Hi Guillaume,

could you have a look in my code to see if there is somethin anormal :

Quote:



public static void main(String[] args) {
register(resource("file:D:/model/MetaModel.ecore", true));
register( UMLPackage.eINSTANCE.eResource() );


Resource model = resource("file:D:/M/input.xml", true);
Resource model1 = resource("file:D:/profile.uml", true);
Resource model2 = resource("file:D:/profile2uml", true);

EMFModel m = inject(model,get("http://www.eclipse.org/MetaModel"));
EMFModel m1 = inject(model1,get("file:D:/profile1.uml"));
EMFModel m2 = inject(model2,get("file:D:/profile2.uml"));


MultiInOneOutTransformation trans = new Transformations.Builder()
.asm("file:D:/tr.asm")
.in(get("http://www.eclipse.org/MetaModel"), "IN", "MMdsl")
.in(get("http:///schemas/persistence/_uXrqoEbwEd-hie3j736G7A/0"), "DATATYPE", "MMUML2")
.in(get("http:///schemas/entity/_uXYIoUbwEd-hie3j736G7A/0"), "ENTITY", "MMUML2")

.out(get(UMLPackage.eNS_URI), "OUT", "MMUML2")
.buildMultiInOneOut();


EMFModel out = transform(Models.setOf(m,m1,m2), trans);

out.getResource().setURI(URI.createURI("file:D:/M/output.xmi "));
try {
out.getResource().save(null);
} catch (IOException e) {
e.printStackTrace();
}
}



}

thanks,
mahmoud

Re: [ATL] announce of a Java DSL for ATL transformations execution. [message #531954 is a reply to message #531940] Thu, 06 May 2010 11:13 Go to previous messageGo to next message
Guillaume Hillairet is currently offline Guillaume Hillairet
Messages: 81
Registered: July 2009
Member
You can try this:

EMFModel m = inject(resource("file:D:/M/input.xml", true), get("http://www.eclipse.org/MetaModel"));
EMFModel m1 = inject(resource("file:D:/profile.uml", true) , get(UMLPackage.eNS_URI));
EMFModel m2 = inject(resource("file:D:/profile2uml", true), get(UMLPackage.eNS_URI));


MultiInOneOutTransformation trans = new Transformations.Builder()
.asm("file:D:/tr.asm")
.in(get("http://www.eclipse.org/MetaModel"), "IN", "MMdsl")
.in(get(UMLPackage.eNS_URI), "DATATYPE", "MMUML2")
.in(get(UMLPackage.eNS_URI), "ENTITY", "MMUML2")
.out(get(UMLPackage.eNS_URI), "OUT", "MMUML2")
.buildMultiInOneOut();

EMFModel out = transform(Models.setOf(m,m1,m2), trans);

[Updated on: Thu, 06 May 2010 11:13]

Report message to a moderator

Re: [ATL] announce of a Java DSL for ATL transformations execution. [message #531972 is a reply to message #531954] Thu, 06 May 2010 12:05 Go to previous messageGo to next message
Elhamlaoui Mahmoud is currently offline Elhamlaoui Mahmoud
Messages: 248
Registered: March 2010
Senior Member

Hi Guillaume,

thanks for the reply, but it shows an error : ATL error this time Smile

the operation applyprofile() in the MMuml wasnt found, perhaps the

profiles werent well loaded i guess,.

any ideas?

thanks for you time

mahmoud
Re: [ATL] announce of a Java DSL for ATL transformations execution. [message #532512 is a reply to message #531972] Mon, 10 May 2010 06:54 Go to previous messageGo to next message
Elhamlaoui Mahmoud is currently offline Elhamlaoui Mahmoud
Messages: 248
Registered: March 2010
Senior Member

Hi,

I wonder if the operations in the metamodel are taken into consideration in java dsl for ATL.

Mahmoud
Re: [ATL] announce of a Java DSL for ATL transformations execution. [message #545610 is a reply to message #510039] Thu, 08 July 2010 08:26 Go to previous messageGo to next message
Jean-Pierre CLAYER is currently offline Jean-Pierre CLAYER
Messages: 1
Registered: April 2010
Junior Member
Hi Guillaume,
I need your help for a project. I use your librairie in a GMF Project and i need to create an action button to execute a Transformation.

My code :


import static com.atl.common.models.Models.get;
import static com.atl.common.models.Models.inject;
import static com.atl.common.models.Models.register;
import static com.atl.common.models.Models.resource;
import static com.atl.common.trans.Transformations.transform;
import java.io.IOException;

import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.m2m.atl.core.emf.EMFModel;

import com.atl.common.trans.OneInOneOutTransformation;
import com.atl.common.trans.Transformations;
import com.atl.common.trans.Transformation;

/**
 * @author Jean-Pierre CLAYER
 * @generated NOT
 */
public class TransformationATL {
	
	public TransformationATL(){
		System.out.println("Enregistrement des MetaModeles");
		try{
			Resource metamodelBosic = resource(Variable.homeDiagram+"BOSiC.ecore");
			Resource metamodelUTL = resource(Variable.homeDiagram+"UTL.ecore");
			register(metamodelBosic);
			register(metamodelUTL);
			System.out.println("Enregistrement des MetaModeles");
		}catch(Exception e){
			System.err.println("Erreur dans l'Enregistrement des MetaModeles");
		}
	}
	
	public void run(){
		System.out.println("Enregistrement du Modele BOSiC");
		Resource model = resource(Variable.homeDiagram+"src/Defaut.bosic");
		register(model);
		
		System.out.println("Définition de la transformation");
		OneInOneOutTransformation trans = new Transformations.Builder()
		.asm(Variable.homeDiagram+"BOSiC2UTL.asm")
		.in(get("src/BOSiC.ecore"), "IN", "BOSiC")
		.out(get("src/UTL.ecore"), "OUT", "UTL")
		.buildOneInOneOut();
		
		System.out.println("Lancement de la transformation");
		EMFModel out = transform(inject(model, get("src/BOSiC.ecore")), trans);
		
		System.out.println("Affectation de sortie");
		out.getResource().setURI(URI.createURI("src/model.utl"));
		try {
			out.getResource().save(null);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}


My problem
Quote:

java.lang.NoClassDefFoundError: com/atl/common/trans/Transformation
at bosic.interrogationpack.BosicDiagramList.buttonOnClick(Bosic DiagramList.java:124)
at bosic.interrogationpack.BosicDiagramList$1.widgetSelected(Bo sicDiagramList.java:94)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListe ner.java:228)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3910)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3503)
at bosic.interrogationpack.BosicDiagramList.display(BosicDiagra mList.java:59)
at bosic.interrogationpack.BosicDiagramList.<init>(BosicDiagramList.java:46)
at bosic.interrogationpack.TransformationATLRequest.<init>(TransformationATLMenuAction.java:61)
at bosic.interrogationpack.TransformationATLMenuAction.createTa rgetRequest(TransformationATLMenuAction.java:46)
at org.eclipse.gmf.runtime.diagram.ui.actions.DiagramAction.get TargetRequest(DiagramAction.java:202)
at org.eclipse.gmf.runtime.diagram.ui.actions.DiagramAction.get Command(DiagramAction.java:161)
at org.eclipse.gmf.runtime.diagram.ui.actions.DiagramAction.doR un(DiagramAction.java:103)
at org.eclipse.gmf.runtime.common.ui.action.AbstractActionHandl er.run(AbstractActionHandler.java:359)
at org.eclipse.gmf.runtime.common.ui.action.ActionManager$1.run (ActionManager.java:225)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator .java:70)
at org.eclipse.gmf.runtime.common.ui.action.ActionManager.run(A ctionManager.java:223)
at org.eclipse.gmf.runtime.common.ui.action.AbstractActionHandl er.runWithEvent(AbstractActionHandler.java:377)
at org.eclipse.jface.action.ActionContributionItem.handleWidget Selection(ActionContributionItem.java:584)
at org.eclipse.jface.action.ActionContributionItem.access$2(Act ionContributionItem.java:501)
at org.eclipse.jface.action.ActionContributionItem$5.handleEven t(ActionContributionItem.java:411)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3910)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3503)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2405)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2369)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:22 21)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:500)
at org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:493)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:113)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:194)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:368)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 559)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
at org.eclipse.equinox.launcher.Main.main(Main.java:1287)
Caused by: java.lang.ClassNotFoundException: com.atl.common.trans.Transformation
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInter nal(BundleLoader.java:494)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(Bund leLoader.java:410)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(Bund leLoader.java:398)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loa dClass(DefaultClassLoader.java:105)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 47 more



The librairie is include in the buildPath and if i use the class "TransformationATL.java" just with a call, i havent the problem.

Can you help me, plz ?
Re: [ATL] announce of a Java DSL for ATL transformations execution. [message #545611 is a reply to message #510039] Thu, 08 July 2010 08:40 Go to previous message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARD
Messages: 511
Registered: July 2009
Senior Member
Did you declare the jar in the manifest of the plug-in ?
Previous Topic:Re: [m2m-dev] [ATL] Does ATL support traceability?
Next Topic:[ATL] containment references cannot span across models.
Goto Forum:
  


Current Time: Fri Apr 18 17:05:09 EDT 2014

Powered by FUDForum. Page generated in 0.04790 seconds