Home » Archived » M2M (model-to-model transformation) » [ATL] launching a transformation programmatically using the UML2.1 metamodel
[ATL] launching a transformation programmatically using the UML2.1 metamodel [message #80143] |
Mon, 28 April 2008 13:39 |
Eclipse User |
|
|
|
Originally posted by: hdubourg.sodifrance.fr
Hello,
I'd like to launch an ATL transformation from some Java code. The
transformation is KDM to UML 2.1. I've already written such a transformation
for the J2SE to KDM case which works fine.
I did test the transformation using the UML21.ecore file and the EMF
registry from within the Eclipse plugin. Both case worked fine.
However when calling the transformation from some piece of Java code,
nothing simply comes out. Here is what the code looks like:
final AtlEMFModelHandler modelHandler =
(AtlEMFModelHandler)AtlModelHandler.getDefault(AtlModelHandl er.AMH_EMF );
ASMModel mofMM = modelHandler.getMof();
//Get MModels
try{
kdmMM = modelHandler.loadModel( "kdm", mofMM, kdmMMurl.openStream());
umlMM = modelHandler.loadModel("uml2" , mofMM, umlMMurl.openStream());
}catch (IOException e){
e.printStackTrace();
}
//Get the kdm Model
kdmModel = modelHandler.loadModel("kdm", kdmMM , kdmModelurl.openStream());
//transform
final AtlLauncher launcher = AtlLauncher.getDefault();
final Map<String, ASMModel> models = new HashMap<String, ASMModel>();
final Map<?, ?> asmParams = Collections.EMPTY_MAP;
final List<?> superimpose = Collections.EMPTY_LIST;
final Map<?, ?> options = Collections.EMPTY_MAP;
final Map<?, ?> libs = Collections.EMPTY_MAP;
ASMModel outputInstance = modelHandler.newModel("OUT", null, umlMM);
models.put( "kdm", kdmMM );
models.put( "uml2", umlMM);
models.put( "IN", kdmModel );
models.put( "OUT", outputInstance);
launcher.launch( transformation, libs, models, asmParams, superimpose,
options );
//The save code...
When loading the UML metamodel from the ecore file, I got lots of Warning
like:
28 avr. 2008 15:28:38 org.eclipse.m2m.atl.drivers.emf4atl.ASMEMFModel
addReferencedExtentsFor
ATTENTION: Resource for org.eclipse.emf.ecore.impl.EClassImpl@cdb06e
(eProxyURI:
platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//E ModelElement) is
null; cannot be referenced
I tried loading the UML metamodel from the EMF registry using:
umlMM =
modelHandler.loadModel("uml2",mofMM,"uri:http://www.eclipse.org/uml2/2.1.0/UML");
I then don't have any warning but still no result.
What am I doing wrong?
Thanks a lot
Hugues Dubourg
|
|
|
Re: [ATL] launching a transformation programmatically using the UML2.1 metamodel [message #80160 is a reply to message #80143] |
Mon, 28 April 2008 14:47 |
Eclipse User |
|
|
|
Originally posted by: Hugo.Bruneliere.univ-nantes.fr
Hi Hugues,
Hugues Dubourg a écrit :
> Hello,
>
> I'd like to launch an ATL transformation from some Java code. The
> transformation is KDM to UML 2.1. I've already written such a transformation
> for the J2SE to KDM case which works fine.
>
> I did test the transformation using the UML21.ecore file and the EMF
> registry from within the Eclipse plugin. Both case worked fine.
>
> However when calling the transformation from some piece of Java code,
> nothing simply comes out. Here is what the code looks like:
>
> final AtlEMFModelHandler modelHandler =
> (AtlEMFModelHandler)AtlModelHandler.getDefault(AtlModelHandl er.AMH_EMF );
>
> ASMModel mofMM = modelHandler.getMof();
>
> //Get MModels
>
> try{
>
> kdmMM = modelHandler.loadModel( "kdm", mofMM, kdmMMurl.openStream());
>
> umlMM = modelHandler.loadModel("uml2" , mofMM, umlMMurl.openStream());
Have you already tried to do something like this (loading the UML2
metamodel from the EMF registry)?
umlMM = modelHandler.loadModel("uml2", mofMM,
URI.createURI("http://www.eclipse.org/uml2/2.1.0/UML"));
Do you know exactly from which line of your program comes your error?
Best regards,
Hugo
>
> }catch (IOException e){
>
> e.printStackTrace();
>
> }
>
> //Get the kdm Model
>
> kdmModel = modelHandler.loadModel("kdm", kdmMM , kdmModelurl.openStream());
>
> //transform
>
> final AtlLauncher launcher = AtlLauncher.getDefault();
>
> final Map<String, ASMModel> models = new HashMap<String, ASMModel>();
>
> final Map<?, ?> asmParams = Collections.EMPTY_MAP;
>
> final List<?> superimpose = Collections.EMPTY_LIST;
>
> final Map<?, ?> options = Collections.EMPTY_MAP;
>
> final Map<?, ?> libs = Collections.EMPTY_MAP;
>
> ASMModel outputInstance = modelHandler.newModel("OUT", null, umlMM);
>
> models.put( "kdm", kdmMM );
>
> models.put( "uml2", umlMM);
>
> models.put( "IN", kdmModel );
>
> models.put( "OUT", outputInstance);
>
>
> launcher.launch( transformation, libs, models, asmParams, superimpose,
> options );
>
> //The save code...
>
>
>
> When loading the UML metamodel from the ecore file, I got lots of Warning
> like:
>
> 28 avr. 2008 15:28:38 org.eclipse.m2m.atl.drivers.emf4atl.ASMEMFModel
> addReferencedExtentsFor
>
> ATTENTION: Resource for org.eclipse.emf.ecore.impl.EClassImpl@cdb06e
> (eProxyURI:
> platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//E ModelElement) is
> null; cannot be referenced
>
>
>
> I tried loading the UML metamodel from the EMF registry using:
>
> umlMM =
> modelHandler.loadModel("uml2",mofMM,"uri:http://www.eclipse.org/uml2/2.1.0/UML");
>
> I then don't have any warning but still no result.
>
> What am I doing wrong?
>
> Thanks a lot
>
>
>
> Hugues Dubourg
>
>
--
--------------------------------------------------------
Hugo Bruneliere - R&D Engineer
ATLAS Group (INRIA & LINA) - University of Nantes
2, rue de la Houssiniere
44322 Nantes Cedex 3 - France
office +33 2 51 12 58 10 /\ cell.+33 6 07 42 45 30
EMail: Hugo.Bruneliere@univ-nantes.fr
http://www.sciences.univ-nantes.fr/lina/atl/
--------------------------------------------------------
|
|
|
Re: [ATL] launching a transformation programmatically using the UML2.1 metamodel [message #80190 is a reply to message #80160] |
Mon, 28 April 2008 15:36 |
Eclipse User |
|
|
|
Originally posted by: hdubourg.sodifrance.fr
Thanks for your swift response Hugo,
I tried to use the EMF registry indeed, but I specified the URI as a String
parameter:
>> umlMM =
>> modelHandler.loadModel("uml2",mofMM,"uri:http://www.eclipse.org/uml2/2.1.0/UML");
I got no error message, but no result either.
When using a new URI as you wrote:
>umlMM = modelHandler.loadModel("uml2", mofMM,
>URI.createURI("http://www.eclipse.org/uml2/2.1.0/UML"));
I now have a null pointer exception whose trace is (sorry it's a bit long):
GRAVE: java.io.FileNotFoundException: http://www.eclipse.org/uml2/2.1.0/UML
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1Diagnos ticWrappedException:
java.io.FileNotFoundException: http://www.eclipse.org/uml2/2.1.0/UML
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
org.eclipse.m2m.atl.drivers.emf4atl.ASMEMFModel.loadASMEMFMo del(ASMEMFModel.java:331)
at
org.eclipse.m2m.atl.engine.AtlEMFModelHandler.loadModel(AtlE MFModelHandler.java:235)
at test.TestKDMtoUML.main(TestKDMtoUML.java:59)
Caused by: java.io.FileNotFoundException:
http://www.eclipse.org/uml2/2.1.0/UML
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(U nknown
Source)
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:299)
at
org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1205)
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
28 avr. 2008 17:21:39 org.eclipse.m2m.atl.engine.AtlEMFModelHandler
loadModel
GRAVE: null
java.lang.NullPointerException
at
org.eclipse.m2m.atl.drivers.emf4atl.ASMEMFModel.adaptMetamod el(ASMEMFModel.java:368)
at
org.eclipse.m2m.atl.drivers.emf4atl.ASMEMFModel.loadASMEMFMo del(ASMEMFModel.java:341)
at
org.eclipse.m2m.atl.engine.AtlEMFModelHandler.loadModel(AtlE MFModelHandler.java:235)
at test.TestKDMtoUML.main(TestKDMtoUML.java:59)
I guess there must a problem matching the metamodel with the given URI. Do
you know where this issue could come from?
I keep debugging my Java code. If ever I make any further breakthrough, I
will let you know.
Hugues
"Hugo Bruneliere" <Hugo.Bruneliere@univ-nantes.fr> a
|
|
|
Re: [ATL] launching a transformation programmatically using the UML2.1 metamodel [message #80388 is a reply to message #80190] |
Tue, 29 April 2008 13:46 |
Eclipse User |
|
|
|
Originally posted by: Hugo.Bruneliere.univ-nantes.fr
Hi Hugues,
Hugues Dubourg a écrit :
> Thanks for your swift response Hugo,
>
>
> I tried to use the EMF registry indeed, but I specified the URI as a String
> parameter:
>>> umlMM =
>>> modelHandler.loadModel("uml2",mofMM,"uri:http://www.eclipse.org/uml2/2.1.0/UML");
> I got no error message, but no result either.
>
>
> When using a new URI as you wrote:
>> umlMM = modelHandler.loadModel("uml2", mofMM,
>> URI.createURI("http://www.eclipse.org/uml2/2.1.0/UML"));
>
> I now have a null pointer exception whose trace is (sorry it's a bit long):
>
> GRAVE: java.io.FileNotFoundException: http://www.eclipse.org/uml2/2.1.0/UML
>
Is the UML2 plugin (version 2.1) installed and loaded onto your Eclipse?
If another version is installed, you may try with the corresponding URI.
Best regards,
Hugo
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1Diagnos ticWrappedException:
> java.io.FileNotFoundException: http://www.eclipse.org/uml2/2.1.0/UML
>
> 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
> org.eclipse.m2m.atl.drivers.emf4atl.ASMEMFModel.loadASMEMFMo del(ASMEMFModel.java:331)
>
> at
> org.eclipse.m2m.atl.engine.AtlEMFModelHandler.loadModel(AtlE MFModelHandler.java:235)
>
> at test.TestKDMtoUML.main(TestKDMtoUML.java:59)
>
> Caused by: java.io.FileNotFoundException:
> http://www.eclipse.org/uml2/2.1.0/UML
>
> at sun.net.www.protocol.http.HttpURLConnection.getInputStream(U nknown
> Source)
>
> 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:299)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1205)
>
> 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
>
> 28 avr. 2008 17:21:39 org.eclipse.m2m.atl.engine.AtlEMFModelHandler
> loadModel
>
> GRAVE: null
>
> java.lang.NullPointerException
>
> at
> org.eclipse.m2m.atl.drivers.emf4atl.ASMEMFModel.adaptMetamod el(ASMEMFModel.java:368)
>
> at
> org.eclipse.m2m.atl.drivers.emf4atl.ASMEMFModel.loadASMEMFMo del(ASMEMFModel.java:341)
>
> at
> org.eclipse.m2m.atl.engine.AtlEMFModelHandler.loadModel(AtlE MFModelHandler.java:235)
>
> at test.TestKDMtoUML.main(TestKDMtoUML.java:59)
>
>
> I guess there must a problem matching the metamodel with the given URI. Do
> you know where this issue could come from?
>
> I keep debugging my Java code. If ever I make any further breakthrough, I
> will let you know.
>
>
> Hugues
>
>
>
>
> "Hugo Bruneliere" <Hugo.Bruneliere@univ-nantes.fr> a écrit dans le message
> de news: fv4o1a$hs4$1@build.eclipse.org...
>> Hi Hugues,
>>
>> Hugues Dubourg a écrit :
>>> Hello,
>>>
>>> I'd like to launch an ATL transformation from some Java code. The
>>> transformation is KDM to UML 2.1. I've already written such a
>>> transformation for the J2SE to KDM case which works fine.
>>>
>>> I did test the transformation using the UML21.ecore file and the EMF
>>> registry from within the Eclipse plugin. Both case worked fine.
>>>
>>> However when calling the transformation from some piece of Java code,
>>> nothing simply comes out. Here is what the code looks like:
>>>
>>> final AtlEMFModelHandler modelHandler =
>>> (AtlEMFModelHandler)AtlModelHandler.getDefault(AtlModelHandl er.AMH_EMF );
>>>
>>> ASMModel mofMM = modelHandler.getMof();
>>>
>>> //Get MModels
>>>
>>> try{
>>>
>>> kdmMM = modelHandler.loadModel( "kdm", mofMM, kdmMMurl.openStream());
>>>
>>> umlMM = modelHandler.loadModel("uml2" , mofMM,
>>> umlMMurl.openStream());
>> Have you already tried to do something like this (loading the UML2
>> metamodel from the EMF registry)?
>>
>> umlMM = modelHandler.loadModel("uml2", mofMM,
>> URI.createURI("http://www.eclipse.org/uml2/2.1.0/UML"));
>>
>>
>> Do you know exactly from which line of your program comes your error?
>>
>>
>> Best regards,
>>
>> Hugo
>>
>>> }catch (IOException e){
>>>
>>> e.printStackTrace();
>>>
>>> }
>>>
>>> //Get the kdm Model
>>>
>>> kdmModel = modelHandler.loadModel("kdm", kdmMM ,
>>> kdmModelurl.openStream());
>>>
>>> //transform
>>>
>>> final AtlLauncher launcher = AtlLauncher.getDefault();
>>>
>>> final Map<String, ASMModel> models = new HashMap<String, ASMModel>();
>>>
>>> final Map<?, ?> asmParams = Collections.EMPTY_MAP;
>>>
>>> final List<?> superimpose = Collections.EMPTY_LIST;
>>>
>>> final Map<?, ?> options = Collections.EMPTY_MAP;
>>>
>>> final Map<?, ?> libs = Collections.EMPTY_MAP;
>>>
>>> ASMModel outputInstance = modelHandler.newModel("OUT", null, umlMM);
>>>
>>> models.put( "kdm", kdmMM );
>>>
>>> models.put( "uml2", umlMM);
>>>
>>> models.put( "IN", kdmModel );
>>>
>>> models.put( "OUT", outputInstance);
>>>
>>>
>>> launcher.launch( transformation, libs, models, asmParams, superimpose,
>>> options );
>>>
>>> //The save code...
>>>
>>>
>>>
>>> When loading the UML metamodel from the ecore file, I got lots of Warning
>>> like:
>>>
>>> 28 avr. 2008 15:28:38 org.eclipse.m2m.atl.drivers.emf4atl.ASMEMFModel
>>> addReferencedExtentsFor
>>>
>>> ATTENTION: Resource for org.eclipse.emf.ecore.impl.EClassImpl@cdb06e
>>> (eProxyURI:
>>> platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//E ModelElement)
>>> is null; cannot be referenced
>>>
>>>
>>>
>>> I tried loading the UML metamodel from the EMF registry using:
>>>
>>> umlMM =
>>> modelHandler.loadModel("uml2",mofMM,"uri:http://www.eclipse.org/uml2/2.1.0/UML");
>>>
>>> I then don't have any warning but still no result.
>>>
>>> What am I doing wrong?
>>>
>>> Thanks a lot
>>>
>>>
>>>
>>> Hugues Dubourg
>>>
>>>
>>
>> --
>> --------------------------------------------------------
>> Hugo Bruneliere - R&D Engineer
>> ATLAS Group (INRIA & LINA) - University of Nantes
>> 2, rue de la Houssiniere
>> 44322 Nantes Cedex 3 - France
>> office +33 2 51 12 58 10 /\ cell.+33 6 07 42 45 30
>> EMail: Hugo.Bruneliere@univ-nantes.fr
>> http://www.sciences.univ-nantes.fr/lina/atl/
>> --------------------------------------------------------
>
>
--
--------------------------------------------------------
Hugo Bruneliere - R&D Engineer
ATLAS Group (INRIA & LINA) - University of Nantes
2, rue de la Houssiniere
44322 Nantes Cedex 3 - France
office +33 2 51 12 58 10 /\ cell.+33 6 07 42 45 30
EMail: Hugo.Bruneliere@univ-nantes.fr
http://www.sciences.univ-nantes.fr/lina/atl/
--------------------------------------------------------
|
|
| | | |
Goto Forum:
Current Time: Fri Sep 20 22:07:27 GMT 2024
Powered by FUDForum. Page generated in 0.05101 seconds
|