Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2013-03-19 12:49:34 -0400
committerEike Stepper2013-03-19 12:49:34 -0400
commit57564f9b21425b1e63542c157562747ded6e93f5 (patch)
treea5bfbbe61852d4fbde10303232d4ab8bac382b71
parentf4fdf66cc3fc6ad4d4e8e42031a4cbe10ad38510 (diff)
downloadcdo-57564f9b21425b1e63542c157562747ded6e93f5.tar.gz
cdo-57564f9b21425b1e63542c157562747ded6e93f5.tar.xz
cdo-57564f9b21425b1e63542c157562747ded6e93f5.zip
[403681] [Legacy] Regression in persistence of Ecore models (e.g., indrops/S20130319-1252
UML Profiles) https://bugs.eclipse.org/bugs/show_bug.cgi?id=403681
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_403681_Test.java91
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOObjectWrapperBase.java12
2 files changed, 102 insertions, 1 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_403681_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_403681_Test.java
new file mode 100644
index 0000000000..46529dcaa7
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_403681_Test.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2004 - 2013 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Christian W. Damus (CEA) - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.config.IModelConfig;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.Requires;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.EcoreFactory;
+
+/**
+ * Bug 403681: Tests the persistence of the {@linkplain EStructuralFeature#getEType() eType} references
+ * (derived from {@linkplain EStructuralFeature#getEGenericType() eGenericType}) of Ecore features.
+ *
+ * @author Christian W. Damus (CEA)
+ */
+@Requires(IModelConfig.CAPABILITY_LEGACY)
+public class Bugzilla_403681_Test extends AbstractCDOTest
+{
+ public void testImportEStructuralFeatureTypes() throws Exception
+ {
+ CDOSession session = openSession();
+
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("localtest.ecore"));
+
+ // Add the package
+ resource.getContents().add(createTestPackage());
+
+ transaction.commit();
+ transaction.close();
+
+ // Load the package again in a new transaction
+ transaction = session.openTransaction();
+ resource = transaction.getResource(getResourcePath("localtest.ecore"));
+
+ assertEquals(resource.getContents().isEmpty(), false);
+ EPackage ePackage = (EPackage)resource.getContents().get(0);
+
+ for (EClassifier next : ePackage.getEClassifiers())
+ {
+ if (next instanceof EClass)
+ {
+ for (EStructuralFeature feature : ((EClass)next).getEStructuralFeatures())
+ {
+ assertNotNull("EStructuralFeature is missing its eType", feature.getEType());
+ }
+ }
+ }
+ }
+
+ protected EPackage createTestPackage()
+ {
+ EPackage result = EcoreFactory.eINSTANCE.createEPackage();
+ result.setName("localtest");
+ result.setNsPrefix("ltest");
+ result.setNsURI("http://www.eclipse.org/schema/cdo/test/localtest");
+
+ EClass classA = EcoreFactory.eINSTANCE.createEClass();
+ classA.setName("A");
+ result.getEClassifiers().add(classA);
+
+ EClass classB = EcoreFactory.eINSTANCE.createEClass();
+ classB.setName("B");
+ result.getEClassifiers().add(classB);
+
+ EReference b_a = EcoreFactory.eINSTANCE.createEReference();
+ b_a.setName("a");
+ b_a.setLowerBound(0);
+ b_a.setEType(classA);
+ classB.getEStructuralFeatures().add(b_a);
+
+ return result;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOObjectWrapperBase.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOObjectWrapperBase.java
index c2d7897e01..e582369ab3 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOObjectWrapperBase.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOObjectWrapperBase.java
@@ -7,6 +7,7 @@
*
* Contributors:
* Eike Stepper - initial API and implementation
+ * Christian W. Damus - Fix failure to attach CDOLegacyAdapter to EGenericTypes (bug 403681)
*/
package org.eclipse.emf.internal.cdo.object;
@@ -341,11 +342,20 @@ public abstract class CDOObjectWrapperBase implements CDOObject, InternalEObject
public boolean eIsSet(EStructuralFeature feature)
{
- return instance.eIsSet(feature);
+ return isSetInstanceValue(instance, feature);
}
public boolean eIsSet(int featureID)
{
+ // Features that need special handling
+ if (featureID == EcorePackage.ETYPED_ELEMENT__EGENERIC_TYPE
+ || featureID == EcorePackage.ECLASSIFIER__INSTANCE_TYPE_NAME
+ || featureID == EcorePackage.ECLASS__EGENERIC_SUPER_TYPES
+ || featureID == EcorePackage.EOPERATION__EGENERIC_EXCEPTIONS)
+ {
+ return isSetInstanceValue(instance, instance.eClass().getEStructuralFeature(featureID));
+ }
+
return instance.eIsSet(featureID);
}

Back to the top