commit 76a5e528ea9c3d2a81d50278f9b26d511e993262
Author: Andreas Müller <a.mueller@bgbm.org>
Date:   Wed Apr 25 14:02:55 2018 +0200

    ref #5499, ref #6517 latest changes to Edaphobase import (also stable uuids)

diff --git a/app-import/src/main/java/eu/etaxonomy/cdm/app/common/CdmDestinations.java b/app-import/src/main/java/eu/etaxonomy/cdm/app/common/CdmDestinations.java
index 7e801e20..e5f7ded8 100644
--- a/app-import/src/main/java/eu/etaxonomy/cdm/app/common/CdmDestinations.java
+++ b/app-import/src/main/java/eu/etaxonomy/cdm/app/common/CdmDestinations.java
@@ -390,6 +390,33 @@ public class CdmDestinations {
         return makeDestination(dbType, cdmServer, cdmDB, -1, cdmUserName, null);
     }
 
+    public static ICdmDataSource cdm_postgres_edaphobase(){
+        DatabaseTypeEnum dbType = DatabaseTypeEnum.PostgreSQL;
+        String cdmServer = "130.133.70.26";
+        String cdmDB = "cdm_edaphobase";
+        String cdmUserName = "edaphobase";
+        int port = 5433;
+        return makeDestination(dbType, cdmServer, cdmDB, port, cdmUserName, null);
+    }
+
+    public static ICdmDataSource cdm_test_postgres_edaphobase(){
+        DatabaseTypeEnum dbType = DatabaseTypeEnum.PostgreSQL;
+        String cdmServer = "160.45.63.175";
+        String cdmDB = "cdm_edaphobase";
+        String cdmUserName = "edaphobase";
+        int port = 5432;
+        return makeDestination(dbType, cdmServer, cdmDB, port, cdmUserName, null);
+    }
+
+    public static ICdmDataSource cdm_test_postgres__ssh_edaphobase(){
+        DatabaseTypeEnum dbType = DatabaseTypeEnum.PostgreSQL;
+        String cdmServer = "localhost";
+        String cdmDB = "cdm_edaphobase";
+        String cdmUserName = "edaphobase";
+        int port = 13306;
+        return makeDestination(dbType, cdmServer, cdmDB, port, cdmUserName, null);
+    }
+
     public static ICdmDataSource cdm_local_caryo_spp(){
         DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL;
         String cdmServer = "127.0.0.1";
diff --git a/app-import/src/main/java/eu/etaxonomy/cdm/app/common/CdmImportSources.java b/app-import/src/main/java/eu/etaxonomy/cdm/app/common/CdmImportSources.java
index e397bc66..4b94da58 100644
--- a/app-import/src/main/java/eu/etaxonomy/cdm/app/common/CdmImportSources.java
+++ b/app-import/src/main/java/eu/etaxonomy/cdm/app/common/CdmImportSources.java
@@ -145,4 +145,13 @@ public class CdmImportSources extends SourceBase{
         return  makeSource(dbms, strServer, strDB, port, userName, null);
     }
 
+    public static Source EDAPHOBASE8(){
+        String dbms = Source.POSTGRESQL9;  //TODO 10
+        String strServer = "130.133.70.26";  //BGBM-PESISQL
+        String strDB = "edaphobase8";
+        int port = 5433;
+        String userName = "edaphobase";
+        return  makeSource(dbms, strServer, strDB, port, userName, null);
+    }
+
 }
