Project

General

Profile

« Previous | Next » 

Revision cd37bc26

Added by Andreas Müller about 1 year ago

ref #9326, ref #3764 fix secion in book-section handling and some cleanup in ReferenceDefaultCacheStrategy (cont.)

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/agent/Team.java
115 115
	 */
116 116
	static public Team NewTitledInstance(String title, String nomTitle){
117 117
		Team result = new Team();
118
		result.setTitleCache(title, true);
119
		result.setNomenclaturalTitle(nomTitle, true);
118
		if (isNotBlank(title)){
119
		    result.setTitleCache(title, true);
120
		}
121
		if (isNotBlank(nomTitle)){
122
		    result.setNomenclaturalTitle(nomTitle, true);
123
		}
120 124
		return result;
121 125
	}
122 126

  
cdmlib-model/src/test/java/eu/etaxonomy/cdm/format/reference/NomenclaturalSourceFormatterTest.java
12 12
import org.junit.Before;
13 13
import org.junit.Test;
14 14

  
15
import eu.etaxonomy.cdm.common.DOI;
15 16
import eu.etaxonomy.cdm.common.URI;
16 17
import eu.etaxonomy.cdm.model.agent.Person;
17 18
import eu.etaxonomy.cdm.model.agent.Team;
......
381 382
        //only inref has volume
382 383
        generic1.setVolume(null);
383 384
        Assert.assertEquals("in InRefAuthor, My InRef 9: 55. 1883"+SEP+"1884", formatter.format(generic1, detail1));
384
   }
385
    }
386

  
387
    @Test  //see also the corresponging method in ReferenceDefaultCacheStrategy
388
    public void testSectionInArticle(){
389
        //#9326, #3764
390
        Reference journal = ReferenceFactory.newJournal();
391
        journal.setTitle("Phytotaxa");
392
        Reference article = ReferenceFactory.newArticle();
393
        String articleTitle = "New diatom species Navicula davidovichii from Vietnam (Southeast Asia)";
394
        article.setTitle(articleTitle);
395
        Team articleTeam = Team.NewTitledInstance("Kulikovskiy, M., Chudaev, D.A., Glushchenko, A., Kuznetsova, I. & Kociolek, J.P.", null);
396
        article.setAuthorship(articleTeam);
397
        article.setInJournal(journal);
398
        article.setVolume("452(1)");
399
        article.setPages("83-91");
400
        article.setDatePublished(TimePeriodParser.parseStringVerbatim("8 Jul 2020"));
401
        article.setDoi(DOI.fromString("10.11646/phytotaxa.452.1.8"));
402
        Reference section = ReferenceFactory.newSection();
403
        Team sectionTeam = Team.NewTitledInstance("Chudaev, D.A., Glushchenko, A., Kulikovskiy, M. & Kociolek, J.P.", null);
404
        section.setAuthorship(sectionTeam);
405
        section.setInReference(article);
406

  
407
        Assert.assertEquals("Unexpected title cache.",
408
                "in Phytotaxa 452(1): 55. 8 Jul 2020",
409
                formatter.format(section, detail1));
410
    }
411

  
412
    @Test  //see also the corresponging method in ReferenceDefaultCacheStrategy
413
    public void testSectionInBookSection(){
414
        //#9326, #3764
415
        Reference book = ReferenceFactory.newBook();
416
        book.setTitle("Species Plantarum");
417
        Person person = Person.NewInstance("L.", "Linne", "C.G.", "Carl-Gustav");
418
        Team bookAuthor = Team.NewInstance(person); // Team.NewTitledInstance("Linne", null);
419

  
420
        book.setAuthorship(bookAuthor);
421
        book.setVolume("3");
422
        Reference bookSection = ReferenceFactory.newBookSection();
423
        String bookSectionTitle = "Trees";
424
        bookSection.setTitle(bookSectionTitle);
425
        Team bookSectionTeam = Team.NewTitledInstance("Chapter author", "Chap. Aut.");
426
        bookSection.setAuthorship(bookSectionTeam);
427
        bookSection.setInBook(book);
428
        bookSection.setPages("83-91");
429
        bookSection.setDatePublished(TimePeriodParser.parseStringVerbatim("1752"));
430
        bookSection.setDoi(DOI.fromString("10.12345/speciesplantarum.3"));
431
        Reference section = ReferenceFactory.newSection();
432
        Team sectionTeam = Team.NewTitledInstance("Section author", null);
433
        section.setAuthorship(sectionTeam);
434
        section.setInReference(bookSection);
435

  
436
        Assert.assertEquals("Unexpected title cache.",
437
                "in Linne, Species Plantarum 3: 55. 1752",
438
                formatter.format(section, detail1));
439
        bookAuthor = Team.NewTitledInstance("Linneus", null);
440
        book.setAuthorship(bookAuthor);
441
        Assert.assertEquals("Unexpected title cache.",
442
                "in Linneus, Species Plantarum 3: 55. 1752",
443
                formatter.format(section, detail1));
444

  
445

  
446
    }
