summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2008-04-20 07:36:05 (EDT)
committerEike Stepper2008-04-20 07:36:05 (EDT)
commita9123beccc02cd6707faba20e15ba8b65ccdb9de (patch)
treeb6e4f9c5807e2682433c43029d14ddd1e8896d16
parentb9fa9bf964be80168afaba280f7935ebcd4a7118 (diff)
downloadcdo-a9123beccc02cd6707faba20e15ba8b65ccdb9de.zip
cdo-a9123beccc02cd6707faba20e15ba8b65ccdb9de.tar.gz
cdo-a9123beccc02cd6707faba20e15ba8b65ccdb9de.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.db/src/org/eclipse/emf/cdo/server/internal/db/CDODBSchema.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreReader.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreWriter.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/PackageManager.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/OpenSessionIndication.java9
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.model3/META-INF/MANIFEST.MF2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/META-INF/MANIFEST.MF3
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PackageRegistryTest.java54
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOPackageRegistryImpl.java54
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionPackageManagerImpl.java3
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java5
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/OpenSessionRequest.java6
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/OpenSessionResult.java4
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ModelUtil.java22
14 files changed, 151 insertions, 27 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/CDODBSchema.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/CDODBSchema.java
index 3378aca..c7e5154 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/CDODBSchema.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/CDODBSchema.java
@@ -75,6 +75,9 @@ public class CDODBSchema extends DBSchema
public static final IDBField PACKAGES_RANGE_UB = //
PACKAGES.addField("range_ub", DBType.BIGINT);
+ public static final IDBField PACKAGES_PARENT = //
+ PACKAGES.addField("parent", DBType.VARCHAR, 255);
+
public static final IDBIndex INDEX_PACKAGES_PK = //
PACKAGES.addIndex(IDBIndex.Type.PRIMARY_KEY, PACKAGES_ID);
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreReader.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreReader.java
index 18f0a04..d6e291b 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreReader.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreReader.java
@@ -81,13 +81,15 @@ public class DBStoreReader extends DBStoreAccessor implements IDBStoreReader
long upperBound = (Long)values[3];
CDOIDMetaRange metaIDRange = lowerBound == 0 ? null : CDOIDUtil.createMetaRange(new CDOIDMetaImpl(lowerBound),
(int)(upperBound - lowerBound) + 1);
- result.add(new CDOPackageInfo(packageURI, dynamic, metaIDRange));
+ String parentURI = (String)values[4];
+
+ result.add(new CDOPackageInfo(packageURI, dynamic, metaIDRange, parentURI));
return true;
}
};
DBUtil.select(getConnection(), rowHandler, CDODBSchema.PACKAGES_URI, CDODBSchema.PACKAGES_DYNAMIC,
- CDODBSchema.PACKAGES_RANGE_LB, CDODBSchema.PACKAGES_RANGE_UB);
+ CDODBSchema.PACKAGES_RANGE_LB, CDODBSchema.PACKAGES_RANGE_UB, CDODBSchema.PACKAGES_PARENT);
return result;
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreWriter.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreWriter.java
index 9918069..19000cc 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreWriter.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreWriter.java
@@ -100,8 +100,9 @@ public class DBStoreWriter extends DBStoreReader implements IDBStoreWriter
CDOIDMetaRange metaIDRange = cdoPackage.getMetaIDRange();
long lowerBound = metaIDRange == null ? 0L : ((CDOIDMeta)metaIDRange.getLowerBound()).getLongValue();
long upperBound = metaIDRange == null ? 0L : ((CDOIDMeta)metaIDRange.getUpperBound()).getLongValue();
+ String parentURI = cdoPackage.getParentURI();
- String sql = "INSERT INTO " + CDODBSchema.PACKAGES + " VALUES (?, ?, ?, ?, ?, ?, ?)";
+ String sql = "INSERT INTO " + CDODBSchema.PACKAGES + " VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
DBUtil.trace(sql);
PreparedStatement pstmt = null;
@@ -115,6 +116,7 @@ public class DBStoreWriter extends DBStoreReader implements IDBStoreWriter
pstmt.setBoolean(5, dynamic);
pstmt.setLong(6, lowerBound);
pstmt.setLong(7, upperBound);
+ pstmt.setString(8, parentURI);
if (pstmt.execute())
{
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/PackageManager.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/PackageManager.java
index 6de591d..cc87d2f 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/PackageManager.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/PackageManager.java
@@ -72,7 +72,8 @@ public class PackageManager extends CDOPackageManagerImpl implements IPackageMan
Collection<CDOPackageInfo> packageInfos = storeReader.readPackageInfos();
for (CDOPackageInfo info : packageInfos)
{
- addPackage(CDOModelUtil.createProxyPackage(this, info.getPackageURI(), info.isDynamic(), info.getMetaIDRange()));
+ addPackage(CDOModelUtil.createProxyPackage(this, info.getPackageURI(), info.isDynamic(), info.getMetaIDRange(),
+ info.getParentURI()));
}
}
finally
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/OpenSessionIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/OpenSessionIndication.java
index 3e13c52..279efac 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/OpenSessionIndication.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/OpenSessionIndication.java
@@ -83,7 +83,7 @@ public class OpenSessionIndication extends IndicationWithResponse
writeSessionID(out, session);
writeRepositoryUUID(out, repository);
repository.getStore().getCDOIDLibraryDescriptor().write(out);
- writePackageURIs(out, repository.getPackageManager());
+ writePackages(out, repository.getPackageManager());
}
catch (RepositoryNotFoundException ex)
{
@@ -140,7 +140,7 @@ public class OpenSessionIndication extends IndicationWithResponse
out.writeString(repository.getUUID());
}
- private void writePackageURIs(ExtendedDataOutputStream out, PackageManager packageManager) throws IOException
+ private void writePackages(ExtendedDataOutputStream out, PackageManager packageManager) throws IOException
{
CDOPackage[] packages = packageManager.getPackages();
for (CDOPackage p : packages)
@@ -149,13 +149,14 @@ public class OpenSessionIndication extends IndicationWithResponse
{
if (PROTOCOL.isEnabled())
{
- PROTOCOL.format("Writing package info: uri={0}, dynamic={1}, metaIDRange={2}", p.getPackageURI(), p
- .isDynamic(), p.getMetaIDRange());
+ PROTOCOL.format("Writing package info: uri={0}, dynamic={1}, metaIDRange={2}, parentURI={3}", p
+ .getPackageURI(), p.isDynamic(), p.getMetaIDRange(), p.getParentURI());
}
out.writeString(p.getPackageURI());
out.writeBoolean(p.isDynamic());
CDOIDUtil.writeMetaRange(out, p.getMetaIDRange());
+ out.writeString(p.getParentURI());
}
}
diff --git a/plugins/org.eclipse.emf.cdo.tests.model3/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.tests.model3/META-INF/MANIFEST.MF
index 814d8f9..ec38b4c 100644
--- a/plugins/org.eclipse.emf.cdo.tests.model3/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.cdo.tests.model3/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.emf.cdo.tests.model3; singleton:=true
-Bundle-Version: 1.0.0
+Bundle-Version: 0.8.0.qualifier
Bundle-ClassPath: .
Bundle-Vendor: %providerName
Bundle-Localization: plugin
diff --git a/plugins/org.eclipse.emf.cdo.tests/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.tests/META-INF/MANIFEST.MF
index 6173f57..6fc397c 100644
--- a/plugins/org.eclipse.emf.cdo.tests/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.cdo.tests/META-INF/MANIFEST.MF
@@ -14,9 +14,10 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.3.0,4.0.0)",
org.eclipse.net4j.tcp;bundle-version="[0.8.0,0.9.0)";resolution:=optional;visibility:=reexport,
org.eclipse.emf.cdo.server;bundle-version="[0.8.0,0.9.0)";visibility:=reexport,
org.eclipse.emf.cdo;bundle-version="[0.8.0,0.9.0)";visibility:=reexport,
+ org.eclipse.emf.cdo.tests.mango;bundle-version="[0.8.0,0.9.0)";visibility:=reexport,
org.eclipse.emf.cdo.tests.model1;bundle-version="[0.8.0,0.9.0)";visibility:=reexport,
org.eclipse.emf.cdo.tests.model2;bundle-version="[0.8.0,0.9.0)",
- org.eclipse.emf.cdo.tests.mango;bundle-version="[0.8.0,0.9.0)";visibility:=reexport,
+ org.eclipse.emf.cdo.tests.model3;bundle-version="[0.8.0,0.9.0)",
org.junit;visibility:=reexport
Export-Package: org.eclipse.emf.cdo.tests,
org.eclipse.net4j.tests
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 28dc260..9b8d932 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
@@ -14,6 +14,7 @@ import org.eclipse.emf.cdo.CDOObject;
import org.eclipse.emf.cdo.CDOSession;
import org.eclipse.emf.cdo.CDOTransaction;
import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.protocol.model.CDOPackage;
import org.eclipse.emf.cdo.tests.mango.MangoFactory;
import org.eclipse.emf.cdo.tests.mango.MangoPackage;
import org.eclipse.emf.cdo.tests.mango.Value;
@@ -24,6 +25,10 @@ import org.eclipse.emf.cdo.tests.model1.PurchaseOrder;
import org.eclipse.emf.cdo.tests.model2.Model2Factory;
import org.eclipse.emf.cdo.tests.model2.Model2Package;
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.SubpackagePackage;
import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.emf.common.util.URI;
@@ -123,6 +128,55 @@ public class PackageRegistryTest extends AbstractCDOTest
}
}
+ public void testCommitNestedPackages() throws Exception
+ {
+ CDOSession session = CDOUtil.openSession(getConnector(), REPOSITORY_NAME, true);
+ session.getPackageRegistry().putEPackage(Model3Package.eINSTANCE);
+
+ try
+ {
+ session.getPackageRegistry().putEPackage(SubpackagePackage.eINSTANCE);
+ fail("IllegalStateException expected");
+ }
+ catch (IllegalStateException success)
+ {
+ }
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.createResource("/res");
+
+ Class1 class1 = Model3Factory.eINSTANCE.createClass1();
+ res.getContents().add(class1);
+ transaction.commit();
+
+ String nsURI = Model3Package.eINSTANCE.getNsURI();
+ CDOPackage model3Package = session.getPackageManager().lookupPackage(nsURI);
+ assertEquals(8, model3Package.getMetaIDRange().size());
+ }
+
+ public void testCommitCircularPackages() 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();
+ }
+
+ {
+ CDOSession session = CDOUtil.openSession(getConnector(), REPOSITORY_NAME);
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource res = transaction.getResource("/res");
+
+ Class1 class1 = (Class1)res.getContents().get(0);
+ assertNotNull(class1);
+ }
+ }
+
/**
* TODO Fix testDynamicPackage()
*/
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 546d4c2..f4b95ed 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
@@ -15,8 +15,11 @@ import org.eclipse.emf.cdo.protocol.model.CDOPackage;
import org.eclipse.emf.cdo.util.CDOPackageRegistry;
import org.eclipse.emf.cdo.util.EMFUtil;
+import org.eclipse.emf.internal.cdo.bundle.OM;
import org.eclipse.emf.internal.cdo.util.ModelUtil;
+import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
+
import org.eclipse.emf.ecore.EFactory;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EPackage.Registry;
@@ -31,6 +34,8 @@ import java.util.Map;
*/
public class CDOPackageRegistryImpl extends EPackageRegistryImpl implements CDOPackageRegistry
{
+ private final ContextTracer TRACER = new ContextTracer(OM.DEBUG_MODEL, CDOPackageRegistryImpl.class);
+
private static final long serialVersionUID = 1L;
private CDOSessionImpl session;
@@ -55,14 +60,59 @@ public class CDOPackageRegistryImpl extends EPackageRegistryImpl implements CDOP
{
EPackage.Descriptor descriptor = new CDOPackageDescriptor(cdoPackage);
String uri = cdoPackage.getPackageURI();
+ checkUnregistered(uri);
+
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Registering package descriptor for {0}", uri);
+ }
+
put(uri, descriptor);
}
public EPackage putEPackage(EPackage ePackage)
{
+ checkUnregistered(ePackage);
+ putEPackageChecked(ePackage);
+ return getEPackage(ePackage.getNsURI());
+ }
+
+ private void putEPackageChecked(EPackage ePackage)
+ {
String uri = ePackage.getNsURI();
- put(uri, ePackage);
- return getEPackage(uri);
+ if (uri != null)
+ {
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Registering package for {0}", uri);
+ }
+
+ put(uri, ePackage);
+ }
+
+ for (EPackage subPackage : ePackage.getESubpackages())
+ {
+ putEPackageChecked(subPackage);
+ }
+ }
+
+ private void checkUnregistered(EPackage ePackage)
+ {
+ String uri = ePackage.getNsURI();
+ checkUnregistered(uri);
+
+ for (EPackage subPackage : ePackage.getESubpackages())
+ {
+ checkUnregistered(subPackage);
+ }
+ }
+
+ private void checkUnregistered(String uri)
+ {
+ if (uri != null && containsKey(uri))
+ {
+ throw new IllegalStateException("Package already registered for " + uri);
+ }
}
@Override
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionPackageManagerImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionPackageManagerImpl.java
index abc6bac..a3021a2 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionPackageManagerImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionPackageManagerImpl.java
@@ -94,8 +94,9 @@ public class CDOSessionPackageManagerImpl extends CDOPackageManagerImpl implemen
String packageURI = info.getPackageURI();
boolean dynamic = info.isDynamic();
CDOIDMetaRange metaIDRange = info.getMetaIDRange();
+ String parentURI = info.getParentURI();
- CDOPackage proxy = CDOModelUtil.createProxyPackage(this, packageURI, dynamic, metaIDRange);
+ CDOPackage proxy = CDOModelUtil.createProxyPackage(this, packageURI, dynamic, metaIDRange, parentURI);
addPackage(proxy);
session.getPackageRegistry().putPackageDescriptor(proxy);
}
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 088b10d..7b96223 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
@@ -81,6 +81,11 @@ public class CommitTransactionRequest extends CDOClientRequest<CommitTransaction
for (CDOPackage newPackage : newPackages)
{
+ if (PROTOCOL.isEnabled())
+ {
+ PROTOCOL.format("Writing package {0}", newPackage);
+ }
+
CDOModelUtil.writePackage(out, newPackage);
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/OpenSessionRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/OpenSessionRequest.java
index d8d3def..c8c5c24 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/OpenSessionRequest.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/OpenSessionRequest.java
@@ -112,12 +112,14 @@ public class OpenSessionRequest extends RequestWithConfirmation<OpenSessionResul
boolean dynamic = in.readBoolean();
CDOIDMetaRange metaIDRange = CDOIDUtil.readMetaRange(in);
+ String parentURI = in.readString();
if (PROTOCOL.isEnabled())
{
- PROTOCOL.format("Read package info: uri={0}, dynamic={1}, metaIDRange={2}", packageURI, dynamic, metaIDRange);
+ PROTOCOL.format("Read package info: uri={0}, dynamic={1}, metaIDRange={2}, parentURI={3}", packageURI, dynamic,
+ metaIDRange, parentURI);
}
- result.addPackageInfo(packageURI, dynamic, metaIDRange);
+ result.addPackageInfo(packageURI, dynamic, metaIDRange, parentURI);
}
return result;
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/OpenSessionResult.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/OpenSessionResult.java
index a736181..4f5a48b 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/OpenSessionResult.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/OpenSessionResult.java
@@ -57,8 +57,8 @@ public final class OpenSessionResult
return packageInfos;
}
- void addPackageInfo(String packageURI, boolean dynamic, CDOIDMetaRange metaIDRange)
+ void addPackageInfo(String packageURI, boolean dynamic, CDOIDMetaRange metaIDRange, String parentURI)
{
- packageInfos.add(new CDOPackageInfo(packageURI, dynamic, metaIDRange));
+ packageInfos.add(new CDOPackageInfo(packageURI, dynamic, metaIDRange, parentURI));
}
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ModelUtil.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ModelUtil.java
index 749a96b..2d4caa2 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ModelUtil.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ModelUtil.java
@@ -57,6 +57,13 @@ public final class ModelUtil
{
}
+ public static String getParentURI(EPackage ePackage)
+ {
+ EPackage superPackage = ePackage.getESuperPackage();
+ String parentURI = superPackage == null ? null : superPackage.getNsURI();
+ return parentURI;
+ }
+
public static CDOType getCDOType(EStructuralFeature eFeature)
{
if (eFeature instanceof EReference)
@@ -151,20 +158,15 @@ public final class ModelUtil
private static CDOPackage createCDOPackage(EPackage ePackage, CDOSessionPackageManagerImpl packageManager)
{
String packageURI = ePackage.getNsURI();
+ String parentURI = getParentURI(ePackage);
String name = ePackage.getName();
boolean dynamic = EMFUtil.isDynamicEPackage(ePackage);
- // String ecore = dynamic ? EMFUtil.ePackageToString(ePackage) : null;
- // TODO Serialize EcorePackage.eINSTANCE, too
- // Current problem with EcorePackage.eINSTANCE is mutual modification of
- // certain Ecore features (see newsgroup thread "eGenericSuperTypes" and
- // EMFUtil.getPersistentFeatures()
-
- String ecore = EcorePackage.eINSTANCE.getNsURI().equals(packageURI) ? null : EMFUtil.ePackageToString(ePackage,
- packageManager.getSession().getPackageRegistry());
- // String ecore = EMFUtil.ePackageToString(ePackage);
+ String ecore = parentURI == null || EcorePackage.eINSTANCE.getNsURI().equals(packageURI) ? null : EMFUtil
+ .ePackageToString(ePackage, packageManager.getSession().getPackageRegistry());
CDOIDMetaRange idRange = packageManager.getSession().registerEPackage(ePackage);
- CDOPackage cdoPackage = CDOModelUtil.createPackage(packageManager, packageURI, name, ecore, dynamic, idRange);
+ CDOPackage cdoPackage = CDOModelUtil.createPackage(packageManager, packageURI, name, ecore, dynamic, idRange,
+ parentURI);
initializeCDOPackage(ePackage, cdoPackage);
return cdoPackage;
}