Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Create a new model (instance) that conforms to my metamodel in Java class
Create a new model (instance) that conforms to my metamodel in Java class [message #1441084] Thu, 09 October 2014 08:35 Go to next message
ngoc tho huynh is currently offline ngoc tho huynhFriend
Messages: 2
Registered: October 2014
Junior Member
Hi,

i have a metamodel EMF (test.ecore). Now,
1. I want to create an instance (or model) that conforms to this metamodel by Java class.
2. If I have a model (my.test) that conforms to this metamodel (test.ecore).
I want to delete any objects of model (my.test) in java class

HOW I CAN IMPLEMENT THIS JAVA CLASS, PLEASE?
Thanks advance,
Re: Create a new model (instance) that conforms to my metamodel in Java class [message #1441215 is a reply to message #1441084] Thu, 09 October 2014 12:00 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Try invoking "Generate Test Code" and have a look at the generated
XyzExample in the *.tests project.

On 09/10/2014 1:43 PM, ngoc tho huynh wrote:
> Hi,
>
> i have a metamodel EMF (test.ecore). Now, 1. I want to create an
> instance (or model) that conforms to this metamodel by Java class. 2.
> If I have a model (my.test) that conforms to this metamodel
> (test.ecore).
> I want to delete any objects of model (my.test) in java class
>
> HOW I CAN IMPLEMENT THIS JAVA CLASS, PLEASE?
> Thanks advance,
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Create a new model (instance) that conforms to my metamodel in Java class [message #1684811 is a reply to message #1441084] Wed, 18 March 2015 15:37 Go to previous messageGo to next message
Edouard R. Batot is currently offline Edouard R. BatotFriend
Messages: 100
Registered: March 2015
Senior Member
Hi folks,

it's been a few days (a lot of hours) I'm looking on a way to register metamodel in an Eclipse application.
I mean, I'm using a personnal metamodel written in ecore (in a .ecore) and I want to use XMI instances of this metamodel in a Java application. To open the topic, I would add that I'm currently playing with transformations and higher-order transformations through ATL and Java mixed.

The point is : when I execute the
resourceSet.createResource(URI.createFileURI("models/myInstance.xmi"));
Java insults me for he consider the base package of the instance doesn't exist or is abstract (which is false as you may guess).
Note that the .xmi opens well in Eclipse as a "Sample Reflexive Ecore Model".

Well, I'm new in the "on-line community" and I don't have the slightest clue about the meaning of the most classic answer to my question :
Quote:
Try invoking "Generate Test Code" and have a look at the generated
XyzExample in the *.tests project.

Ed, if you can develop just enough to let me use that advice of yours Smile

Any clue welcome, I'm kind of stuck.
Thanks for your attention.
Ed
Re: Create a new model (instance) that conforms to my metamodel in Java class [message #1684821 is a reply to message #1441215] Wed, 18 March 2015 15:43 Go to previous messageGo to next message
Edouard R. Batot is currently offline Edouard R. BatotFriend
Messages: 100
Registered: March 2015
Senior Member
Hi folks,
as the same answer is poping again, I've created an account to ask your light on a little black point.

Ed Merks wrote on Thu, 09 October 2014 12:00
Try invoking "Generate Test Code" and have a look at the generated
XyzExample in the *.tests project.

Please, Ed, what does this mean ?

Where do I invoke "Generate test code" ?


Re: Create a new model (instance) that conforms to my metamodel in Java class [message #1685165 is a reply to message #1684821] Wed, 18 March 2015 18:44 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
When you open a *.genmodel these are actions available in the context menu.

On 18/03/2015 7:00 PM, Edoaurd Batot wrote:
> Hi folks,
> as the same answer is poping again, I've created an account to ask
> your light on a little black point.
>
> Ed Merks wrote on Thu, 09 October 2014 12:00
>> Try invoking "Generate Test Code" and have a look at the generated
>> XyzExample in the *.tests project.
>
> Please, Ed, what does this mean ?
>
> Where do I invoke "Generate test code" ?
>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Create a new model (instance) that conforms to my metamodel in Java class [message #1685175 is a reply to message #1685165] Wed, 18 March 2015 18:47 Go to previous messageGo to next message
Edouard R. Batot is currently offline Edouard R. BatotFriend
Messages: 100
Registered: March 2015
Senior Member
I don't use prensently any *.genmodel.
I'll create one and have a look.
Thanks a lot Ed for your presence.

[Updated on: Wed, 18 March 2015 18:50]

Report message to a moderator

Re: Create a new model (instance) that conforms to my metamodel in Java class [message #1685176 is a reply to message #1684811] Wed, 18 March 2015 18:48 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Edoaurd,

Comments below.


On 18/03/2015 7:00 PM, Edoaurd Batot wrote:
> Hi folks,
>
> it's been a few days (a lot of hours) I'm looking on a way to register
> metamodel in an Eclipse application.
> I mean, I'm using a personnal metamodel written in ecore (in a .ecore)
> and I want to use XMI instances of this metamodel in a Java application.
So you've generated the Java code for it?
> To open the topic, I would add that I'm currently playing with
> transformations and higher-order transformations through ATL and Java
> mixed.
>
> The point is : when I execute the
> resourceSet.createResource(URI.createFileURI("models/myInstance.xmi"));
Is this supposed to run inside the IDE where there is a workspace?
Please try to generate the test project and look at the generated Example.
> Java insults me for he consider the base package of the instance
> doesn't exist or is abstract (which is false as you may guess).
> Note that the .xmi opens well in Eclipse as a "Sample Reflexive Ecore
> Model".
So you don't want to generate Java code? You just want to use dynamic EMF?
>
> Well, I'm new in the "on-line community" and I don't have the
> slightest clue about the meaning of the most classic answer to my
> question :
> Quote:
>> Try invoking "Generate Test Code" and have a look at the generated
>> XyzExample in the *.tests project.
>
> Ed, if you can develop just enough to let me use that advice of yours :)
Do you have a *.genmodel for your *.ecore model? The introductory
tutorials should be helpful...
>
> Any clue welcome, I'm kind of stuck.
> Thanks for your attention.
> Ed


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Create a new model (instance) that conforms to my metamodel in Java class [message #1685177 is a reply to message #1685175] Wed, 18 March 2015 18:49 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Maybe reading
http://www.ibm.com/developerworks/library/os-eclipse-dynamicemf/ will help.

On 18/03/2015 7:47 PM, Edoaurd Batot wrote:
> I don't use prensently any *.genmodel.
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Create a new model (instance) that conforms to my metamodel in Java class [message #1685198 is a reply to message #1685177] Wed, 18 March 2015 18:56 Go to previous messageGo to next message
Edouard R. Batot is currently offline Edouard R. BatotFriend
Messages: 100
Registered: March 2015
Senior Member
Ok, well, you're going fast.
You'll excuse my precipitation, it's been a while I haven't used a forum.

I don't want to generate any Java code.
In a nutshell, I want to load an .ecore and its .xmi instances in order to play with. Everything is in the same project - and to start easy, in the same folder.
(Why ? I'm trying to build preconditions for a transformation plugin using ecore)


But wait a minute, I'll try what you told me.
I've got the tests and the reading open.

Thanks again.

[Updated on: Wed, 18 March 2015 18:58]

Report message to a moderator

Re: Create a new model (instance) that conforms to my metamodel in Java class [message #1685236 is a reply to message #1685198] Wed, 18 March 2015 19:18 Go to previous message
Edouard R. Batot is currently offline Edouard R. BatotFriend
Messages: 100
Registered: March 2015
Senior Member
        Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
        Map<String, Object> m = reg.getExtensionToFactoryMap();
        
        m.put("xmi",   new XMIResourceFactoryImpl());
        m.put("ecore", new XMIResourceFactoryImpl());
       
        ResourceSet resourceSet = new ResourceSetImpl();

       [b]Ramified mm = new Ramified(resourceSet);
        resourceSet.getPackageRegistry().put(
            "RamRoot", mm.getRoot()
        );[/b]
     
        
        Resource resource = (Resource) resourceSet.createResource(URI.createFileURI("models/MyInstance.xmi"));
        resource.load(null);

Registering the package explicitly from the "instance" I've built from the .ecore (and more precisly, its root EPackage).

This looks like what changed this day in a beautyfull one !

Thanks a lot Ed for your support !
Edouard

[Updated on: Wed, 18 March 2015 19:18]

Report message to a moderator

Previous Topic:Converting Ecore Model to java classes
Next Topic:Incorrect references when serializing xtext model
Goto Forum:
  


Current Time: Fri Apr 19 20:22:19 GMT 2024

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

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

Back to the top