Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon McDuff2008-11-09 16:00:54 -0500
committerSimon McDuff2008-11-09 16:00:54 -0500
commita2bbfece55533fa3ea41698b60923d72d9fed4f6 (patch)
treead31e90788dced9fe636b0b37780a0732f60bb92 /plugins/org.eclipse.emf.cdo/src
parent5565dc604f87abcdda90faab90d40077c6d1feb9 (diff)
downloadcdo-a2bbfece55533fa3ea41698b60923d72d9fed4f6.tar.gz
cdo-a2bbfece55533fa3ea41698b60923d72d9fed4f6.tar.xz
cdo-a2bbfece55533fa3ea41698b60923d72d9fed4f6.zip
[249436] Support FeatureMap
https://bugs.eclipse.org/bugs/show_bug.cgi?id=249436
Diffstat (limited to 'plugins/org.eclipse.emf.cdo/src')
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java30
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectWrapper.java2
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStore.java130
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ModelUtil.java1
4 files changed, 89 insertions, 74 deletions
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 61b7e3a735..5ac55f845b 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
@@ -17,7 +17,6 @@ import org.eclipse.emf.cdo.CDOView;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.model.CDOClass;
import org.eclipse.emf.cdo.common.model.CDOFeature;
-import org.eclipse.emf.cdo.common.model.CDOType;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl;
@@ -26,7 +25,6 @@ import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.emf.internal.cdo.bundle.OM;
import org.eclipse.emf.internal.cdo.util.FSMUtil;
-import org.eclipse.emf.internal.cdo.util.GenUtil;
import org.eclipse.emf.internal.cdo.util.ModelUtil;
import org.eclipse.net4j.util.ImplementationError;
@@ -44,7 +42,6 @@ import org.eclipse.emf.common.util.ECollections;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EDataType;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EStructuralFeature;
@@ -57,7 +54,6 @@ import org.eclipse.emf.ecore.resource.Resource.Internal;
import org.eclipse.emf.ecore.util.DelegatingFeatureMap;
import org.eclipse.emf.ecore.util.EcoreEList;
import org.eclipse.emf.ecore.util.EcoreEMap;
-import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.util.FeatureMap;
import org.eclipse.emf.ecore.util.InternalEList;
@@ -349,6 +345,7 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
setting = eFeature.getDefaultValue();
}
+ CDOStore cdoStore = cdoStore();
if (cdoFeature.isMany())
{
if (setting != null)
@@ -357,33 +354,14 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
EList<Object> list = (EList<Object>)setting;
for (Object value : list)
{
- if (cdoFeature.isReference())
- {
- value = view.convertObjectToID(value, true);
- }
-
+ value = cdoStore.convertToCDO(cdoView(), eFeature, cdoFeature, value);
revision.add(cdoFeature, index++, value);
}
}
}
else
{
- if (cdoFeature.isReference())
- {
- setting = view.convertObjectToID(setting, true);
- }
- else
- {
- if (cdoFeature.getType() == CDOType.CUSTOM)
- {
- setting = EcoreUtil.convertToString((EDataType)eFeature.getEType(), setting);
- }
- else if (setting == null && GenUtil.isPrimitiveType(eFeature.getEType()))
- {
- setting = eFeature.getDefaultValue();
- }
- }
-
+ setting = cdoStore.convertToCDO(cdoView(), eFeature, cdoFeature, setting);
revision.set(cdoFeature, 0, setting);
}
}
@@ -400,7 +378,7 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
}
CDOViewImpl view = cdoView();
- super.eSetDirectResource(cdoDirectResource());
+ super.eSetDirectResource((Resource.Internal)cdoStore().getResource(this));
CDOStore store = cdoStore();
eContainer = store.getContainer(this);
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectWrapper.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectWrapper.java
index 699451eac6..54b83f104a 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectWrapper.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectWrapper.java
@@ -10,8 +10,8 @@
**************************************************************************/
package org.eclipse.emf.internal.cdo;
-import org.eclipse.emf.cdo.CDOView;
import org.eclipse.emf.cdo.CDOLock;
+import org.eclipse.emf.cdo.CDOView;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl;
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStore.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStore.java
index 39d5dc2038..6265cb61b6 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStore.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStore.java
@@ -15,12 +15,15 @@
package org.eclipse.emf.internal.cdo;
import org.eclipse.emf.cdo.CDORevisionPrefetchingPolicy;
+import org.eclipse.emf.cdo.CDOView;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.model.CDOFeature;
import org.eclipse.emf.cdo.common.model.CDOType;
import org.eclipse.emf.cdo.common.revision.CDOList;
+import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.internal.common.model.core.CDOFeatureMapEntryDataTypeImpl;
import org.eclipse.emf.cdo.internal.common.revision.delta.CDOAddFeatureDeltaImpl;
import org.eclipse.emf.cdo.internal.common.revision.delta.CDOClearFeatureDeltaImpl;
import org.eclipse.emf.cdo.internal.common.revision.delta.CDOContainerFeatureDeltaImpl;
@@ -37,6 +40,7 @@ import org.eclipse.emf.internal.cdo.util.GenUtil;
import org.eclipse.net4j.util.om.trace.ContextTracer;
+import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EDataType;
import org.eclipse.emf.ecore.EObject;
@@ -44,6 +48,8 @@ import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.InternalEObject.EStore;
import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.ecore.util.FeatureMap;
+import org.eclipse.emf.ecore.util.FeatureMapUtil;
import java.text.MessageFormat;
import java.util.Collection;
@@ -160,29 +166,7 @@ public final class CDOStore implements EStore
view.getFeatureAnalyzer().preTraverseFeature(cdoObject, cdoFeature, index);
InternalCDORevision revision = getRevisionForReading(cdoObject);
Object value = revision.get(cdoFeature, index);
- if (cdoFeature.isReference())
- {
- value = resolveProxy(revision, cdoFeature, index, value);
- if (cdoFeature.isMany() && value instanceof CDOID)
- {
- CDOID id = (CDOID)value;
- CDOList list = revision.getList(cdoFeature);
- CDORevisionManagerImpl revisionManager = view.getSession().getRevisionManager();
- CDORevisionPrefetchingPolicy policy = view.getRevisionPrefetchingPolicy();
-
- Collection<CDOID> listOfIDs = policy.loadAhead(revisionManager, eObject, eFeature, list, index, id);
- if (!listOfIDs.isEmpty())
- {
- revisionManager.getRevisions(listOfIDs, view.getSession().getCollectionLoadingPolicy().getInitialChunkSize());
- }
- }
-
- value = view.convertIDToObject(value);
- }
- else if (cdoFeature.getType() == CDOType.CUSTOM)
- {
- value = EcoreUtil.createFromString((EDataType)eFeature.getEType(), (String)value);
- }
+ value = convertToEMF(view, eObject, revision, eFeature, cdoFeature, index, value);
view.getFeatureAnalyzer().postTraverseFeature(cdoObject, cdoFeature, index, value);
return value;
@@ -346,14 +330,7 @@ public final class CDOStore implements EStore
TRACER.format("set({0}, {1}, {2}, {3})", cdoObject, cdoFeature, index, value);
}
- if (cdoFeature.getType() == CDOType.CUSTOM)
- {
- value = EcoreUtil.convertToString((EDataType)eFeature.getEType(), value);
- }
- else if (value == null && GenUtil.isPrimitiveType(eFeature.getEType()))
- {
- value = eFeature.getDefaultValue();
- }
+ value = convertToCDO(getView(), eFeature, cdoFeature, value);
CDOFeatureDelta delta = new CDOSetFeatureDeltaImpl(cdoFeature, index, value);
InternalCDORevision revision = getRevisionForWriting(cdoObject, delta);
@@ -365,12 +342,81 @@ public final class CDOStore implements EStore
}
Object oldValue = revision.set(cdoFeature, index, value);
+ oldValue = convertToEMF(cdoObject.cdoView(), eObject, revision, eFeature, cdoFeature, index, oldValue);
+
+ return oldValue;
+ }
+
+ /**
+ * @since 2.0
+ */
+ public Object convertToEMF(CDOView view, EObject eObject, InternalCDORevision revision, EStructuralFeature eFeature,
+ CDOFeature cdoFeature, int index, Object value)
+ {
if (cdoFeature.isReference())
{
- oldValue = ((CDOViewImpl)cdoObject.cdoView()).convertIDToObject(oldValue);
+ if (cdoFeature.isMany() && EStore.NO_INDEX != index)
+ {
+ value = resolveProxy(revision, cdoFeature, index, value);
+ if (cdoFeature.isMany() && value instanceof CDOID)
+ {
+ CDOID id = (CDOID)value;
+ CDOList list = revision.getList(cdoFeature);
+ CDORevisionManagerImpl revisionManager = ((CDOViewImpl)view).getSession().getRevisionManager();
+ CDORevisionPrefetchingPolicy policy = view.getRevisionPrefetchingPolicy();
+
+ Collection<CDOID> listOfIDs = policy.loadAhead(revisionManager, eObject, eFeature, list, index, id);
+ if (!listOfIDs.isEmpty())
+ {
+ revisionManager.getRevisions(listOfIDs, view.getSession().getCollectionLoadingPolicy()
+ .getInitialChunkSize());
+ }
+ }
+ }
+
+ value = ((CDOViewImpl)view).convertIDToObject(value);
+ }
+ else if (cdoFeature.getType() == CDOType.CUSTOM)
+ {
+ value = EcoreUtil.createFromString((EDataType)eFeature.getEType(), (String)value);
+ }
+ else if (cdoFeature.getType() == CDOType.FEATURE_MAP_ENTRY)
+ {
+ CDOFeatureMapEntryDataTypeImpl entry = (CDOFeatureMapEntryDataTypeImpl)value;
+ EStructuralFeature feature = (EStructuralFeature)view.getResourceSet().getEObject(URI.createURI(entry.getURI()),
+ true);
+ Object object = ((CDOViewImpl)view).convertIDToObject(entry.getObject());
+ value = FeatureMapUtil.createEntry(feature, object);
}
- return oldValue;
+ return value;
+ }
+
+ /**
+ * @since 2.0
+ */
+ public Object convertToCDO(CDOView view, EStructuralFeature eFeature, CDOFeature cdoFeature, Object value)
+ {
+ if (cdoFeature.isReference())
+ {
+ value = ((CDOViewImpl)view).convertObjectToID(value, true);
+ }
+ else if (cdoFeature.getType() == CDOType.FEATURE_MAP_ENTRY)
+ {
+ FeatureMap.Entry entry = (FeatureMap.Entry)value;
+ String uri = EcoreUtil.getURI(entry.getEStructuralFeature()).toString();
+ value = CDORevisionUtil.createFeatureMapEntry(uri, entry.getValue());
+ }
+ else if (cdoFeature.getType() == CDOType.CUSTOM)
+ {
+ value = EcoreUtil.convertToString((EDataType)eFeature.getEType(), value);
+ }
+ else if (value == null && GenUtil.isPrimitiveType(eFeature.getEType()))
+ {
+ value = eFeature.getDefaultValue();
+ }
+
+ return value;
}
public void unset(InternalEObject eObject, EStructuralFeature eFeature)
@@ -397,10 +443,7 @@ public final class CDOStore implements EStore
TRACER.format("add({0}, {1}, {2}, {3})", cdoObject, cdoFeature, index, value);
}
- if (cdoFeature.isReference())
- {
- value = ((CDOViewImpl)cdoObject.cdoView()).convertObjectToID(value, true);
- }
+ value = convertToCDO(cdoObject.cdoView(), eFeature, cdoFeature, value);
CDOFeatureDelta delta = new CDOAddFeatureDeltaImpl(cdoFeature, index, value);
InternalCDORevision revision = getRevisionForWriting(cdoObject, delta);
@@ -419,11 +462,8 @@ public final class CDOStore implements EStore
CDOFeatureDelta delta = new CDORemoveFeatureDeltaImpl(cdoFeature, index);
InternalCDORevision revision = getRevisionForWriting(cdoObject, delta);
Object result = revision.remove(cdoFeature, index);
- if (cdoFeature.isReference())
- {
- result = resolveProxy(revision, cdoFeature, index, result);
- result = ((CDOViewImpl)cdoObject.cdoView()).convertIDToObject(result);
- }
+
+ result = convertToEMF(cdoObject.cdoView(), eObject, revision, eFeature, cdoFeature, index, result);
return result;
}
@@ -455,12 +495,8 @@ public final class CDOStore implements EStore
CDOFeatureDelta delta = new CDOMoveFeatureDeltaImpl(cdoFeature, target, source);
InternalCDORevision revision = getRevisionForWriting(cdoObject, delta);
Object result = revision.move(cdoFeature, target, source);
- if (cdoFeature.isReference())
- {
- result = resolveProxy(revision, cdoFeature, target, result);
- result = ((CDOViewImpl)cdoObject.cdoView()).convertIDToObject(result);
- }
+ result = convertToEMF(cdoObject.cdoView(), eObject, revision, eFeature, cdoFeature, EStore.NO_INDEX, result);
return result;
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ModelUtil.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ModelUtil.java
index 28717c37c8..9eb4715f2c 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ModelUtil.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ModelUtil.java
@@ -106,6 +106,7 @@ public final class ModelUtil
case EcorePackage.ELONG_OBJECT:
case EcorePackage.ESHORT:
case EcorePackage.ESHORT_OBJECT:
+ case EcorePackage.EFEATURE_MAP_ENTRY:
CDOType type = CDOModelUtil.getType(classifierID);
if (type == CDOType.OBJECT)
{

Back to the top