Skip to main content



      Home
Home » Modeling » EMF » Copying proxy objects
Copying proxy objects [message #663368] Mon, 04 April 2011 15:26 Go to next message
Eclipse UserFriend
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 15:31] by Moderator

Re: Copying proxy objects [message #663387 is a reply to message #663368] Mon, 04 April 2011 15:47 Go to previous messageGo to next message
Eclipse UserFriend
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] Mon, 04 April 2011 20:05 Go to previous messageGo to next message
Eclipse UserFriend
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] Mon, 04 April 2011 20:53 Go to previous message
Eclipse UserFriend
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: Wed Jul 23 16:30:12 EDT 2025

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

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

Back to the top