1
|
/**
|
2
|
* Copyright (C) 2007 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
|
10
|
package eu.etaxonomy.cdm.strategy.cache.name;
|
11
|
|
12
|
import java.util.List;
|
13
|
import java.util.UUID;
|
14
|
|
15
|
import org.apache.log4j.Logger;
|
16
|
|
17
|
import eu.etaxonomy.cdm.common.CdmUtils;
|
18
|
import eu.etaxonomy.cdm.model.agent.INomenclaturalAuthor;
|
19
|
import eu.etaxonomy.cdm.model.name.ZoologicalName;
|
20
|
import eu.etaxonomy.cdm.strategy.cache.TaggedText;
|
21
|
|
22
|
public class ZooNameDefaultCacheStrategy extends NonViralNameDefaultCacheStrategy<ZoologicalName> implements INonViralNameCacheStrategy<ZoologicalName> {
|
23
|
@SuppressWarnings("unused")
|
24
|
private static final Logger logger = Logger.getLogger(ZooNameDefaultCacheStrategy.class);
|
25
|
private static final long serialVersionUID = 6640953957903705560L;
|
26
|
|
27
|
final static UUID uuid = UUID.fromString("950c4236-8156-4675-b866-785df33bc4d9");
|
28
|
|
29
|
protected String AuthorYearSeperator = ", ";
|
30
|
|
31
|
@Override
|
32
|
public UUID getUuid(){
|
33
|
return uuid;
|
34
|
}
|
35
|
|
36
|
|
37
|
/**
|
38
|
* Factory method
|
39
|
* @return
|
40
|
*/
|
41
|
public static ZooNameDefaultCacheStrategy NewInstance(){
|
42
|
return new ZooNameDefaultCacheStrategy();
|
43
|
}
|
44
|
|
45
|
/**
|
46
|
* Constructor
|
47
|
*/
|
48
|
protected ZooNameDefaultCacheStrategy(){
|
49
|
super();
|
50
|
}
|
51
|
|
52
|
|
53
|
|
54
|
/**
|
55
|
* @return Strings that separates the author part and the year part
|
56
|
* @return
|
57
|
*/
|
58
|
public String getAuthorYearSeperator() {
|
59
|
return AuthorYearSeperator;
|
60
|
}
|
61
|
|
62
|
|
63
|
public void setAuthorYearSeperator(String authorYearSeperator) {
|
64
|
AuthorYearSeperator = authorYearSeperator;
|
65
|
}
|
66
|
|
67
|
/* (non-Javadoc)
|
68
|
* @see eu.etaxonomy.cdm.strategy.cache.name.NonViralNameDefaultCacheStrategy#getNonCacheAuthorshipCache(eu.etaxonomy.cdm.model.name.NonViralName)
|
69
|
*/
|
70
|
@Override
|
71
|
protected String getNonCacheAuthorshipCache(ZoologicalName nonViralName) {
|
72
|
if (nonViralName == null){
|
73
|
return null;
|
74
|
}
|
75
|
String result = "";
|
76
|
INomenclaturalAuthor combinationAuthor = nonViralName.getCombinationAuthorship();
|
77
|
INomenclaturalAuthor exCombinationAuthor = nonViralName.getExCombinationAuthorship();
|
78
|
INomenclaturalAuthor basionymAuthor = nonViralName.getBasionymAuthorship();
|
79
|
INomenclaturalAuthor exBasionymAuthor = nonViralName.getExBasionymAuthorship();
|
80
|
Integer publicationYear = nonViralName.getPublicationYear();
|
81
|
Integer originalPublicationYear = nonViralName.getOriginalPublicationYear();
|
82
|
|
83
|
String basionymPart = "";
|
84
|
String authorPart = "";
|
85
|
//basionym
|
86
|
if (basionymAuthor != null || exBasionymAuthor != null || originalPublicationYear != null ){
|
87
|
String authorAndEx = getAuthorAndExAuthor(basionymAuthor, exBasionymAuthor);
|
88
|
String originalPublicationYearString = originalPublicationYear == null ? null : String.valueOf(originalPublicationYear);
|
89
|
String authorAndExAndYear = CdmUtils.concat(AuthorYearSeperator, authorAndEx, originalPublicationYearString );
|
90
|
basionymPart = BasionymStart + authorAndExAndYear +BasionymEnd;
|
91
|
}
|
92
|
if (combinationAuthor != null || exCombinationAuthor != null){
|
93
|
String authorAndEx = getAuthorAndExAuthor(combinationAuthor, exCombinationAuthor);
|
94
|
String publicationYearString = publicationYear == null ? null : String.valueOf(publicationYear);
|
95
|
authorPart = CdmUtils.concat(AuthorYearSeperator, authorAndEx, publicationYearString);
|
96
|
}
|
97
|
result = CdmUtils.concat(BasionymAuthorCombinationAuthorSeperator, basionymPart, authorPart);
|
98
|
if (result == null){
|
99
|
result = "";
|
100
|
}
|
101
|
return result;
|
102
|
}
|
103
|
|
104
|
|
105
|
@Override
|
106
|
protected List<TaggedText> getInfraSpeciesTaggedNameCache(ZoologicalName nonViralName){
|
107
|
boolean includeMarker = ! (nonViralName.isAutonym());
|
108
|
return getInfraSpeciesTaggedNameCache(nonViralName, includeMarker);
|
109
|
}
|
110
|
|
111
|
}
|