Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2013-01-06 18:59:09 +0000
committerChristian W. Damus2013-01-06 19:00:41 +0000
commit53d0b136b63e086d7af9865be12b0c51abac7288 (patch)
tree27f03aac889adfca6d39fe8f8ae00001c96d5bf2 /plugins
parentb3750dcebc2bb70a7e6547f329e1e1054f6a2adb (diff)
downloadcdo-53d0b136b63e086d7af9865be12b0c51abac7288.tar.gz
cdo-53d0b136b63e086d7af9865be12b0c51abac7288.tar.xz
cdo-53d0b136b63e086d7af9865be12b0c51abac7288.zip
[378620] [Legacy] ClassCastException in unsettable attribute of Custom Datatype
https://bugs.eclipse.org/bugs/show_bug.cgi?id=378620
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOTypeImpl.java9
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AttributeTest.java42
2 files changed, 47 insertions, 4 deletions
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOTypeImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOTypeImpl.java
index fbd2724e8d..cfb23b8e55 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOTypeImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOTypeImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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
@@ -9,6 +9,7 @@
* Eike Stepper - initial API and implementation
* Stefan Winkler - Bug 299194: unsettable features inconsistent between revisions
* Erdal Karaca - added support for HASHMAP CDO Type
+ * Christian W. Damus (CEA) - 378620 support unsettable features of custom data type
*/
package org.eclipse.emf.cdo.internal.common.model;
@@ -34,6 +35,7 @@ import org.eclipse.emf.ecore.EEnum;
import org.eclipse.emf.ecore.EEnumLiteral;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.EStructuralFeature.Internal.DynamicValueHolder;
import org.eclipse.emf.ecore.EcorePackage;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.util.FeatureMap;
@@ -569,13 +571,14 @@ public abstract class CDOTypeImpl implements CDOType
@Override
public Object convertToEMF(EClassifier eType, Object value)
{
- return EcoreUtil.createFromString((EDataType)eType, (String)value);
+ return value == CDORevisionData.NIL ? DynamicValueHolder.NIL : EcoreUtil.createFromString((EDataType)eType,
+ (String)value);
}
@Override
public Object convertToCDO(EClassifier eType, Object value)
{
- return EcoreUtil.convertToString((EDataType)eType, value);
+ return value == DynamicValueHolder.NIL ? CDORevisionData.NIL : EcoreUtil.convertToString((EDataType)eType, value);
}
};
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AttributeTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AttributeTest.java
index 7285fe572f..92d7725f8b 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AttributeTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AttributeTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * 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
@@ -8,6 +8,7 @@
* Contributors:
* Eike Stepper - initial API and implementation
* Simon McDuff - maintenance
+ * Christian W. Damus (CEA) - 378620 support unsettable features of custom data type
*/
package org.eclipse.emf.cdo.tests;
@@ -22,6 +23,7 @@ import org.eclipse.emf.cdo.tests.model3.ClassWithJavaObjectAttribute;
import org.eclipse.emf.cdo.tests.model3.Point;
import org.eclipse.emf.cdo.tests.model3.Polygon;
import org.eclipse.emf.cdo.tests.model3.PolygonWithDuplicates;
+import org.eclipse.emf.cdo.tests.model6.HasNillableAttribute;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.emf.cdo.view.CDOView;
@@ -914,4 +916,42 @@ public class AttributeTest extends AbstractCDOTest
object.setJavaObject(javaObject);
return object;
}
+
+ /**
+ * Bug 378620.
+ */
+ public void testNillableAttributeOfCustomType() throws Exception
+ {
+ HasNillableAttribute hasNonNull = getModel6Factory().createHasNillableAttribute();
+ hasNonNull.setNillable("not nil");
+ HasNillableAttribute hasImplicitNull = getModel6Factory().createHasNillableAttribute();
+ hasImplicitNull.unsetNillable(); // implicit null
+ HasNillableAttribute hasExplicitNull = getModel6Factory().createHasNillableAttribute();
+ hasExplicitNull.setNillable(null); // explicit null
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/my/nillable"));
+ resource.getContents().add(hasNonNull);
+ resource.getContents().add(hasImplicitNull);
+ resource.getContents().add(hasExplicitNull);
+ transaction.commit();
+ session.close();
+
+ session = openSession();
+ transaction = session.openTransaction();
+ resource = transaction.getResource(getResourcePath("/my/nillable"));
+ EList<EObject> contents = resource.getContents();
+ assertEquals(3, contents.size());
+
+ HasNillableAttribute hasNillable = (HasNillableAttribute)contents.get(0);
+ assertEquals("not nil", hasNillable.getNillable());
+ assertEquals(true, hasNillable.isSetNillable());
+ hasNillable = (HasNillableAttribute)contents.get(1);
+ assertNull(hasNillable.getNillable());
+ assertEquals(false, hasNillable.isSetNillable());
+ hasNillable = (HasNillableAttribute)contents.get(2);
+ assertNull(hasNillable.getNillable());
+ assertEquals(true, hasNillable.isSetNillable());
+ }
}

Back to the top