commit 2a2eb365eeb337c2d123667c55b0c21725129e1a
Author: Andreas Müller <a.mueller@bgbm.org>
Date:   Thu Dec 26 13:50:27 2019 +0100

    ref #1444 replace tu_acctaxon by tu_accfinal

diff --git a/cdm-pesi/src/main/java/eu/etaxonomy/cdm/app/pesi/validate/PesiErmsValidator.java b/cdm-pesi/src/main/java/eu/etaxonomy/cdm/app/pesi/validate/PesiErmsValidator.java
index c3d62edb..d88f7bba 100644
--- a/cdm-pesi/src/main/java/eu/etaxonomy/cdm/app/pesi/validate/PesiErmsValidator.java
+++ b/cdm-pesi/src/main/java/eu/etaxonomy/cdm/app/pesi/validate/PesiErmsValidator.java
@@ -236,8 +236,8 @@ public class PesiErmsValidator {
         return equals("CommonName count ", countSrc, countDest, String.valueOf(-1));
     }
 
-    private final String countSynonymRelation = "SELECT count(*) FROM tu syn LEFT JOIN tu acc ON syn.tu_acctaxon = acc.id WHERE (syn.id <> acc.id AND syn.tu_acctaxon IS NOT NULL AND syn.id <> acc.tu_parent) AND syn.id " + moneraFilter;
-    private final String countParentRelation  = "SELECT count(*)-1 FROM tu syn LEFT JOIN tu acc ON syn.tu_acctaxon = acc.id WHERE (syn.id =  acc.id OR  syn.tu_acctaxon IS     NULL OR  syn.id =  acc.tu_parent) AND syn.id " + moneraFilter;
+    private final String countSynonymRelation = "SELECT count(*) FROM tu syn LEFT JOIN tu acc ON syn.tu_accfinal = acc.id WHERE (syn.id <> acc.id AND syn.tu_accfinal IS NOT NULL AND syn.id <> acc.tu_parent) AND syn.id " + moneraFilter;
+    private final String countParentRelation  = "SELECT count(*)-1 FROM tu syn LEFT JOIN tu acc ON syn.tu_accfinal = acc.id WHERE (syn.id =  acc.id OR  syn.tu_accfinal IS  NULL OR  syn.id =  acc.tu_parent) AND syn.id " + moneraFilter;
 
     private final String countTaxon = "SELECT count(*) FROM tu WHERE id " + moneraFilter;
     private boolean testTaxaCount() {
@@ -268,7 +268,7 @@ public class PesiErmsValidator {
                 + " FROM tu t "
                 + " LEFT JOIN tu as tu1 on t.tu_parent = tu1.id "
                 + " LEFT JOIN (SELECT DISTINCT rank_id, rank_name FROM ranks WHERE NOT(rank_id = 30 AND rank_name = 'Phylum (Division)' OR rank_id = 40 AND rank_name = 'Subphylum (Subdivision)' OR rank_id = 122 AND rank_name='Subsection')) as r ON t.tu_rank = r.rank_id "
-                + " LEFT JOIN tu acc ON acc.id = t.tu_acctaxon "
+                + " LEFT JOIN tu acc ON acc.id = t.tu_accfinal "
                 + " LEFT JOIN status st ON st.status_id = t.tu_status "
                 + " LEFT JOIN tu type ON type.id = t.tu_typetaxon "
                 + " LEFT JOIN fossil fo ON t.tu_fossil = fo.fossil_id "
@@ -491,7 +491,7 @@ public class PesiErmsValidator {
         ResultSet srcRS = source.getResultSet(""
                 + " SELECT t.* "
                 + " FROM tu t "
-                + " WHERE t.id "+ moneraFilter + " AND tu_acctaxon <> id "
+                + " WHERE t.id "+ moneraFilter + " AND tu_accfinal <> id "
                 + " ORDER BY CAST(t.id as nvarchar(20)) ");
         ResultSet destRS = destination.getResultSet("SELECT rel.*, t1.IdInSource t1Id, t2.IdInSource t2Id "
                 + " FROM RelTaxon rel "
@@ -511,7 +511,7 @@ public class PesiErmsValidator {
     private boolean testSingleTaxonRelation(ResultSet srcRS, ResultSet destRS) throws SQLException {
         String id = String.valueOf(srcRS.getInt("id"));
         boolean success = equals("Taxon relation taxon1", "tu_id: " + srcRS.getInt("id"), destRS.getString("t1Id"), id);
-        success &= equals("Taxon relation taxon2", "tu_id: " + srcRS.getInt("tu_acctaxon"), destRS.getString("t2Id"), id);
+        success &= equals("Taxon relation taxon2", "tu_id: " + srcRS.getInt("tu_accfinal"), destRS.getString("t2Id"), id);
         success &= equals("Taxon relation qualifier fk", PesiTransformer.IS_SYNONYM_OF, destRS.getInt("RelTaxonQualifierFk"), id);
         success &= equals("Taxon relation qualifier cache", "is synonym of", destRS.getString("RelQualifierCache"), id);
         //TODO enable after next import
diff --git a/cdm-pesi/src/main/java/eu/etaxonomy/cdm/app/pesi/validate/PesiEuroMedValidator.java b/cdm-pesi/src/main/java/eu/etaxonomy/cdm/app/pesi/validate/PesiEuroMedValidator.java
index 251d83eb..41432412 100644
--- a/cdm-pesi/src/main/java/eu/etaxonomy/cdm/app/pesi/validate/PesiEuroMedValidator.java
+++ b/cdm-pesi/src/main/java/eu/etaxonomy/cdm/app/pesi/validate/PesiEuroMedValidator.java
@@ -195,7 +195,7 @@ public class PesiEuroMedValidator {
     private boolean testSingleSynonymRelation(ResultSet srcRS, ResultSet destRS) throws SQLException {
         String id = String.valueOf(srcRS.getInt("id"));
         boolean success = equals("Taxon relation taxon1", "NameId: " + srcRS.getInt("id"), destRS.getString("t1Id"), id);
-        success &= equals("Taxon relation taxon2", "NameId: " + srcRS.getInt("tu_acctaxon"), destRS.getString("t2Id"), id);
+        success &= equals("Taxon relation taxon2", "NameId: " + srcRS.getInt("tu_accfinal"), destRS.getString("t2Id"), id);
         success &= equals("Taxon relation qualifier fk", PesiTransformer.IS_SYNONYM_OF, destRS.getInt("RelTaxonQualifierFk"), id);
         success &= equals("Taxon relation qualifier cache", "is synonym of", destRS.getString("RelQualifierCache"), id);
         //TODO enable after next import
diff --git a/cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsDistributionImport.java b/cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsDistributionImport.java
index 95cc35ac..17fc3d9d 100644
--- a/cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsDistributionImport.java
+++ b/cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsDistributionImport.java
@@ -63,7 +63,7 @@ public class ErmsDistributionImport
 	@Override
 	protected String getRecordQuery(ErmsImportConfigurator config) {
 		String strRecordQuery =
-			" SELECT dr.*, ISNULL(ISNULL(tu.tu_acctaxon, tu.tu_accfinal), tu.id) acctaxon, " +
+			" SELECT dr.*, ISNULL(ISNULL(tu.tu_accfinal, tu.tu_accfinal), tu.id) acctaxon, " +
 	                  " s.sessiondate lastActionDate, a.action_name lastAction, s.ExpertName " +
 			" FROM dr INNER JOIN tu ON dr.tu_id = tu.id " +
             "     LEFT OUTER JOIN dr_sessions MN ON MN.dr_id = dr.id " +
diff --git a/cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsTaxonImport.java b/cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsTaxonImport.java
index 2c006ef5..b96145b4 100644
--- a/cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsTaxonImport.java
+++ b/cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsTaxonImport.java
@@ -192,9 +192,9 @@ public class ErmsTaxonImport
 		String distributionTable = "dr";
 		String notesTable = "notes";
 		String sql =
-		        "          SELECT id FROM tu WHERE tu_acctaxon is NULL" //id of taxa not having accepted taxon
-		        + " UNION  SELECT DISTINCT tu_acctaxon FROM tu "  //fk to accepted taxon (either the accepted taxon or the taxon itself, if accepted)
-		        + " UNION  SELECT syn.id FROM tu syn INNER JOIN tu acc ON syn.tu_acctaxon = acc.id WHERE syn.id = acc.tu_parent AND acc.id <> syn.id "  //see also ErmsTaxonRelationImport.isAccepted, there are some autonyms being the accepted taxon of there own parents
+		        "          SELECT id FROM tu WHERE tu_accfinal is NULL" //id of taxa not having accepted taxon
+                + " UNION  SELECT DISTINCT tu_accfinal FROM tu "  //fk to accepted taxon (either the accepted taxon or the taxon itself, if accepted)
+                + " UNION  SELECT syn.id FROM tu syn INNER JOIN tu acc ON syn.tu_accfinal = acc.id WHERE syn.id = acc.tu_parent AND acc.id <> syn.id "  //see also ErmsTaxonRelationImport.isAccepted, there are some autonyms being the accepted taxon of there own parents
                 + " UNION  SELECT DISTINCT %s FROM %s " //vernaculars
 		        + " UNION  SELECT DISTINCT %s FROM %s "  //distributions
 		        + " UNION  SELECT DISTINCT %s FROM %s ";  //notes
@@ -226,7 +226,7 @@ public class ErmsTaxonImport
 	@Override
 	public TaxonBase<?> createObject(ResultSet rs, ErmsImportState state) throws SQLException {
 		int statusId = rs.getInt("status_id");
-//		Object accTaxonId = rs.getObject("tu_acctaxon");
+//		Object accTaxonId = rs.getObject("tu_accfinal");
 		Integer meId = rs.getInt("id");
 
         TaxonName taxonName = getTaxonName(rs, state);
diff --git a/cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsTaxonRelationImport.java b/cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsTaxonRelationImport.java
index 7767fc28..0a4b39b8 100644
--- a/cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsTaxonRelationImport.java
+++ b/cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsTaxonRelationImport.java
@@ -64,7 +64,7 @@ public class ErmsTaxonRelationImport extends ErmsImportBase<TaxonBase<?>> implem
 			    = DbImportTaxIncludedInMapper.NewInstance("id", TAXON_NAMESPACE, "accId", TAXON_NAMESPACE, "parentAccId", TAXON_NAMESPACE, null);
 			mapping.addMapper(includedIn);//there is only one tree
 			//synonym
-			mapping.addMapper(DbImportSynonymMapper.NewInstance("id", "tu_acctaxon", TAXON_NAMESPACE,
+			mapping.addMapper(DbImportSynonymMapper.NewInstance("id", "tu_accfinal", TAXON_NAMESPACE,
 			        "tu_unacceptreason", null, null, true));
 			//type designations
 			mapping.addMapper(DbImportNameTypeDesignationMapper.NewInstance("id", "tu_typetaxon", ErmsImportBase.NAME_NAMESPACE, "tu_typedesignationstatus"));
@@ -84,7 +84,7 @@ public class ErmsTaxonRelationImport extends ErmsImportBase<TaxonBase<?>> implem
 		//TODO get automatic by second path mappers
 		String selectAttributes =
 		    "   myTaxon.id, myTaxon.tu_parent, myTaxon.tu_typetaxon, myTaxon.tu_typedesignation, "
-		    + " myTaxon.tu_acctaxon, myTaxon.tu_status, myTaxon.tu_unacceptreason, "
+		    + " myTaxon.tu_accfinal, myTaxon.tu_status, myTaxon.tu_unacceptreason, "
 			+ " parent.tu_status AS parentStatus, parent.id AS parentId, "
 		    + " parentAcc.id AS parentAccId,"
 		    + " accTaxon.tu_parent accParentId, "
@@ -92,9 +92,9 @@ public class ErmsTaxonRelationImport extends ErmsImportBase<TaxonBase<?>> implem
 		String strRecordQuery =
 			"   SELECT  " + selectAttributes
 			+ " FROM tu AS myTaxon "
-			+ "   LEFT JOIN tu AS accTaxon ON myTaxon.tu_acctaxon = accTaxon.id "
+			+ "   LEFT JOIN tu AS accTaxon ON myTaxon.tu_accfinal = accTaxon.id "
 			+ "   LEFT JOIN tu AS parent ON myTaxon.tu_parent = parent.id "
-			+ "   LEFT JOIN tu AS parentAcc ON parentAcc.id = parent.tu_acctaxon "
+			+ "   LEFT JOIN tu AS parentAcc ON parentAcc.id = parent.tu_accfinal "
 			+ " WHERE ( myTaxon.id IN (" + ID_LIST_TOKEN + ") )";
 		return strRecordQuery;
 	}
@@ -116,7 +116,7 @@ public class ErmsTaxonRelationImport extends ErmsImportBase<TaxonBase<?>> implem
 			Set<String> nameIdSet = new HashSet<>();
 			while (rs.next()){
 			    handleForeignKey(rs, taxonIdSet, "accId");
-				handleForeignKey(rs, taxonIdSet, "tu_acctaxon");
+				handleForeignKey(rs, taxonIdSet, "tu_accfinal");
 				handleForeignKey(rs, taxonIdSet, "id");
 				handleForeignKey(rs, nameIdSet, "tu_typetaxon");
 				handleForeignKey(rs, nameIdSet, "id");
@@ -152,8 +152,8 @@ public class ErmsTaxonRelationImport extends ErmsImportBase<TaxonBase<?>> implem
 		    //here we should add the direct parent or the accepted taxon of the parent
 		    return !isAccepted;
 		}else if (mapper instanceof DbImportSynonymMapper){
-	        //the only exact rule in ERMS is that the accepted taxon (tu_acctaxon)
-	        // of a synonym (def: id <> tu_acctaxon) never again has another
+	        //the only exact rule in ERMS is that the accepted taxon (tu_accfinal)
+	        // of a synonym (def: id <> tu_accfinal) never again has another
 	        // accepted taxon.
 	        //So the synonym relation is clearly defined, no matter which status
 	        //both related taxa have.
@@ -170,7 +170,7 @@ public class ErmsTaxonRelationImport extends ErmsImportBase<TaxonBase<?>> implem
 
     private boolean isAccepted(ResultSet rs) throws SQLException {
         int id = rs.getInt("id");
-        Object accTaxonId = rs.getObject("tu_acctaxon");
+        Object accTaxonId = rs.getObject("tu_accfinal");
         Object accParentId = rs.getObject("accParentId");
 
         boolean isAccepted = false;
diff --git a/cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsVernacularImport.java b/cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsVernacularImport.java
index fb1e35be..3c6ae25e 100644
--- a/cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsVernacularImport.java
+++ b/cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsVernacularImport.java
@@ -62,7 +62,7 @@ public class ErmsVernacularImport  extends ErmsImportBase<CommonTaxonName> {
 	@Override
 	protected String getRecordQuery(ErmsImportConfigurator config) {
 		String strRecordQuery =
-			" SELECT v.*, tu.tu_acctaxon, tu.id, l.*, " +
+			" SELECT v.*, tu.tu_accfinal, tu.id, l.*, " +
 			       " s.sessiondate lastActionDate, a.action_name lastAction, s.ExpertName " +
 			" FROM vernaculars v INNER JOIN tu ON v.tu_id = tu.id " +
 			"     LEFT OUTER JOIN languages l ON l.LanID = v.lan_id " +
diff --git a/cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/validation/ErmsSourceUsesImportValidator.java b/cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/validation/ErmsSourceUsesImportValidator.java
index d1469cc2..f9eb5af5 100644
--- a/cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/validation/ErmsSourceUsesImportValidator.java
+++ b/cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/validation/ErmsSourceUsesImportValidator.java
@@ -40,7 +40,7 @@ public class ErmsSourceUsesImportValidator implements IOValidator<ErmsImportStat
 		try {
 			boolean result = true;
 			Source source = bmiConfig.getSource();
-			String strSQL = " SELECT tu_sources.sourceuse_id, sourceuses.sourceuse_name, tu.tu_acctaxon, tu.tu_parent, tu.id, tu.tu_name, " +
+			String strSQL = " SELECT tu_sources.sourceuse_id, sourceuses.sourceuse_name, tu.tu_accfinal, tu.tu_parent, tu.id, tu.tu_name, " +
 						" tu.tu_authority, tu.tu_displayname, status.status_name "  +
 				" FROM  tu_sources " +
 					" INNER JOIN sourceuses ON tu_sources.sourceuse_id = sourceuses.sourceuse_id " +
@@ -54,7 +54,7 @@ public class ErmsSourceUsesImportValidator implements IOValidator<ErmsImportStat
 				i++;
 				if (firstRow){
 					System.out.println("========================================================");
-					logger.warn("There are source uses of typ 'source of synonymy' having equal 'id' and 'tu_acctaxon'");
+					logger.warn("There are source uses of typ 'source of synonymy' having equal 'id' and 'tu_accfinal'");
 					System.out.println("========================================================");
 				}
 				int id = rs.getInt("id");
diff --git a/cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/validation/ErmsTaxonImportValidator.java b/cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/validation/ErmsTaxonImportValidator.java
index 486bcce1..2ef9e54b 100644
--- a/cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/validation/ErmsTaxonImportValidator.java
+++ b/cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/validation/ErmsTaxonImportValidator.java
@@ -48,7 +48,7 @@ public class ErmsTaxonImportValidator implements IOValidator<ErmsImportState>{
                       " parentAcc.tu_status AS Expr1 " +
                 " FROM status AS parentAccStatus INNER JOIN " +
                       " tu AS parentAcc ON parentAccStatus.status_id = parentAcc.tu_status RIGHT OUTER JOIN " +
-                      " tu AS parent ON parentAcc.id = parent.tu_acctaxon RIGHT OUTER JOIN " +
+                      " tu AS parent ON parentAcc.id = parent.tu_accfinal RIGHT OUTER JOIN " +
                       " tu AS myTaxon ON parent.id = myTaxon.tu_parent LEFT OUTER JOIN " +
                       " status AS parentStatus ON parent.tu_status = parentStatus.status_id LEFT OUTER JOIN " +
                       " status AS childStatus ON myTaxon.tu_status = childStatus.status_id " +
@@ -61,7 +61,7 @@ public class ErmsTaxonImportValidator implements IOValidator<ErmsImportState>{
 				i++;
 				if (firstRow){
 					System.out.println("========================================================");
-					logger.warn("There are accepted taxa that have an unaccepted parent and also the parents accepted taxon (tu_acctaxon) is not accepted. ");
+					logger.warn("There are accepted taxa that have an unaccepted parent and also the parents accepted taxon (tu_accfinal) is not accepted. ");
 					System.out.println("========================================================");
 				}
 				int childId = rs.getInt("childId");
@@ -100,7 +100,7 @@ public class ErmsTaxonImportValidator implements IOValidator<ErmsImportState>{
 				" SELECT    myTaxon.id AS synonymId, myTaxon.tu_displayname AS synonymName, synonymStatus.status_name AS synonymStatus, " +
 					" accTaxon.id AS acceptedId, accTaxon.tu_displayname AS acceptedName, acceptedStatus.status_name AS acceptedStatus " +
 				" FROM tu AS myTaxon INNER JOIN " +
-                    " tu AS accTaxon ON myTaxon.tu_acctaxon = accTaxon.id INNER JOIN " +
+                    " tu AS accTaxon ON myTaxon.tu_accfinal = accTaxon.id INNER JOIN " +
                     " status AS synonymStatus ON myTaxon.tu_status = synonymStatus.status_id INNER JOIN " +
                     " status AS acceptedStatus ON accTaxon.tu_status = acceptedStatus.status_id " +
                 " WHERE (myTaxon.tu_status <> 1) AND (accTaxon.tu_status <> 1) " +
diff --git a/cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/indexFungorum/IndexFungorumGeneraImport.java b/cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/indexFungorum/IndexFungorumGeneraImport.java
index feb11734..f223604d 100644
--- a/cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/indexFungorum/IndexFungorumGeneraImport.java
+++ b/cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/indexFungorum/IndexFungorumGeneraImport.java
@@ -162,7 +162,7 @@ public class IndexFungorumGeneraImport  extends IndexFungorumImportBase {
 		try{
 //			Set<String> taxonNameSet = new HashSet<>();
 			while (rs.next()){
-//				handleForeignKey(rs, taxonIdSet,"tu_acctaxon" );
+//				handleForeignKey(rs, taxonIdSet,"tu_accfinal" );
 			}
 
 			//taxon map
diff --git a/cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/indexFungorum/IndexFungorumHigherClassificationImport.java b/cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/indexFungorum/IndexFungorumHigherClassificationImport.java
index ac941a59..944b986f 100644
--- a/cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/indexFungorum/IndexFungorumHigherClassificationImport.java
+++ b/cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/indexFungorum/IndexFungorumHigherClassificationImport.java
@@ -273,7 +273,7 @@ public class IndexFungorumHigherClassificationImport  extends IndexFungorumImpor
 		try{
 			Set<String> taxonNameSet = new HashSet<String>();
 //			while (rs.next()){
-//				handleForeignKey(rs, taxonIdSet,"tu_acctaxon" );
+//				handleForeignKey(rs, taxonIdSet,"tu_accfinal" );
 //			}
 
 			//taxon map
