Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2009-11-05 14:17:32 -0500
committerEike Stepper2009-11-05 14:17:32 -0500
commit700e13e0ff460d906fae92d4e2ea64c960767719 (patch)
tree29cd214bfdf349feda5f5771dd7e761114f2a46d /plugins/org.eclipse.emf.cdo/src/org
parent39722b8c3978c68490e619df26539320ea2a832d (diff)
downloadcdo-700e13e0ff460d906fae92d4e2ea64c960767719.tar.gz
cdo-700e13e0ff460d906fae92d4e2ea64c960767719.tar.xz
cdo-700e13e0ff460d906fae92d4e2ea64c960767719.zip
[290990] Provide a persistent=true annotation
https://bugs.eclipse.org/bugs/show_bug.cgi?id=290990
Diffstat (limited to 'plugins/org.eclipse.emf.cdo/src/org')
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java69
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java3
2 files changed, 50 insertions, 22 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 43b1ad4644..eacc3f2b24 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
@@ -14,6 +14,7 @@ package org.eclipse.emf.internal.cdo;
import org.eclipse.emf.cdo.CDOLock;
import org.eclipse.emf.cdo.CDOState;
import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.model.EMFUtil;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl;
@@ -53,6 +54,7 @@ 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.FeatureMap;
+import org.eclipse.emf.ecore.util.FeatureMapUtil;
import org.eclipse.emf.ecore.util.InternalEList;
import org.eclipse.emf.spi.cdo.InternalCDOLoadable;
import org.eclipse.emf.spi.cdo.InternalCDOObject;
@@ -289,7 +291,7 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
EStructuralFeature eFeature = cdoInternalDynamicFeature(i);
// We need to keep the existing list if possible.
- if (!eFeature.isTransient() && eSettings[i] instanceof InternalCDOLoadable)
+ if (EMFUtil.isPersistent(eFeature) && eSettings[i] instanceof InternalCDOLoadable)
{
((InternalCDOLoadable)eSettings[i]).cdoInternalPostLoad();
}
@@ -327,7 +329,7 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
for (int i = 0; i < eClass.getFeatureCount(); i++)
{
EStructuralFeature eFeature = cdoInternalDynamicFeature(i);
- if (!eFeature.isTransient())
+ if (EMFUtil.isPersistent(eFeature))
{
Object setting = cdoBasicSettings() != null ? cdoSettings()[i] : null;
instanceToRevisionFeature(view, this, eFeature, setting);
@@ -373,7 +375,7 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
for (int i = 0; i < eClass.getFeatureCount(); i++)
{
EStructuralFeature eFeature = cdoInternalDynamicFeature(i);
- if (!eFeature.isTransient())
+ if (EMFUtil.isPersistent(eFeature))
{
revisionToInstanceFeature(this, revision, eFeature);
}
@@ -455,14 +457,42 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
return (Resource.Internal)cdoStore().getResource(this);
}
- /**
- * TODO: TO BE REMOVED once https://bugs.eclipse.org/bugs/show_bug.cgi?id=259855 is available to downloads
- */
+ @Override
+ public Object dynamicGet(int dynamicFeatureID)
+ {
+ Object result = eSettings[dynamicFeatureID];
+ if (result == null)
+ {
+ EStructuralFeature eStructuralFeature = eDynamicFeature(dynamicFeatureID);
+ if (EMFUtil.isPersistent(eStructuralFeature))
+ {
+ if (FeatureMapUtil.isFeatureMap(eStructuralFeature))
+ {
+ eSettings[dynamicFeatureID] = result = createFeatureMap(eStructuralFeature);
+ }
+ else if (eStructuralFeature.isMany())
+ {
+ eSettings[dynamicFeatureID] = result = createList(eStructuralFeature);
+ }
+ else
+ {
+ result = eStore().get(this, eStructuralFeature, InternalEObject.EStore.NO_INDEX);
+ if (eIsCaching())
+ {
+ eSettings[dynamicFeatureID] = result;
+ }
+ }
+ }
+ }
+
+ return result;
+ }
+
@Override
public void dynamicSet(int dynamicFeatureID, Object value)
{
EStructuralFeature eStructuralFeature = eDynamicFeature(dynamicFeatureID);
- if (eStructuralFeature.isTransient())
+ if (!EMFUtil.isPersistent(eStructuralFeature))
{
eSettings[dynamicFeatureID] = value;
}
@@ -476,14 +506,11 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
}
}
- /**
- * TODO: TO BE REMOVED once https://bugs.eclipse.org/bugs/show_bug.cgi?id=276712 is available
- */
@Override
public void dynamicUnset(int dynamicFeatureID)
{
EStructuralFeature eStructuralFeature = eDynamicFeature(dynamicFeatureID);
- if (eStructuralFeature.isTransient())
+ if (!EMFUtil.isPersistent(eStructuralFeature))
{
eSettings[dynamicFeatureID] = null;
}
@@ -501,6 +528,16 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
* @since 2.0
*/
@Override
+ protected boolean eDynamicIsSet(int dynamicFeatureID, EStructuralFeature eFeature)
+ {
+ return dynamicFeatureID < 0 ? eOpenIsSet(eFeature) : eSettingDelegate(eFeature).dynamicIsSet(this, eSettings(),
+ dynamicFeatureID);
+ }
+
+ /**
+ * @since 2.0
+ */
+ @Override
public InternalEObject.EStore eStore()
{
if (FSMUtil.isTransient(this))
@@ -902,16 +939,6 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
}
/**
- * @since 2.0
- */
- @Override
- protected boolean eDynamicIsSet(int dynamicFeatureID, EStructuralFeature eFeature)
- {
- return dynamicFeatureID < 0 ? eOpenIsSet(eFeature) : eSettingDelegate(eFeature).dynamicIsSet(this, eSettings(),
- dynamicFeatureID);
- }
-
- /**
* Don't cache non-transient features in this CDOObject's {@link #eSettings()}.
*/
@Override
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 64752a777f..a9c7b449fd 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
@@ -14,6 +14,7 @@ package org.eclipse.emf.internal.cdo.util;
import org.eclipse.emf.cdo.CDOObject;
import org.eclipse.emf.cdo.CDOState;
import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.model.EMFUtil;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry;
import org.eclipse.emf.cdo.util.InvalidObjectException;
@@ -273,7 +274,7 @@ public final class FSMUtil
EStructuralFeature eContainingFeature = eObject.eContainingFeature();
if (isResource || eObject.eDirectResource() == null
- && (eContainingFeature == null || !eContainingFeature.isTransient()))
+ && (eContainingFeature == null || EMFUtil.isPersistent(eContainingFeature)))
{
next = adapt(eObject, cdoView);
if (next instanceof InternalCDOObject)

Back to the top