Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » MoDisco » Register XMI without ECORE source(How to navigate through an XMI that is not made out of an ecore mmodel)
Register XMI without ECORE source [message #854459] Tue, 24 April 2012 01:12 Go to next message
Juan Castel is currently offline Juan CastelFriend
Messages: 20
Registered: April 2012
Junior Member
Hi, everyone.

I've been resolving a lot of issues here, and now I'm half way:

- after discovering a Java project by MoDisco Java Discoverer, how could I load the resultant XMI model in some XMIResource and navigate? I did so with an Ecore file.

What if I only have the XMI model?

ResourceSet resourceSet = new ResourceSetImpl();		resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put
			(Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl());		resourceSet.getPackageRegistry().put(MyMModelPackage.eNS_URI,MyMModelPackage.eINSTANCE);
File file = new File("C:\\Users\\USER\\workspace\\mmodels\\MyMModel.ecore");
		//System.out.println(file);
		URI uri = URI.createFileURI(file.getAbsolutePath());
		//System.out.println(uri);
		Resource resource = resourceSet.getResource(uri, true);

The above code works fine, but without the Ecore file, I can't figure it out.

By the way, I got the code from MyMModel.ecore-->MyMModel.genmodel->generate test code->*tests folders; thanks to this forum.

Thank you.
Re: Register XMI without ECORE source [message #854692 is a reply to message #854459] Tue, 24 April 2012 06:50 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 26283
Registered: July 2009
Senior Member
On 24/04/2012 3:12 AM, Juan Castel wrote:
> Hi, everyone.
>
> I've been resolving a lot of issues here, and now I'm half way:
>
> - after discovering a Java project by MoDisco Java Discoverer, how
> could I load the resultant XMI model in some XMIResource and navigate?
> I did so with an Ecore file.
>
> What if I only have the XMI model?
>
>
> ResourceSet resourceSet = new ResourceSetImpl();
> resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put
> (Resource.Factory.Registry.DEFAULT_EXTENSION, new
> XMIResourceFactoryImpl());
> resourceSet.getPackageRegistry().put(MyMModelPackage.eNS_URI,MyMModelPackage.eINSTANCE);
> File file = new
> File("C:\\Users\\USER\\workspace\\mmodels\\MyMModel.ecore");
You registrations are for reading instances of the generated model. Why
do you also need to read the original model into a resource? I'd expect
you to be reading instances at this point.
> //System.out.println(file);
> URI uri = URI.createFileURI(file.getAbsolutePath());
> //System.out.println(uri);
> Resource resource = resourceSet.getResource(uri, true);
>
> The above code works fine, but without the Ecore file, I can't figure
> it out.
>
> By the way, I got the code from
> MyMModel.ecore-->MyMModel.genmodel->generate test code->*tests
> folders; thanks to this forum.
>
> Thank you.
Re: Register XMI without ECORE source [message #855721 is a reply to message #854692] Wed, 25 April 2012 03:40 Go to previous message
Juan Castel is currently offline Juan CastelFriend
Messages: 20
Registered: April 2012
Junior Member
Thank you, Ed.
I actually have advanced a lot: I already have the Enterprise Architect XMI exported file and know a way to navigate through its UML elements. I attach the code for reference. This file is one of two inputs.

On the other hand, I exported a JAR file containing the parsing of the entire Ecore metamodel so I can build metaclasses out of the Ecore. An XMI model will be constructed with information about the first input.

Now I have the XMI model conforming to Java metamodel, discovered by MoDisco toolbox, but I get this exception in a standalone:

Package with uri '...MoDisco/Java/0.2.incubation/java' not found. (file:/C:/Users/USER/workspace/Dc3AdminEJB/Dc3AdminEJB_java.xmi, 2, 208)


(The forum editor won't let me post links unless 25 messages posted by me.)

The file Dc3AdminEJB_java.xmi was the result of java discoverer by MoDisco.

I guess the question is how to register MoDisco java metamodel.

Thanks.
Previous Topic:EMF api - constructing XMI from XMI
Next Topic:JSP MoDisco discoverer with JSP files from Struts Project
Goto Forum:
  


Current Time: Fri Dec 19 09:25:07 GMT 2014

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

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