ref #6360 and ref #6369 update cached model in taxeditor
authorAndreas Müller <a.mueller@bgbm.org>
Thu, 26 Jan 2017 13:26:04 +0000 (14:26 +0100)
committerAndreas Müller <a.mueller@bgbm.org>
Thu, 26 Jan 2017 13:26:04 +0000 (14:26 +0100)
eu.etaxonomy.taxeditor.cdmlib/resources/cdm.map.ser
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/remoting/cache/CdmModelCacher.java
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/remoting/cache/CdmModelCacherConnectionProvider.java
eu.etaxonomy.taxeditor.cdmlib/src/main/resources/eu/etaxonomy/cdm/mappings/hibernate.cfg.xml

index 2579773260a2facc141046eae6f28a9c92bb8880..f9658fb2e6295ec939b04252275eb8e2637c6a7f 100644 (file)
Binary files a/eu.etaxonomy.taxeditor.cdmlib/resources/cdm.map.ser and b/eu.etaxonomy.taxeditor.cdmlib/resources/cdm.map.ser differ
index 0ba73ba4e70b9c47ddef3871586edf772213692b..af18a29a979ff7aefd45a9e53dad26eedf018461 100644 (file)
@@ -30,11 +30,18 @@ import org.hibernate.property.access.spi.Getter;
 import org.osgi.framework.Bundle;
 
 
+/**
+ * This class serializing and deserializing the CDM model for performance purposes.
+ * To serialize it see the comments on {@link #main(String[])} and on 
+ * https://dev.e-taxonomy.eu/redmine/projects/edit/wiki/TaxonomicEditorDevelopersGuide#Model-Change-Actions
+ * 
+ * @author c.mathew
+ * @date 2015
+ *
+ */
 public class CdmModelCacher {
 
 
-
-
     public static String HB_CONFIG_FILE_PATH= "/eu/etaxonomy/cdm/mappings/hibernate.cfg.xml";
 
     public static final String CDM_MAP_SER_FILE_PATH = "resources/cdm.map.ser";
@@ -62,7 +69,8 @@ public class CdmModelCacher {
 
         FileInputStream fin = new FileInputStream(modelMapFilePath);
         ObjectInputStream ois = new ObjectInputStream(fin);
-        Map<String, CdmModelFieldPropertyFromClass> modelClassMap = (Map<String, CdmModelFieldPropertyFromClass>) ois.readObject();
+        @SuppressWarnings("unchecked")
+               Map<String, CdmModelFieldPropertyFromClass> modelClassMap = (Map<String, CdmModelFieldPropertyFromClass>) ois.readObject();
         ois.close();
         return modelClassMap;
     }
@@ -143,6 +151,8 @@ public class CdmModelCacher {
         // To re-create the serialised cdm map run,
         // mvn exec:java -Dexec.mainClass="eu.etaxonomy.taxeditor.remoting.cache.CdmModelCacher"
         // in the eu.etaxonomy.taxeditor.cdmlib project root dir
+       // See also https://dev.e-taxonomy.eu/redmine/projects/edit/wiki/TaxonomicEditorDevelopersGuide#Model-Change-Actions
+       //Note AM: does not fully work for me, but running the main from the IDE works. 
         String CDM_MAP_SER_DIR = "resources/";
 
         CdmModelCacher cdmModelCacher = new CdmModelCacher();
index 097c3b496698d0ba7e926c20b959b467cb16ce7f..dacfcfecc0e53feef4eece5905533883911c5b87 100644 (file)
@@ -14,6 +14,7 @@ import eu.etaxonomy.cdm.database.CdmDataSource;
  *
  */
 public class CdmModelCacherConnectionProvider extends DatasourceConnectionProviderImpl{
+       private static final long serialVersionUID = 454393966637126346L;
 
        public CdmModelCacherConnectionProvider() {
                super();
index 954af2e222f82cbb828bdfb9cc52df53433d4a4c..fb4446a232aa862d2598e9c959dcd5b1c6df1998 100644 (file)
@@ -8,9 +8,13 @@
 
       <property name="connection.release_mode">after_transaction</property>
 
+      <property name="hibernate.implicit_naming_strategy">org.hibernate.boot.model.naming.ImplicitNamingStrategyComponentPathImpl</property>
       <!-- Connection Pooling -->
 <!--       <property name="hibernate.connection.provider_class">org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider</property> -->
-      <property name="hibernate.connection.provider_class">org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl</property>
+<!--       <property name="hibernate.connection.provider_class">org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl</property> -->
+         <property name="hibernate.connection.provider_class">eu.etaxonomy.taxeditor.remoting.cache.CdmModelCacherConnectionProvider</property>
+          
            <!--
           Configuring the C3P0ConnectionProvider
           ========================================