summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2008-05-23 09:05:41 (EDT)
committerEike Stepper2008-05-23 09:05:41 (EDT)
commit4b8c0fae1815454dc232a109028d130a79668eac (patch)
tree782f2545a1303d92cf9f8ef4c879537e5976a9ba
parent6e640f2141817d3789c42b6dbcc09917df30ea0d (diff)
downloadcdo-4b8c0fae1815454dc232a109028d130a79668eac.zip
cdo-4b8c0fae1815454dc232a109028d130a79668eac.tar.gz
cdo-4b8c0fae1815454dc232a109028d130a79668eac.tar.bz2
[233644] eDirectResource is always null
https://bugs.eclipse.org/bugs/show_bug.cgi?id=233644
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/InitialTest.java46
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PackageRegistryTest.java3
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java20
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java23
4 files changed, 75 insertions, 17 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/InitialTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/InitialTest.java
index ce16758..7dd1e89 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/InitialTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/InitialTest.java
@@ -14,6 +14,7 @@ import org.eclipse.emf.cdo.CDOSession;
import org.eclipse.emf.cdo.CDOState;
import org.eclipse.emf.cdo.CDOTransaction;
import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.tests.model1.Category;
import org.eclipse.emf.cdo.tests.model1.Model1Factory;
import org.eclipse.emf.cdo.tests.model1.Model1Package;
import org.eclipse.emf.cdo.tests.model1.OrderAddress;
@@ -27,9 +28,15 @@ import org.eclipse.net4j.channel.IChannel;
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.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EcoreFactory;
+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.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl;
import java.util.Date;
@@ -733,4 +740,43 @@ public class InitialTest extends AbstractCDOTest
msg("Verifying product");
assertEquals(null, orderDetail.getProduct());
}
+
+ public void testDirectResourceEMF() throws Exception
+ {
+ Resource resource1 = new XMLResourceImpl();
+
+ EPackage p = EcoreFactory.eINSTANCE.createEPackage();
+ EClass c = EcoreFactory.eINSTANCE.createEClass();
+
+ resource1.getContents().add(p);
+ p.getEClassifiers().add(c);
+
+ assertEquals(null, ((InternalEObject)c).eDirectResource());
+ assertEquals(resource1, ((InternalEObject)p).eDirectResource());
+ }
+
+ public void testDirectResource() throws Exception
+ {
+ CDOSession session = openModel1Session();
+ CDOTransaction transaction = (CDOTransaction)session.openTransaction();
+
+ CDOResource resource1 = transaction.getOrCreateResource("/test1");
+ // Resource resource1 = new XMIResourceImpl();
+
+ Category cat1 = Model1Factory.eINSTANCE.createCategory();
+ assertTransient(cat1);
+
+ Category cat2 = Model1Factory.eINSTANCE.createCategory();
+ assertTransient(cat2);
+
+ // resource1.getContents().add(cat2);
+ resource1.getContents().add(cat1);
+ cat1.getCategories().add(cat2);
+
+ assertEquals(null, ((InternalEObject)cat2).eDirectResource());
+ assertEquals(resource1, ((InternalEObject)cat1).eDirectResource());
+
+ transaction.close();
+ session.close();
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PackageRegistryTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PackageRegistryTest.java
index 905e1f8..09ade27 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PackageRegistryTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PackageRegistryTest.java
@@ -133,8 +133,7 @@ public class PackageRegistryTest extends AbstractCDOTest
public void testCommitNestedPackages() throws Exception
{
CDOSession session = openSession();
- session.getPackageRegistry().putEPackage(Model3Package.eINSTANCE);
- assertEquals(2, session.getPackageRegistry().size());
+ assertEquals(5, session.getPackageRegistry().size());
try
{
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java
index 915c7c2..3d410c0 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java
@@ -18,7 +18,6 @@ import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.emf.internal.cdo.CDOLegacyImpl;
import org.eclipse.emf.internal.cdo.CDOObjectImpl;
-import org.eclipse.emf.internal.cdo.CDOStateMachine;
import org.eclipse.emf.internal.cdo.CDOViewImpl;
import org.eclipse.emf.internal.cdo.InternalCDOObject;
import org.eclipse.emf.internal.cdo.bundle.OM;
@@ -406,16 +405,11 @@ public class CDOResourceImpl extends CDOObjectImpl implements CDOResource
*/
public void attached(EObject object)
{
- InternalCDOObject legacy = getLegacyWrapper(object);
- if (legacy.cdoState() != CDOState.CLEAN)
- {
- CDOStateMachine.INSTANCE.attach(legacy, this, view);
- // if (legacy.eContainer() == this)
- // {
- // legacy.eBasicSetContainer(null, 0, null);
- // legacy.eSetResource(this, null);
- // }
- }
+ // InternalCDOObject legacy = getLegacyWrapper(object);
+ // if (legacy.cdoState() != CDOState.CLEAN)
+ // {
+ // CDOStateMachine.INSTANCE.attach(legacy, this, view);
+ // }
}
/**
@@ -423,8 +417,8 @@ public class CDOResourceImpl extends CDOObjectImpl implements CDOResource
*/
public void detached(EObject object)
{
- InternalCDOObject legacy = getLegacyWrapper(object);
- CDOStateMachine.INSTANCE.detach(legacy);
+ // InternalCDOObject legacy = getLegacyWrapper(object);
+ // CDOStateMachine.INSTANCE.detach(legacy);
}
/**
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 6bda90a..4202387 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
@@ -432,6 +432,22 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
throw new ImplementationError();
}
+ // @Override
+ // public Internal eDirectResource()
+ // {
+ // if (revision != null && resource instanceof InternalCDOObject)
+ // {
+ // CDOID containerID = revision.getContainerID();
+ // CDOID resourceID = ((InternalCDOObject)resource).cdoID();
+ // if (containerID.equals(resourceID))
+ // {
+ // return resource;
+ // }
+ // }
+ //
+ // return null;
+ // }
+
@Override
protected void eSetDirectResource(Internal resource)
{
@@ -562,13 +578,16 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
if (FSMUtil.isTransient(this))
{
- eContainer = newContainer;
- eContainerFeatureID = newContainerFeatureID;
+ super.eBasicSetContainer(newContainer, newContainerFeatureID);
}
else
{
// Delegate to CDOStore
getStore().setContainer(this, newContainer, newContainerFeatureID);
+ if (newContainer instanceof Resource.Internal)
+ {
+ eSetDirectResource((Resource.Internal)newContainer);
+ }
}
}