Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Dynamic EMF
Dynamic EMF [message #1656338] Sat, 07 March 2015 13:08 Go to next message
UmaShankar Subramani is currently offline UmaShankar SubramaniFriend
Messages: 194
Registered: December 2011
Location: SWEDEN
Senior Member
I need to add an extra EAttribute to an eObject.

For doing this, I extend the eClass of this eObject using Dynamic EMF. I succeed doing that.

Then, I added eAttribute to this dynamically created eClass. Then, the extended eObject is created successfully.

Now, I want to add all the values of EStructuralFeatures from the originalObject to the extendedObject.

The following method fails to do that: What is wrong in this method?


public static EObject clone( EObject originalObject,EObject extendedObject) {


for ( Iterator i = extendedObject.eClass().getEStructuralFeatures().iterator(); i.hasNext(); )
{

EStructuralFeature feature = (EStructuralFeature) i.next();
extendedObject.eSet( feature, originalObject.eGet( feature ) );

}


return extendedObject;

}
Re: Dynamic EMF [message #1656776 is a reply to message #1656338] Sat, 07 March 2015 17:30 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30465
Registered: July 2009
Senior Member
You're using getEStructuralFeatures rather than
getAllEStructuralFeatures. The former returns the locally defined
features while the later returns the inherited features as well as the
locally defined features.

On 07/03/2015 2:08 PM, UmaShankar Subramani wrote:
> I need to add an extra EAttribute to an eObject.
>
> For doing this, I extend the eClass of this eObject using Dynamic EMF.
> I succeed doing that.
> Then, I added eAttribute to this dynamically created eClass. Then, the
> extended eObject is created successfully.
>
> Now, I want to add all the values of EStructuralFeatures from the
> originalObject to the extendedObject.
>
> The following method fails to do that: What is wrong in this method?
>
>
> public static EObject clone( EObject originalObject,EObject
> extendedObject) {
>
>
> for ( Iterator i =
> extendedObject.eClass().getEStructuralFeatures().iterator();
> i.hasNext(); )
> {
>
> EStructuralFeature feature = (EStructuralFeature) i.next();
> extendedObject.eSet( feature, originalObject.eGet( feature ) );
>
> }
>
>
> return extendedObject;
>
> }
Re: Dynamic EMF [message #1662089 is a reply to message #1656776] Mon, 09 March 2015 22:57 Go to previous messageGo to next message
UmaShankar Subramani is currently offline UmaShankar SubramaniFriend
Messages: 194
Registered: December 2011
Location: SWEDEN
Senior Member
Hi,

Thanks for you reply. That worked.

But I have another problem now. After extending the new original class, now I have the extended class with additional EAttribute.

This EAttribute is named "type". I set a value to the EAttribute in the extended eObject.

Then I add it to a resource. The resource file is saved and sent as a CDORemoteSessionMessage to all CDO clients.

The clients then try to load the resource file like the following

resource.load(message.getInputStream(),null);

Here is where I get the following exception:

Caused by: org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'type' not found.


What am I doing wrong here?

[Updated on: Mon, 09 March 2015 22:58]

Report message to a moderator

Re: Dynamic EMF [message #1663759 is a reply to message #1662089] Tue, 10 March 2015 15:26 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30465
Registered: July 2009
Senior Member
I believe with CDO you must register the model with the server. I'm not
sure how that's done though...

On 09/03/2015 11:57 PM, UmaShankar Subramani wrote:
> Hi,
>
> Thanks for you reply. That worked.
>
> But I have another problem now. After extending the new original
> class, now I have the extended class with additional EAttribute.
>
> This EAttribute is named "type". I set a value to the EAttribute in
> the extended eObject.
> Then I add it to a resource. The resource file is saved and sent as a
> CDORemoteSessionMessage to all CDO clients.
>
> The clients then try to load the resource file like the following
>
> resource.load(message.getInputStream(),null);
>
> Here is where I get the following exception:
>
> Caused by: org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature
> 'type' not found.
>
>
Re: Dynamic EMF [message #1664122 is a reply to message #1662089] Tue, 10 March 2015 18:57 Go to previous message
Christian W. Damus is currently offline Christian W. DamusFriend
Messages: 1199
Registered: July 2009
Location: Canada
Senior Member

Hi,

In addition to Ed's comment, it is probably also necessary for the
other connected clients to have the same package available locally in
their VMs. Moreover, if you're dealing with dynamically created Ecore
models, although CDO supports dynamic Ecore, it does not support
changes to an Ecore model once that model has been published to it.

Cheers,

Christian


On 2015-03-09 22:57:01 +0000, UmaShankar Subramani said:

> Hi,
>
> Thanks for you reply. That worked.
>
> But I have another problem now. After extending the new original
> class, now I have the extended class with additional EAttribute.
>
> This EAttribute is named "type". I set a value to the EAttribute in
> the extended eObject.
> Then I add it to a resource. The resource file is saved and sent as a
> CDORemoteSessionMessage to all CDO clients.
>
> The clients then try to load the resource file like the following
>
> resource.load(message.getInputStream(),null);
>
> Here is where I get the following exception:
>
> Caused by: org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature
> 'type' not found.
Previous Topic:Custom resource with non XML persistence
Next Topic:Texo Example is Missing Files
Goto Forum:
  


Current Time: Mon Sep 23 09:12:57 GMT 2019

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

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

Back to the top