commit 2c29834733d18538c1f447d70e7bc64ac42e87e2
Author: Patrick Plitzner <p.plitzner@bgbm.org>
Date:   Mon Jan 16 12:40:51 2017 +0100

    ref #5448 Add new rank "forme"
    
     - did some refactoring and advanced logging

diff --git a/app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/gefaesspflanzen/RedListGefaesspflanzenImportClassification.java b/app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/gefaesspflanzen/RedListGefaesspflanzenImportClassification.java
index f58c3231..16111cb5 100644
--- a/app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/gefaesspflanzen/RedListGefaesspflanzenImportClassification.java
+++ b/app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/gefaesspflanzen/RedListGefaesspflanzenImportClassification.java
@@ -169,6 +169,7 @@ public class RedListGefaesspflanzenImportClassification extends DbImportBase<Red
 
         //Gesamtliste
         TaxonBase<?> taxonBase = state.getRelatedObject(RedListUtil.TAXON_GESAMTLISTE_NAMESPACE, String.valueOf(id), TaxonBase.class);
+        taxonBase.setSec(gesamtListeClassification.getReference());
         Taxon parent = state.getRelatedObject(RedListUtil.TAXON_GESAMTLISTE_NAMESPACE, parentId, Taxon.class);
         if(parent!=null && !parent.isInstanceOf(Taxon.class)){
             RedListUtil.logMessage(id, parent+" is no taxon but is a parent of "+taxonBase+" (Gesamtliste)", logger);
@@ -182,8 +183,9 @@ public class RedListGefaesspflanzenImportClassification extends DbImportBase<Red
                 Taxon family = (Taxon) state.getRelatedObject(RedListUtil.FAMILY_NAMESPACE_GESAMTLISTE, familieString);
                 gesamtListeClassification.addParentChild(family, HibernateProxyHelper.deproxy(taxonBase, Taxon.class), null, null);
                 //Buttler/Checklist taxon
-                if(CdmUtils.isNotBlank(clTaxonString) && clTaxonString.equals("b")){
+                if(CdmUtils.isNotBlank(clTaxonString) && clTaxonString.equals(RedListUtil.CL_TAXON_B)){
                     checklistClassification.addParentChild(family, HibernateProxyHelper.deproxy(taxonBase, Taxon.class), null, null);
+                    taxonBase.setSec(checklistClassification.getReference());
                 }
                 if(family.getTaxonNodes().isEmpty()){
                     gesamtListeClassification.addChildTaxon(family, null, null);
@@ -198,19 +200,25 @@ public class RedListGefaesspflanzenImportClassification extends DbImportBase<Red
         else{
             createParentChildNodes(gesamtListeClassification, id, gueltString, taxZusatzString, taxonBase, parent);
             //Buttler/Checklist taxon
-            if(CdmUtils.isNotBlank(clTaxonString) && clTaxonString.equals("b")){
-                if(taxonBase.isInstanceOf(Taxon.class)){
-                    createParentChildNodes(checklistClassification, id, gueltString, taxZusatzString, taxonBase, parent);
+            if(CdmUtils.isNotBlank(clTaxonString) && clTaxonString.equals(RedListUtil.CL_TAXON_B)){
+                if(!checklistClassification.isTaxonInTree(parent)){
+                    RedListUtil.logInfoMessage(id, parent+" is parent taxon but is not in checklist. Skipping child "+taxonBase, logger);
                 }
-                else if(taxonBase.isInstanceOf(Synonym.class)){
-                    //if it is a synonym it is already added to the accepted taxon
-                    //so we just change the sec reference
-                    taxonBase.setSec(checklistClassification.getReference());
-                    taxonBase.setTitleCache(null);
+                else{
+                    if(taxonBase.isInstanceOf(Taxon.class)){
+                        createParentChildNodes(checklistClassification, id, gueltString, taxZusatzString, taxonBase, parent);
+                    }
+                    else if(taxonBase.isInstanceOf(Synonym.class)){
+                        //if it is a synonym it is already added to the accepted taxon
+                        //so we just change the sec reference
+                        taxonBase.setSec(checklistClassification.getReference());
+                        taxonBase.setTitleCache(null);
+                    }
                 }
 
             }
         }
+        taxonBase.setTitleCache(null, false);//refresh title cache
 
         //add taxa for concept relationships to E, W, K, AW, AO, R, O, S
         addTaxonToClassification(classificationE, RedListUtil.CLASSIFICATION_NAMESPACE_E, relationE, taxonBase, id, state);
@@ -325,7 +333,6 @@ public class RedListGefaesspflanzenImportClassification extends DbImportBase<Red
         }
         //set sec reference
         taxonBase.setSec(classification.getReference());
-        taxonBase.setTitleCache(null, false);//refresh title cache
     }
 
     @Override
diff --git a/app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/gefaesspflanzen/RedListGefaesspflanzenImportNames.java b/app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/gefaesspflanzen/RedListGefaesspflanzenImportNames.java
index d2d3e768..b3100204 100644
--- a/app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/gefaesspflanzen/RedListGefaesspflanzenImportNames.java
+++ b/app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/gefaesspflanzen/RedListGefaesspflanzenImportNames.java
@@ -166,7 +166,7 @@ public class RedListGefaesspflanzenImportNames extends DbImportBase<RedListGefae
         //---TAXON---
         TaxonBase<?> taxonBase = importTaxon(rs, name, state);
         if(taxonBase==null){
-            RedListUtil.logMessage(id, "Taxon for name "+name+" could not be created.", logger);
+            RedListUtil.logMessage(id, "!SERIOUS ERROR! Taxon for name "+name+" could not be created!", logger);
             return;
         }
 
@@ -235,6 +235,7 @@ public class RedListGefaesspflanzenImportNames extends DbImportBase<RedListGefae
             taxonBase = Synonym.NewInstance(name, null);
         }
         else{
+            RedListUtil.logMessage(id, "Taxon was not created!! Unknown value for "+RedListUtil.GUELT+"!", logger);
             return null;
         }
 
@@ -615,6 +616,9 @@ public class RedListGefaesspflanzenImportNames extends DbImportBase<RedListGefae
             else if(rankStr.equals("KMB")){
                 return getRank(state, RedListUtil.uuidRankCombination, "Combination", "Combination", "", (OrderedTermVocabulary<Rank>) Rank.GENUS().getVocabulary(), null, RankClass.Infraspecific);
             }
+            else if(rankStr.equals("'FO")){
+                return getRank(state, RedListUtil.uuidRankForme, "Forme'", "Forme'", "", (OrderedTermVocabulary<Rank>) Rank.GENUS().getVocabulary(), null, RankClass.Infraspecific);
+            }
             else{
                 rank = state.getTransformer().getRankByKey(rankStr);
             }
diff --git a/app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/gefaesspflanzen/RedListUtil.java b/app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/gefaesspflanzen/RedListUtil.java
index fd3facbe..c03600ac 100644
--- a/app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/gefaesspflanzen/RedListUtil.java
+++ b/app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/gefaesspflanzen/RedListUtil.java
@@ -50,6 +50,7 @@ public class RedListUtil {
     public static final UUID uuidRankLusus = UUID.fromString("4c8e12f6-2c16-4eda-a7d9-2fd247dcce789");
     public static final UUID uuidRankSubspeciesPrincipes = UUID.fromString("b6b9351b-6beb-431d-8c7a-d30fe0cf3a90");
     public static final UUID uuidRankCombination = UUID.fromString("ec2c580e-416a-4ecf-85df-d03641f3bd64");
+    public static final UUID uuidRankForme = UUID.fromString("05b4f66f-5559-4e44-bbb8-70744a5ea64a");
 
     public static final String NAME_NAMESPACE = "name";
     public static final String AUTHOR_NAMESPACE = "author";
@@ -71,6 +72,8 @@ public class RedListUtil {
     public static final String GUELT_BASIONYM = "b";
     public static final String GUELT_SYNONYM = "x";
     public static final String GUELT_ACCEPTED_TAXON = "1";
+    public static final String CL_TAXON_B = "b";
+    public static final String CL_TAXON_K = "k";
     public static final String HYB_X = "x";
     public static final String HYB_XF = "xf";
     public static final String HYB_XS = "xs";
@@ -86,7 +89,7 @@ public class RedListUtil {
     public static final String NAMNR = "NAMNR";
     public static final String SEQNUM = "SEQNUM";
     public static final String GUELT = "GUELT";
-    public static final String LOWER = "LOWER";
+    public static final String LOWER = "LOWER_G";
     public static final String AUTOR_BASI = "AUTOR_BASI";
     public static final String AUTOR_KOMB = "AUTOR_KOMB";
     public static final String ZUSATZ = "ZUSATZ";
@@ -120,7 +123,8 @@ public class RedListUtil {
     public static final String AO = "AO";
     public static final String R = "R";
     public static final String O = "O";
-    public static final String S = "S";
+    public static final String S = "S1";
+    public static final String S2 = "S2";
 
     public static void logMessage(long id, String message, Logger logger){
         logger.error(NAMNR+": "+id+" "+message);
