Revision d4657a24
Added by Andreas Müller almost 10 years ago
cdmlib-model/src/main/java/eu/etaxonomy/cdm/strategy/cache/reference/ArticleDefaultCacheStrategy.java | ||
---|---|---|
10 | 10 |
|
11 | 11 |
import java.util.UUID; |
12 | 12 |
|
13 |
import org.apache.commons.lang.StringUtils; |
|
14 | 13 |
import org.apache.log4j.Logger; |
15 | 14 |
|
16 | 15 |
import eu.etaxonomy.cdm.common.CdmUtils; |
... | ... | |
62 | 61 |
result = addYear(result, article, false); |
63 | 62 |
TeamOrPersonBase<?> team = article.getAuthorTeam(); |
64 | 63 |
result = CdmUtils.concat(" ", article.getTitle(), result); |
65 |
if (team != null && StringUtils.isNotBlank(team.getTitleCache())){
|
|
66 |
String authorSeparator = StringUtils.isNotBlank(article.getTitle())? afterAuthor : " ";
|
|
64 |
if (team != null && isNotBlank(team.getTitleCache())){ |
|
65 |
String authorSeparator = isNotBlank(article.getTitle())? afterAuthor : " "; |
|
67 | 66 |
result = team.getTitleCache() + authorSeparator + result; |
68 | 67 |
} |
69 | 68 |
return result; |
... | ... | |
79 | 78 |
TeamOrPersonBase<?> team = article.getAuthorTeam(); |
80 | 79 |
String articleTitle = CdmUtils.getPreferredNonEmptyString(article.getAbbrevTitle(), article.getTitle(), false, true); |
81 | 80 |
result = CdmUtils.concat(" ", articleTitle, result); //Article should maybe left out for nomenclatural references (?) |
82 |
if (team != null && StringUtils.isNotBlank(team.getNomenclaturalTitle())){
|
|
83 |
String authorSeparator = StringUtils.isNotBlank(articleTitle) ? afterAuthor : " ";
|
|
81 |
if (team != null && isNotBlank(team.getNomenclaturalTitle())){ |
|
82 |
String authorSeparator = isNotBlank(articleTitle) ? afterAuthor : " "; |
|
84 | 83 |
result = team.getNomenclaturalTitle() + authorSeparator + result; |
85 | 84 |
} |
86 | 85 |
return result; |
... | ... | |
101 | 100 |
journalTitel = UNDEFINED_JOURNAL; |
102 | 101 |
} |
103 | 102 |
|
104 |
String series = Nz(article.getSeries()).trim(); |
|
103 |
String series = Nz(article.getSeriesPart()).trim();
|
|
105 | 104 |
String volume = Nz(article.getVolume()).trim(); |
106 | 105 |
|
107 | 106 |
boolean needsComma = false; |
... | ... | |
110 | 109 |
|
111 | 110 |
//inJournal |
112 | 111 |
nomRefCache = prefixReferenceJounal + blank; |
113 |
|
|
112 |
|
|
114 | 113 |
//titelAbbrev |
115 | 114 |
if (isNotBlank(journalTitel)){ |
116 |
nomRefCache = nomRefCache + journalTitel + blank; |
|
115 |
nomRefCache = nomRefCache + journalTitel; |
|
116 |
needsComma = makeNeedsComma(needsComma, nomRefCache, volume, series); |
|
117 |
if (! needsComma){ |
|
118 |
nomRefCache = nomRefCache + blank; |
|
119 |
} |
|
117 | 120 |
} |
118 | 121 |
|
122 |
//series and vol. |
|
119 | 123 |
nomRefCache = getSeriesAndVolPart(series, volume, needsComma, nomRefCache); |
120 |
|
|
124 |
|
|
121 | 125 |
//delete "." |
122 | 126 |
while (nomRefCache.endsWith(".")){ |
123 | 127 |
nomRefCache = nomRefCache.substring(0, nomRefCache.length()-1); |
... | ... | |
126 | 130 |
return nomRefCache.trim(); |
127 | 131 |
} |
128 | 132 |
|
133 |
private boolean makeNeedsComma(boolean needsComma, String nomRefCache, String volume, String series) { |
|
134 |
if (needsComma){ |
|
135 |
return true; |
|
136 |
}else{ |
|
137 |
nomRefCache = nomRefCache.toLowerCase(); |
|
138 |
int serIndex = nomRefCache.indexOf(" ser. "); |
|
139 |
int sectIndex = nomRefCache.indexOf(" sect. "); |
|
140 |
int abtIndex = nomRefCache.indexOf(" abt. "); |
|
141 |
int index = Math.max(Math.max(serIndex, sectIndex), abtIndex); |
|
142 |
int commaIndex = nomRefCache.indexOf(",", index); |
|
143 |
if (index > -1 && commaIndex == -1 && isNotBlank(volume)){ |
|
144 |
return true; |
|
145 |
}else if (isNotBlank(series)){ |
|
146 |
return true; |
|
147 |
}else{ |
|
148 |
return false; |
|
149 |
} |
|
150 |
} |
|
151 |
} |
|
152 |
|
|
153 |
|
|
129 | 154 |
protected String getSeriesAndVolPart(String series, String volume, |
130 | 155 |
boolean needsComma, String nomRefCache) { |
131 | 156 |
//inSeries |
... | ... | |
135 | 160 |
if (CdmUtils.isNumeric(series)){ |
136 | 161 |
seriesPart = prefixSeries + blank + seriesPart; |
137 | 162 |
} |
138 |
if (needsComma){ |
|
139 |
seriesPart = comma + seriesPart; |
|
140 |
} |
|
163 |
// if (needsComma){
|
|
164 |
seriesPart = comma + blank + seriesPart;
|
|
165 |
// }
|
|
141 | 166 |
needsComma = true; |
142 | 167 |
} |
143 | 168 |
nomRefCache += seriesPart; |
Also available in: Unified diff
better handling of abbreviated title cache in references, series -> seriesPart and some improvements in the reference cache strategies #4280, #4239