Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » Cross Document References persistence with Translator
Cross Document References persistence with Translator [message #506357] Thu, 07 January 2010 09:23 Go to next message
Nidhi  is currently offline Nidhi Friend
Messages: 92
Registered: December 2009
Member

Hi,

I am using Translators to persist my EMF model entities.
This works fine otherwise but for the case of Cross Document References. In this case, I was expecting a similar to how EMF Resource persists as href with the location of the referenced document.

However, instead of the location to the referenced document, the to string version of the referenced EMF entity is persisted.

Please suggest what is going wrong in my case.

Best Regards,
Nidhi

Re: Cross Document References persistence with Translator [message #506829 is a reply to message #506357] Sun, 10 January 2010 16:00 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 4435
Registered: July 2009
Senior Member

Nidhi wrote:
> I am using Translators to persist my EMF model entities.
> This works fine otherwise but for the case of Cross Document References.
> In this case, I was expecting a similar to how EMF Resource persists as
> href with the location of the referenced document.
>
> However, instead of the location to the referenced document, the to
> string version of the referenced EMF entity is persisted.
>
> Please suggest what is going wrong in my case.

You may have better luck in an EMF newsgroup.

--
Nitin Dahyabhai
Eclipse WTP Source Editing
IBM Rational


_
Nitin Dahyabhai
Eclipse Web Tools Platform
Re: Cross Document References persistence with Translator [message #506832 is a reply to message #506829] Sun, 10 January 2010 16:00 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Unfortunately I know nothing about how the translator does things...
One could produce a URI that references an object using
EcoreUtil.getURI(), but I don't know how one would specialize the
translator framework to produce that result.


Nitin Dahyabhai wrote:
> Nidhi wrote:
>> I am using Translators to persist my EMF model entities.
>> This works fine otherwise but for the case of Cross Document
>> References. In this case, I was expecting a similar to how EMF
>> Resource persists as href with the location of the referenced document.
>>
>> However, instead of the location to the referenced document, the to
>> string version of the referenced EMF entity is persisted.
>>
>> Please suggest what is going wrong in my case.
>
> You may have better luck in an EMF newsgroup.
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Cross Document References persistence with Translator [message #506905 is a reply to message #506832] Mon, 11 January 2010 05:15 Go to previous messageGo to next message
Nidhi  is currently offline Nidhi Friend
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 10: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 06:50 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
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
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Cross Document References persistence with Translator [message #506938 is a reply to message #506930] Mon, 11 January 2010 12:44 Go to previous messageGo to next message
Nidhi  is currently offline Nidhi Friend
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 15: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 15:46 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
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
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Cross Document References persistence with Translator [message #506993 is a reply to message #506981] Mon, 11 January 2010 11:11 Go to previous messageGo to next message
Nidhi  is currently offline Nidhi Friend
Messages: 92
Registered: December 2009
Member

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.

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...).

Thanks,
Nidhi
Re: Cross Document References persistence with Translator [message #507014 is a reply to message #506993] Mon, 11 January 2010 16:36 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
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


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:how to add the Refactor action to the extension tab of the properties view of the wsdl editor
Next Topic:Disable JSP Search
Goto Forum:
  


Current Time: Thu Apr 25 08:39:10 GMT 2024

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

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

Back to the top