diff --git a/app-import/src/main/java/eu/etaxonomy/cdm/app/edaphobase/EdaphobaseActivator.java b/app-import/src/main/java/eu/etaxonomy/cdm/app/edaphobase/EdaphobaseActivator.java
index e6ba961d..7b1cbf29 100644
--- a/app-import/src/main/java/eu/etaxonomy/cdm/app/edaphobase/EdaphobaseActivator.java
+++ b/app-import/src/main/java/eu/etaxonomy/cdm/app/edaphobase/EdaphobaseActivator.java
@@ -38,11 +38,16 @@ public class EdaphobaseActivator {
     static DbSchemaValidation dbSchemaValidation = DbSchemaValidation.CREATE;
 
 //    static final Source edaphoSource = CdmImportSources.EDAPHOBASE();
-    static final Source edaphoSource = CdmImportSources.EDAPHOBASE6();
+    static final Source edaphoSource = CdmImportSources.EDAPHOBASE8();
 
 //    static final ICdmDataSource cdmDestination = CdmDestinations.localH2();
-    static final ICdmDataSource cdmDestination = CdmDestinations.cdm_local_edaphobase();
+//    static final ICdmDataSource cdmDestination = CdmDestinations.cdm_local_edaphobase();
 //    static final ICdmDataSource cdmDestination = CdmDestinations.cdm_production_edaphobase();
+//    static final ICdmDataSource cdmDestination = CdmDestinations.cdm_postgres_edaphobase();
+//    static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_postgres_edaphobase();
+    static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_postgres_edaphobase();
+
+
 
     //feature tree uuid
     private static final UUID featureTreeUuid = UUID.fromString("a543d66a-e310-4b3e-a9fa-b729afefad16");
@@ -59,6 +64,10 @@ public class EdaphobaseActivator {
     private static final boolean doReferences = true;
     private static final boolean doDescriptions = false;
 
+    //logging
+    private static final boolean ignoreSubgenus = true;
+    private static final boolean ignore4nomial = true;
+
 
     //check - import
     static CHECK check = CHECK.IMPORT_WITHOUT_CHECK;
@@ -77,6 +86,9 @@ public class EdaphobaseActivator {
         config.setDoDescriptions(doDescriptions);
         config.setCheck(check);
 
+        config.setIgnoreSubgenus(ignoreSubgenus);
+        config.setIgnore4nomial(ignore4nomial);
+
         CdmDefaultImport<EdaphobaseImportConfigurator> myImport = new CdmDefaultImport<>();
         myImport.invoke(config);
 
diff --git a/app-import/src/main/java/eu/etaxonomy/cdm/io/edaphobase/EdaphobaseImportConfigurator.java b/app-import/src/main/java/eu/etaxonomy/cdm/io/edaphobase/EdaphobaseImportConfigurator.java
index 7136127b..ebced173 100644
--- a/app-import/src/main/java/eu/etaxonomy/cdm/io/edaphobase/EdaphobaseImportConfigurator.java
+++ b/app-import/src/main/java/eu/etaxonomy/cdm/io/edaphobase/EdaphobaseImportConfigurator.java
@@ -50,6 +50,15 @@ public class EdaphobaseImportConfigurator
     public String getEdaphobaseSecundumTitle() {return edaphobaseSecundumTitle;}
     public void setEdaphobaseSecundumTitle(String edaphobaseSecundumTitle) {this.edaphobaseSecundumTitle = edaphobaseSecundumTitle;}
 
+    //logging
+    private boolean ignoreSubgenus = true;
+    public boolean isIgnoreSubgenus() {return ignoreSubgenus;}
+    public void setIgnoreSubgenus(boolean ignoreSubgenus) {this.ignoreSubgenus = ignoreSubgenus;}
+
+    private boolean ignore4nomial = true;
+    public boolean isIgnore4nomial() {return ignore4nomial;}
+    public void setIgnore4nomial(boolean ignore4nomial) {this.ignore4nomial = ignore4nomial;}
+
 
     /**
      * @param source
diff --git a/app-import/src/main/java/eu/etaxonomy/cdm/io/edaphobase/EdaphobaseTaxonImport.java b/app-import/src/main/java/eu/etaxonomy/cdm/io/edaphobase/EdaphobaseTaxonImport.java
index 7979878e..a4262901 100644
--- a/app-import/src/main/java/eu/etaxonomy/cdm/io/edaphobase/EdaphobaseTaxonImport.java
+++ b/app-import/src/main/java/eu/etaxonomy/cdm/io/edaphobase/EdaphobaseTaxonImport.java
@@ -175,6 +175,7 @@ public class EdaphobaseTaxonImport extends EdaphobaseImportBase {
         String parentNameStr = rs.getString("parentName");
         String grandParentNameStr = rs.getString("grandParentName");
         String grandGrandParentNameStr = rs.getString("grandGrandParentName");
+        String editUuid = rs.getString("edit_uuid");
 
 
         if (isDeleted){
@@ -297,7 +298,7 @@ public class EdaphobaseTaxonImport extends EdaphobaseImportBase {
             }
             name.setNomenclaturalReference(nomRef);
         }
-        name.setNomenclaturalMicroReference(StringUtils.isBlank(pages)? null : pages);
+        name.setNomenclaturalMicroReference(isBlank(pages)? null : pages);
 
         //taxon
         Reference secRef = state.getRelatedObject(REFERENCE_NAMESPACE, state.getConfig().getSecUuid().toString(), Reference.class);
@@ -328,23 +329,42 @@ public class EdaphobaseTaxonImport extends EdaphobaseImportBase {
         //id
         ImportHelper.setOriginalSource(taxonBase, state.getTransactionalSourceReference(), id, TAXON_NAMESPACE);
         ImportHelper.setOriginalSource(name, state.getTransactionalSourceReference(), id, TAXON_NAMESPACE);
+        taxonBase.setUuid(UUID.fromString(editUuid));
         handleExampleIdentifiers(taxonBase, id);
 
         if (!nameAdditionUsed){
             logger.warn("name_addition not recognized: " +  nameAddition + ". ID="+id);
             name.setAppendedPhrase(nameAddition);
         }
-        String orig = displayString.replace("nomen nudum [Hirschmann, 1951]", "Hirschmann, 1951")
-                .replace("  ", " ");
-        String nameTitleCache = name.getTitleCache().replace("species group", "group");
-        String taxonTitleCache = taxonBase.getTitleCache().replace("species group", "group");
-        if (!orig.equals(nameTitleCache) && !orig.equals(name.getFullTitleCache()) && !orig.equals(taxonTitleCache)){
+
+        if (titleCacheDiffers(state, displayString, name, taxonBase)){
             String titleCache = taxonBase.getAppendedPhrase() != null ? taxonBase.getTitleCache() : name.getTitleCache();
             logger.warn("Displaystring differs from titleCache. ID=" + id + ".\n   " + displayString + "\n   " + titleCache);
         }
     }
 
 
+    /**
+     * @param state
+     * @param displayString
+     * @param name
+     * @param taxonBase
+     * @return
+     */
+    private boolean titleCacheDiffers(EdaphobaseImportState state, String displayString, IZoologicalName name, TaxonBase<?> taxonBase) {
+        String orig = displayString.replace("nomen nudum [Hirschmann, 1951]", "Hirschmann, 1951")
+                .replace("  ", " ");
+        String nameTitleCache = name.getTitleCache().replace("species group", "group");
+        String taxonTitleCache = taxonBase.getTitleCache().replace("species group", "group");
+
+//        if (state.getConfig().isIgnore4nomial() && orig.matches(".* subsp"))
+        boolean result =
+                !orig.equals(nameTitleCache)
+                && !orig.equals(name.getFullTitleCache())
+                && !orig.equals(taxonTitleCache);
+        return result;
+    }
+
     /**
      * @param authorStr
      * @return
@@ -436,6 +456,7 @@ public class EdaphobaseTaxonImport extends EdaphobaseImportBase {
     private void handleExampleIdentifiers(TaxonBase<?> taxonBase, Integer id) {
         if (idMap.get(id) != null){
             taxonBase.setUuid(idMap.get(id));
+            logger.warn("Override UUID for specific taxa. ID="+ id +  "; uuid="+idMap.get(id) + "; name="+ taxonBase.getName().getTitleCache());
         }
     }
 
