Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » EMF model to Property bag(EMF model to Property bag)
EMF model to Property bag [message #890322] Thu, 21 June 2012 19:14 Go to next message
Aditya Wagle is currently offline Aditya Wagle
Messages: 7
Registered: November 2011
Junior Member
Hi,

I have editors for activities which are tied to EMF models. These models need to be converted from the activity EMF model to a PropertyBag (name,value) pair.
The idea is to have an adapter which understands EMF and converts it to a property bag.

The problem however there will be multiple such activities each with their own model. Is there a way I can write a Generic adapter which can convert EMF models? I also wanted to know if I can provide some meta data in the model itself which will allow the generic adapter to understand which fields of the model need to be part of the property bag.

If a generic adapter cannot be built, is there a way to automate building adapter for each activity when I generate the Model code? Again is there a way to mark / annotate the model to auto-generate the adapter code based on what fields are marked?

Note that the model is not a flat ecore.
Also is there an out of the box way to get the property bag and not have the adapter at all?

Thanks,
-Aditya
Re: EMF model to Property bag [message #890379 is a reply to message #890322] Fri, 22 June 2012 03:25 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 25945
Registered: July 2009
Senior Member
Aditya,

Comments below.

On 21/06/2012 7:14 PM, Aditya Wagle wrote:
> Hi,
>
> I have editors for activities which are tied to EMF models. These
> models need to be converted from the activity EMF model to a
> PropertyBag (name,value) pair.
> The idea is to have an adapter which understands EMF and converts it
> to a property bag.
Could you give an example? EMF does support EMap but that's really a
map not a bag. Are the names the names of the features and the values
the value of the feature?
>
> The problem however there will be multiple such activities each with
> their own model. Is there a way I can write a Generic adapter which
> can convert EMF models? I also wanted to know if I can provide some
> meta data in the model itself which will allow the generic adapter to
> understand which fields of the model need to be part of the property bag.
You can always add EAnnotations. They're used for a number of things,
e.g., EcoreUtil.getAnnotation/setAnnotation.
>
> If a generic adapter cannot be built, is there a way to automate
> building adapter for each activity when I generate the Model code?
> Again is there a way to mark / annotate the model to auto-generate the
> adapter code based on what fields are marked?
Maybe by setting the Root Extends Interface and implementing a
specialized Root Extends Class you can generate a model where all
objects implement your bag interface and do so in a generic way looking
at annotations in the EClass's features.
>
>
> Note that the model is not a flat ecore.
> Also is there an out of the box way to get the property bag and not
> have the adapter at all?
>
> Thanks,
> -Aditya
Re: EMF model to Property bag [message #890725 is a reply to message #890379] Fri, 22 June 2012 19:10 Go to previous messageGo to next message
Aditya Wagle is currently offline Aditya Wagle
Messages: 7
Registered: November 2011
Junior Member
Here is an example of a sample model:

SampleHTTPActivity
-httpURL (type:HTTPURL)
-timeout(int)
-closeOnTimeout(boolean)

HTTPURL
-hostName(String)
-port(long)
-------------------------
Here's how it could possibly look like after conversion

SampleHTTPActivityProperties
-(httpURL, propertiesObject)
-(timeout, 10)
-(closeOnTimeout, true) (or 0/1)

propertieObject would be again a bag of properies

HTTPURLPropertiesObject
-(hostname,"localhost")
-(port, 8080)

The keys would always be the EAttributes for the model (as you can see above). The values would come from the UI.

Any reference should automatically again be converted to a reference properties object.

The consumer of the object would know the data type for each of the model elements. So that's not a worry.

Thanks,
-Aditya
Re: EMF model to Property bag [message #890860 is a reply to message #890725] Sat, 23 June 2012 04:42 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 25945
Registered: July 2009
Senior Member
Aditya,

Comments below.

On 23/06/2012 1:11 AM, Aditya Wagle wrote:
> Here is an example of a sample model:
>
> SampleHTTPActivity
> -httpURL (type:HTTPURL)
> -timeout(int)
> -closeOnTimeout(boolean)
>
> HTTPURL
> -hostName(String)
> -port(long)
> -------------------------
> Here's how it could possibly look like after conversion
>
> SampleHTTPActivityProperties
> -(httpURL, propertiesObject)
> -(timeout, 10)
> -(closeOnTimeout, true) (or 0/1)
>
> propertieObject would be again a bag of properies
What if the property is multi-valued? I guess it would be a list of bags...
>
> HTTPURLPropertiesObject
> -(hostname,"localhost")
> -(port, 8080)
>
> The keys would always be the EAttributes for the model (as you can see
> above). The values would come from the UI.
>
> Any reference should automatically again be converted to a reference
> properties object.
>
> The consumer of the object would know the data type for each of the
> model elements. So that's not a worry.
So it would be good to define a class that extends EObjectImpl or
MinimalEObjectImpl that implements your bag interface and use it as the
Root Extends Class for your model. Then any of your modeled objects can
be cast to a bag and used directly.
>
> Thanks,
> -Aditya
>
Previous Topic:Ecore code generation strategy using inheritance
Next Topic:[CDO] Problem with resource after transaction rollback
Goto Forum:
  


Current Time: Wed Jul 30 11:27:20 EDT 2014

Powered by FUDForum. Page generated in 0.07433 seconds