Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » EObject <-> Nested Property Map/Bean
EObject <-> Nested Property Map/Bean [message #425945] Fri, 12 December 2008 21:54 Go to next message
Eclipse UserFriend
Originally posted by: mduduzi.keswa.isizwe.com

With all the tooling around EMF, I thought this capability is available
somehow. Let me explain:

1. I'm trying to send to clients Data Transfer Objects (DTOs) that have
been converted from instances of EObjects.

2. I imagine the conversion will be such that all nested attributes will
be converted to name-value pairs of the form
('attribname1.attribname2.attribname3','value') pair and references
will be converted to ('attribname1.attribname2.attribname3','RefID').


Is there a feature/tool/util that allows reflection (setting and
getting) using 'a.b.c.d' form of nested attributes within an EObject?

Thanks for your help.
-Mdu
Re: EObject <-> Nested Property Map/Bean [message #425948 is a reply to message #425945] Fri, 12 December 2008 22:08 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30993
Registered: July 2009
Senior Member
Mdu,

Comments below.

Mdu wrote:
> With all the tooling around EMF, I thought this capability is
> available somehow. Let me explain:
>
> 1. I'm trying to send to clients Data Transfer Objects (DTOs) that
> have been converted from instances of EObjects.
>
> 2. I imagine the conversion will be such that all nested attributes
> will be converted to name-value pairs of the form
> ('attribname1.attribname2.attribname3','value') pair and references
> will be converted to ('attribname1.attribname2.attribname3','RefID').
I don't really follow.
>
>
> Is there a feature/tool/util that allows reflection (setting and
> getting) using 'a.b.c.d' form of nested attributes within an EObject?
You can use eObject.eGet(eObject.eClass().getEStructuralFeature(<name>))
to look up a named feature...
>
>
> Thanks for your help.
> -Mdu
Re: EObject <-> Nested Property Map/Bean [message #425949 is a reply to message #425948] Fri, 12 December 2008 22:26 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mduduzi.keswa.isizwe.com

Thanks Ed - see my comments below:
Ed Merks wrote:
> Mdu,
>
> Comments below.
>
> Mdu wrote:
>> With all the tooling around EMF, I thought this capability is
>> available somehow. Let me explain:
>>
>> 1. I'm trying to send to clients Data Transfer Objects (DTOs) that
>> have been converted from instances of EObjects.
>>
>> 2. I imagine the conversion will be such that all nested attributes
>> will be converted to name-value pairs of the form
>> ('attribname1.attribname2.attribname3','value') pair and references
>> will be converted to ('attribname1.attribname2.attribname3','RefID').
> I don't really follow.
I'm using databinding feature of a GUI library that generally works with
beans. The GUI/form fields are bound using a.b.c.d conversion to
refer to a nested bean property whose literal value is 3 levels deep -
in this example. In java code I would normally call getA().getB().getC().

Now I want to use reflective features of an EObject to do the same. From
below it sounds like you're suggesting doing something like:

EObject p = eObject.eGet(eObject.eClass().getEStructuralFeature("a"));
p = p.eGet(eObject.eClass().getEStructuralFeature("b"));
p = p.eGet(eObject.eClass().getEStructuralFeature("c"));

I could then take any EObject and convert to a java Map object of the
form [('a.b.c','some literal value'), ...] and back to the original EOBject?

I'm oversimplifying my example for clarity.
>>
>>
>> Is there a feature/tool/util that allows reflection (setting and
>> getting) using 'a.b.c.d' form of nested attributes within an EObject?
> You can use eObject.eGet(eObject.eClass().getEStructuralFeature(<name>))
> to look up a named feature...
>>
>>
>> Thanks for your help.
>> -Mdu
Re: EObject <-> Nested Property Map/Bean [message #425950 is a reply to message #425949] Fri, 12 December 2008 22:44 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 30993
Registered: July 2009
Senior Member
Mdu,

Comments below.

Mdu wrote:
> Thanks Ed - see my comments below:
> Ed Merks wrote:
>> Mdu,
>>
>> Comments below.
>>
>> Mdu wrote:
>>> With all the tooling around EMF, I thought this capability is
>>> available somehow. Let me explain:
>>>
>>> 1. I'm trying to send to clients Data Transfer Objects (DTOs) that
>>> have been converted from instances of EObjects.
>>>
>>> 2. I imagine the conversion will be such that all nested attributes
>>> will be converted to name-value pairs of the form
>>> ('attribname1.attribname2.attribname3','value') pair and references
>>> will be converted to ('attribname1.attribname2.attribname3','RefID').
>> I don't really follow.
> I'm using databinding feature of a GUI library that generally works
> with beans. The GUI/form fields are bound using a.b.c.d conversion
> to refer to a nested bean property whose literal value is 3 levels
> deep - in this example. In java code I would normally call
> getA().getB().getC().
The data binding guys are doing some new work on properties-based data
binding that sounds related...
>
> Now I want to use reflective features of an EObject to do the same.
> From below it sounds like you're suggesting doing something like:
>
> EObject p = eObject.eGet(eObject.eClass().getEStructuralFeature("a"));
> p = p.eGet(eObject.eClass().getEStructuralFeature("b"));
You'd want to use p's eClass().
> p = p.eGet(eObject.eClass().getEStructuralFeature("c"));
>
> I could then take any EObject and convert to a java Map object of the
> form [('a.b.c','some literal value'), ...] and back to the original
> EOBject?
I guess so. I don't really understand that part... It does sound like
what you want is closely related to some new APIs the guys are working on.
>
> I'm oversimplifying my example for clarity.
>>>
>>>
>>> Is there a feature/tool/util that allows reflection (setting and
>>> getting) using 'a.b.c.d' form of nested attributes within an EObject?
>> You can use
>> eObject.eGet(eObject.eClass().getEStructuralFeature(<name>)) to look
>> up a named feature...
>>>
>>>
>>> Thanks for your help.
>>> -Mdu
Previous Topic:Synchronizing the form editor with an XML source editor
Next Topic:[CDO] Update from 1.0.0 to 1.0.x
Goto Forum:
  


Current Time: Mon Mar 30 01:17:33 GMT 2020

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

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

Back to the top