summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2008-04-21 07:52:36 (EDT)
committerEike Stepper2008-04-21 07:52:36 (EDT)
commit2c87a1698647742d33fc35dbebe46007696333a5 (patch)
tree6b70eca9786d87505bc0544e3b7bcece0f008847
parent2124fc5183c3cbec4bb37ecac59e65eb82b4a945 (diff)
downloadcdo-2c87a1698647742d33fc35dbebe46007696333a5.zip
cdo-2c87a1698647742d33fc35dbebe46007696333a5.tar.gz
cdo-2c87a1698647742d33fc35dbebe46007696333a5.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.server/src/org/eclipse/emf/cdo/internal/server/Transaction.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PackageRegistryTest.java28
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java10
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java19
4 files changed, 51 insertions, 11 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Transaction.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Transaction.java
index de1e835..73dfc12 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Transaction.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Transaction.java
@@ -240,7 +240,10 @@ public class Transaction extends View implements ITransaction, IStoreWriter.Comm
{
for (CDOPackage newPackage : newPackages)
{
- adjustMetaRange(newPackage);
+ if (newPackage.getParentURI() == null)
+ {
+ adjustMetaRange(newPackage);
+ }
}
}
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 d8ab83f..28cc085 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
@@ -157,6 +157,34 @@ public class PackageRegistryTest extends AbstractCDOTest
CDOPackage subPackage = session.getPackageManager().lookupPackage(SubpackagePackage.eINSTANCE.getNsURI());
assertNull(subPackage.getMetaIDRange());
assertNull(subPackage.getEcore());
+ session.close();
+ }
+
+ public void testLoadNestedPackages() throws Exception
+ {
+ {
+ CDOSession session = CDOUtil.openSession(getConnector(), REPOSITORY_NAME, true);
+ session.getPackageRegistry().putEPackage(Model3Package.eINSTANCE);
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.createResource("/res");
+
+ Class1 class1 = Model3Factory.eINSTANCE.createClass1();
+ res.getContents().add(class1);
+ transaction.commit();
+ session.close();
+ }
+
+ {
+ CDOSession session = CDOUtil.openSession(getConnector(), REPOSITORY_NAME, true);
+ CDOPackage model3Package = session.getPackageManager().lookupPackage(Model3Package.eINSTANCE.getNsURI());
+ assertEquals(8, model3Package.getMetaIDRange().size());
+ assertNotNull(model3Package.getEcore());
+
+ CDOPackage subPackage = session.getPackageManager().lookupPackage(SubpackagePackage.eINSTANCE.getNsURI());
+ assertNull(subPackage.getMetaIDRange());
+ assertNull(subPackage.getEcore());
+ }
}
public void testCommitCircularPackages() throws Exception
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java
index ad9540c..9dfaefd 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java
@@ -404,11 +404,12 @@ public class CDOTransactionImpl extends CDOViewImpl implements CDOTransaction
}
}
- // Calculate the packages of the used classes
+ // Calculate the top level packages of the used classes
Set<EPackage> usedPackages = new HashSet<EPackage>();
for (EClass usedClass : usedClasses)
{
- usedPackages.add(usedClass.getEPackage());
+ EPackage topLevelPackage = ModelUtil.getTopLevelPackage(usedClass.getEPackage());
+ usedPackages.add(topLevelPackage);
}
// Determine which of the used packages are new
@@ -425,6 +426,11 @@ public class CDOTransactionImpl extends CDOViewImpl implements CDOTransaction
if (!cdoPackage.isPersistent() && !cdoPackage.isSystem())
{
newPackages.add(cdoPackage);
+ CDOPackage[] subPackages = cdoPackage.getSubPackages(true);
+ for (CDOPackage subPackage : subPackages)
+ {
+ newPackages.add(subPackage);
+ }
}
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java
index 7b96223..c09232a 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java
@@ -130,15 +130,18 @@ public class CommitTransactionRequest extends CDOClientRequest<CommitTransaction
List<CDOPackage> newPackages = transaction.getNewPackages();
for (CDOPackage newPackage : newPackages)
{
- CDOIDMetaRange oldRange = newPackage.getMetaIDRange();
- CDOIDMetaRange newRange = CDOIDUtil.readMetaRange(in);
- ((InternalCDOPackage)newPackage).setMetaIDRange(newRange);
- for (int i = 0; i < oldRange.size(); i++)
+ if (newPackage.getParentURI() == null)
{
- CDOIDTemp oldID = (CDOIDTemp)oldRange.get(i);
- CDOID newID = newRange.get(i);
- session.remapMetaInstance(oldID, newID);
- result.addIDMapping(oldID, newID);
+ CDOIDMetaRange oldRange = newPackage.getMetaIDRange();
+ CDOIDMetaRange newRange = CDOIDUtil.readMetaRange(in);
+ ((InternalCDOPackage)newPackage).setMetaIDRange(newRange);
+ for (int i = 0; i < oldRange.size(); i++)
+ {
+ CDOIDTemp oldID = (CDOIDTemp)oldRange.get(i);
+ CDOID newID = newRange.get(i);
+ session.remapMetaInstance(oldID, newID);
+ result.addIDMapping(oldID, newID);
+ }
}
}