Revision 90046bc4
Added by Andreas Müller almost 8 years ago
cdmlib-model/src/main/java/eu/etaxonomy/cdm/strategy/cache/reference/InRefDefaultCacheStrategyBase.java | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* Copyright (C) 2007 EDIT |
3 |
* European Distributed Institute of Taxonomy
|
|
3 |
* European Distributed Institute of Taxonomy |
|
4 | 4 |
* http://www.e-taxonomy.eu |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 | 8 |
*/ |
... | ... | |
25 | 25 |
|
26 | 26 |
private static final long serialVersionUID = -8418443677312335864L; |
27 | 27 |
private static final Logger logger = Logger.getLogger(InRefDefaultCacheStrategyBase.class); |
28 |
|
|
28 |
|
|
29 | 29 |
private String inSeparator = "in "; |
30 | 30 |
private String afterSectionAuthor = " - "; |
31 | 31 |
private String blank = " "; |
32 |
|
|
33 |
|
|
34 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 | 35 |
protected abstract String getInRefType(); |
36 |
|
|
36 |
|
|
37 | 37 |
protected String afterInRefAuthor = ", "; |
38 | 38 |
|
39 | 39 |
@Override |
40 | 40 |
public String getTokenizedNomenclaturalTitel(Reference generic) { |
41 | 41 |
return getTokenizedNomenclaturalTitel(generic, false); |
42 | 42 |
} |
43 |
|
|
43 |
|
|
44 | 44 |
protected String getTokenizedNomenclaturalTitel(Reference thisRef, boolean inRefIsObligatory) { |
45 | 45 |
//generic == null |
46 | 46 |
if (thisRef == null /* || generic.getInReference() == null */){ |
47 | 47 |
return null; |
48 | 48 |
} |
49 | 49 |
|
50 |
Reference<?> inRef = thisRef.getInReference();
|
|
51 |
|
|
50 |
Reference inRef = thisRef.getInReference(); |
|
51 |
|
|
52 | 52 |
//inRef == null |
53 | 53 |
if (! inRefIsObligatory && inRef == null){ |
54 | 54 |
return super.getTokenizedNomenclaturalTitel(thisRef); |
55 | 55 |
} |
56 |
|
|
56 |
|
|
57 | 57 |
String result; |
58 | 58 |
//use generics's publication date if it exists |
59 | 59 |
if (inRef == null || (thisRef.hasDatePublished() ) ){ |
60 | 60 |
GenericDefaultCacheStrategy inRefStrategy = GenericDefaultCacheStrategy.NewInstance(); |
61 | 61 |
result = inRef == null ? "" : inRefStrategy.getTitleWithoutYearAndAuthor(inRef, true); |
62 | 62 |
//added //TODO unify with non-inRef references formatting |
63 |
|
|
63 |
|
|
64 | 64 |
if (isNotBlank(thisRef.getVolume())){ |
65 | 65 |
result = result + " " + thisRef.getVolume(); |
66 | 66 |
} |
67 | 67 |
//TODO series / edition |
68 |
|
|
68 |
|
|
69 | 69 |
//end added |
70 | 70 |
result += INomenclaturalReference.MICRO_REFERENCE_TOKEN; |
71 | 71 |
result = addYear(result, thisRef, true); |
... | ... | |
77 | 77 |
} |
78 | 78 |
} |
79 | 79 |
//FIXME: vol. etc., http://dev.e-taxonomy.eu/trac/ticket/2862 |
80 |
|
|
80 |
|
|
81 | 81 |
result = getInRefAuthorPart(thisRef.getInReference(), afterInRefAuthor) + result; |
82 | 82 |
result = "in " + result; |
83 | 83 |
return result; |
84 | 84 |
} |
85 |
|
|
86 | 85 |
|
87 |
|
|
86 |
|
|
87 |
|
|
88 | 88 |
protected String getInRefAuthorPart(Reference book, String seperator){ |
89 | 89 |
if (book == null){ |
90 | 90 |
return ""; |
... | ... | |
92 | 92 |
TeamOrPersonBase<?> team = book.getAuthorship(); |
93 | 93 |
String result = Nz( team == null ? "" : team.getNomenclaturalTitle()); |
94 | 94 |
if (! result.trim().equals("")){ |
95 |
result = result + seperator;
|
|
95 |
result = result + seperator; |
|
96 | 96 |
} |
97 | 97 |
return result; |
98 | 98 |
} |
99 |
|
|
99 |
|
|
100 | 100 |
|
101 | 101 |
@Override |
102 | 102 |
public String getTitleCache(Reference thisRef) { |
103 | 103 |
return getTitleCache(thisRef, false, false); |
104 | 104 |
} |
105 |
|
|
105 |
|
|
106 | 106 |
@Override |
107 | 107 |
public String getAbbrevTitleCache(Reference thisRef) { |
108 | 108 |
return getTitleCache(thisRef, false, true); |
109 | 109 |
} |
110 |
|
|
111 |
|
|
110 |
|
|
111 |
|
|
112 | 112 |
protected String getTitleCache(Reference thisRef, boolean inRefIsObligatory, boolean isAbbrev) { |
113 | 113 |
String result; |
114 |
|
|
115 |
Reference<?> inRef = thisRef.getInReference();
|
|
114 |
|
|
115 |
Reference inRef = thisRef.getInReference(); |
|
116 | 116 |
boolean hasInRef = (inRef != null); |
117 | 117 |
// get inRef part |
118 | 118 |
if (hasInRef){ |
... | ... | |
124 | 124 |
result = String.format("- undefined %s -", getInRefType()); |
125 | 125 |
} |
126 | 126 |
} |
127 |
|
|
127 |
|
|
128 | 128 |
//in |
129 | 129 |
result = inSeparator + result; |
130 |
|
|
130 |
|
|
131 | 131 |
//section title |
132 | 132 |
String title = CdmUtils.getPreferredNonEmptyString( |
133 | 133 |
thisRef.getTitle(), thisRef.getAbbrevTitle(), isAbbrev, true); |
134 | 134 |
if (title.length() > 0){ |
135 | 135 |
result = title + blank + result; |
136 | 136 |
} |
137 |
|
|
137 |
|
|
138 | 138 |
//section author |
139 | 139 |
TeamOrPersonBase<?> thisRefTeam = thisRef.getAuthorship(); |
140 | 140 |
String thisRefAuthor = ""; |
... | ... | |
142 | 142 |
thisRefAuthor = CdmUtils.getPreferredNonEmptyString(thisRefTeam.getTitleCache(), thisRefTeam.getNomenclaturalTitle(), isAbbrev, true); |
143 | 143 |
} |
144 | 144 |
result = CdmUtils.concat(afterSectionAuthor, thisRefAuthor, result); |
145 |
|
|
145 |
|
|
146 | 146 |
//date |
147 | 147 |
if (thisRef.getDatePublished() != null && ! thisRef.getDatePublished().isEmpty()){ |
148 | 148 |
String thisRefDate = thisRef.getDatePublished().toString(); |
Also available in: Unified diff
Remove generics from Reference in cdmlib-model #5830