cleanup
authorAndreas Müller <a.mueller@bgbm.org>
Wed, 10 Jun 2020 21:59:34 +0000 (23:59 +0200)
committerAndreas Müller <a.mueller@bgbm.org>
Wed, 10 Jun 2020 21:59:34 +0000 (23:59 +0200)
cdmlib-model/src/main/java/eu/etaxonomy/cdm/strategy/match/MatchStrategyFactory.java
cdmlib-model/src/main/java/eu/etaxonomy/cdm/strategy/match/ParsedBaseMatchStrategy.java
cdmlib-model/src/main/java/eu/etaxonomy/cdm/strategy/match/ParsedReferenceMatchStrategy.java
cdmlib-model/src/main/java/eu/etaxonomy/cdm/strategy/match/SubClassMatchStrategy.java
cdmlib-model/src/test/java/eu/etaxonomy/cdm/strategy/match/MatchStrategyFactoryTest.java

index 73002bc2f3bb3615b0531f044427b71169d368ed..89cd09ff0045ee3573efb206a166867ccb6d98d1 100644 (file)
@@ -16,7 +16,6 @@ import eu.etaxonomy.cdm.model.reference.Reference;
 /**
  * @author a.mueller
  * @since 17.10.2018
- *
  */
 public class MatchStrategyFactory {
 
@@ -37,7 +36,6 @@ public class MatchStrategyFactory {
         } catch (MatchException e) {
             throw new RuntimeException("Exception when creating parsed person match strategy.", e);
         }
-
     }
 
     public static IParsedMatchStrategy NewParsedTeamInstance(){
@@ -68,7 +66,6 @@ public class MatchStrategyFactory {
         }
     }
 
