Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Dynamic EMF
Dynamic EMF [message #423167] Wed, 24 September 2008 09:49 Go to next message
Kristian Sons is currently offline Kristian SonsFriend
Messages: 27
Registered: July 2009
Junior Member
Hello!

I like the functionality of dynamic creation of meta models. But it
seems to me, that the creation of the model should be finished before
the first instances are created!?

Example:

EPackage myDynamicPackage = EcoreFactory.eINSTANCE.createEPackage();
myDynamicPackage.setName("coolPackage");



EClass myClass = EcoreFactory.eINSTANCE.createEClass();
myClass.setName("My Name");
myDynamicPackage.getEClassifiers().add(myClass);

EObject inst = EcoreUtil.create(myClass);

EAttribute myAttribute = EcoreFactory.eINSTANCE.createEAttribute();
myAttribute.setName("attribute1");
myAttribute.setEType(EcorePackage.eINSTANCE.getEString());
myClass.getEStructuralFeatures().add(myAttribute);

inst.eSet(myAttribute, "attValue1");

EAttribute myAttribute2 = EcoreFactory.eINSTANCE.createEAttribute();
myAttribute2.setName("attribute2");
myAttribute2.setEType(EcorePackage.eINSTANCE.getEString());
myClass.getEStructuralFeatures().add(myAttribute2);

inst.eSet(myAttribute2, "attValue2");


The second eSet generates an ArrayIndexOutOfBoundsException.

Is this meant to be or perhaps a bug?

Thanks,
Kristian
Re: Dynamic EMF [message #423172 is a reply to message #423167] Wed, 24 September 2008 11:26 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30804
Registered: July 2009
Senior Member
Kristian,

Comments below.


Kristian Sons wrote:
> Hello!
>
> I like the functionality of dynamic creation of meta models. But it
> seems to me, that the creation of the model should be finished before
> the first instances are created!?
Yes.
>
> Example:
>
> EPackage myDynamicPackage = EcoreFactory.eINSTANCE.createEPackage();
> myDynamicPackage.setName("coolPackage");
Settings an nsURI is important as well.
>
>
>
> EClass myClass = EcoreFactory.eINSTANCE.createEClass();
> myClass.setName("My Name");
> myDynamicPackage.getEClassifiers().add(myClass);
>
> EObject inst = EcoreUtil.create(myClass);
>
> EAttribute myAttribute = EcoreFactory.eINSTANCE.createEAttribute();
> myAttribute.setName("attribute1");
> myAttribute.setEType(EcorePackage.eINSTANCE.getEString());
> myClass.getEStructuralFeatures().add(myAttribute);
>
> inst.eSet(myAttribute, "attValue1");
>
> EAttribute myAttribute2 = EcoreFactory.eINSTANCE.createEAttribute();
> myAttribute2.setName("attribute2");
> myAttribute2.setEType(EcorePackage.eINSTANCE.getEString());
> myClass.getEStructuralFeatures().add(myAttribute2);
>
> inst.eSet(myAttribute2, "attValue2");
>
>
> The second eSet generates an ArrayIndexOutOfBoundsException.
>
> Is this meant to be or perhaps a bug?
Until we implement https://bugs.eclipse.org/bugs/show_bug.cgi?id=177107,
i.e., a specialized EObjectImpl subclass that's tolerant of changes to
the metamodel, it's just meant to be.
>
> Thanks,
> Kristian
Re: Dynamic EMF [message #423179 is a reply to message #423172] Wed, 24 September 2008 13:38 Go to previous messageGo to next message
Kristian Sons is currently offline Kristian SonsFriend
Messages: 27
Registered: July 2009
Junior Member
Ed,

thanks for the answer!

>> EPackage myDynamicPackage = EcoreFactory.eINSTANCE.createEPackage();
>> myDynamicPackage.setName("coolPackage");
> Settings an nsURI is important as well.

Of course.

>> Is this meant to be or perhaps a bug?
> Until we implement https://bugs.eclipse.org/bugs/show_bug.cgi?id=177107,
> i.e., a specialized EObjectImpl subclass that's tolerant of changes to
> the metamodel, it's just meant to be.

Great! When is it available ;)

I saw the Estore stuff in EObjectImpl. Is this meant to become something
like this?

Kristian
Re: Dynamic EMF [message #423181 is a reply to message #423179] Wed, 24 September 2008 14:03 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 30804
Registered: July 2009
Senior Member
Kristian,

I suppose the EStore could be used for such a purpose, but the primary
purpose for it is to separate out all the data values from the objects
themselves such that the object act merely as a facade and all data
management is handled by the store. CDO is a great example of how it
can be used to support facade objects where the real backing model is on
the server rather than the client.


Kristian Sons wrote:
> Ed,
>
> thanks for the answer!
>
>>> EPackage myDynamicPackage = EcoreFactory.eINSTANCE.createEPackage();
>>> myDynamicPackage.setName("coolPackage");
>> Settings an nsURI is important as well.
>
> Of course.
>
>>> Is this meant to be or perhaps a bug?
>> Until we implement
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=177107, i.e., a
>> specialized EObjectImpl subclass that's tolerant of changes to the
>> metamodel, it's just meant to be.
>
> Great! When is it available ;)
>
> I saw the Estore stuff in EObjectImpl. Is this meant to become
> something like this?
>
> Kristian
Previous Topic:Finding an CDOObject based on its intrinsic ID
Next Topic:bugs 240299 and 240502: interesting for EMF?
Goto Forum:
  


Current Time: Sun Jan 19 14:36:20 GMT 2020

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

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

Back to the top