Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL]Loading UML models
[ATL]Loading UML models [message #84072] Mon, 09 June 2008 21:21 Go to next message
neto Mising name is currently offline neto Mising nameFriend
Messages: 33
Registered: July 2009
Member
Hi,

i created some Atl Transformations, and they are working right on atl
plugin. However, i need run this transformation automatically by a java
applications.

I read some material about it.

http://wiki.eclipse.org/ATL_Howtos#How_do_I_launch_transform ations_programmatically.3F

http://dev.eclipse.org/newslists/news.eclipse.modeling.m2m/m sg00042.html
http://dev.eclipse.org/newslists/news.eclipse.modeling.m2m/m sg02574.html
http://wiki.eclipse.org/JWT_Transformations#About_ATL

http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.gmt/AM3 /org.eclipse.gmt.am3.dsls.km3/src/org/eclipse/gmt/am3/dsls/k m3/KM3Projector.java?root=Technology_Project&view=log

http://ssel.vub.ac.be/viewvc/UML1CaseStudies/uml1cs-atlcomma ndline/src/org/atl/commandline/Main.java
http://dev.eclipse.org/newslists/news.eclipse.modeling.m2m/m sg02663.html

The head of my transformatios is:
create OUT : JavaAbstractSyntax from IN : uml2;

a excerpt of my transformation is following.

modelHandler = (AtlEMFModelHandler)
AtlModelHandler.getDefault(AtlModelHandler.AMH_EMF);
...
ASMEMFModel jasMetamodel = (ASMEMFModel)
modelHandler.loadModel("JavaAbstractSyntax", modelHandler.getMof(),
new FileInputStream
("Z:/<<path>>/MetaModels/JavaAbstractSyntax.ecore"));
ASMEMFModel UmlMetamodel = (ASMEMFModel) modelHandler.loadModel(
"UML", modelHandler.getMof(),
"uri:http://www.eclipse.org/uml2/2.1.0/UML");
//i try it too
//ASMEMFModelUmlMetamodel = (ASMEMFModel) modelHandler.loadModel("uml2",
modelHandler.getMof(),
// new FileInputStream ("Z:/<<Path>>/MetaModels/UML2.ecore"));

models.put("JavaAbstractSyntax", jasMetamodel);
models.put("uml2", UmlMetamodel);
...

ASMEMFModel umlInputModel = (ASMEMFModel) modelHandler.loadModel("IN",
UmlMetamodel,
new FileInputStream ("Z:/<<path>>/Models/input Models/UMLTesters.uml"));
ASMEMFModel jasOutputModel = (ASMEMFModel) modelHandler.newModel("OUT",
"arquivo", jasMetamodel);

models.put("IN", umlInputModel);
models.put("OUT", jasOutputModel);

AtlLauncher.getDefault().launch(this.UML2DesignWizard_Pool_T ransfoResource,
Collections.EMPTY_MAP, models, Collections.EMPTY_MAP,
Collections.EMPTY_LIST, Collections.EMPTY_MAP);

modelHandler.saveModel(jasOutputModel, "arquivo", false);


Well, but the line of creation of umlInputModel throws the exception:

09/06/2008 18:14:43 org.eclipse.m2m.atl.drivers.emf4atl.ASMEMFModel
loadASMEMFModel
SEVERE: Package with uri 'http://www.eclipse.org/uml2/2.0.0/UML' not
found. (file:///Z:/Mestrado/MoDELS/workspace/GeneratorTool/IN, 3, 75)
org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Package with
uri 'http://www.eclipse.org/uml2/2.0.0/UML' not found.
(file:///Z:/Mestrado/MoDELS/workspace/GeneratorTool/IN, 3, 75)
at
org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.handleErrors(XMLL oadImpl.java:83)
at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:191)
at
org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes ourceImpl.java:180)
at
org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1414)
at
org.eclipse.m2m.atl.drivers.emf4atl.ASMEMFModel.loadASMEMFMo del(ASMEMFModel.java:365)
at
org.eclipse.m2m.atl.engine.AtlEMFModelHandler.loadModel(AtlE MFModelHandler.java:222)
at UML2ModelDesignTest.uml2DesignTest(UML2ModelDesignTest.java: 79)
at UML2ModelDesignTest.main(UML2ModelDesignTest.java:105)
Caused by: org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package
with uri 'http://www.eclipse.org/uml2/2.0.0/UML' not found.
(file:///Z:/Mestrado/MoDELS/workspace/GeneratorTool/IN, 3, 75)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.getPackageForURI(X MLHandler.java:2566)

the input files are generated by the MagicDraw, and works right in ATL
Plugin. Someone can help me?

Thanks in advance.
Re: [ATL]Loading UML models [message #84104 is a reply to message #84072] Tue, 10 June 2008 09:07 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: john.gmail.com

Maybe the jar for uml is missing in your classpath?

Netuh has written :
> Hi,
>
> i created some Atl Transformations, and they are working right on atl
> plugin. However, i need run this transformation automatically by a java
> applications.
>
> I read some material about it.
>
> http://wiki.eclipse.org/ATL_Howtos#How_do_I_launch_transform ations_programmatically.3F
>
>
> http://dev.eclipse.org/newslists/news.eclipse.modeling.m2m/m sg00042.html
> http://dev.eclipse.org/newslists/news.eclipse.modeling.m2m/m sg02574.html
> http://wiki.eclipse.org/JWT_Transformations#About_ATL
>
> http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.gmt/AM3 /org.eclipse.gmt.am3.dsls.km3/src/org/eclipse/gmt/am3/dsls/k m3/KM3Projector.java?root=Technology_Project&view=log
>
>
> http://ssel.vub.ac.be/viewvc/UML1CaseStudies/uml1cs-atlcomma ndline/src/org/atl/commandline/Main.java
>
> http://dev.eclipse.org/newslists/news.eclipse.modeling.m2m/m sg02663.html
>
> The head of my transformatios is:
> create OUT : JavaAbstractSyntax from IN : uml2;
>
> a excerpt of my transformation is following.
>
> modelHandler = (AtlEMFModelHandler)
> AtlModelHandler.getDefault(AtlModelHandler.AMH_EMF);
> ..
> ASMEMFModel jasMetamodel = (ASMEMFModel)
> modelHandler.loadModel("JavaAbstractSyntax", modelHandler.getMof(),
> new FileInputStream
> ("Z:/<<path>>/MetaModels/JavaAbstractSyntax.ecore"));
> ASMEMFModel UmlMetamodel = (ASMEMFModel) modelHandler.loadModel(
> "UML", modelHandler.getMof(),
> "uri:http://www.eclipse.org/uml2/2.1.0/UML");
> //i try it too
> //ASMEMFModelUmlMetamodel = (ASMEMFModel) modelHandler.loadModel("uml2",
> modelHandler.getMof(),
> // new FileInputStream ("Z:/<<Path>>/MetaModels/UML2.ecore"));
>
> models.put("JavaAbstractSyntax", jasMetamodel);
> models.put("uml2", UmlMetamodel);
> ..
>
> ASMEMFModel umlInputModel = (ASMEMFModel) modelHandler.loadModel("IN",
> UmlMetamodel,
> new FileInputStream ("Z:/<<path>>/Models/input
> Models/UMLTesters.uml"));
> ASMEMFModel jasOutputModel = (ASMEMFModel) modelHandler.newModel("OUT",
> "arquivo", jasMetamodel);
>
> models.put("IN", umlInputModel);
> models.put("OUT", jasOutputModel);
>
> AtlLauncher.getDefault().launch(this.UML2DesignWizard_Pool_T ransfoResource,
> Collections.EMPTY_MAP, models, Collections.EMPTY_MAP,
> Collections.EMPTY_LIST, Collections.EMPTY_MAP);
>
> modelHandler.saveModel(jasOutputModel, "arquivo", false);
>
>
> Well, but the line of creation of umlInputModel throws the exception:
>
> 09/06/2008 18:14:43 org.eclipse.m2m.atl.drivers.emf4atl.ASMEMFModel
> loadASMEMFModel
> SEVERE: Package with uri 'http://www.eclipse.org/uml2/2.0.0/UML' not
> found. (file:///Z:/Mestrado/MoDELS/workspace/GeneratorTool/IN, 3, 75)
> org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Package with
> uri 'http://www.eclipse.org/uml2/2.0.0/UML' not found.
> (file:///Z:/Mestrado/MoDELS/workspace/GeneratorTool/IN, 3, 75)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.handleErrors(XMLL oadImpl.java:83)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:191)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes ourceImpl.java:180)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1414)
>
> at
> org.eclipse.m2m.atl.drivers.emf4atl.ASMEMFModel.loadASMEMFMo del(ASMEMFModel.java:365)
>
> at
> org.eclipse.m2m.atl.engine.AtlEMFModelHandler.loadModel(AtlE MFModelHandler.java:222)
>
> at UML2ModelDesignTest.uml2DesignTest(UML2ModelDesignTest.java: 79)
> at UML2ModelDesignTest.main(UML2ModelDesignTest.java:105)
> Caused by: org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package
> with uri 'http://www.eclipse.org/uml2/2.0.0/UML' not found.
> (file:///Z:/Mestrado/MoDELS/workspace/GeneratorTool/IN, 3, 75)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.getPackageForURI(X MLHandler.java:2566)
>
>
> the input files are generated by the MagicDraw, and works right in ATL
> Plugin. Someone can help me?
>
> Thanks in advance.
>
>
Re: [ATL]Loading UML models [message #84135 is a reply to message #84104] Tue, 10 June 2008 13:58 Go to previous messageGo to next message
neto Mising name is currently offline neto Mising nameFriend
Messages: 33
Registered: July 2009
Member
the jars that i m using are:

antlr-runtime-3.0.jar
ATL-parser.jar
org.antlr.runtime_3.0.0.v200803061811.jar
org.eclipse.core.jobs_3.4.0.v20080310.jar
org.eclipse.core.resources_3.4.0.v20080326.jar
org.eclipse.core.runtime.compatibility_3.2.0.v20071008.jar
org.eclipse.core.runtime_3.4.0.v20080324-1725.jar
org.eclipse.emf.common_2.4.0.v200804012208.jar
org.eclipse.emf.ecore.xmi_2.4.0.v200804012208.jar
org.eclipse.emf.ecore_2.4.0.v200804012208.jar
org.eclipse.equinox.common_3.4.0.v20080320.jar
org.eclipse.gmt.tcs.extractor_1.0.0.jar
org.eclipse.gmt.tcs.injector_1.0.0.jar
org.eclipse.m2m.atl.drivers.emf4atl_2.0.0.v200804031124.jar
org.eclipse.m2m.atl.engine.jar
org.eclipse.m2m.atl.engine.vm_2.0.0.v200804031124.jar
org.eclipse.osgi_3.4.0.v20080326.jar
org.eclipse.uml2.codegen.ecore_1.4.0.v200805201126.jar
org.eclipse.uml2.common_1.4.0.v200805131030.jar
org.eclipse.uml2.uml.ecore.exporter_2.2.0.v200805131030.jar
org.eclipse.uml2.uml.ecore.importer_2.2.0.v200805131030.jar
org.eclipse.uml2.uml_2.2.0.v200805141133.jar
org.eclipse.uml2_2.1.0.v200805131030.jar

(all are correct in te classpath)

What am i doing whong?

Thanks
Re: [ATL]Loading UML models [message #84197 is a reply to message #84135] Tue, 10 June 2008 15:28 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: john.gmail.com

I don't know if your version of your UML jars (2.1) is compatible with
your models (2.0). Also you need to register your uri in the EMF
registry as explained here
http://dev.eclipse.org/newslists/news.eclipse.modeling.m2m/m sg00956.html.


Netuh has written :
> the jars that i m using are:
>
> antlr-runtime-3.0.jar
> ATL-parser.jar
> org.antlr.runtime_3.0.0.v200803061811.jar
> org.eclipse.core.jobs_3.4.0.v20080310.jar
> org.eclipse.core.resources_3.4.0.v20080326.jar
> org.eclipse.core.runtime.compatibility_3.2.0.v20071008.jar
> org.eclipse.core.runtime_3.4.0.v20080324-1725.jar
> org.eclipse.emf.common_2.4.0.v200804012208.jar
> org.eclipse.emf.ecore.xmi_2.4.0.v200804012208.jar
> org.eclipse.emf.ecore_2.4.0.v200804012208.jar
> org.eclipse.equinox.common_3.4.0.v20080320.jar
> org.eclipse.gmt.tcs.extractor_1.0.0.jar
> org.eclipse.gmt.tcs.injector_1.0.0.jar
> org.eclipse.m2m.atl.drivers.emf4atl_2.0.0.v200804031124.jar
> org.eclipse.m2m.atl.engine.jar
> org.eclipse.m2m.atl.engine.vm_2.0.0.v200804031124.jar
> org.eclipse.osgi_3.4.0.v20080326.jar
> org.eclipse.uml2.codegen.ecore_1.4.0.v200805201126.jar
> org.eclipse.uml2.common_1.4.0.v200805131030.jar
> org.eclipse.uml2.uml.ecore.exporter_2.2.0.v200805131030.jar
> org.eclipse.uml2.uml.ecore.importer_2.2.0.v200805131030.jar
> org.eclipse.uml2.uml_2.2.0.v200805141133.jar
> org.eclipse.uml2_2.1.0.v200805131030.jar
>
> (all are correct in te classpath)
>
> What am i doing whong?
>
> Thanks
>
Re: [ATL]Loading UML models [message #84241 is a reply to message #84197] Wed, 11 June 2008 06:20 Go to previous message
neto Mising name is currently offline neto Mising nameFriend
Messages: 33
Registered: July 2009
Member
Thanks john, thanks a lot.

I neeeded register the uri.

my solution was:

ResourceSet resourceSet = ASMEMFModel.getResourceSet();

resourceSet.getPackageRegistry().put("http://www.eclipse.org/uml2/2.0.0/UML",
UMLPackage.eINSTANCE);
resourceSet.getPackageRegistry().put("http:///schemas/MagicDrawProfile/_J72JQCGrEd2cVNUYIoYh2A/0",
UMLPackage.eINSTANCE);

URI uri =
URI.createURI("jar:file:///Z:/<<path>>/lib/org.eclipse.uml2.uml.resources_2.2.0.v20080309.jar!/ ");

resourceSet.getURIConverter().URI_MAP.put(URI.createURI(UMLR esource.LIBRARIES_PATHMAP),
uri.appendSegment("libraries").appendSegment(""));

resourceSet.getURIConverter().URI_MAP.put(URI.createURI(UMLR esource.METAMODELS_PATHMAP),
uri.appendSegment("metamodels").appendSegment(""));

resourceSet.getURIConverter().URI_MAP.put(URI.createURI(UMLR esource.PROFILES_PATHMAP),
uri.appendSegment("profiles").appendSegment(""));
resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put(UMLResource.FILE_EXTENSION,
UMLResource.Factory.INSTANCE);


Now i have another doubt. When the magicDraw create the file of the model,
it put the xsi:schemaLocation attribute as
"http:///schemas/MagicDrawProfile/_J72JQCGrEd2cVNUYIoYh2A/0" and it add a
node on xmi the <MagicDrawProfile:auxiliaryResource>. You know how can i
ignorate this information?

for now, i m pre-processing the xmi altering these infomation.

Well, Thanks again
Previous Topic:QVT XSD
Next Topic:[ATL] invalid zip files?
Goto Forum:
  


Current Time: Fri Apr 19 23:57:36 GMT 2024

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

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

Back to the top