ref #9326, ref #3764 fix secion in book-section handling and some cleanup in Referen...
authorAndreas Müller <a.mueller@bgbm.org>
Thu, 20 May 2021 10:49:24 +0000 (12:49 +0200)
committerAndreas Müller <a.mueller@bgbm.org>
Thu, 20 May 2021 10:49:38 +0000 (12:49 +0200)
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/agent/Team.java
cdmlib-model/src/test/java/eu/etaxonomy/cdm/format/reference/NomenclaturalSourceFormatterTest.java
cdmlib-model/src/test/java/eu/etaxonomy/cdm/strategy/cache/reference/ReferenceDefaultCacheStrategyTest.java

index c45f38600d7ff0cd73ff34d3fa973c8ade1d153a..a3c9ad85c35efe6db41f3decb9c2a44a37411c9b 100644 (file)
@@ -115,8 +115,12 @@ public class Team extends TeamOrPersonBase<Team> {
         */
        static public Team NewTitledInstance(String title, String nomTitle){
                Team result = new Team();
-               result.setTitleCache(title, true);
-               result.setNomenclaturalTitle(nomTitle, true);
+               if (isNotBlank(title)){
+                   result.setTitleCache(title, true);
+               }
+               if (isNotBlank(nomTitle)){
+                   result.setNomenclaturalTitle(nomTitle, true);
+               }
                return result;
        }
 
index 1ef0ea8e14a617d5541883bda09a3cfcf72bb128..776a23fd2ac6a07a26f8553b0dca127ffa421b5f 100644 (file)
@@ -12,6 +12,7 @@ import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 
+import eu.etaxonomy.cdm.common.DOI;
 import eu.etaxonomy.cdm.common.URI;
 import eu.etaxonomy.cdm.model.agent.Person;
 import eu.etaxonomy.cdm.model.agent.Team;
@@ -381,5 +382,66 @@ public class NomenclaturalSourceFormatterTest {
         //only inref has volume
         generic1.setVolume(null);
         Assert.assertEquals("in InRefAuthor, My InRef 9: 55. 1883"+SEP+"1884", formatter.format(generic1, detail1));
-   }
+    }
+
+    @Test  //see also the corresponging method in ReferenceDefaultCacheStrategy
+    public void testSectionInArticle(){
+        //#9326, #3764
+        Reference journal = ReferenceFactory.newJournal();
+        journal.setTitle("Phytotaxa");
+        Reference article = ReferenceFactory.newArticle();
+        String articleTitle = "New diatom species Navicula davidovichii from Vietnam (Southeast Asia)";
+        article.setTitle(articleTitle);
+        Team articleTeam = Team.NewTitledInstance("Kulikovskiy, M., Chudaev, D.A., Glushchenko, A., Kuznetsova, I. & Kociolek, J.P.", null);
+        article.setAuthorship(articleTeam);
+        article.setInJournal(journal);
+        article.setVolume("452(1)");
+        article.setPages("83-91");
+        article.setDatePublished(TimePeriodParser.parseStringVerbatim("8 Jul 2020"));
+        article.setDoi(DOI.fromString("10.11646/phytotaxa.452.1.8"));
+        Reference section = ReferenceFactory.newSection();
+        Team sectionTeam = Team.NewTitledInstance("Chudaev, D.A., Glushchenko, A., Kulikovskiy, M. & Kociolek, J.P.", null);
+        section.setAuthorship(sectionTeam);
+        section.setInReference(article);
+
+        Assert.assertEquals("Unexpected title cache.",
+                "in Phytotaxa 452(1): 55. 8 Jul 2020",
+                formatter.format(section, detail1));
+    }
+
+    @Test  //see also the corresponging method in ReferenceDefaultCacheStrategy
+    public void testSectionInBookSection(){
+        //#9326, #3764
+        Reference book = ReferenceFactory.newBook();
+        book.setTitle("Species Plantarum");
+        Person person = Person.NewInstance("L.", "Linne", "C.G.", "Carl-Gustav");
+        Team bookAuthor = Team.NewInstance(person); // Team.NewTitledInstance("Linne", null);
+
+        book.setAuthorship(bookAuthor);
+        book.setVolume("3");
+        Reference bookSection = ReferenceFactory.newBookSection();
+        String bookSectionTitle = "Trees";
+        bookSection.setTitle(bookSectionTitle);
+        Team bookSectionTeam = Team.NewTitledInstance("Chapter author", "Chap. Aut.");
+        bookSection.setAuthorship(bookSectionTeam);
+        bookSection.setInBook(book);
+        bookSection.setPages("83-91");
+        bookSection.setDatePublished(TimePeriodParser.parseStringVerbatim("1752"));
+        bookSection.setDoi(DOI.fromString("10.12345/speciesplantarum.3"));
+        Reference section = ReferenceFactory.newSection();
+        Team sectionTeam = Team.NewTitledInstance("Section author", null);
+        section.setAuthorship(sectionTeam);
+        section.setInReference(bookSection);
+
+        Assert.assertEquals("Unexpected title cache.",
+                "in Linne, Species Plantarum 3: 55. 1752",
+                formatter.format(section, detail1));
+        bookAuthor = Team.NewTitledInstance("Linneus", null);
+        book.setAuthorship(bookAuthor);
+        Assert.assertEquals("Unexpected title cache.",
+                "in Linneus, Species Plantarum 3: 55. 1752",
+                formatter.format(section, detail1));
+
+
+    }
 }
