Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Taal2012-11-26 14:36:58 +0000
committerMartin Taal2012-11-26 14:36:58 +0000
commit421263b831c9735011581132d70097e782335cad (patch)
tree666b43c897580c2ae0342e0c5c270082a91a465a /hibernate
parent163d5be47a9906ccf3dc4db81aeca59b7fb27bf3 (diff)
downloadorg.eclipse.emf.teneo-421263b831c9735011581132d70097e782335cad.tar.gz
org.eclipse.emf.teneo-421263b831c9735011581132d70097e782335cad.tar.xz
org.eclipse.emf.teneo-421263b831c9735011581132d70097e782335cad.zip
EAnnotation of primitive eattributes is re-used for auditing
Diffstat (limited to 'hibernate')
-rw-r--r--hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/auditing/AuditHandler.java23
1 files changed, 16 insertions, 7 deletions
diff --git a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/auditing/AuditHandler.java b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/auditing/AuditHandler.java
index 56a037b4b..72c01a56a 100644
--- a/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/auditing/AuditHandler.java
+++ b/hibernate/org.eclipse.emf.teneo.hibernate/src/org/eclipse/emf/teneo/hibernate/auditing/AuditHandler.java
@@ -136,8 +136,7 @@ public class AuditHandler implements ExtensionPoint {
if (sourceEFeature.isMany()) {
if (StoreUtil.isMap(sourceEFeature)) {
convertEMap(session, ((Collection<?>) source.eGet(sourceEFeature)),
- (EReference) sourceEFeature, auditEntry,
- (EReference) targetEFeature);
+ (EReference) sourceEFeature, auditEntry, (EReference) targetEFeature);
} else if (FeatureMapUtil.isFeatureMap(sourceEFeature)) {
convertFeatureMap(session, ((Collection<?>) source.eGet(sourceEFeature)),
sourceEFeature, auditEntry, targetEFeature);
@@ -213,7 +212,7 @@ public class AuditHandler implements ExtensionPoint {
if (eFeature.getEType() instanceof EEnum && value instanceof Integer) {
final int ordinal = (Integer) value;
- final EEnum eeNum = (EEnum)eFeature.getEType();
+ final EEnum eeNum = (EEnum) eFeature.getEType();
if (eeNum.getInstanceClass() != null && eeNum.getInstanceClass().isEnum()) {
final Object[] constants = eeNum.getInstanceClass().getEnumConstants();
for (Object constant : constants) {
@@ -226,9 +225,9 @@ public class AuditHandler implements ExtensionPoint {
}
return constants[ordinal];
}
- return eeNum.getEEnumLiteral((Integer)value);
+ return eeNum.getEEnumLiteral((Integer) value);
}
-
+
if (eFeature instanceof EReference && ((EReference) eFeature).isContainment()) {
return EcoreUtil.copy((EObject) value);
}
@@ -645,8 +644,9 @@ public class AuditHandler implements ExtensionPoint {
}
// get rid of all teneo.jpa eannotations
- auditingEFeature.getEAnnotations().remove(
- auditingEFeature.getEAnnotation(Constants.ANNOTATION_SOURCE_TENEO_JPA));
+ final EAnnotation jpaEAnnotation = auditingEFeature
+ .getEAnnotation(Constants.ANNOTATION_SOURCE_TENEO_JPA);
+ auditingEFeature.getEAnnotations().remove(jpaEAnnotation);
auditingEFeature.getEAnnotations().remove(
auditingEFeature.getEAnnotation(Constants.ANNOTATION_SOURCE_TENEO_HIBERNATE));
// re-use the other ones
@@ -661,7 +661,16 @@ public class AuditHandler implements ExtensionPoint {
Constants.ANNOTATION_SOURCE_TENEO_JPA_AUDITING));
teneoAnnotation.setSource(Constants.ANNOTATION_SOURCE_TENEO_JPA);
auditingEFeature.getEAnnotations().add(teneoAnnotation);
+ } else if (jpaEAnnotation != null && eFeature instanceof EAttribute && !eFeature.isMany()) {
+ // check if the annotation is @Id or @Version, ignore these
+ final String value = jpaEAnnotation.getDetails().get(Constants.ANNOTATION_KEY_VALUE)
+ + jpaEAnnotation.getDetails().get(Constants.ANNOTATION_KEY_APPINFO);
+ if (!value.contains("@Id") && !value.contains("@Version")) {
+ // reuse the eannotations on eattributes
+ auditingEFeature.getEAnnotations().add(EcoreUtil.copy(jpaEAnnotation));
+ }
}
+
// never be an id
if (auditingEFeature instanceof EAttribute) {
((EAttribute) auditingEFeature).setID(false);

Back to the top