-
     public static IParsedMatchStrategy NewParsedBookInstance(){
         IParsedMatchStrategy parsedBookMatchStrategy = NewParsedInstance(Reference.class);
         try {
@@ -117,7 +114,6 @@ public class MatchStrategyFactory {
         }
     }
 
-
     public static IParsedMatchStrategy NewParsedArticleInstance(){ //or should it better be Section (in Journal)
         try {
             IParsedMatchStrategy articleMatchStrategy = (IParsedMatchStrategy)NewDefaultInstance(Reference.class);
@@ -143,7 +139,6 @@ public class MatchStrategyFactory {
         }
     }
 
-
     public static IParsedMatchStrategy NewParsedJournalInstance(){
         IParsedMatchStrategy parsedJournalMatchStrategy = NewParsedInstance(Reference.class);
         try {
@@ -181,8 +176,6 @@ public class MatchStrategyFactory {
         return refStrat;
     }
 
-
-
     //  public static IMatchStrategy NewParsedNameInstance(){
     //      IMatchStrategy result = new DefaultMatchStrategy(TaxonName.class);
     //      return result;
index 033f2f7313b2a27da54ee7b7011792c7880d257a..d663964d62506a1e2a0665e626fabdb4763d31bf 100644 (file)
@@ -20,6 +20,7 @@ import org.apache.log4j.Logger;
 public class ParsedBaseMatchStrategy extends DefaultMatchStrategy implements IParsedMatchStrategy {
 
     private static final long serialVersionUID = 1253144282030211050L;
+    @SuppressWarnings("unused")
     private static final Logger logger = Logger.getLogger(ParsedBaseMatchStrategy.class);
 
        final static UUID uuid = UUID.fromString("4e2efeca-96a3-4894-80f4-f1015295f059");
index 6d310f9b2ee6e689aa5b1b5a61800786f4350d83..9af252ab277ea80a8bac9b80411c215e9c587a07 100644 (file)
@@ -15,7 +15,6 @@ import eu.etaxonomy.cdm.model.reference.ReferenceType;
 /**
  * @author a.mueller
  * @since 20.10.2018
- *
  */
 public class ParsedReferenceMatchStrategy implements IParsedMatchStrategy{
 
@@ -32,26 +31,17 @@ public class ParsedReferenceMatchStrategy implements IParsedMatchStrategy{
         return instance;
     }
 
-    /**
-     * {@inheritDoc}
-     */
     @Override
     public void setMatchMode(String propertyName, MatchMode matchMode) throws MatchException {
         setMatchMode(propertyName, matchMode, null);
     }
 
-    /**
-     * {@inheritDoc}
-     */
     @Override
     public void setMatchMode(String propertyName, MatchMode matchMode, IMatchStrategy matchStrategy)
             throws MatchException {
         throw new MatchException("ParsedReferenceMatchStrategy is immutable");
     }
 
-    /**
-     * {@inheritDoc}
-     */
     @Override
     public Matching getMatching() {
         //why does it not throw MatchException?
@@ -65,9 +55,6 @@ public class ParsedReferenceMatchStrategy implements IParsedMatchStrategy{
     //TODO no generic reference yet
     private IMatchStrategy genericStrategy = MatchStrategyFactory.NewDefaultInstance(Reference.class);
 
-    /**
-     * {@inheritDoc}
-     */
     @Override
     public <T extends IMatchable> MatchResult invoke(T fullInstance, T parsedInstance) throws MatchException {
         return invoke(fullInstance, parsedInstance, false);
@@ -81,10 +68,6 @@ public class ParsedReferenceMatchStrategy implements IParsedMatchStrategy{
         return matchResult;
     }
 
-
-    /**
-     * {@inheritDoc}
-     */
     @Override
     public <T extends IMatchable> void invoke(T fullInstance, T parsedInstance, MatchResult matchResult,
             boolean failAll)
@@ -119,7 +102,5 @@ public class ParsedReferenceMatchStrategy implements IParsedMatchStrategy{
             }
             return;
         }
-
     }
-
 }
index 9f3d29bd2686bc409018acab198d41be245d1f34..a749166368eab1e96c78bce13f7d9103616926e7 100644 (file)
@@ -33,8 +33,6 @@ import eu.etaxonomy.cdm.strategy.StrategyBase;
  * modes for the same property path in short cut methods like {@link #getMatching()}
  * or {@link #getMatchMode(String)}. Are these needed at all?
  *
- *
- *
  * @author a.mueller
  * @since 15.10.2018
  */
@@ -87,10 +85,6 @@ public class SubClassMatchStrategy<T extends IMatchable> extends StrategyBase
         updateMatching();
     }
 
-    /**
-     * @throws MatchException
-     *
-     */
     private void updateMatching() throws MatchException {
         for (IMatchStrategy strategy : strategies.values()){
             matching = new Matching();
@@ -123,9 +117,6 @@ public class SubClassMatchStrategy<T extends IMatchable> extends StrategyBase
         return uuid;
     }
 
-//    /**
-//     * {@inheritDoc}
-//     */
 //    @Override
 //    public MatchMode getMatchMode(String propertyName) {
 //        //Copied from DefaultMatchStrategy
@@ -154,7 +145,7 @@ public class SubClassMatchStrategy<T extends IMatchable> extends StrategyBase
 
     /**
      * {@inheritDoc}
-     * @deprecated deprecated in this class, use {@link #setMatchMode(String, MatchMode, IMatchStrategyEqual)}
+     * @deprecated deprecated in this class, use {@link #setMatchMode(String, MatchMode, IMatchStrategyEqual)}
      * instead.
      */
     @Deprecated
@@ -177,7 +168,6 @@ public class SubClassMatchStrategy<T extends IMatchable> extends StrategyBase
         }
      }
 
-
     /**
      * {@inheritDoc}
      * @throws MatchException
@@ -186,9 +176,6 @@ public class SubClassMatchStrategy<T extends IMatchable> extends StrategyBase
         getBestMatchingStrategy(clazz).setMatchMode(propertyName, matchMode, matchStrategy);
     }
 
-    /**
-     * @param clazz
-     */
     private IMatchStrategy getBestMatchingStrategy(Class<? extends T> clazz) {
         IMatchStrategy result = strategies.get(clazz);
         //TODO use subclass hierarchie
@@ -198,15 +185,11 @@ public class SubClassMatchStrategy<T extends IMatchable> extends StrategyBase
         return result;
     }
 
-    /**
-     * {@inheritDoc}
-     */
     @Override
     public <S extends IMatchable> MatchResult invoke(S matchFirst, S matchSecond) throws MatchException {
         return invoke(matchFirst, matchSecond, false);
     }
 
-
     @Override
     public <T extends IMatchable> MatchResult invoke(T matchFirst, T matchSecond, boolean failAll)
             throws MatchException {
@@ -228,20 +211,13 @@ public class SubClassMatchStrategy<T extends IMatchable> extends StrategyBase
             matchResult.addClass(clazz);
         }
 
-
         strategy.invoke(matchFirst, matchSecond, matchResult, failAll);
     }
 
-    /**
-     * @return
-     */
     private IMatchStrategy getBaseClassStrategy() {
         return strategies.get(baseClass);
     }
 
-    /**
-     * {@inheritDoc}
-     */
     @Override
     public Matching getMatching() {
         //preliminary not yet implemented
@@ -254,18 +230,12 @@ public class SubClassMatchStrategy<T extends IMatchable> extends StrategyBase
 //        return baseClass;
 //    }
 //
-//    /**
-//     * {@inheritDoc}
-//     */
 //    @Override
 //    public Set<String> getMatchFieldPropertyNames() {
 //        //preliminary not implemented. Simply aggregate, or change signature to xxx(clazz), or .. ?
 //        throw new RuntimeException("getMatchFieldPropertyNames not yet implemented in " + getClass().getName());
 //    }
 //
-//    /**
-//     * {@inheritDoc}
-//     */
 //    @Override
 //    public void setDefaultMatchMode(MatchMode defaultMatchMode) {
 //        for (IMatchStrategy matchStrategy : strategies.values()){
@@ -273,9 +243,6 @@ public class SubClassMatchStrategy<T extends IMatchable> extends StrategyBase
 //        }
 //    }
 //
-//    /**
-//     * {@inheritDoc}
-//     */
 //    @Override
 //    public void setDefaultCollectionMatchMode(MatchMode defaultCollectionMatchMode) {
 //        for (IMatchStrategy matchStrategy : strategies.values()){
@@ -283,9 +250,6 @@ public class SubClassMatchStrategy<T extends IMatchable> extends StrategyBase
 //        }
 //    }
 //
-//    /**
-//     * {@inheritDoc}
-//     */
 //    @Override
 //    public void setDefaultMatchMatchMode(MatchMode defaultMatchMatchMode) {
 //        for (IMatchStrategy matchStrategy : strategies.values()){
index aad600d88eb749c768b4c400073786b518f49ca9..fcbd6959050a1be971768df30498863c3a9b41e6 100644 (file)
@@ -68,19 +68,12 @@ public class MatchStrategyFactoryTest {
 
        private Institution institution1;
 
-       /**
-        * @throws java.lang.Exception
-        */
        @BeforeClass
        public static void setUpBeforeClass() throws Exception {
                DefaultTermInitializer termInitializer = new DefaultTermInitializer();
                termInitializer.initialize();
        }
 
-
-       /**
-        * @throws java.lang.Exception
-        */
        @Before
        public void setUp() throws Exception {
 //             team1 = Team.NewInstance();
@@ -125,12 +118,8 @@ public class MatchStrategyFactoryTest {
 
        }
 
-
 //********************* TEST *********************************************/
 
-       /**
-        * Test method for {@link eu.etaxonomy.cdm.strategy.match.DefaultMatchStrategy#NewInstance(java.lang.Class)}.
-        */
        @Test
        public void testNewInstance() {
                matchStrategy = MatchStrategyFactory.NewDefaultInstance(Reference.class);
@@ -138,10 +127,6 @@ public class MatchStrategyFactoryTest {
 //             Assert.assertEquals(Reference.class, matchStrategy.getMatchClass());
        }
 
-          /**
-     * Test method for {@link eu.etaxonomy.cdm.strategy.match.DefaultMatchStrategy#invoke(IMatchable, IMatchable), eu.etaxonomy.cdm.strategy.match.IMatchable)}.
-     * @throws MatchException
-     */
     @Test
     public void testParsedPerson() throws MatchException {
         IParsedMatchStrategy matchStrategy = MatchStrategyFactory.NewParsedPersonInstance();
@@ -195,14 +180,8 @@ public class MatchStrategyFactoryTest {
 //        System.out.println(fullPerson.getTitleCache());
 //        System.out.println(parsedPerson.getTitleCache());
         Assert.assertFalse("Differing nom. title should not match", matchStrategy.invoke(fullPerson, parsedPerson).isSuccessful());
-
-
     }
 
-
-    /**
-     * @return
-     */
     protected Person getDefaultFullPerson() {
         Person fullPerson = Person.NewInstance();
         fullPerson.setInitials("F.G.");
@@ -217,13 +196,6 @@ public class MatchStrategyFactoryTest {
         return fullPerson;
     }
 
-
-
-
-
-    /**
-     * @return
-     */
     protected Person getDefaultParsedPerson() {
         Person parsedPerson = Person.NewInstance();
         parsedPerson.setNomenclaturalTitle("Nam.");
@@ -234,70 +206,63 @@ public class MatchStrategyFactoryTest {
       * Test method for {@link eu.etaxonomy.cdm.strategy.match.DefaultMatchStrategy#invoke(IMatchable, IMatchable), eu.etaxonomy.cdm.strategy.match.IMatchable)}.
       * @throws MatchException
       */
-     @Test
-     public void testParsedTeam() throws MatchException {
-         IParsedMatchStrategy matchStrategy = MatchStrategyFactory.NewParsedTeamInstance();
-         Assert.assertNotNull(matchStrategy);
-         Team fullTeam;
-         Team parsedTeam;
-         MatchResult matchResult;
-
-         fullTeam = getDefaultFullTeam();
-         parsedTeam = getDefaultParsedTeam();
-
-         //should match
-         Assert.assertTrue("Same nom.title. should match", matchStrategy.invoke(fullTeam, parsedTeam).isSuccessful());
-
-         //differing nom. title.
-         parsedTeam.setNomenclaturalTitle("Wrong");
-         Assert.assertFalse("Differing nom.title. should not match", matchStrategy.invoke(fullTeam, parsedTeam).isSuccessful());
-
-         //differing family
-         parsedTeam = getDefaultParsedTeam();
-         parsedTeam.getTeamMembers().get(0).setFamilyName("Wrong");
-         matchResult = matchStrategy.invoke(fullTeam, parsedTeam, true);
-         Assert.assertFalse("Differing family name should not match", matchResult.isSuccessful());
-         parsedTeam.getTeamMembers().get(0).setNomenclaturalTitle("Wrong.");
-         matchResult = matchStrategy.invoke(fullTeam, parsedTeam, true);
-         System.out.println(matchResult);
-         Assert.assertFalse("Differing family name should not match", matchResult.isSuccessful());
-
-
-         //
-         parsedTeam = getDefaultParsedTeam();
-         parsedTeam.getTeamMembers().get(0).setInitials("D.");
-         Assert.assertFalse("Differing nom. title should not match", matchStrategy.invoke(fullTeam, parsedTeam).isSuccessful());
-
-         //nom. title. (2)
-         fullTeam = getDefaultFullTeam();
-         parsedTeam = getDefaultParsedTeam();
-         fullTeam.setNomenclaturalTitle("Wro.");
-         Assert.assertFalse("Differing nom. title should not match", matchStrategy.invoke(fullTeam, parsedTeam).isSuccessful());
-
-         //fullPerson protected
-         fullTeam = getDefaultFullTeam();
-         parsedTeam = getDefaultParsedTeam();
-         fullTeam.setTitleCache(fullTeam.getTitleCache(), true);
-         Assert.assertFalse("Differing protected title should not match", matchStrategy.invoke(fullTeam, parsedTeam).isSuccessful());
-
-         //parsedPerson protected
-         fullTeam = getDefaultFullTeam();
-         parsedTeam = getDefaultParsedTeam();
-         parsedTeam.setTitleCache(parsedTeam.getTitleCache(), true);
-         Assert.assertFalse("Differing nom. title should not match", matchStrategy.invoke(fullTeam, parsedTeam).isSuccessful());
-
-         fullTeam = getDefaultFullTeam();
-         parsedTeam = getDefaultParsedTeam();
-         fullTeam.setHasMoreMembers(true);
-         Assert.assertFalse("Differing nom. title should not match", matchStrategy.invoke(fullTeam, parsedTeam).isSuccessful());
-
-
-     }
+    @Test
+    public void testParsedTeam() throws MatchException {
+        IParsedMatchStrategy matchStrategy = MatchStrategyFactory.NewParsedTeamInstance();
+        Assert.assertNotNull(matchStrategy);
+        Team fullTeam;
+        Team parsedTeam;
+        MatchResult matchResult;
 
+        fullTeam = getDefaultFullTeam();
+        parsedTeam = getDefaultParsedTeam();
+
+        //should match
+        Assert.assertTrue("Same nom.title. should match", matchStrategy.invoke(fullTeam, parsedTeam).isSuccessful());
+
+        //differing nom. title.
+        parsedTeam.setNomenclaturalTitle("Wrong");
+        Assert.assertFalse("Differing nom.title. should not match", matchStrategy.invoke(fullTeam, parsedTeam).isSuccessful());
+
+        //differing family
+        parsedTeam = getDefaultParsedTeam();
+        parsedTeam.getTeamMembers().get(0).setFamilyName("Wrong");
+        matchResult = matchStrategy.invoke(fullTeam, parsedTeam, true);
+        Assert.assertFalse("Differing family name should not match", matchResult.isSuccessful());
+        parsedTeam.getTeamMembers().get(0).setNomenclaturalTitle("Wrong.");
+        matchResult = matchStrategy.invoke(fullTeam, parsedTeam, true);
+        System.out.println(matchResult);
+        Assert.assertFalse("Differing family name should not match", matchResult.isSuccessful());
+
+        //
+        parsedTeam = getDefaultParsedTeam();
+        parsedTeam.getTeamMembers().get(0).setInitials("D.");
+        Assert.assertFalse("Differing nom. title should not match", matchStrategy.invoke(fullTeam, parsedTeam).isSuccessful());
+
+        //nom. title. (2)
+        fullTeam = getDefaultFullTeam();
+        parsedTeam = getDefaultParsedTeam();
+        fullTeam.setNomenclaturalTitle("Wro.");
+        Assert.assertFalse("Differing nom. title should not match", matchStrategy.invoke(fullTeam, parsedTeam).isSuccessful());
+
+        //fullPerson protected
+        fullTeam = getDefaultFullTeam();
+        parsedTeam = getDefaultParsedTeam();
+        fullTeam.setTitleCache(fullTeam.getTitleCache(), true);
+        Assert.assertFalse("Differing protected title should not match", matchStrategy.invoke(fullTeam, parsedTeam).isSuccessful());
+
+        //parsedPerson protected
+        fullTeam = getDefaultFullTeam();
+        parsedTeam = getDefaultParsedTeam();
+        parsedTeam.setTitleCache(parsedTeam.getTitleCache(), true);
+        Assert.assertFalse("Differing nom. title should not match", matchStrategy.invoke(fullTeam, parsedTeam).isSuccessful());
+
+        fullTeam = getDefaultFullTeam();
+        parsedTeam = getDefaultParsedTeam();
+        fullTeam.setHasMoreMembers(true);
+        Assert.assertFalse("Differing nom. title should not match", matchStrategy.invoke(fullTeam, parsedTeam).isSuccessful());
+    }
 
-    /**
-     * @return
-     */
     private Team getDefaultFullTeam() {
         Team team = Team.NewInstance();
         team.addTeamMember(getDefaultFullPerson());
@@ -367,11 +332,8 @@ public class MatchStrategyFactoryTest {
         parsedBook = getDefaultParsedBook();
         ((Team)fullBook.getAuthorship()).getTeamMembers().get(0).setFamilyName("Changed");
         Assert.assertTrue("Full book family name author changed should still match", matchStrategy.invoke(fullBook, parsedBook).isSuccessful());
-
-
     }
 
-
     @Test
     public void testParsedBookSection() throws MatchException {
         IParsedMatchStrategy matchStrategy = MatchStrategyFactory.NewParsedBookSectionInstance();
@@ -415,10 +377,6 @@ public class MatchStrategyFactoryTest {
         Assert.assertTrue("Full book family name author changed should still match", matchStrategy.invoke(fullBookSection, parsedBookSection).isSuccessful());
     }
 
-
-    /**
-     * @return
-     */
     private IBook getDefaultFullBook() {
         IBook book = getDefaultParsedBook();
         book.setAuthorship(getDefaultFullTeam());
@@ -430,10 +388,6 @@ public class MatchStrategyFactoryTest {
         return book;
     }
 
-
-    /**
-     * @return
-     */
     private IBook getDefaultParsedBook() {
         IBook book = ReferenceFactory.newBook();
         book.setAbbrevTitle("Fl. Hell.");
@@ -446,10 +400,6 @@ public class MatchStrategyFactoryTest {
         return book;
     }
 
-
-    /**
-     * @return
-     */
     private IBookSection getDefaultFullBookSection() {
         IBookSection bookSection = getMatchingFullBookSection();
         bookSection.setTitle("Book section title");
@@ -466,9 +416,6 @@ public class MatchStrategyFactoryTest {
         return bookSection;
     }
 
-    /**
-     * @return
-     */
     private IBookSection getDefaultParsedBookSection() {
         IBookSection bookSection = ReferenceFactory.newBookSection();
         bookSection.setAuthorship(getDefaultParsedPerson());
@@ -477,7 +424,6 @@ public class MatchStrategyFactoryTest {
         return bookSection;
     }
 
-
     @Test
     public void testParsedArticle() throws MatchException {
         IParsedMatchStrategy matchStrategy = MatchStrategyFactory.NewParsedArticleInstance();
@@ -537,9 +483,6 @@ public class MatchStrategyFactoryTest {
         return article;
     }
 
-    /**
-     * @return
-     */
     private IArticle getDefaultParsedArticle() {
         IArticle article = ReferenceFactory.newArticle();
         article.setAuthorship(getDefaultParsedTeam());
@@ -559,10 +502,6 @@ public class MatchStrategyFactoryTest {
         return journal;
     }
 
-
-    /**
-     * @return
-     */
     private IJournal getDefaultParsedJournal() {
         IJournal journal = ReferenceFactory.newJournal();
         journal.setAbbrevTitle("Fl. Hell.");
@@ -614,6 +553,4 @@ public class MatchStrategyFactoryTest {
         ((Team)fullArticle.getAuthorship()).getTeamMembers().get(0).setFamilyName("Changed");
         Assert.assertTrue("Full book family name author changed should still match", matchStrategy.invoke(fullArticle, parsedArticle).isSuccessful());
     }
-
-
 }