improve logging and change signature
authorAndreas Müller <a.mueller@bgbm.org>
Sun, 3 Nov 2013 16:47:52 +0000 (16:47 +0000)
committerAndreas Müller <a.mueller@bgbm.org>
Sun, 3 Nov 2013 16:47:52 +0000 (16:47 +0000)
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/PersistentTermInitializer.java

index c60f14fb00ec0b5037c8a633e21709514c811f78..4c9620c385d18a99c7945d5017905d48545ba853 100644 (file)
@@ -145,7 +145,7 @@ public class PersistentTermInitializer extends DefaultTermInitializer {
                                vocabularyDao.saveOrUpdate(voc);\r
                        }\r
                    }\r
-                   initializeAndStore(vocabularyType.getClazz(),vocUuid, terms, vocabularyMap);  //TODO \r
+                   initializeAndStore(vocabularyType, terms, vocabularyMap);  //TODO \r
                }\r
            \r
             transactionManager.commit(txStatus);\r
@@ -168,8 +168,11 @@ public class PersistentTermInitializer extends DefaultTermInitializer {
      *                                                  loaded terms with their <code>UUID</code> as key\r
      * @param vocabularyMap \r
      */\r
-    protected void initializeAndStore(Class clazz, UUID vocabularyUuid, Map<UUID,DefinedTermBase> terms, Map<UUID, TermVocabulary<?>> vocabularyMap) {\r
-        logger.debug("Loading vocabulary for class " + clazz.getSimpleName() + " with uuid " + vocabularyUuid );\r
+    protected void initializeAndStore(VocabularyEnum vocType, Map<UUID,DefinedTermBase> terms, Map<UUID, TermVocabulary<?>> vocabularyMap) {\r
+       Class<? extends DefinedTermBase<?>> clazz = vocType.getClazz();\r
+        UUID vocabularyUuid = vocType.getUuid();\r
+       \r
+        if (logger.isDebugEnabled()){ logger.debug("Loading vocabulary for class " + clazz.getSimpleName() + " with uuid " + vocabularyUuid );}\r
 \r
         TermVocabulary<?> persistedVocabulary;\r
         if (vocabularyMap == null || vocabularyMap.get(vocabularyUuid) == null ){\r
@@ -178,8 +181,7 @@ public class PersistentTermInitializer extends DefaultTermInitializer {
                persistedVocabulary = vocabularyMap.get(vocabularyUuid);\r
         }\r
         \r
-        \r
-        logger.debug("Initializing terms in vocabulary for class " + clazz.getSimpleName() + " with uuid " + vocabularyUuid );\r
+        if (logger.isDebugEnabled()){ logger.debug("Initializing terms in vocabulary for class " + clazz.getSimpleName() + " with uuid " + vocabularyUuid );}\r
         //not really needed anymore as we do term initializing from the beginning now\r
         if (persistedVocabulary != null){\r
             for(Object object : persistedVocabulary.getTerms()) {\r
@@ -197,9 +199,9 @@ public class PersistentTermInitializer extends DefaultTermInitializer {
         \r
         \r
         //fill term store\r
-        logger.debug("Setting defined Terms for class " + clazz.getSimpleName() + ", " + persistedVocabulary.getTerms().size() + " in vocabulary");\r
+        if (logger.isDebugEnabled()){ logger.debug("Setting defined Terms for class " + clazz.getSimpleName() + ", " + persistedVocabulary.getTerms().size() + " in vocabulary");}\r
         super.setDefinedTerms(clazz, persistedVocabulary);\r
-        logger.debug("Second pass - DONE");\r
+        if (logger.isDebugEnabled()){ logger.debug("Second pass - DONE");}\r
 \r
     }\r
 \r