summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2008-04-21 08:18:14 (EDT)
committerEike Stepper2008-04-21 08:18:14 (EDT)
commitfb2041d89323f36733787ce0b5b84371158dbd80 (patch)
tree664389e67fbb1fcc275ba0864fa3a9165108f3ea
parent2c87a1698647742d33fc35dbebe46007696333a5 (diff)
downloadcdo-fb2041d89323f36733787ce0b5b84371158dbd80.zip
cdo-fb2041d89323f36733787ce0b5b84371158dbd80.tar.gz
cdo-fb2041d89323f36733787ce0b5b84371158dbd80.tar.bz2
[226233] Issues with EPackages having inter-dependencies
https://bugs.eclipse.org/bugs/show_bug.cgi?id=226233
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PackageRegistryTest.java30
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOPackageRegistryImpl.java8
2 files changed, 33 insertions, 5 deletions
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 28cc085..d1d2053 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
@@ -28,6 +28,8 @@ import org.eclipse.emf.cdo.tests.model2.SpecialPurchaseOrder;
import org.eclipse.emf.cdo.tests.model3.Class1;
import org.eclipse.emf.cdo.tests.model3.Model3Factory;
import org.eclipse.emf.cdo.tests.model3.Model3Package;
+import org.eclipse.emf.cdo.tests.model3.subpackage.Class2;
+import org.eclipse.emf.cdo.tests.model3.subpackage.SubpackageFactory;
import org.eclipse.emf.cdo.tests.model3.subpackage.SubpackagePackage;
import org.eclipse.emf.cdo.util.CDOUtil;
@@ -184,6 +186,7 @@ public class PackageRegistryTest extends AbstractCDOTest
CDOPackage subPackage = session.getPackageManager().lookupPackage(SubpackagePackage.eINSTANCE.getNsURI());
assertNull(subPackage.getMetaIDRange());
assertNull(subPackage.getEcore());
+ session.close();
}
}
@@ -193,19 +196,38 @@ public class PackageRegistryTest extends AbstractCDOTest
CDOSession session = CDOUtil.openSession(getConnector(), REPOSITORY_NAME, true);
session.getPackageRegistry().putEPackage(Model3Package.eINSTANCE);
CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.createResource("/res");
+ CDOResource res1 = transaction.createResource("/res1");
+ CDOResource res2 = transaction.createResource("/res2");
Class1 class1 = Model3Factory.eINSTANCE.createClass1();
- res.getContents().add(class1);
+ Class2 class2 = SubpackageFactory.eINSTANCE.createClass2();
+ class1.getClass2().add(class2);
+
+ res1.getContents().add(class1);
+ res2.getContents().add(class2);
transaction.commit();
+ session.close();
}
{
CDOSession session = CDOUtil.openSession(getConnector(), REPOSITORY_NAME);
CDOTransaction transaction = session.openTransaction();
- CDOResource res = transaction.getResource("/res");
+ CDOResource res1 = transaction.getResource("/res1");
+
+ Class1 class1 = (Class1)res1.getContents().get(0);
+ assertNotNull(class1);
+ Class2 class2 = class1.getClass2().get(0);
+ assertNotNull(class2);
+ }
+
+ {
+ CDOSession session = CDOUtil.openSession(getConnector(), REPOSITORY_NAME);
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res2 = transaction.getResource("/res2");
- Class1 class1 = (Class1)res.getContents().get(0);
+ Class2 class2 = (Class2)res2.getContents().get(0);
+ assertNotNull(class2);
+ Class1 class1 = class2.getClass1().get(0);
assertNotNull(class1);
}
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOPackageRegistryImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOPackageRegistryImpl.java
index 96884f3..04d0d51 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOPackageRegistryImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOPackageRegistryImpl.java
@@ -11,6 +11,7 @@
package org.eclipse.emf.internal.cdo;
import org.eclipse.emf.cdo.internal.protocol.model.InternalCDOPackage;
+import org.eclipse.emf.cdo.protocol.id.CDOIDMetaRange;
import org.eclipse.emf.cdo.protocol.model.CDOPackage;
import org.eclipse.emf.cdo.util.CDOPackageRegistry;
import org.eclipse.emf.cdo.util.EMFUtil;
@@ -147,7 +148,12 @@ public class CDOPackageRegistryImpl extends EPackageRegistryImpl implements CDOP
public EPackage getEPackage()
{
EPackage ePackage = ModelUtil.createEPackage(cdoPackage);
- session.registerEPackage(ePackage, cdoPackage.getMetaIDRange());
+ CDOIDMetaRange idRange = cdoPackage.getMetaIDRange();
+ if (idRange != null)
+ {
+ session.registerEPackage(ePackage, idRange);
+ }
+
return ePackage;
}