Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Taal2015-01-18 11:15:30 -0500
committerMartin Taal2015-01-18 11:15:30 -0500
commitb5f4566231f4f6f5f64c12227613656a46c4374f (patch)
tree0a9641a09a9ce891af9ecaa579d0186ed3207b5f /generator/org.eclipse.emf.texo.orm
parentead3ddc8022e4a3c9867c2bedd4b2805bdee35ba (diff)
downloadorg.eclipse.emf.texo-b5f4566231f4f6f5f64c12227613656a46c4374f.tar.gz
org.eclipse.emf.texo-b5f4566231f4f6f5f64c12227613656a46c4374f.tar.xz
org.eclipse.emf.texo-b5f4566231f4f6f5f64c12227613656a46c4374f.zip
[423155] Fixes - @AttributeOverride(s) from annotation model not generated
Diffstat (limited to 'generator/org.eclipse.emf.texo.orm')
-rwxr-xr-xgenerator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/EReferenceORMAnnotator.java13
-rwxr-xr-xgenerator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/ORMGenerator.java28
-rw-r--r--generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/ORMJavaAnnotationGenerator.java4
3 files changed, 40 insertions, 5 deletions
diff --git a/generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/EReferenceORMAnnotator.java b/generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/EReferenceORMAnnotator.java
index 1614b764..8cd8c353 100755
--- a/generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/EReferenceORMAnnotator.java
+++ b/generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/EReferenceORMAnnotator.java
@@ -55,7 +55,7 @@ import org.eclipse.emf.texo.utils.ModelUtils;
*/
public class EReferenceORMAnnotator extends EStructuralFeatureORMAnnotator implements
- Annotator<EReferenceORMAnnotation> {
+Annotator<EReferenceORMAnnotation> {
/*
* (non-Javadoc)
@@ -91,7 +91,7 @@ public class EReferenceORMAnnotator extends EStructuralFeatureORMAnnotator imple
final EReference eOpposite = eReference.getEOpposite();
if (!isPartOfFeatureMap && eReference.isMany()) {
- if (doAddConverter(eReferenceModelGenAnnotation)) {
+ if (doAddConverter(eReferenceModelGenAnnotation) || annotation.getEmbedded() != null) {
addElementCollection(annotation);
} else if (annotation.getElementCollection() != null) {
annotateElementCollection(annotation);
@@ -143,6 +143,15 @@ public class EReferenceORMAnnotator extends EStructuralFeatureORMAnnotator imple
final EReferenceModelGenAnnotation eReferenceModelGenAnnotation = (EReferenceModelGenAnnotation) getAnnotationManager()
.getAnnotation(eReference, ModelcodegeneratorPackage.eINSTANCE.getEReferenceModelGenAnnotation());
+ // clear the embedded, we can only have one of the two...
+ if (annotation.getEmbedded() != null) {
+ annotation.getElementCollection().getAttributeOverride().addAll(annotation.getEmbedded().getAttributeOverride());
+ annotation.getElementCollection().getAssociationOverride()
+ .addAll(annotation.getEmbedded().getAssociationOverride());
+ annotation.getElementCollection().setAttributeType(annotation.getEmbedded().getAttributeType());
+ annotation.setEmbedded(null);
+ }
+
final ElementCollection elementCollection = annotation.getElementCollection();
// make the access field if not changeable, as there won't be a setter
diff --git a/generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/ORMGenerator.java b/generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/ORMGenerator.java
index 6e2bcfec..d44943c8 100755
--- a/generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/ORMGenerator.java
+++ b/generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/ORMGenerator.java
@@ -120,7 +120,9 @@ public class ORMGenerator extends BaseGenerateAction {
}
final Object value = annotationOwner.eGet(eReference);
- if (value instanceof BaseOrmAnnotation) {
+ if (value instanceof Collection<?>) {
+ sb.append(getAnnotationArray((EClass) eReference.getEType(), identifier, (Collection<?>) value));
+ } else if (value instanceof BaseOrmAnnotation) {
if (sb.length() > 0) {
sb.append("\n"); //$NON-NLS-1$
}
@@ -131,6 +133,30 @@ public class ORMGenerator extends BaseGenerateAction {
return sb.toString();
}
+ // handle a list of annotations
+ private static String getAnnotationArray(EClass eClassifier, String identifier, Collection<?> annotations) {
+ final StringBuffer sb = new StringBuffer();
+ sb.append("\n@" + ORMJavaAnnotationGenerator.getInstance().getJavaPackage(eClassifier) + "."
+ + eClassifier.getName() + "s({");
+ boolean validContent = false;
+ for (Object value : annotations) {
+ if (value instanceof BaseOrmAnnotation) {
+ if (validContent) {
+ sb.append(", ");
+ }
+ sb.append("\n"); //$NON-NLS-1$
+ sb.append(((BaseOrmAnnotation) value).getJavaAnnotation(identifier));
+ validContent = true;
+ }
+ }
+
+ if (!validContent) {
+ return "";
+ }
+ sb.append("\n})");
+ return sb.toString();
+ }
+
// if the type has an accesstype set then generate the javaannotation
// on the correct location
private static boolean isValidIdentifier(EObject annotation, String identifier) {
diff --git a/generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/ORMJavaAnnotationGenerator.java b/generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/ORMJavaAnnotationGenerator.java
index 60ae121e..51543f0c 100644
--- a/generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/ORMJavaAnnotationGenerator.java
+++ b/generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/ORMJavaAnnotationGenerator.java
@@ -210,7 +210,7 @@ public class ORMJavaAnnotationGenerator {
continue;
}
separateAnnotation
- .append("@" + getJavaPackage(eFeature.getEType()) + "." + pluralize(upperCaseFirst(getName(eFeature))) + "({"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ .append("@" + getJavaPackage(eFeature.getEType()) + "." + pluralize(upperCaseFirst(getName(eFeature))) + "({"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
boolean addArrayComma = false;
for (Object val : values) {
if (val instanceof BaseOrmAnnotation) {
@@ -327,7 +327,7 @@ public class ORMJavaAnnotationGenerator {
+ "." + enumerator.getLiteral() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
}
- private String getJavaPackage(EClassifier eClassifier) {
+ public String getJavaPackage(EClassifier eClassifier) {
for (EClassifier chkEClassifier : eclipseLinkEClassifiers) {
if (chkEClassifier == eClassifier) {

Back to the top