Home » Eclipse Projects » Web Tools Project (WTP) » Cross Document References persistence with Translator
| | |
| Re: Cross Document References persistence with Translator [message #506905 is a reply to message #506832] |
Mon, 11 January 2010 00:15   |
Nidhi Messages: 92 Registered: December 2009 |
Member |

|
|
Hi,
I am not sure what is the way to go now :(
With the Translator framework, this is persistence I get for cross document references:
<myClass>
<dependency> mylib.library.impl.DependencyImpl@14799af (library: null, name: mydep, author: null, documentation: nulll)</dependency>
</myClass>
instead of:
<myClass>
<dependency>mydep.dependency</dependency>
</myClass>
If I go with pure EMF, I achieve the desired persistence, but with two issues:
1.https://bugs.eclipse.org/bugs/show_bug.cgi?id=298678 which is not that big an issue as I get around with it.
2. EMF <-> SSE synchronization (for which there does not seem any other elegant way rather than using EMF2DOMSSEAdapter which is a part and parcel of the Translator framework).
Any small lead would really help me proceed, am pretty badly stuck here.
Thanks a lot,
Nidhi
[Updated on: Mon, 11 January 2010 05:33] Report message to a moderator
|
|
|
| Re: Cross Document References persistence with Translator [message #506930 is a reply to message #506905] |
Mon, 11 January 2010 01:50   |
Ed Merks Messages: 24688 Registered: July 2009 |
Senior Member |
|
|
Nidhi,
You'll need to specialize the code that's calling toString on the
Dependency instance. Instead of calling toString, it looks like you'll
need to fetch the ID; EcoreUtil.getID should do the trick. In the other
direction you'd need to use Resource.getEObject to resolve the ID to the
correct Dependency instance. I'm not sure how 298678, a validation
issue with unreported problems in a broken instance, causes problems...
Nidhi wrote:
> Hi Ed,
>
> I am not sure what is the way to go now :(
>
> With the Translator framework, this is persistence I get for cross
> document references:
>
> <myClass>
> <dependency> mailto:mylib.library.impl.DependencyImpl@14799af
> (library: null, name: mydep, author: null, documentation:
> nulll)</dependency>
> </myClass>
>
> instead of:
> <myClass>
> <dependency>mydep.dependency</dependency>
> </myClass>
>
> If I go with pure EMF, I achieve the desired persistence, but with two
> issues:
> 1.https://bugs.eclipse.org/bugs/show_bug.cgi?id=298678 which is not
> that big an issue as I get around with it.
> 2. EMF <-> SSE synchronization (for which there does not seem any
> other elegant way rather than using EMF2DOMSSEAdapter which is a part
> and parcel of the Translator framework).
>
> Any small lead would really help me proceed, am pretty badly stuck here.
>
> Thanks a lot,
> Nidhi
>
|
|
|
| Re: Cross Document References persistence with Translator [message #506938 is a reply to message #506930] |
Mon, 11 January 2010 07:44   |
Nidhi Messages: 92 Registered: December 2009 |
Member |

|
|
Many Many thanks Ed,
sorry that was a typo, it is not 298678, it's 201662 (https://bugs.eclipse.org/bugs/show_bug.cgi?id=201662).
>> Instead of calling toString, it looks like you'll
need to fetch the ID; EcoreUtil.getID should do the trick
This would definitely give the desired persistence. For this I'll have to change the toString() of the generated EMF entity, which is decent enough.
>> the other direction you'd need to use Resource.getEObject to resolve the ID to the
correct Dependency instance.
But, for this I guess I'll have change the TranslatorResource logic of load, where it tries to get an Object out of the persisted value : Translator -> convertStringToValue
Is my understanding right? And the worst part is that I wont be able to use the lazy loading (proxies) feature of EMF if I go with Translators.
Is there no way that I can use "pure EMF" for loading and persistence and use these translators only and only for synchronization.
OR
Is there no way I can achieve synchronization in "Pure EMF" (may be using DOMHandlers,...).
Best Regards,
Nidhi
[Updated on: Mon, 11 January 2010 10:12] Report message to a moderator
|
|
|
| Re: Cross Document References persistence with Translator [message #506981 is a reply to message #506938] |
Mon, 11 January 2010 10:46   |
Ed Merks Messages: 24688 Registered: July 2009 |
Senior Member |
|
|
Nidhi,
I guess modifying toString is one way, but I can't imagine that being
the proper/only way. Isn't there a convertValueToString method that's
better? And yes, you'll have to modifying the loading somehow.
Nidhi wrote:
> Many Many thanks Ed,
>
> sorry that was a typo, it is not 298678, it's 201662
> (https://bugs.eclipse.org/bugs/show_bug.cgi?id=201662).
>
>>> Instead of calling toString, it looks like you'll
> need to fetch the ID; EcoreUtil.getID should do the trick
>
> This would definitely give the desired persistence. For this I'll have
> to change the toString() of the generated EMF entity, which is decent
> enough.
>
>>> the other direction you'd need to use Resource.getEObject to
>>> resolve the ID to the
> correct Dependency instance.
>
> But, for this I guess I'll have change the TranslatorResource logic of
> load, where it tries to get an Object out of the persisted value :
> Translator -> convertStringToValue
>
> Is my understanding right?
>
> Best Regards,
> Nidhi
>
>
|
|
| |
| Re: Cross Document References persistence with Translator [message #507014 is a reply to message #506993] |
Mon, 11 January 2010 11:36  |
Ed Merks Messages: 24688 Registered: July 2009 |
Senior Member |
|
|
Nidhi,
Comments below.
Nidhi wrote:
> Hi Ed,
>
> That's right, TranslatorResourse does have convertValueToString that
> helps.
> But the bad part of it is that I wont be able to use the lazy loading
> (proxies) feature of EMF if I go with Translators.
You were showing an ID, rather than a cross document reference so I
assumed you has a non-proxy resolving reference.
>
> Is there no way that I can use "pure EMF" for loading and persistence
> and use these translators only and only for synchronization.
Synchronization needs to handle all possible changes, which I imagine
would include changing the reference in the model, or changing the value
used to denote the reference in the source.
>
> OR
>
> Is there no way I can achieve synchronization in "Pure EMF" (may be
> using DOMHandlers...).
If you want to support cross document references, you'd just need to
serialize a URI, much like produced by EcoreUtil.getURI. Be sure to
deresolve such URIs to make them relative. It's also easy to make use
of proxies. Just create a normal Dependency instance, cast it to
InternalEObject, and use eSetProxyURI to make it an unresolve proxy; be
sure the resolve the URI to make it absolute.
>
> Thanks,
> Nidhi
|
|
|
Goto Forum:
Current Time: Tue Jun 18 01:46:05 EDT 2013
Powered by FUDForum. Page generated in 0.02258 seconds
|