Home » Archived » M2M (model-to-model transformation) » [ATL] announce of a Java DSL for ATL transformations execution.
| | | | |
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   |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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] by Moderator
|
|
| | | | | | | | |
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   |
Eclipse User |
|
|
|
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 #530688 is a reply to message #510039] |
Fri, 30 April 2010 10:22   |
Eclipse User |
|
|
|
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 #531940 is a reply to message #531892] |
Thu, 06 May 2010 10:44   |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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] by Moderator
|
|
| | |
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   |
Eclipse User |
|
|
|
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 ?
|
|
| |
Goto Forum:
Current Time: Wed Jul 16 17:58:49 EDT 2025
Powered by FUDForum. Page generated in 0.09439 seconds
|