\ No newline at end of file
index 05d7d9e31bdf7d0631804a05bbf84052e3eb6151..3769ec8aca2f92bd3640b819df8eba7aa38d58c0 100644 (file)
@@ -132,10 +132,11 @@ public class ReferenceDefaultCacheStrategyTest {
        public void testArticleGetTitleCache(){
                journal1.setTitle("My journal");
                ((Reference)journal1).setAuthorship(articleTeam2);  //incorrect use anyway
-               article1.setTitle("My article");
                article1.setInJournal(journal1);
                article1.setAuthorship(articleTeam1);
                article1.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(1975));
+           Assert.assertEquals("Team1 1975: "+UTF8.EN_DASH+" My journal.", article1.getTitleCache());
+           article1.setTitle("My article");
                Assert.assertEquals("Team1 1975: My article. "+UTF8.EN_DASH+" My journal.", article1.getTitleCache());
 
                article1.setInJournal(null);
@@ -375,7 +376,7 @@ public class ReferenceDefaultCacheStrategyTest {
         article.setAuthorship(articleTeam);
         article.setInJournal(journal);
         article.setVolume("452(1)");
-        article.setVolume("83-91");
+        article.setPages("83-91");
         article.setDatePublished(TimePeriodParser.parseStringVerbatim("8 Jul 2020"));
         article.setDoi(DOI.fromString("10.11646/phytotaxa.452.1.8"));
         Reference section = ReferenceFactory.newSection();
@@ -384,8 +385,37 @@ public class ReferenceDefaultCacheStrategyTest {
         section.setInReference(article);
 
         Assert.assertEquals("Unexpected title cache.",
-                "Chudaev, D.A., Glushchenko, A., Kulikovskiy, M. & Kociolek, J.P. 2020 – In: "
-                + "Kulikovskiy, M., Chudaev, D.A., Glushchenko, A., Kuznetsova, I. & Kociolek, J.P., New diatom species Navicula davidovichii from Vietnam (Southeast Asia). – Phytotaxa 83-91.", section.getTitleCache());
+                "Chudaev, D.A., Glushchenko, A., Kulikovskiy, M. & Kociolek, J.P. 2020 "+UTF8.EN_DASH+" In: "
+                + "Kulikovskiy, M., Chudaev, D.A., Glushchenko, A., Kuznetsova, I. & Kociolek, J.P., "
+                + "New diatom species Navicula davidovichii from Vietnam (Southeast Asia). "+UTF8.EN_DASH+" Phytotaxa 452(1).",
+                section.getTitleCache());
+    }
+
+    @Test
+    public void testSectionInBookSection(){
+        //#9326, #3764
+        Reference book = ReferenceFactory.newBook();
+        book.setTitle("Species Plantarum");
+        Team bookAuthor = Team.NewTitledInstance("Linne", null);
+        book.setAuthorship(bookAuthor);
+        book.setVolume("3");
+        Reference bookSection = ReferenceFactory.newBookSection();
+        String bookSectionTitle = "Trees";
+        bookSection.setTitle(bookSectionTitle);
+        Team bookSectionTeam = Team.NewTitledInstance("Chapter author", null);
+        bookSection.setAuthorship(bookSectionTeam);
+        bookSection.setInBook(book);
+        bookSection.setPages("83-91");
+        bookSection.setDatePublished(TimePeriodParser.parseStringVerbatim("1752"));
+        bookSection.setDoi(DOI.fromString("10.12345/speciesplantarum.3"));
+        Reference section = ReferenceFactory.newSection();
+        Team sectionTeam = Team.NewTitledInstance("Section author", null);
+        section.setAuthorship(sectionTeam);
+        section.setInReference(bookSection);
+
+        Assert.assertEquals("Unexpected title cache.",
+                "Section author 1752 "+UTF8.EN_DASH+" In: Chapter author, Trees, pp. 83-91. "+UTF8.EN_DASH+" In: Linne, Species Plantarum 3.",
+                section.getTitleCache());
     }
 
     @Test