Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Taal2012-11-08 07:27:37 -0500
committerMartin Taal2012-11-08 07:27:37 -0500
commit78326471dcb1b490c85271d45efe86c3e76c8191 (patch)
treef27e3076fc4a909bcfd361eacf45925218b278ad /plugins/org.eclipse.emf.cdo.server.hibernate.teneo
parent0a7004d5082934bcbb55df64c877ae5ce68b35b8 (diff)
downloadcdo-78326471dcb1b490c85271d45efe86c3e76c8191.tar.gz
cdo-78326471dcb1b490c85271d45efe86c3e76c8191.tar.xz
cdo-78326471dcb1b490c85271d45efe86c3e76c8191.zip
[244141] - [Hibernate] Store to support auditing mode
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.server.hibernate.teneo')
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate.teneo/META-INF/MANIFEST.MF33
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/internal/teneo/TeneoHibernateMappingProvider.java54
2 files changed, 59 insertions, 28 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/META-INF/MANIFEST.MF
index 53c3583521..05c7f2c9c8 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/META-INF/MANIFEST.MF
@@ -11,20 +11,23 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)",
org.eclipse.emf.ecore.xmi;bundle-version="[2.4.0,3.0.0)",
org.eclipse.emf.cdo;bundle-version="[4.0.0,5.0.0)",
org.eclipse.emf.cdo.server;bundle-version="[4.0.0,5.0.0)",
- org.eclipse.emf.cdo.common;bundle-version="[4.0.0,5.0.0)",
- org.eclipse.emf.cdo.server.hibernate;bundle-version="[4.0.0,5.0.0)"
-Import-Package: org.eclipse.emf.teneo;version="[2.0.0,3.0.0)",
- org.eclipse.emf.teneo.annotations.mapper;version="[2.0.0,3.0.0)",
- org.eclipse.emf.teneo.annotations.pamodel;version="[2.0.0,3.0.0)",
- org.eclipse.emf.teneo.annotations.pannotation;version="[2.0.0,3.0.0)",
- org.eclipse.emf.teneo.annotations.xml;version="[2.0.0,3.0.0)",
- org.eclipse.emf.teneo.extension;version="[2.0.0,3.0.0)",
- org.eclipse.emf.teneo.hibernate.annotations;version="[2.0.0,3.0.0)",
- org.eclipse.emf.teneo.hibernate.mapper;version="[2.0.0,3.0.0)",
- org.eclipse.emf.teneo.hibernate.hbannotation;version="[2.0.0,3.0.0)",
- org.eclipse.emf.teneo.simpledom;version="[2.0.0,3.0.0)"
-Export-Package: org.eclipse.emf.cdo.server.hibernate.internal.teneo;version="4.1.100";x-friends:="org.eclipse.emf.cdo.tests.hibernate",
- org.eclipse.emf.cdo.server.hibernate.internal.teneo.bundle;version="4.1.100";x-friends:="org.eclipse.emf.cdo.tests.hibernate",
- org.eclipse.emf.cdo.server.hibernate.teneo;version="4.1.100"
+ org.eclipse.emf.cdo.common;bundle-version="[4.0.0,5.0.0)"
+Import-Package: org.eclipse.emf.cdo.security;version="[4.0.0,5.0.0)",
+ org.eclipse.emf.cdo.server.hibernate;version="[4.0.0,5.0.0)",
+ org.eclipse.emf.cdo.server.internal.hibernate;version="[4.0.0,5.0.0)",
+ org.eclipse.emf.cdo.server.internal.hibernate.tuplizer;version="[4.0.0,5.0.0)",
+ org.eclipse.emf.teneo;version="[2.0.1,3.0.0)",
+ org.eclipse.emf.teneo.annotations.mapper;version="[2.0.1,3.0.0)",
+ org.eclipse.emf.teneo.annotations.pamodel;version="[2.0.1,3.0.0)",
+ org.eclipse.emf.teneo.annotations.pannotation;version="[2.0.1,3.0.0)",
+ org.eclipse.emf.teneo.annotations.xml;version="[2.0.1,3.0.0)",
+ org.eclipse.emf.teneo.extension;version="[2.0.1,3.0.0)",
+ org.eclipse.emf.teneo.hibernate.annotations;version="[2.0.1,3.0.0)",
+ org.eclipse.emf.teneo.hibernate.hbannotation;version="[2.0.1,3.0.0)",
+ org.eclipse.emf.teneo.hibernate.mapper;version="[2.0.1,3.0.0)",
+ org.eclipse.emf.teneo.simpledom;version="[2.0.1,3.0.0)"
+Export-Package: org.eclipse.emf.cdo.server.hibernate.internal.teneo;version="4.2.0";x-friends:="org.eclipse.emf.cdo.tests.hibernate",
+ org.eclipse.emf.cdo.server.hibernate.internal.teneo.bundle;version="4.2.0";x-friends:="org.eclipse.emf.cdo.tests.hibernate",
+ org.eclipse.emf.cdo.server.hibernate.teneo;version="4.2.0"
Bundle-ActivationPolicy: lazy
Bundle-Activator: org.eclipse.emf.cdo.server.hibernate.internal.teneo.bundle.OM$Activator
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/internal/teneo/TeneoHibernateMappingProvider.java b/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/internal/teneo/TeneoHibernateMappingProvider.java
index 006013a38b..09b729c7e7 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/internal/teneo/TeneoHibernateMappingProvider.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate.teneo/src/org/eclipse/emf/cdo/server/hibernate/internal/teneo/TeneoHibernateMappingProvider.java
@@ -11,9 +11,9 @@
*/
package org.eclipse.emf.cdo.server.hibernate.internal.teneo;
-import org.eclipse.emf.cdo.common.model.CDOModelUtil;
import org.eclipse.emf.cdo.eresource.EresourcePackage;
import org.eclipse.emf.cdo.etypes.EtypesPackage;
+import org.eclipse.emf.cdo.security.SecurityPackage;
import org.eclipse.emf.cdo.server.hibernate.internal.teneo.bundle.OM;
import org.eclipse.emf.cdo.server.hibernate.teneo.CDOMappingGenerator;
import org.eclipse.emf.cdo.server.internal.hibernate.CDOHibernateConstants;
@@ -96,6 +96,7 @@ public class TeneoHibernateMappingProvider extends HibernateMappingProvider
// merge the store properties with the mapping provider properties
// the mapping provider props take precedence
+ // this also prevents overwriting the original properties
final Properties properties = new Properties();
properties.putAll(storeProperties);
@@ -106,19 +107,18 @@ public class TeneoHibernateMappingProvider extends HibernateMappingProvider
// translate the list of EPackages to an array
boolean hasXMLTypePackage = false;
- final List<EPackage> epacks = getHibernateStore().getPackageHandler().getEPackages();
+ final List<EPackage> epacks = getHibernateStore().getModelEPackages();
final ListIterator<EPackage> iterator = epacks.listIterator();
while (iterator.hasNext())
{
final EPackage epack = iterator.next();
- if (CDOModelUtil.isSystemPackage(epack) && epack != EtypesPackage.eINSTANCE)
+ if (epack == XMLTypePackage.eINSTANCE)
{
- iterator.remove();
+ hasXMLTypePackage = true;
}
- else if (epack == XMLTypePackage.eINSTANCE)
+ if (SecurityPackage.eNS_URI.equals(epack.getNsURI()))
{
- hasXMLTypePackage = true;
- // iterator.remove();
+ setEntityOnSecurityModel(epack);
}
}
@@ -151,11 +151,30 @@ public class TeneoHibernateMappingProvider extends HibernateMappingProvider
// to solve an issue with older versions of teneo
hbm = hbm.replaceAll("_cont", "cont"); //$NON-NLS-1$ //$NON-NLS-2$
- // System.err.println(hbm);
+ System.err.println(hbm);
return hbm;
}
+ private void setEntityOnSecurityModel(EPackage ePackage)
+ {
+ for (EClassifier eClassifier : ePackage.getEClassifiers())
+ {
+ if (eClassifier instanceof EClass)
+ {
+ final EClass eClass = (EClass)eClassifier;
+ if (eClass.getEAnnotation(Constants.ANNOTATION_SOURCE_TENEO_JPA) != null)
+ {
+ return;
+ }
+ final EAnnotation eAnnotation = EcoreFactory.eINSTANCE.createEAnnotation();
+ eAnnotation.setSource(Constants.ANNOTATION_SOURCE_TENEO_JPA);
+ eAnnotation.getDetails().put("value", "@Entity(name=\"CdoSecurity" + eClass.getName() + "\")");
+ eClass.getEAnnotations().add(eAnnotation);
+ }
+ }
+ }
+
private void addTypeAnnotationToXMLTypes()
{
for (EClassifier eClassifier : XMLTypePackage.eINSTANCE.getEClassifiers())
@@ -185,11 +204,20 @@ public class TeneoHibernateMappingProvider extends HibernateMappingProvider
return;
}
- final EAnnotation eAnnotation = EcoreFactory.eINSTANCE.createEAnnotation();
- eAnnotation.setSource(Constants.ANNOTATION_SOURCE_TENEO_JPA);
- final String typeAnnotation = "@Type(type=\"" + type + "\")";
- eAnnotation.getDetails().put("value", typeAnnotation);
- eDataType.getEAnnotations().add(eAnnotation);
+ {
+ final EAnnotation eAnnotation = EcoreFactory.eINSTANCE.createEAnnotation();
+ eAnnotation.setSource(Constants.ANNOTATION_SOURCE_TENEO_JPA);
+ final String typeAnnotation = "@Type(type=\"" + type + "\")";
+ eAnnotation.getDetails().put("value", typeAnnotation);
+ eDataType.getEAnnotations().add(eAnnotation);
+ }
+ {
+ final EAnnotation eAnnotation = EcoreFactory.eINSTANCE.createEAnnotation();
+ eAnnotation.setSource(Constants.ANNOTATION_SOURCE_TENEO_JPA_AUDITING);
+ final String typeAnnotation = "@Type(type=\"" + type + "\")";
+ eAnnotation.getDetails().put("value", typeAnnotation);
+ eDataType.getEAnnotations().add(eAnnotation);
+ }
}
private void addTransientAnnotationToEClass(EClass eClass)

Back to the top