Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util')
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CDOViewSetPackageRegistryImpl.java83
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java60
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/RevisionAdjuster.java9
3 files changed, 150 insertions, 2 deletions
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CDOViewSetPackageRegistryImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CDOViewSetPackageRegistryImpl.java
new file mode 100644
index 0000000000..cc9042384a
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CDOViewSetPackageRegistryImpl.java
@@ -0,0 +1,83 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ **************************************************************************/
+package org.eclipse.emf.internal.cdo.util;
+
+import org.eclipse.emf.cdo.CDOView;
+import org.eclipse.emf.cdo.CDOViewSet;
+
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.impl.EPackageRegistryImpl;
+
+/**
+ * @author Simon McDuff
+ */
+public class CDOViewSetPackageRegistryImpl extends EPackageRegistryImpl
+{
+ private static final long serialVersionUID = 1L;
+
+ private CDOViewSet viewSet;
+
+ public CDOViewSetPackageRegistryImpl(CDOViewSet viewSet)
+ {
+ this.viewSet = viewSet;
+ }
+
+ @Override
+ public synchronized EPackage getEPackage(String nsURI)
+ {
+ EPackage ePackage = super.getEPackage(nsURI);
+ if (ePackage == null)
+ {
+ for (CDOView view : viewSet.getViews())
+ {
+ ePackage = view.getSession().getPackageRegistry().getEPackage(nsURI);
+ if (ePackage != null)
+ {
+ break;
+ }
+ }
+ }
+
+ return ePackage;
+ }
+
+ @Override
+ public Object put(String key, Object value)
+ {
+ super.put(key, value);
+
+ for (CDOView view : viewSet.getViews())
+ {
+ view.getSession().getPackageRegistry().put(key, value);
+ }
+
+ return null;
+ }
+
+ @Override
+ synchronized public Object get(Object key)
+ {
+ Object ePackage = super.get(key);
+ if (ePackage == null)
+ {
+ for (CDOView view : viewSet.getViews())
+ {
+ ePackage = view.getSession().getPackageRegistry().get(key);
+ if (ePackage != null)
+ {
+ return ePackage;
+ }
+ }
+ }
+
+ return ePackage;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java
index 91a6778b62..b55a0a6215 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java
@@ -7,6 +7,7 @@
*
* Contributors:
* Eike Stepper - initial API and implementation
+ * Simon McDuff - http://bugs.eclipse.org/246705
**************************************************************************/
package org.eclipse.emf.internal.cdo.util;
@@ -28,7 +29,9 @@ import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EGenericType;
import org.eclipse.emf.ecore.EModelElement;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.InternalEObject;
+import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.util.EcoreUtil;
import java.lang.reflect.Method;
@@ -92,6 +95,12 @@ public final class FSMUtil
return state == CDOState.TRANSIENT || state == CDOState.PREPARED;
}
+ public static boolean isNew(CDOObject object)
+ {
+ CDOState state = object.cdoState();
+ return state == CDOState.NEW;
+ }
+
/**
* @param view
* Only needed if object is a meta instance.
@@ -157,9 +166,51 @@ public final class FSMUtil
return null;
}
- public static Iterator<InternalCDOObject> iterator(Collection<?> instances, final CDOViewImpl view)
+ /**
+ * Similar to {@link EcoreUtil#getAllProperContents(Resource, boolean)} except gives only one depth
+ */
+ public static Iterator<InternalCDOObject> getProperContents(final InternalCDOObject object)
+ {
+ final boolean isResource = object instanceof Resource;
+ final CDOView cdoView = object.cdoView();
+ final Iterator<EObject> delegate = object.eContents().iterator();
+
+ return new Iterator<InternalCDOObject>()
+ {
+ private Object next;
+
+ public boolean hasNext()
+ {
+ while (delegate.hasNext())
+ {
+ InternalEObject eObject = (InternalEObject)delegate.next();
+
+ if (isResource || eObject.eDirectResource() == null)
+ {
+ next = adapt(eObject, cdoView);
+ if (next instanceof InternalCDOObject)
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ public InternalCDOObject next()
+ {
+ return (InternalCDOObject)next;
+ }
+
+ public void remove()
+ {
+ throw new UnsupportedOperationException();
+ }
+ };
+ }
+
+ public static Iterator<InternalCDOObject> iterator(final Iterator<?> delegate, final CDOViewImpl view)
{
- final Iterator<?> delegate = instances.iterator();
return new Iterator<InternalCDOObject>()
{
private Object next;
@@ -189,4 +240,9 @@ public final class FSMUtil
}
};
}
+
+ public static Iterator<InternalCDOObject> iterator(Collection<?> instances, final CDOViewImpl view)
+ {
+ return iterator(instances.iterator(), view);
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/RevisionAdjuster.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/RevisionAdjuster.java
index 48eb6b7b7c..705c343130 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/RevisionAdjuster.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/RevisionAdjuster.java
@@ -7,6 +7,7 @@
*
* Contributors:
* Simon McDuff - initial API and implementation
+ * Simon McDuff - http://bugs.eclipse.org/246705
**************************************************************************/
package org.eclipse.emf.internal.cdo.util;
@@ -15,6 +16,7 @@ import org.eclipse.emf.cdo.common.id.CDOIDProvider;
import org.eclipse.emf.cdo.common.model.CDOFeature;
import org.eclipse.emf.cdo.common.revision.CDOReferenceProxy;
import org.eclipse.emf.cdo.common.revision.delta.CDOAddFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDOContainerFeatureDelta;
import org.eclipse.emf.cdo.common.revision.delta.CDOListFeatureDelta;
import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
import org.eclipse.emf.cdo.common.revision.delta.CDOSetFeatureDelta;
@@ -45,6 +47,13 @@ public class RevisionAdjuster extends CDOFeatureDeltaVisitorImpl
}
@Override
+ public void visit(CDOContainerFeatureDelta delta)
+ {
+ // Delta value must have been adjusted before!
+ revision.setContainerID(idProvider.provideCDOID(revision.getContainerID()));
+ }
+
+ @Override
public void visit(CDOAddFeatureDelta delta)
{
// Delta value must have been adjusted before!

Back to the top