summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-07-19 14:45:16 (EDT)
committerEike Stepper2007-07-19 14:45:16 (EDT)
commitff11efee7dead8e18b07dd8516cc660cc2dbdb74 (patch)
tree05d46948eff5f66326c3c3446b7e10b063120bba
parenta74c23d4204e29c4ca3999be746664c16e26ad60 (diff)
downloadcdo-ff11efee7dead8e18b07dd8516cc660cc2dbdb74.zip
cdo-ff11efee7dead8e18b07dd8516cc660cc2dbdb74.tar.gz
cdo-ff11efee7dead8e18b07dd8516cc660cc2dbdb74.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectAdapter.java61
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java5
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java12
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStore.java6
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java85
5 files changed, 76 insertions, 93 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 adb06e8..552a5ef 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
@@ -29,6 +29,7 @@ import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.common.notify.Notifier;
import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.common.util.BasicEList;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.common.util.URI;
@@ -43,6 +44,7 @@ import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.internal.cdo.bundle.OM;
import java.lang.reflect.Field;
+import java.util.List;
/**
* @author Eike Stepper
@@ -180,7 +182,6 @@ public class CDOObjectAdapter extends AdapterImpl implements InternalCDOObject
}
this.revision = (CDORevisionImpl)revision;
- transferTargetToRevision();
}
public void cdoInternalSetView(CDOView view)
@@ -200,12 +201,7 @@ public class CDOObjectAdapter extends AdapterImpl implements InternalCDOObject
public void cdoInternalFinalizeRevision()
{
- // InternalEObject target = getTarget();
- // EObject eContainer = target.eContainer();
- // int eContainerFeatureID = target.eContainerFeatureID();
- // // Setting setting = target.eSetting(null);
- // CDOObjectImpl.finalizeCDORevision(this, eContainer, eContainerFeatureID,
- // null);
+ transferTargetToRevision();
}
public EStructuralFeature cdoInternalDynamicFeature(int dynamicFeatureID)
@@ -214,6 +210,17 @@ public class CDOObjectAdapter extends AdapterImpl implements InternalCDOObject
throw new UnsupportedOperationException("Not yet implemented");
}
+ @Override
+ public String toString()
+ {
+ if (id == null)
+ {
+ return eClass().getName() + "?";
+ }
+
+ return eClass().getName() + "@" + id;
+ }
+
private void transferTargetToRevision()
{
InternalEObject target = getTarget();
@@ -226,17 +233,37 @@ public class CDOObjectAdapter extends AdapterImpl implements InternalCDOObject
for (int i = 0; i < features.length; i++)
{
CDOFeatureImpl feature = features[i];
- Object value = revision.getValue(feature);
+ System.out.println("FEATURE " + feature);
+
+ Object targetValue = getTargetValue(target, feature);
if (feature.isMany())
{
- EList list = (EList)getTargetValue(target, feature);
- dumpSetting(feature, list);
+ List revisionList = revision.getList(feature);
+ revisionList.clear();
+
+ BasicEList targetList = (BasicEList)targetValue;
+ Object[] data = targetList.data();
+ if (data != null)
+ {
+ for (Object targetElement : data)
+ {
+ if (feature.isReference())
+ {
+ targetElement = view.convertToID(targetElement);
+ }
+
+ revisionList.add(targetElement);
+ }
+ }
}
else
{
- value = view.convertToObject(value);
- dumpSetting(feature, value);
- setTargetValue(target, feature, value);
+ if (feature.isReference())
+ {
+ targetValue = view.convertToID(targetValue);
+ }
+
+ revision.setValue(feature, targetValue);
}
}
}
@@ -561,7 +588,13 @@ public class CDOObjectAdapter extends AdapterImpl implements InternalCDOObject
return getTarget().eURIFragmentSegment(feature, object);
}
- public static CDOObjectAdapter getFor(InternalEObject eObject)
+ public static CDOObjectAdapter get(InternalEObject eObject)
+ {
+ EList<Adapter> adapters = eObject.eAdapters();
+ return (CDOObjectAdapter)EcoreUtil.getAdapter(adapters, CDOObjectAdapter.class);
+ }
+
+ public static CDOObjectAdapter getOrCreate(InternalEObject eObject)
{
EList<Adapter> adapters = eObject.eAdapters();
CDOObjectAdapter adapter = (CDOObjectAdapter)EcoreUtil.getAdapter(adapters, CDOObjectAdapter.class);
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 5a7bcdc..05fe66c 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
@@ -161,6 +161,7 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
public void cdoInternalFinalizeRevision()
{
+ // TODO Inline
finalizeCDORevision(this, eContainer, eContainerFeatureID, eSettings);
}
@@ -391,6 +392,10 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
return cdoState == CDOState.TRANSIENT || cdoState == CDOState.PREPARED_ATTACH;
}
+ /**
+ * TODO Inline
+ */
+ @Deprecated
static void finalizeCDORevision(InternalCDOObject cdoObject, EObject eContainer, int eContainerFeatureID,
Object[] eSettings)
{
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java
index 09e29d8..583ff8f 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java
@@ -329,10 +329,8 @@ public final class CDOStateMachine
// Prepare content tree
for (EObject content : object.eContents())
{
- if (content instanceof InternalCDOObject)
- {
- INSTANCE.processEvent((InternalCDOObject)content, Event.ATTACH, resource, view);
- }
+ InternalCDOObject objectOrAdapter = CDOStore.getCDOObject(content);
+ INSTANCE.processEvent(objectOrAdapter, Event.ATTACH, resource, view);
}
}
}
@@ -351,10 +349,8 @@ public final class CDOStateMachine
// Prepare content tree
for (EObject content : object.eContents())
{
- if (content instanceof InternalCDOObject)
- {
- INSTANCE.processEvent((InternalCDOObject)content, Event.FINALIZE_ATTACH, null, null);
- }
+ InternalCDOObject objectOrAdapter = CDOStore.getCDOObject(content);
+ INSTANCE.processEvent(objectOrAdapter, Event.FINALIZE_ATTACH, null, null);
}
}
}
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 879892e..bd1d579 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
@@ -365,7 +365,7 @@ public final class CDOStore implements EStore
return "PersistentStore";
}
- private static InternalCDOObject getCDOObject(Object object)
+ public static InternalCDOObject getCDOObject(Object object)
{
if (object instanceof InternalCDOObject)
{
@@ -374,13 +374,13 @@ public final class CDOStore implements EStore
if (object instanceof InternalEObject)
{
- return CDOObjectAdapter.getFor((InternalEObject)object);
+ return CDOObjectAdapter.getOrCreate((InternalEObject)object);
}
throw new ImplementationError("Neither InternalCDOObject nor InternalEObject: " + object.getClass().getName());
}
- private static CDOFeatureImpl getCDOFeature(InternalCDOObject cdoObject, EStructuralFeature eFeature)
+ public static CDOFeatureImpl getCDOFeature(InternalCDOObject cdoObject, EStructuralFeature eFeature)
{
CDOViewImpl view = (CDOViewImpl)cdoObject.cdoView();
if (view == null)
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 5f9f521..82a112b 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
@@ -38,6 +38,7 @@ import org.eclipse.emf.common.notify.Notifier;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.util.EcoreUtil;
@@ -306,75 +307,23 @@ 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)
+ if (!(potentialObject instanceof InternalCDOObject))
+ {
+ if (potentialObject instanceof InternalEObject)
+ {
+ CDOObjectAdapter adapter = CDOObjectAdapter.get((InternalEObject)potentialObject);
+ if (adapter != null)
+ {
+ potentialObject = adapter;
+ }
+ }
+ }
+
+ if (potentialObject instanceof InternalCDOObject)
{
- CDOObject object = (CDOObject)potentialObject;
+ InternalCDOObject object = (InternalCDOObject)potentialObject;
if (object.cdoView() == this)
{
return object.cdoID();
@@ -490,7 +439,7 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
ResourceSet resourceSet = (ResourceSet)newTarget;
if (TRACER.isEnabled())
{
- TRACER.trace("Attaching CDO adapter to " + resourceSet);
+ TRACER.trace("Attaching CDO view to " + resourceSet);
}
this.resourceSet = resourceSet;
@@ -518,7 +467,7 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
if (TRACER.isEnabled())
{
- TRACER.trace("Detaching CDO adapter from " + resourceSet);
+ TRACER.trace("Detaching CDO view from " + resourceSet);
}
if (resourceSet == oldTarget)