385 447
}
cdmlib-model/src/test/java/eu/etaxonomy/cdm/strategy/cache/reference/ReferenceDefaultCacheStrategyTest.java
132 132
	public void testArticleGetTitleCache(){
133 133
		journal1.setTitle("My journal");
134 134
		((Reference)journal1).setAuthorship(articleTeam2);  //incorrect use anyway
135
		article1.setTitle("My article");
136 135
		article1.setInJournal(journal1);
137 136
		article1.setAuthorship(articleTeam1);
138 137
		article1.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(1975));
138
	    Assert.assertEquals("Team1 1975: "+UTF8.EN_DASH+" My journal.", article1.getTitleCache());
139
	    article1.setTitle("My article");
139 140
		Assert.assertEquals("Team1 1975: My article. "+UTF8.EN_DASH+" My journal.", article1.getTitleCache());
140 141

  
141 142
		article1.setInJournal(null);
......
375 376
        article.setAuthorship(articleTeam);
376 377
        article.setInJournal(journal);
377 378
        article.setVolume("452(1)");
378
        article.setVolume("83-91");
379
        article.setPages("83-91");
379 380
        article.setDatePublished(TimePeriodParser.parseStringVerbatim("8 Jul 2020"));
380 381
        article.setDoi(DOI.fromString("10.11646/phytotaxa.452.1.8"));
381 382
        Reference section = ReferenceFactory.newSection();
......
384 385
        section.setInReference(article);
385 386

  
386 387
        Assert.assertEquals("Unexpected title cache.",
387
                "Chudaev, D.A., Glushchenko, A., Kulikovskiy, M. & Kociolek, J.P. 2020 – In: "
388
                + "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());
388
                "Chudaev, D.A., Glushchenko, A., Kulikovskiy, M. & Kociolek, J.P. 2020 "+UTF8.EN_DASH+" In: "
389
                + "Kulikovskiy, M., Chudaev, D.A., Glushchenko, A., Kuznetsova, I. & Kociolek, J.P., "
390
                + "New diatom species Navicula davidovichii from Vietnam (Southeast Asia). "+UTF8.EN_DASH+" Phytotaxa 452(1).",
391
                section.getTitleCache());
392
    }
393

  
394
    @Test
395
    public void testSectionInBookSection(){
396
        //#9326, #3764
397
        Reference book = ReferenceFactory.newBook();
398
        book.setTitle("Species Plantarum");
399
        Team bookAuthor = Team.NewTitledInstance("Linne", null);
400
        book.setAuthorship(bookAuthor);
401
        book.setVolume("3");
402
        Reference bookSection = ReferenceFactory.newBookSection();
403
        String bookSectionTitle = "Trees";
404
        bookSection.setTitle(bookSectionTitle);
405
        Team bookSectionTeam = Team.NewTitledInstance("Chapter author", null);
406
        bookSection.setAuthorship(bookSectionTeam);
407
        bookSection.setInBook(book);
408
        bookSection.setPages("83-91");
409
        bookSection.setDatePublished(TimePeriodParser.parseStringVerbatim("1752"));
410
        bookSection.setDoi(DOI.fromString("10.12345/speciesplantarum.3"));
411
        Reference section = ReferenceFactory.newSection();
412
        Team sectionTeam = Team.NewTitledInstance("Section author", null);
413
        section.setAuthorship(sectionTeam);
414
        section.setInReference(bookSection);
415

  
416
        Assert.assertEquals("Unexpected title cache.",
417
                "Section author 1752 "+UTF8.EN_DASH+" In: Chapter author, Trees, pp. 83-91. "+UTF8.EN_DASH+" In: Linne, Species Plantarum 3.",
418
                section.getTitleCache());
389 419
    }
390 420

  
391 421
    @Test

Also available in: Unified diff