Project

General

Profile

« Previous | Next » 

Revision 6701ae84

Added by Andreas Müller over 3 years ago

fix #8881 Use pure last names (without initials) for in-references of taxon names

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/agent/Team.java
120 120
		return result;
121 121
	}
122 122

  
123
    public static Team NewInstance(Person... members) {
124
        Team team = new Team();
125
        for (Person member : members){
126
            team.addTeamMember(member);
127
        }
128
        return team;
129
    }
130

  
131
//************************ CONSTRUCTOR *******************************/
132

  
123 133
	/**
124 134
	 * Class constructor (including the cache strategy defined in
125 135
	 * {@link eu.etaxonomy.cdm.strategy.cache.agent.TeamDefaultCacheStrategy TeamDefaultCacheStrategy}).
cdmlib-model/src/main/java/eu/etaxonomy/cdm/strategy/cache/reference/DefaultReferenceCacheStrategy.java
28 28
import eu.etaxonomy.cdm.model.reference.Reference;
29 29
import eu.etaxonomy.cdm.model.reference.ReferenceType;
30 30
import eu.etaxonomy.cdm.strategy.StrategyBase;
31
import eu.etaxonomy.cdm.strategy.cache.agent.TeamDefaultCacheStrategy;
31 32

  
32 33
/**
33 34
 * #5833
......
673 674
        return result;
674 675
    }
675 676

  
677
    /**
678
     * See https://dev.e-taxonomy.eu/redmine/issues/8881
679
     */
676 680
    private String getInRefAuthorPart(Reference book, String seperator){
677 681
        if (book == null){
678 682
            return "";
679 683
        }
680
        TeamOrPersonBase<?> team = book.getAuthorship();
681
        String result = Nz( team == null ? "" : team.getNomenclaturalTitle());
684

  
685
        TeamOrPersonBase<?> author = book.getAuthorship();
686
        String result;
687
        if (author == null){
688
            result = "";
689
        }else if(author.isInstanceOf(Person.class)){
690
            Person person = CdmBase.deproxy(author, Person.class);
691
            result = getInRefPerson(person);
692
        }else{
693
            Team team = CdmBase.deproxy(author, Team.class);
694
            if (team.isProtectedNomenclaturalTitleCache()){
695
                //not yet finally discussed may change in future
696
                result = team.getNomenclaturalTitle();
697
            }else if (team.isProtectedTitleCache()){
698
                //not yet finally discussed may change in future
699
                result = team.getTitleCache();
700
            }else if (team.getTeamMembers().isEmpty()){
701
                //not yet finally discussed may change in future
702
                result = team.getTitleCache();
703
            }else{
704
                result = "";
705
                int size = team.getTeamMembers().size();
706
                for (Person person : team.getTeamMembers()){
707
                    int index = team.getTeamMembers().lastIndexOf(person);
708
                    String sep = (team.isHasMoreMembers() || index != size - 1) ?
709
                            TeamDefaultCacheStrategy.STD_TEAM_CONCATINATION : TeamDefaultCacheStrategy.FINAL_TEAM_CONCATINATION;
710
                    result = CdmUtils.concat(sep, result, getInRefPerson(person));
711
                }
712
                if (team.isHasMoreMembers()){
713
                    result += TeamDefaultCacheStrategy.ET_AL_TEAM_CONCATINATION_FULL + "al.";
714
                }
715
            }
716
        }
717

  
718
        result = Nz(result);
682 719
        if (! result.trim().equals("")){
683 720
            result = result + seperator;
684 721
        }
685 722
        return result;
686 723
    }
687 724

  
725
    private String getInRefPerson(Person person) {
726
        String result;
727
        if (isNotBlank(person.getFamilyName())){
728
            result = person.getFamilyName();
729
        }else if (isNotBlank(person.getNomenclaturalTitle())){
730
            result = person.getNomenclaturalTitle();  //TODO discuss if nomTitle is really better here then titleCache
731
        }else{
732
            result = person.getTitleCache();  //maybe remove everything behind a ","
733
        }
734
        return result;
735
    }
