Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Taal2012-08-23 06:16:40 -0400
committerMartin Taal2012-08-23 06:16:40 -0400
commit1d2412017020d6e1ceedb01a1c8e1a693b7b5dd5 (patch)
tree30cb0fda85b681984cf3555e1457cbf277251cf1 /generator/org.eclipse.emf.texo.orm
parent60789ea13577740395c1dc410efe1394c654f50e (diff)
downloadorg.eclipse.emf.texo-1d2412017020d6e1ceedb01a1c8e1a693b7b5dd5.tar.gz
org.eclipse.emf.texo-1d2412017020d6e1ceedb01a1c8e1a693b7b5dd5.tar.xz
org.eclipse.emf.texo-1d2412017020d6e1ceedb01a1c8e1a693b7b5dd5.zip
Added test converter, updated orbit update site
Diffstat (limited to 'generator/org.eclipse.emf.texo.orm')
-rwxr-xr-xgenerator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/EAttributeORMAnnotator.java2
-rwxr-xr-xgenerator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/EClassORMAnnotator.java2
-rw-r--r--generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/EStructuralFeatureORMAnnotator.java24
-rw-r--r--generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/ORMUtils.java18
4 files changed, 46 insertions, 0 deletions
diff --git a/generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/EAttributeORMAnnotator.java b/generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/EAttributeORMAnnotator.java
index d746f3d4..ea988cda 100755
--- a/generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/EAttributeORMAnnotator.java
+++ b/generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/EAttributeORMAnnotator.java
@@ -227,6 +227,8 @@ public class EAttributeORMAnnotator extends EStructuralFeatureORMAnnotator imple
elementCollection.setColumn(column);
} else if (doAddConverter(eAttributeModelGen)) {
elementCollection.setConvert(ORMUtils.OBJECT_CONVERTER_NAME);
+ } else if (doAddQNameConverter(eAttributeModelGen)) {
+ elementCollection.setConvert(ORMUtils.QNAME_CONVERTER_NAME);
}
if (isEnum && elementCollection.getEnumerated() == null) {
diff --git a/generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/EClassORMAnnotator.java b/generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/EClassORMAnnotator.java
index 410b93a2..efac3f3d 100755
--- a/generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/EClassORMAnnotator.java
+++ b/generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/EClassORMAnnotator.java
@@ -93,8 +93,10 @@ public class EClassORMAnnotator extends ETypeElementORMAnnotator implements Anno
if (ORMMappingOptions.getDefaultOptions().isTestRun()) {
if (annotation.getEntity() != null) {
annotation.getEntity().getConverter().add(ORMUtils.createDefaultConverter());
+ annotation.getEntity().getConverter().add(ORMUtils.createQNameConverter());
} else if (annotation.getMappedSuperclass() != null) {
annotation.getMappedSuperclass().getConverter().add(ORMUtils.createDefaultConverter());
+ annotation.getMappedSuperclass().getConverter().add(ORMUtils.createQNameConverter());
}
}
diff --git a/generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/EStructuralFeatureORMAnnotator.java b/generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/EStructuralFeatureORMAnnotator.java
index f9d78288..14fd96d6 100644
--- a/generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/EStructuralFeatureORMAnnotator.java
+++ b/generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/EStructuralFeatureORMAnnotator.java
@@ -17,6 +17,9 @@
package org.eclipse.emf.texo.orm.annotator;
+import javax.xml.namespace.QName;
+
+import org.eclipse.emf.ecore.EClassifier;
import org.eclipse.emf.ecore.EEnum;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
@@ -32,6 +35,27 @@ import org.eclipse.emf.texo.utils.ModelUtils;
*/
public class EStructuralFeatureORMAnnotator extends ETypeElementORMAnnotator {
+ protected boolean doAddQNameConverter(EStructuralFeatureModelGenAnnotation annotation) {
+ final EStructuralFeature eFeature = annotation.getEStructuralFeature();
+ if (FeatureMapUtil.isFeatureMap(eFeature)) {
+ return false;
+ }
+ if (!ORMMappingOptions.getDefaultOptions().isTestRun()) {
+ return false;
+ }
+ if (annotation.getEStructuralFeature().getEType() instanceof EEnum) {
+ return false;
+ }
+ if (ModelUtils.isAnyType(eFeature)) {
+ return true;
+ }
+ final EClassifier eClassifier = eFeature.getEType();
+ if (eClassifier.getInstanceClass() != null && QName.class == eClassifier.getInstanceClass()) {
+ return true;
+ }
+ return false;
+ }
+
protected boolean doAddConverter(EStructuralFeatureModelGenAnnotation annotation) {
final EStructuralFeature eFeature = annotation.getEStructuralFeature();
if (FeatureMapUtil.isFeatureMap(eFeature)) {
diff --git a/generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/ORMUtils.java b/generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/ORMUtils.java
index 11351dc4..1ac14f8f 100644
--- a/generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/ORMUtils.java
+++ b/generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/ORMUtils.java
@@ -33,8 +33,13 @@ import org.eclipse.emf.texo.orm.ormannotations.EPackageORMAnnotation;
*/
public class ORMUtils {
+ /**
+ * Note the CONVERTER statics are used in Texo testing, not intended for general use.
+ */
public static final String OBJECT_CONVERTER_CLASS = "org.eclipse.emf.texo.test.TexoTestObjectConverter";
public static final String OBJECT_CONVERTER_NAME = "TexoTestObjectConverter";
+ public static final String QNAME_CONVERTER_CLASS = "org.eclipse.emf.texo.test.TexoTestQNameConverter";
+ public static final String QNAME_CONVERTER_NAME = "TexoTestQNameConverter";
/**
* Creates the default converter used to convert Objects to String and back.
@@ -50,6 +55,19 @@ public class ORMUtils {
}
/**
+ * Creates the default converter used to convert QNames to String and back.
+ *
+ * @see #QNAME_CONVERTER_CLASS
+ * @see #QNAME_CONVERTER_NAME
+ */
+ public static Converter createQNameConverter() {
+ final Converter converter = OrmFactory.eINSTANCE.createConverter();
+ converter.setClass(ORMUtils.QNAME_CONVERTER_CLASS);
+ converter.setName(ORMUtils.QNAME_CONVERTER_NAME);
+ return converter;
+ }
+
+ /**
* Reads project properties and creates a {@link ORMMappingOptions} object and sets it in the
* {@link ORMMappingOptions#setDefaultOptions(ORMMappingOptions)}. This is picked up during ORM and JPA code
* generation if there is no {@link EPackageORMAnnotation} for an {@link EPackage}.

Back to the top