Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Copying proxy objects
Copying proxy objects [message #663368] Mon, 04 April 2011 19:26 Go to next message
Vinny  is currently offline Vinny Friend
Messages: 20
Registered: July 2009
Junior Member
Assuming I have the following:

1. eObjA and eObjB are EObjects
2. eObjA has a containment reference to eObjB
3. eObjB is a proxy (eIsProxy() returns true)

If I do:

Copier myCopier = new Copier(true, true);
Collection<EObject> myCopiedCollection = myCopier.copyAll(eObjA);

I assumed that the copyAll() method, since instantiated with resolveProxies set, would resolve the proxy URI's and then copy the object pointed to by the proxy URI during the copyAll() operation. It doesn't seem to be working that way. My proxy URI's are still pointing to the original objects. I want the eObjB proxy object pointed to to be copied, and then the new reference URI to point to that new copied object.

[Updated on: Mon, 04 April 2011 19:31]

Report message to a moderator

Re: Copying proxy objects [message #663387 is a reply to message #663368] Mon, 04 April 2011 19:47 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30544
Registered: July 2009
Senior Member
Vinny,

Comments below.

Vinny wrote:
> Assuming I have the following:
>
> 1. eObjA and eObjB are EObjects
> 2. eObjA has a containment reference to eObjB
> 3. eObjB is a proxy (eIsProxy() returns true)
It's a proxy resolving containment reference?
>
> If I do:
>
> Copier myCopier = new Copier(true, true);
> Collection<EObject> myCopiedCollection = myCopier.copyAll(eObjA);
>
> I assumed that the copyAll() method, since instantiated with
> resolveProxies set, would resolve the proxy URI's and then copy the
> object pointed to by the proxy URI during the copyAll() operation.
It does walk all the containment references to copy the entire
containment tree.
> It doesn't seem to be working that way. My proxy URI's are still
> pointing to the original objects.
You're saying proxies aren't resolved? I imagine that's the case only
if the proxy can't be resolved. Is eObjA contained by a resource in a
resource set, i.e., is eObjA.eResource().getResourceSet() != null?
> I want the eObjB proxy object pointed to to be copied, and then the
> new reference URI to point to that new copied object.
I'm not sure I follow this comment about "reference URI" either.
Re: Copying proxy objects [message #663421 is a reply to message #663387] Tue, 05 April 2011 00:05 Go to previous messageGo to next message
Vinny  is currently offline Vinny Friend
Messages: 20
Registered: July 2009
Junior Member
I override copyProxyURI() in the Copier class:

protected void copyProxyURI(EObject eObject, EObject copyEObject) {
if (eObject.eIsProxy()) {
if (eObject.eResource().getResourceSet() != null) {
System.out.println("Looks like the resource set is good.");
} else {
System.out.println("Looks like the resource set is NULL!!!");
}
((InternalEObject) copyEObject)
.eSetProxyURI(((InternalEObject) eObject).eProxyURI());
}
}

On a copyAll(), I always see "Looks like the resource set is good" for my proxy objects.

Also, The last line in the method is what sets the eProxyURI of the copied object to that of the original object, which points the URI to the original path. This seems to be where the issue is, or at least an indication of me doing something incorrectly.
Re: Copying proxy objects [message #663425 is a reply to message #663421] Tue, 05 April 2011 00:53 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 30544
Registered: July 2009
Senior Member
Vinny,

If you call the getter on eObjA to fetch eObjB, does that resolve the
proxy or is eObjB.eIsProxy() true?


Vinny wrote:
> I override copyProxyURI() in the Copier class:
>
> protected void copyProxyURI(EObject eObject, EObject copyEObject) {
> if (eObject.eIsProxy()) {
> if (eObject.eResource().getResourceSet() != null) {
> System.out.println("Looks like the resource set is good.");
> } else {
> System.out.println("Looks like the resource set is NULL!!!");
> }
> ((InternalEObject) copyEObject)
> .eSetProxyURI(((InternalEObject) eObject).eProxyURI());
> }
> }
>
> On a copyAll(), I always see "Looks like the resource set is good" for
> my proxy objects.
> Also, The last line in the method is what sets the eProxyURI of the
> copied object to that of the original object, which points the URI to
> the original path. This seems to be where the issue is, or at least
> an indication of me doing something incorrectly.
Previous Topic:XMLResource.OPTION_SAVE_TYPE_INFORMATION has no effect when saved as xml
Next Topic:TreeViewer setInput error
Goto Forum:
  


Current Time: Tue Oct 15 17:17:59 GMT 2019

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

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

Back to the top