summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-07-19 06:25:29 (EDT)
committerEike Stepper2007-07-19 06:25:29 (EDT)
commitfd4d8b37c349c376c85a644297bc161f3ddb75b6 (patch)
tree4c8f138f986f4fa302a26e0d93eb9132a1561c8a
parent7ac6fe6f3913f533e7d701bb404f6fc6897f01b2 (diff)
downloadcdo-fd4d8b37c349c376c85a644297bc161f3ddb75b6.zip
cdo-fd4d8b37c349c376c85a644297bc161f3ddb75b6.tar.gz
cdo-fd4d8b37c349c376c85a644297bc161f3ddb75b6.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectAdapter.java13
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java4
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStore.java73
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java107
4 files changed, 133 insertions, 64 deletions
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectAdapter.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectAdapter.java
index 7178655..522f850 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectAdapter.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectAdapter.java
@@ -183,13 +183,18 @@ public class CDOObjectAdapter extends AdapterImpl implements InternalCDOObject
private void transferRevisionToTarget()
{
InternalEObject target = getTarget();
- CDOReferenceConverter converter = ((CDOViewImpl)cdoView()).getReferenceConverter();
+ CDOViewImpl view = (CDOViewImpl)cdoView();
+ CDOPackageRegistryImpl packageRegistry = view.getSession().getPackageRegistry();
+ CDOReferenceConverter converter = view.getReferenceConverter();
CDOClassImpl cdoClass = revision.getCDOClass();
CDOFeatureImpl[] features = cdoClass.getAllFeatures();
for (int i = 0; i < features.length; i++)
{
CDOFeatureImpl feature = features[i];
+ // EStructuralFeature eFeature = ModelUtil.getEFeature(feature,
+ // packageRegistry);
+
CDOTypeImpl type = feature.getType();
Object value = revision.getValue(feature);
if (feature.isMany())
@@ -197,6 +202,12 @@ public class CDOObjectAdapter extends AdapterImpl implements InternalCDOObject
}
else
{
+ if (feature.isReference())
+ {
+ }
+ else
+ {
+ }
}
}
}
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 37b9023..5a7bcdc 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
@@ -441,7 +441,7 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
{
if (isReference)
{
- value = CDOStore.convertToID(view, value);
+ value = view.convertToID(value);
}
revision.add(cdoFeature, index++, value);
@@ -451,7 +451,7 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
{
if (isReference)
{
- setting = CDOStore.convertToID(view, setting);
+ setting = view.convertToID(setting);
}
revision.set(cdoFeature, 0, setting);
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 bdb6c58..4f791bf 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
@@ -10,13 +10,10 @@
**************************************************************************/
package org.eclipse.emf.internal.cdo;
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.CDOView;
import org.eclipse.emf.cdo.internal.protocol.model.CDOFeatureImpl;
import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageManagerImpl;
import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl;
import org.eclipse.emf.cdo.protocol.CDOID;
-import org.eclipse.emf.cdo.protocol.util.ImplementationError;
import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
@@ -36,7 +33,7 @@ public final class CDOStore implements EStore
// @Singleton
public static final CDOStore INSTANCE = new CDOStore();
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_OBJECT, CDOStore.class);
+ private final ContextTracer TRACER = new ContextTracer(OM.DEBUG_OBJECT, CDOStore.class);
private CDOStore()
{
@@ -52,7 +49,7 @@ public final class CDOStore implements EStore
CDORevisionImpl revision = getRevisionForReading(cdoObject);
CDOID id = revision.getContainerID();
- return (InternalEObject)convertToObject(cdoObject.cdoView(), id);
+ return (InternalEObject)((CDOViewImpl)cdoObject.cdoView()).convertToObject(id);
}
public int getContainingFeatureID(InternalEObject eObject)
@@ -75,7 +72,7 @@ public final class CDOStore implements EStore
TRACER.format("setContainer({0}, {1}, {2})", cdoObject, newContainer, newContainerFeatureID);
}
- CDOID containerID = (CDOID)convertToID(cdoObject.cdoView(), newContainer);
+ CDOID containerID = (CDOID)((CDOViewImpl)cdoObject.cdoView()).convertToID(newContainer);
CDORevisionImpl revision = getRevisionForWriting(cdoObject);
revision.setContainerID(containerID);
@@ -100,7 +97,7 @@ public final class CDOStore implements EStore
Object result = revision.get(cdoFeature, index);
if (cdoFeature.isReference())
{
- result = convertToObject(cdoObject.cdoView(), result);
+ result = ((CDOViewImpl)cdoObject.cdoView()).convertToObject(result);
}
return result;
@@ -156,7 +153,7 @@ public final class CDOStore implements EStore
if (cdoFeature.isReference())
{
- value = convertToID(cdoObject.cdoView(), value);
+ value = ((CDOViewImpl)cdoObject.cdoView()).convertToID(value);
}
CDORevisionImpl revision = getRevisionForReading(cdoObject);
@@ -174,7 +171,7 @@ public final class CDOStore implements EStore
if (cdoFeature.isReference())
{
- value = convertToID(cdoObject.cdoView(), value);
+ value = ((CDOViewImpl)cdoObject.cdoView()).convertToID(value);
}
CDORevisionImpl revision = getRevisionForReading(cdoObject);
@@ -192,7 +189,7 @@ public final class CDOStore implements EStore
if (cdoFeature.isReference())
{
- value = convertToID(cdoObject.cdoView(), value);
+ value = ((CDOViewImpl)cdoObject.cdoView()).convertToID(value);
}
CDORevisionImpl revision = getRevisionForReading(cdoObject);
@@ -227,7 +224,7 @@ public final class CDOStore implements EStore
{
for (int i = 0; i < result.length; i++)
{
- result[i] = convertToObject(cdoObject.cdoView(), result[i]);
+ result[i] = ((CDOViewImpl)cdoObject.cdoView()).convertToObject(result[i]);
}
}
@@ -256,14 +253,14 @@ public final class CDOStore implements EStore
handleContainmentAdd(cdoObject, cdoFeature, value);
}
- value = convertToID(cdoObject.cdoView(), value);
+ value = ((CDOViewImpl)cdoObject.cdoView()).convertToID(value);
}
CDORevisionImpl revision = getRevisionForWriting(cdoObject);
Object result = revision.set(cdoFeature, index, value);
if (cdoFeature.isReference())
{
- result = convertToObject(cdoObject.cdoView(), result);
+ result = ((CDOViewImpl)cdoObject.cdoView()).convertToObject(result);
}
return result;
@@ -298,7 +295,7 @@ public final class CDOStore implements EStore
handleContainmentAdd(cdoObject, cdoFeature, value);
}
- value = convertToID(cdoObject.cdoView(), value);
+ value = ((CDOViewImpl)cdoObject.cdoView()).convertToID(value);
}
CDORevisionImpl revision = getRevisionForWriting(cdoObject);
@@ -318,7 +315,7 @@ public final class CDOStore implements EStore
Object result = revision.remove(cdoFeature, index);
if (cdoFeature.isReference())
{
- result = convertToObject(cdoObject.cdoView(), result);
+ result = ((CDOViewImpl)cdoObject.cdoView()).convertToObject(result);
}
return result;
@@ -350,7 +347,7 @@ public final class CDOStore implements EStore
Object result = revision.move(cdoFeature, target, source);
if (cdoFeature.isReference())
{
- result = convertToObject(cdoObject.cdoView(), result);
+ result = ((CDOViewImpl)cdoObject.cdoView()).convertToObject(result);
}
return result;
@@ -367,50 +364,6 @@ public final class CDOStore implements EStore
return "PersistentStore";
}
- public static Object convertToID(CDOView adapter, Object potentialObject)
- {
- if (potentialObject instanceof CDOObject)
- {
- CDOObject object = (CDOObject)potentialObject;
- if (object.cdoView() == adapter)
- {
- return object.cdoID();
- }
- }
-
- if (TRACER.isEnabled())
- {
- TRACER.format("Dangling reference: {0}", potentialObject);
- }
-
- return potentialObject;
- }
-
- /**
- * TODO Move to adapter
- */
- public static Object convertToObject(CDOView adapter, Object potentialID)
- {
- if (potentialID instanceof CDOID)
- {
- if (potentialID == CDOID.NULL)
- {
- return null;
- }
-
- CDOID id = (CDOID)potentialID;
- CDOObject result = ((CDOViewImpl)adapter).lookupObject(id);
- if (result == null)
- {
- throw new ImplementationError("ID not registered: " + id);
- }
-
- return result;
- }
-
- return potentialID;
- }
-
private static CDOFeatureImpl getCDOFeature(InternalCDOObject cdoObject, EStructuralFeature eFeature)
{
CDOViewImpl view = (CDOViewImpl)cdoObject.cdoView();
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
index f1b566f..74a06a3 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
@@ -93,7 +93,7 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
{
try
{
- CDOID id = (CDOID)CDOStore.convertToID(CDOViewImpl.this, object);
+ CDOID id = (CDOID)CDOViewImpl.this.convertToID(object);
if (TRACER.isEnabled())
{
TRACER.format("Converted dangling reference: {0} --> {1}", object, id);
@@ -305,6 +305,111 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
return referenceConverter;
}
+ // public final class HistoryEntryImpl implements HistoryEntry, Comparable
+ // {
+ // private String resourcePath;
+ //
+ // private HistoryEntryImpl(String resourcePath)
+ // {
+ // this.resourcePath = resourcePath;
+ // }
+ //
+ // public CDOView getView()
+ // {
+ // return CDOViewImpl.this;
+ // }
+ //
+ // public String getResourcePath()
+ // {
+ // return resourcePath;
+ // }
+ //
+ // public int compareTo(Object o)
+ // {
+ // HistoryEntry that = (HistoryEntry)o;
+ // return resourcePath.compareTo(that.getResourcePath());
+ // }
+ //
+ // @Override
+ // public String toString()
+ // {
+ // return resourcePath;
+ // }
+ // }
+
+ // public final class HistoryEntryImpl implements HistoryEntry, Comparable
+ // {
+ // private String resourcePath;
+ //
+ // private HistoryEntryImpl(String resourcePath)
+ // {
+ // this.resourcePath = resourcePath;
+ // }
+ //
+ // public CDOView getView()
+ // {
+ // return CDOViewImpl.this;
+ // }
+ //
+ // public String getResourcePath()
+ // {
+ // return resourcePath;
+ // }
+ //
+ // public int compareTo(Object o)
+ // {
+ // HistoryEntry that = (HistoryEntry)o;
+ // return resourcePath.compareTo(that.getResourcePath());
+ // }
+ //
+ // @Override
+ // public String toString()
+ // {
+ // return resourcePath;
+ // }
+ // }
+
+ public Object convertToID(Object potentialObject)
+ {
+ if (potentialObject instanceof CDOObject)
+ {
+ CDOObject object = (CDOObject)potentialObject;
+ if (object.cdoView() == this)
+ {
+ return object.cdoID();
+ }
+ }
+
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Dangling reference: {0}", potentialObject);
+ }
+
+ return potentialObject;
+ }
+
+ public Object convertToObject(Object potentialID)
+ {
+ if (potentialID instanceof CDOID)
+ {
+ if (potentialID == CDOID.NULL)
+ {
+ return null;
+ }
+
+ CDOID id = (CDOID)potentialID;
+ CDOObject result = lookupObject(id);
+ if (result == null)
+ {
+ throw new ImplementationError("ID not registered: " + id);
+ }
+
+ return result;
+ }
+
+ return potentialID;
+ }
+
/**
* Turns registered objects into proxies and synchronously delivers
* invalidation events to registered event listeners.