summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-07-24 10:29:27 (EDT)
committerEike Stepper2007-07-24 10:29:27 (EDT)
commitf16da00a6d3a018358e72227702d79c201b036f9 (patch)
tree9b8b3fa089809016df693088590d00f2604fc45e
parentfd61b3b8c6074263087f94d806bad6b7320660a8 (diff)
downloadcdo-f16da00a6d3a018358e72227702d79c201b036f9.zip
cdo-f16da00a6d3a018358e72227702d79c201b036f9.tar.gz
cdo-f16da00a6d3a018358e72227702d79c201b036f9.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java76
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java12
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java5
3 files changed, 88 insertions, 5 deletions
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java
index 01c4509..cdd63e8 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java
@@ -27,13 +27,17 @@ import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EcoreFactory;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.Resource.Factory.Registry;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.ecore.util.EcoreUtil.Copier;
import org.eclipse.emf.internal.cdo.CDOSessionImpl;
+import java.util.List;
import java.util.Map;
/**
@@ -184,4 +188,76 @@ public final class CDOUtil
eClass.getEStructuralFeatures().add(eReference);
return eReference;
}
+
+ /**
+ * Returns a self-contained copy of the eObject with all proxies resolved.
+ *
+ * @param eObject
+ * the object to copy.
+ * @return the copy.
+ * @see EcoreUtil#copy(EObject)
+ */
+ public static EObject copy(EObject eObject, CDOView view)
+ {
+ Copier copier = new CDOCopier(view);
+ EObject result = copier.copy(eObject);
+ copier.copyReferences();
+ return result;
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public static final class CDOCopier extends Copier
+ {
+ private static final long serialVersionUID = 1L;
+
+ private CDOView view;
+
+ public CDOCopier(CDOView view)
+ {
+ this.view = view;
+ }
+
+ @Override
+ protected void copyReference(EReference eReference, EObject eObject, EObject copyEObject)
+ {
+ resolve(eReference, eObject);
+ super.copyReference(eReference, eObject, copyEObject);
+ }
+
+ @Override
+ protected void copyContainment(EReference eReference, EObject eObject, EObject copyEObject)
+ {
+ resolve(eReference, eObject);
+ super.copyContainment(eReference, eObject, copyEObject);
+ }
+
+ protected void resolve(EReference eReference, EObject eObject)
+ {
+ if (eObject.eIsSet(eReference))
+ {
+ if (eReference.isMany())
+ {
+ @SuppressWarnings("unchecked")
+ List<EObject> list = (List<EObject>)eObject.eGet(eReference);
+ for (EObject element : list)
+ {
+ if (element.eIsProxy())
+ {
+ EcoreUtil.resolve(element, view.getResourceSet());
+ }
+ }
+ }
+ else
+ {
+ EObject childEObject = (EObject)eObject.eGet(eReference);
+ if (childEObject.eIsProxy())
+ {
+ EcoreUtil.resolve(childEObject, view.getResourceSet());
+ }
+ }
+ }
+ }
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java
index 0b3c55b..f0d20e5 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java
@@ -506,6 +506,12 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
}
@Override
+ protected boolean hasProxies()
+ {
+ return true;
+ }
+
+ @Override
protected List<E> delegateList()
{
throw new UnsupportedOperationException();
@@ -717,6 +723,12 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
}
@Override
+ protected boolean hasProxies()
+ {
+ return true;
+ }
+
+ @Override
protected List<FeatureMap.Entry> delegateList()
{
throw new UnsupportedOperationException();
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java
index 48cea1a..7b0ad62 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java
@@ -291,11 +291,6 @@ public class CDOSessionImpl extends Lifecycle implements CDOSession
--nextTemporaryID;
--nextTemporaryID;
- // for (EReference reference : metaInstance.eClass().getEAllReferences())
- // {
- // metaInstance.eGet(reference);
- // }
-
for (EObject content : metaInstance.eContents())
{
registerMetaInstance((InternalEObject)content);