Project

General

Profile

Revision d27fae52

IDd27fae52ff1902333e6617e0a3f79285f8bd6e25
Parent abf1c13b
Child 307bc7da

Added by Patrick Plitzner about 4 years ago

ref #5448 Reduce multiple ex authors to only two

View differences:

app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/gefaesspflanzen/RedListGefaesspflanzenImportAuthor.java
100 100
        TeamOrPersonBase<?> teamOrPerson;
101 101
        //check if there are ex authors
102 102
        if(authorName.contains(RedListUtil.EX)){
103
            String[] split = authorName.split(RedListUtil.EX);
104
            for (int i = 0; i < split.length; i++) {
105
                makePerson(state, split[i].trim());
106
            }
103
            String author = RedListUtil.getAuthorOfExAuthorshipString(authorName);
104
            String exAuthor = RedListUtil.getExAuthorOfExAuthorshipString(authorName);
105
            makePerson(state, author);
106
            makePerson(state, exAuthor);
107 107
        }
108 108
        //check if it is a team
109 109
        if(authorName.contains("&")){
app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/gefaesspflanzen/RedListGefaesspflanzenImportNames.java
265 265
        if(authorKombString.contains(RedListUtil.EX)){
266 266
            // multiple ex authors will be reduced to only the last one
267 267
            // e.g. Almq. ex Sternström ex Dahlst. -> Almq. ex Dahlst.
268
            String[] kombSplit = authorKombString.split(RedListUtil.EX);
269 268
            //first author is ex combination author
270
            String exAuthorString = kombSplit[0];
269
            String exAuthorString = RedListUtil.getExAuthorOfExAuthorshipString(authorKombString);
271 270
            TeamOrPersonBase<?> exAuthor = (TeamOrPersonBase<?>) state.getRelatedObject(RedListUtil.AUTHOR_NAMESPACE, exAuthorString);
272 271
            name.setExCombinationAuthorship(exAuthor);
273 272
            //the last author is the combination author
274
            String authorString = kombSplit[kombSplit.length-1];
273
            String authorString = RedListUtil.getAuthorOfExAuthorshipString(authorKombString);
275 274
            TeamOrPersonBase<?> combAuthor = (TeamOrPersonBase<?>) state.getRelatedObject(RedListUtil.AUTHOR_NAMESPACE, authorString);
276 275
            name.setCombinationAuthorship(combAuthor);
277 276
        }
......
284 283
        }
285 284
        //basionym author
286 285
        if(authorBasiString.contains(RedListUtil.EX)){
287
            String[] basiSplit = authorBasiString.split(RedListUtil.EX);
288
            for (int i = 0; i < basiSplit.length; i++) {
289
                if(basiSplit.length!=2){
290
                    RedListUtil.logMessage(id, "Multiple ex basionymn authors found", logger);
291
                }
292
                if(i==0){
293
                    TeamOrPersonBase<?> authorBasi= (TeamOrPersonBase<?>) state.getRelatedObject(RedListUtil.AUTHOR_NAMESPACE, basiSplit[i]);
294
                    if(CdmUtils.isBlank(authorKombString)){
295
                        name.setExCombinationAuthorship(authorBasi);
296
                    }
297
                    else{
298
                        name.setExBasionymAuthorship(authorBasi);
299
                    }
300
                }
301
                else{
302
                    TeamOrPersonBase<?> authorBasi= (TeamOrPersonBase<?>) state.getRelatedObject(RedListUtil.AUTHOR_NAMESPACE, basiSplit[i]);
303
                    if(CdmUtils.isBlank(authorKombString)){
304
                        name.setCombinationAuthorship(authorBasi);
305
                    }
306
                    else{
307
                        name.setBasionymAuthorship(authorBasi);
308
                    }
309
                }
286
            TeamOrPersonBase<?> authorExBasi= (TeamOrPersonBase<?>) state.getRelatedObject(RedListUtil.AUTHOR_NAMESPACE, RedListUtil.getExAuthorOfExAuthorshipString(authorBasiString));
287
            if(CdmUtils.isBlank(authorKombString)){
288
                name.setExCombinationAuthorship(authorExBasi);
289
            }
290
            else{
291
                name.setExBasionymAuthorship(authorExBasi);
292
            }
293
            TeamOrPersonBase<?> authorBasi= (TeamOrPersonBase<?>) state.getRelatedObject(RedListUtil.AUTHOR_NAMESPACE, RedListUtil.getAuthorOfExAuthorshipString(authorBasiString));
294
            if(CdmUtils.isBlank(authorKombString)){
295
                name.setCombinationAuthorship(authorBasi);
296
            }
297
            else{
298
                name.setBasionymAuthorship(authorBasi);
310 299
            }
311 300
        }
312 301
        else if(CdmUtils.isNotBlank(authorBasiString)){
......
508 497
        if(authorString.equals(RedListUtil.AUCT)){
509 498
            authorString = "";
510 499
        }
500
        if(authorString.contains(RedListUtil.EX)){
501
            String exAuthor = RedListUtil.getExAuthorOfExAuthorshipString(authorString);
502
            String author = RedListUtil.getAuthorOfExAuthorshipString(authorString);
503
            authorString = exAuthor+RedListUtil.EX+author;
504
        }
511 505
        if(STRICT_TITLE_CHECK){
512 506
            if(!authorString.equals(authorshipCache)){
513 507
                RedListUtil.logMessage(id, "Authorship inconsistent! name.authorhshipCache <-> Column "+RedListUtil.AUTOR+": "+authorshipCache+" <-> "+authorString, logger);
app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/gefaesspflanzen/RedListUtil.java
132 132
        logger.info(NAMNR+": "+id+" "+message);
133 133
    }
134 134

  
135
    public static String getAuthorOfExAuthorshipString(String authorshipString){
136
        return getAuthorOfExAuthorship(authorshipString, false);
137
    }
138

  
139
    public static String getExAuthorOfExAuthorshipString(String authorshipString){
140
        return getAuthorOfExAuthorship(authorshipString, true);
141
    }
142

  
143
    private static String getAuthorOfExAuthorship(String authorshipString, boolean isExAuthor){
144
        String[] split = authorshipString.split(EX);
145
        if(split.length>0){
146
            return isExAuthor?split[0].trim():split[split.length-1].trim();
147
        }
148
        return null;
149
    }
150

  
135 151
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)