736

  
688 737
    private String replaceMicroRefToken(String microReference, String string) {
689 738
        int index = string.indexOf(INomenclaturalReference.MICRO_REFERENCE_TOKEN);
690 739

  
cdmlib-model/src/test/java/eu/etaxonomy/cdm/strategy/cache/reference/DefaultReferenceCacheStrategyTest.java
33 33
import eu.etaxonomy.cdm.model.reference.IWebPage;
34 34
import eu.etaxonomy.cdm.model.reference.Reference;
35 35
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
36
import eu.etaxonomy.cdm.strategy.cache.agent.TeamDefaultCacheStrategy;
36 37
import eu.etaxonomy.cdm.strategy.parser.TimePeriodParser;
37 38

  
38 39
/**
......
318 319

  
319 320
    }
320 321

  
322
    //https://dev.e-taxonomy.eu/redmine/issues/8881
323
    @Test
324
    public void testInRefAuthor(){
325
        Person person1 = Person.NewInstance("Inauth.", "Inauthor", "A.B.", "Ala Bala");
326
        Person person2 = Person.NewInstance("Twoauth.", "Twoauthor", "C.", "Cla");
327
        Person person3 = Person.NewTitledInstance("Threeauth.");
328
        Team team = Team.NewInstance(person1, person2, person3);
329
        IBook book1 = ReferenceFactory.newBook();
330
        book1.setAbbrevTitle("Acta Inst. Bot. Acad. Sci. URSS");
331
        book1.setVolume("Fasc. 11");
332
        book1.setDatePublished(TimePeriodParser.parseStringVerbatim("1955"));
333
        bookSection1.setTitle("My chapter");
334
        bookSection1.setInBook(book1);
335
        book1.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(1956));
336

  
337
        book1.setAuthorship(person1);
338
        Assert.assertEquals("Unexpected nomencl. reference", "in Inauthor, Acta Inst. Bot. Acad. Sci. URSS Fasc. 11: 248. 1956", bookSection1.getNomenclaturalCitation("248"));
339
        book1.setAuthorship(team);
340
        Assert.assertEquals("Unexpected nomencl. reference", "in Inauthor, Twoauthor & Threeauth., Acta Inst. Bot. Acad. Sci. URSS Fasc. 11: 248. 1956", bookSection1.getNomenclaturalCitation("248"));
341
        team.setHasMoreMembers(true);
342
        Assert.assertEquals("Unexpected nomencl. reference", "in Inauthor, Twoauthor, Threeauth. & al., Acta Inst. Bot. Acad. Sci. URSS Fasc. 11: 248. 1956", bookSection1.getNomenclaturalCitation("248"));
343
        book1.setAuthorship(Team.NewInstance(person1));
344
        Assert.assertEquals("Unexpected nomencl. reference", "in Inauthor, Acta Inst. Bot. Acad. Sci. URSS Fasc. 11: 248. 1956", bookSection1.getNomenclaturalCitation("248"));
345

  
346
        //for the following the behavior is not yet finally discussed, may change in future
347
        book1.setAuthorship(team);
348
        team.setTitleCache("Teamcache", true);
349
        Assert.assertEquals("Unexpected nomencl. reference", "in Teamcache, Acta Inst. Bot. Acad. Sci. URSS Fasc. 11: 248. 1956", bookSection1.getNomenclaturalCitation("248"));
350
        team.setTitleCache("Teamc.", true);
351
        Assert.assertEquals("Unexpected nomencl. reference", "in Teamc., Acta Inst. Bot. Acad. Sci. URSS Fasc. 11: 248. 1956", bookSection1.getNomenclaturalCitation("248"));
352
        book1.setAuthorship(Team.NewInstance());
353
        Assert.assertEquals("Unexpected nomencl. reference", "in "+TeamDefaultCacheStrategy.EMPTY_TEAM+", Acta Inst. Bot. Acad. Sci. URSS Fasc. 11: 248. 1956", bookSection1.getNomenclaturalCitation("248"));
354

  
355
    }
321 356

  
322 357
    @Test
323 358
    public void testBookGetTitleCache1(){

Also available in: Unified diff