From 34965c7d9a020910d8a3e36ed3299fb05936f47b Mon Sep 17 00:00:00 2001 From: Katja Luther Date: Wed, 29 May 2019 09:19:22 +0200 Subject: [PATCH] fix #8315: fix Parser in TaxEditor to avoid inReference change of existing references --- .../taxeditor/parser/ParseHandler.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/parser/ParseHandler.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/parser/ParseHandler.java index ece1e56aa..5d6c5388a 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/parser/ParseHandler.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/parser/ParseHandler.java @@ -61,7 +61,7 @@ public class ParseHandler{ if(name == null){ this.name = nonViralNameParser.getNonViralNameInstance("", PreferencesUtil.getPreferredNomenclaturalCode()); }else{ - this.name = (INonViralName) HibernateProxyHelper.deproxy(name); + this.name = HibernateProxyHelper.deproxy(name); } } @@ -102,7 +102,7 @@ public class ParseHandler{ public static TaxonName parseName(String unparsedNameString, Rank rank){ INonViralName name = nonViralNameParser.parseFullName(unparsedNameString, PreferencesUtil.getPreferredNomenclaturalCode(), rank); - + return (TaxonName)name; } @@ -180,9 +180,9 @@ public class ParseHandler{ resolveDuplicateReferences(name, matchMatrix); - if(matchMatrix.duplicateInReferences != null) { - resolveDuplicateInReferences(name, matchMatrix); - } +// if(matchMatrix.duplicateInReferences != null) { +// resolveDuplicateInReferences(name, matchMatrix); +// } } @@ -212,13 +212,17 @@ public class ParseHandler{ INomenclaturalReference duplicate = matchMatrix.duplicateReferences.iterator().next(); name.setNomenclaturalReference(duplicate); } + //if reference is new but the in reference is already in db + if (matchMatrix.duplicateReferences.size() == 0 && name.getNomenclaturalReference().getInReference() != null && matchMatrix.duplicateInReferences.size() > 0){ + resolveDuplicateInReferences(name, matchMatrix); + } } /** * @param name The name to resolve duplicates for. */ - private void resolveDuplicateInReferences(INonViralName name, MatchMatrix matchMatrix) { - Reference reference = (Reference) HibernateProxyHelper.deproxy(name.getNomenclaturalReference()); + private void resolveDuplicateInReferences(INonViralName name, MatchMatrix matchMatrix) { + Reference reference = HibernateProxyHelper.deproxy(name.getNomenclaturalReference()); if(matchMatrix.duplicateInReferences.size() > 0){ Reference inReference = (Reference) matchMatrix.duplicateInReferences.iterator().next(); @@ -237,7 +241,7 @@ public class ParseHandler{ if(matchMatrix.duplicateCombinationAuthorships.size() > 0){ name.setCombinationAuthorship(matchMatrix.duplicateCombinationAuthorships.iterator().next()); - Reference reference = (Reference) name.getNomenclaturalReference(); + Reference reference = name.getNomenclaturalReference(); if(reference != null){ reference.setAuthorship(matchMatrix.duplicateCombinationAuthorships.iterator().next()); } -- 2.34.1