(no commit message)
authorAndreas Müller <a.mueller@bgbm.org>
Tue, 5 Oct 2010 20:37:57 +0000 (20:37 +0000)
committerAndreas Müller <a.mueller@bgbm.org>
Tue, 5 Oct 2010 20:37:57 +0000 (20:37 +0000)
cdmlib-ext/src/main/java/eu/etaxonomy/cdm/ext/ipni/IpniService.java
cdmlib-ext/src/test/java/eu/etaxonomy/cdm/ext/ipni/IpniServiceTest.java

index fbbd960cbf716894ed5061ee9696fe10658a0165..7f020c47a874194ea5f7f1577ac87bf49700a6e3 100644 (file)
@@ -304,6 +304,13 @@ public class IpniService  implements IIpniService{
        }\r
 \r
 \r
+       /**\r
+        * @param line\r
+        * @param parameterMap\r
+        * @param appConfig\r
+        * @param config\r
+        * @return\r
+        */\r
        private ReferenceBase getPublicationFromLine(String line, Map<Integer, String> parameterMap, ICdmApplicationConfiguration appConfig, IpniServicePublicationConfigurator config) {\r
                //fill value map\r
                String[] splits = line.split("%");\r
@@ -330,30 +337,45 @@ public class IpniService  implements IIpniService{
                ref.setPlacePublished(valueMap.get(PLACE));\r
 \r
                String author = valueMap.get(PUBLICATION_AUTHOR_TEAM);\r
-               Team team = Team.NewTitledInstance(author, author);\r
-               ref.setAuthorTeam(team);\r
+               if (StringUtils.isNotBlank(author)){\r
+                       Team team = Team.NewTitledInstance(author, author);\r
+                       ref.setAuthorTeam(team);\r
+               }\r
                \r
                //remarks\r
                String remarks = valueMap.get(REMARKS);\r
                Annotation annotation = Annotation.NewInstance(remarks, AnnotationType.EDITORIAL(), Language.ENGLISH());\r
                ref.addAnnotation(annotation);\r
 \r
+\r
+               String tl2AuthorString = valueMap.get(TL2_AUTHOR);\r
+               if (ref.getAuthorTeam() == null){\r
+                       Team tl2Author = Team.NewTitledInstance(tl2AuthorString, null);\r
+                       ref.setAuthorTeam(tl2Author);\r
+               }else{\r
+                       //TODO parse name, \r
+                       ref.getAuthorTeam().setTitleCache(tl2AuthorString, true);\r
+                       ref.addAnnotation(Annotation.NewInstance(tl2AuthorString, AnnotationType.EDITORIAL(), Language.ENGLISH()));\r
+               }\r
+\r
+               \r
                //dates\r
                TimePeriod date = TimePeriod.parseString(valueMap.get(DATE));\r
                ref.setDatePublished(date);\r
 \r
+\r
                //source\r
                ReferenceBase citation = getIpniCitation(appConfig);\r
                ref.addSource(valueMap.get(ID), "Publication", citation, valueMap.get(VERSION));\r
 \r
                \r
+               \r
 /*             TODO\r
                BPH number\r
                Authors role\r
                In publication facade\r
                LC number\r
                Preceded by\r
-               TL2 author\r
                TL2 number\r
                TDWG abbreviation\r
        */\r
index eb0c5701358a1faa2a286596ff6606457ad2fc19..811e87b5e89c4bb3124d96326befb066a9bec704 100644 (file)
@@ -155,10 +155,21 @@ public class IpniServiceTest {
                //20009158-1%1.2%Pinaceae%%N%Abies%%N%alba%apennina%subsp.%Brullo, Scelsi & Spamp.%%Brullo, Scelsi & Spamp.%Abies alba subsp. apennina%Vegetaz. Aspromonte%41 (2001)%2001%%%%%%Italy%tax. nov.\r
 \r
                Assert.assertEquals("There should be exactly 1 result for 'Species Plantarum, Edition 3'", 1, refList.size());\r
-               ReferenceBase name = refList.get(0);\r
+               ReferenceBase ref = refList.get(0);\r
                //title cache\r
-               Assert.assertEquals("Title Cache for Abies albertiana should be 'Species Plantarum, Edition 3'", "Species Plantarum, Edition 3. 1764", name.getTitleCache());\r
+               //the author title may be improved in future\r
+               Assert.assertEquals("Title Cache should be 'Linnaeus, Carl, Species Plantarum, Edition 3'", "Linnaeus, Carl, Species Plantarum, Edition 3. 1764", ref.getTitleCache());\r
 \r
+               \r
+               refList = service1.getPublications("Flora of Macar", null, services, config);\r
+               Assert.assertNotNull("Empty resultset should not throw exception and should not be null", refList);\r
+                       \r
+               refList = service1.getPublications("Flora Europaea [ed. 2]", null, services, config);\r
+               Assert.assertEquals("There should be exactly 1 result for 'Flora Europaea [ed. 2]'", 1, refList.size());\r
+               ref = refList.get(0);\r
+               Assert.assertEquals("", "Tutin, Thomas Gaskell", ref.getAuthorTeam().getTitleCache());\r
+               \r
+               \r
 //             for (ReferenceBase ref : refList){\r
 //                     System.out.println(ref.getTitleCache());\r
 //             }\r