XMI Serialization - Multiple Ecore Models with cross-references [message #632141] |
Mon, 11 October 2010 17:47 |
Nelson Ramos Messages: 3 Registered: October 2010 |
Junior Member |
|
|
Hi,
I'm facing a problem regarding xmi serialization of two ecore models together.
Problem Context:
I'm developing an application with MVC pattern. The data model is being modeled with Ecore.
The M (model) and C (controller) are shared by two view technology (GMF and GWT). So, we decided to have an aditional ecore model for GUI where graphical information are being stored (like x,y coordinates, etc).
So, we have two models: DATAModel and GUIModel.
The GUIModel objects implements the Adapter interface and are being registered in the eAdapters list of the DATAModel eObjects.
Problem
1st try: Create a resource for DATAModel and hope for automatically adapters serialization (from GUIModel) ---> don't work....the adapters are not serializable (maybe the containment is false by default)
2nd try: Create a list with containment=true in the rootContainer of DATAModel for all adapters. The result was :
<allAdapters>com.nsn.on.xxxxx.nse.model.impl.NseExternalDirectionImpl@120a8f3</allAdapters>
<allAdapters>com.nsn.on.xxxxx.nse.model.impl.NseCardImpl@133fa82 (userLabel: null)</allAdapters>
so, It returns an error during desserialization (because the stored adapter is just a reference for a Java Object).
3rd try: I'm trying to use the resourceSet and put here the two models DATAModel and GUIModel. However I'm not seeing how the references between the two models will be kept.
Is it the correct approach? If so, can you post some example code that deal with this requirements? If not, do you know other approaches?
Thanks in advance,
Nelson
|
|
|
Re: XMI Serialization - Multiple Ecore Models with cross-references [message #632153 is a reply to message #632141] |
Mon, 11 October 2010 18:42 |
Ed Merks Messages: 33133 Registered: July 2009 |
Senior Member |
|
|
Nelson,
Comments below.
Nelson Ramos wrote:
> Hi,
>
>
> I'm facing a problem regarding xmi serialization of two ecore models
> together.
>
> Problem Context:
>
> I'm developing an application with MVC pattern. The data model is
> being modeled with Ecore.
>
> The M (model) and C (controller) are shared by two view technology
> (GMF and GWT). So, we decided to have an aditional ecore model for GUI
> where graphical information are being stored (like x,y coordinates, etc).
>
> So, we have two models: DATAModel and GUIModel.
> The GUIModel objects implements the Adapter interface and are being
> registered in the eAdapters list of the DATAModel eObjects.
>
> Problem
>
> 1st try: Create a resource for DATAModel and hope for automatically
> adapters serialization (from GUIModel) ---> don't work....the adapters
> are not serializable (maybe the containment is false by default)
You should not expect the data model to serialize its eAdapters. That's
not a modeled feature and in fact isn't even part of the data model;
it's for viewing the data model.
>
> 2nd try: Create a list with containment=true in the rootContainer of
> DATAModel for all adapters. The result was :
>
>
>
> <allAdapters>com.nsn.on.xxxxx.nse.model.impl.NseExternalDirectionImpl@120a8f3</allAdapters>
>
> <allAdapters>com.nsn.on.xxxxx.nse.model.impl.NseCardImpl@133fa82
> (userLabel: null)</allAdapters>
It doesn't look like you're actually serializing EObjects here. You'll
need this to be an EReference.
>
>
>
> so, It returns an error during desserialization (because the stored
> adapter is just a reference for a Java Object).
Yes, it sounds like you have modeled this as an EAttribute rather than
an EReference.
>
>
> 3rd try: I'm trying to use the resourceSet and put here the two models
> DATAModel and GUIModel. However I'm not seeing how the references
> between the two models will be kept.
If you model things as EReference, they should definitely be kept.
>
> Is it the correct approach? If so, can you post some example code that
> deal with this requirements? If not, do you know other approaches?
>
>
> Thanks in advance,
> Nelson
>
>
>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.04010 seconds