|EMF model to Property bag [message #890322]
||Thu, 21 June 2012 23:14
| Aditya Wagle
Registered: November 2011
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?
|Re: EMF model to Property bag [message #890860 is a reply to message #890725]
||Sat, 23 June 2012 08:42
| Ed Merks
Registered: July 2009
On 23/06/2012 1:11 AM, Aditya Wagle wrote:
> Here is an example of a sample model:
> -httpURL (type:HTTPURL)
> Here's how it could possibly look like after conversion
> -(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...
> -(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.
Powered by FUDForum
. Page generated in 0.02111 seconds