1
|
package eu.etaxonomy.cdm.strategy.cache.name;
|
2
|
|
3
|
import java.util.UUID;
|
4
|
|
5
|
import org.apache.log4j.Logger;
|
6
|
|
7
|
import eu.etaxonomy.cdm.common.CdmUtils;
|
8
|
import eu.etaxonomy.cdm.model.agent.INomenclaturalAuthor;
|
9
|
import eu.etaxonomy.cdm.model.name.ZoologicalName;
|
10
|
|
11
|
public class ZooNameDefaultCacheStrategy <T extends ZoologicalName> extends NonViralNameDefaultCacheStrategy<T> implements INonViralNameCacheStrategy<T> {
|
12
|
private static final Logger logger = Logger.getLogger(ZooNameDefaultCacheStrategy.class);
|
13
|
|
14
|
final static UUID uuid = UUID.fromString("950c4236-8156-4675-b866-785df33bc4d9");
|
15
|
|
16
|
protected String AuthorYearSeperator = ", ";
|
17
|
|
18
|
@Override
|
19
|
public UUID getUuid(){
|
20
|
return uuid;
|
21
|
}
|
22
|
|
23
|
|
24
|
/**
|
25
|
* Factory method
|
26
|
* @return
|
27
|
*/
|
28
|
public static ZooNameDefaultCacheStrategy NewInstance(){
|
29
|
return new ZooNameDefaultCacheStrategy();
|
30
|
}
|
31
|
|
32
|
/**
|
33
|
* Constructor
|
34
|
*/
|
35
|
private ZooNameDefaultCacheStrategy(){
|
36
|
super();
|
37
|
}
|
38
|
|
39
|
|
40
|
/* (non-Javadoc)
|
41
|
* @see eu.etaxonomy.cdm.strategy.cache.NonViralNameDefaultCacheStrategy#getAuthorCache(eu.etaxonomy.cdm.model.name.NonViralName)
|
42
|
*/
|
43
|
@Override
|
44
|
public String getAuthorshipCache(T nonViralName) {
|
45
|
if (nonViralName == null){
|
46
|
return null;
|
47
|
}
|
48
|
String result = "";
|
49
|
INomenclaturalAuthor combinationAuthor = nonViralName.getCombinationAuthorTeam();
|
50
|
INomenclaturalAuthor exCombinationAuthor = nonViralName.getExCombinationAuthorTeam();
|
51
|
INomenclaturalAuthor basionymAuthor = nonViralName.getBasionymAuthorTeam();
|
52
|
INomenclaturalAuthor exBasionymAuthor = nonViralName.getExBasionymAuthorTeam();
|
53
|
Integer publicationYear = nonViralName.getPublicationYear();
|
54
|
Integer originalPublicationYear = nonViralName.getOriginalPublicationYear();
|
55
|
|
56
|
String basionymPart = "";
|
57
|
String authorPart = "";
|
58
|
//basionym
|
59
|
if (basionymAuthor != null || exBasionymAuthor != null || originalPublicationYear != null ){
|
60
|
String authorAndEx = getAuthorAndExAuthor(basionymAuthor, exBasionymAuthor);
|
61
|
String originalPublicationYearString = originalPublicationYear == null ? null : String.valueOf(originalPublicationYear);
|
62
|
String authorAndExAndYear = CdmUtils.concat(", ", authorAndEx, originalPublicationYearString );
|
63
|
basionymPart = BasionymStart + authorAndExAndYear +BasionymEnd;
|
64
|
}
|
65
|
if (combinationAuthor != null || exCombinationAuthor != null){
|
66
|
String authorAndEx = getAuthorAndExAuthor(combinationAuthor, exCombinationAuthor);
|
67
|
String publicationYearString = publicationYear == null ? null : String.valueOf(publicationYear);
|
68
|
authorPart = CdmUtils.concat(", ", authorAndEx, publicationYearString);
|
69
|
}
|
70
|
result = CdmUtils.concat(BasionymAuthorCombinationAuthorSeperator, basionymPart, authorPart);
|
71
|
return result;
|
72
|
}
|
73
|
|
74
|
|
75
|
/**
|
76
|
* @return Strings that seperates the author part and the year part
|
77
|
* @return
|
78
|
*/
|
79
|
public String getAuthorYearSeperator() {
|
80
|
return AuthorYearSeperator;
|
81
|
}
|
82
|
|
83
|
|
84
|
public void setAuthorYearSeperator(String authorYearSeperator) {
|
85
|
AuthorYearSeperator = authorYearSeperator;
|
86
|
}
|
87
|
|
88
|
}
|