partly fixes #1119
authorn.hoffmann <n.hoffmann@localhost>
Mon, 1 Feb 2010 17:04:46 +0000 (17:04 +0000)
committern.hoffmann <n.hoffmann@localhost>
Mon, 1 Feb 2010 17:04:46 +0000 (17:04 +0000)
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/parser/MatchStrategyConfigurator.java
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/parser/ParseHandler.java

index 0b81e3c1c325721c0cbbc0f1964d02df522e1475..5179311b7ee611ee7a104d8d7b1a290c4606c2b9 100644 (file)
@@ -33,7 +33,7 @@ public class MatchStrategyConfigurator {
         * @throws MatchException
         */
        public static IMatchStrategy NonViralNameMatchStrategy() throws MatchException{
-               return PreferencesUtil.getMatchStrategy(NonViralName.class);
+               return getDefaultNonViralNameMatchStrategy();// PreferencesUtil.getMatchStrategy(NonViralName.class);
        }
        
        /**
@@ -42,8 +42,8 @@ public class MatchStrategyConfigurator {
         * @throws MatchException
         */
        public static IMatchStrategy TeamOrPersonMatchStrategy() throws MatchException{
-               return PreferencesUtil.getMatchStrategy(TeamOrPersonBase.class);
-       }
+               return null;// PreferencesUtil.getMatchStrategy(TeamOrPersonBase.class);
+       } 
        
        /**
         * 
@@ -51,7 +51,7 @@ public class MatchStrategyConfigurator {
         * @throws MatchException
         */
        public static IMatchStrategy ReferenceMatchStrategy() throws MatchException{
-               return PreferencesUtil.getMatchStrategy(ReferenceBase.class);
+               return getDefaultReferenceMatchStrategy();// PreferencesUtil.getMatchStrategy(ReferenceBase.class);
        }
 
        /**
@@ -85,6 +85,9 @@ public class MatchStrategyConfigurator {
        public static IMatchStrategy getDefaultReferenceMatchStrategy() throws MatchException{
                IMatchStrategy strategy = PreferencesUtil.getDefaultMatchStrategy(ReferenceBase.class);
                
+               strategy.setMatchMode("title", MatchMode.EQUAL);
+               strategy.setMatchMode("inReference", MatchMode.IGNORE);
+               
                return strategy;
        }
 
index e3747375d2a6738c9a466681cdd3e9183becd2ea..a545ac6a87bd8403449a29f624d1d912bc483bba 100644 (file)
@@ -195,7 +195,7 @@ public class ParseHandler{
                resolveDuplicateNames(name);
                
                resolveAllDuplicateAuthors(name);
-                               
+               
                resolveDuplicateReferences(name);
                
                if(duplicateInReferences != null)
@@ -235,13 +235,14 @@ public class ParseHandler{
         * @param name The name to resolve duplicates for.
         */
        private void resolveDuplicateInReferences(NonViralName name) {
-               ReferenceBase reference = (ReferenceBase) name.getNomenclaturalReference();
-               if(duplicateInReferences.size() == 1){
-                       // exactly one match. We assume that the user wants this reference
-                       reference.setInReference((ReferenceBase) duplicateInReferences.iterator().next());
-               }else if(duplicateInReferences.size() > 1){
-                       // FIXME TODO resolve multiple duplications. Use first match for a start
-                       reference.setInReference((ReferenceBase) duplicateInReferences.iterator().next());
+               ReferenceBase reference = (ReferenceBase) HibernateProxyHelper.deproxy(name.getNomenclaturalReference());
+               
+               if(duplicateInReferences.size() > 0){
+                       ReferenceBase inReference = (ReferenceBase) duplicateInReferences.iterator().next();
+                       reference.setInReference(inReference);
+                       logger.warn(reference.generateTitle());
+                       // FIXME TODO resolve multiple duplications. We use first match for a start
+                       logger.warn(reference.getTitleCache());
                }
        }
        
@@ -251,32 +252,26 @@ public class ParseHandler{
         */
        private void resolveAllDuplicateAuthors(NonViralName name) {
                
-               if(duplicateCombinationAuthorTeams.size() == 1){
-                       name.setCombinationAuthorTeam(duplicateCombinationAuthorTeams.iterator().next());
-               }else if(duplicateCombinationAuthorTeams.size() > 1){
-                       // FIXME TODO resolve multiple duplications. Use first match for a start
+               if(duplicateCombinationAuthorTeams.size() > 0){
                        name.setCombinationAuthorTeam(duplicateCombinationAuthorTeams.iterator().next());
+                       ReferenceBase reference = (ReferenceBase) name.getNomenclaturalReference();
+                       reference.setAuthorTeam(duplicateCombinationAuthorTeams.iterator().next());
+                       // FIXME TODO resolve multiple duplications. We use first match for a start.
                }
                
-               if(duplicateExCombinationAuthorTeams.size() == 1){
-                       name.setExCombinationAuthorTeam(duplicateExCombinationAuthorTeams.iterator().next());
-               }else if(duplicateExCombinationAuthorTeams.size() > 1){
-                       // FIXME TODO resolve multiple duplications. Use first match for a start
+               if(duplicateExCombinationAuthorTeams.size() > 0){
                        name.setExCombinationAuthorTeam(duplicateExCombinationAuthorTeams.iterator().next());
+                       // FIXME TODO resolve multiple duplications. We use first match for a start.
                }
                
-               if(duplicateBasionymAuthorTeams.size() == 1){
-                       name.setBasionymAuthorTeam(duplicateBasionymAuthorTeams.iterator().next());
-               }else if(duplicateBasionymAuthorTeams.size() > 1){
-                       // FIXME TODO resolve multiple duplications. Use first match for a start
+               if(duplicateBasionymAuthorTeams.size() > 0){
                        name.setBasionymAuthorTeam(duplicateBasionymAuthorTeams.iterator().next());
+                       // FIXME TODO resolve multiple duplications. We use first match for a start.
                }
                
-               if(duplicateExBasionymAuthorTeams.size() == 1){
-                       name.setExBasionymAuthorTeam(duplicateExBasionymAuthorTeams.iterator().next());
-               }else if(duplicateExBasionymAuthorTeams.size() > 1){
-                       // FIXME TODO resolve multiple duplications. Use first match for a start
+               if(duplicateExBasionymAuthorTeams.size() > 0){
                        name.setExBasionymAuthorTeam(duplicateExBasionymAuthorTeams.iterator().next());
+                       // FIXME TODO resolve multiple duplications. We use first match for a start.
                }
        }
        
@@ -296,10 +291,8 @@ public class ParseHandler{
                duplicateExBasionymAuthorTeams = findMatchingAuthors((TeamOrPersonBase) name.getExBasionymAuthorTeam());
                
                INomenclaturalReference nomenclaturalReference = name.getNomenclaturalReference();
-               duplicateReferences = findMatchingNomenclaturalReference(nomenclaturalReference);
                
-               // check if the reference has an inreference and also check if the inReference already exists
-               // FIXME implement this once the transition to new reference model is complete (cdmlib 3.2) 
+               // check if the reference has an inreference and also check if the inReference already exists 
                if(nomenclaturalReference != null){
                        ReferenceBase inReference = ((ReferenceBase)nomenclaturalReference).getInReference();
                        if(inReference != null){
@@ -307,6 +300,8 @@ public class ParseHandler{
                                duplicateInReferences = findMatchingNomenclaturalReference(inReference);
                        }
                }
+               
+               duplicateReferences = findMatchingNomenclaturalReference(nomenclaturalReference);
        }
        
        /**