Revision bad14dbc
Added by Andreas Müller about 6 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/DescriptionHelper.java | ||
---|---|---|
18 | 18 |
import org.apache.commons.lang.StringUtils; |
19 | 19 |
import org.hibernate.LazyInitializationException; |
20 | 20 |
|
21 |
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade; |
|
21 | 22 |
import eu.etaxonomy.cdm.api.service.DefaultCategoricalDescriptionBuilder; |
22 | 23 |
import eu.etaxonomy.cdm.api.service.DefaultQuantitativeDescriptionBuilder; |
23 | 24 |
import eu.etaxonomy.cdm.api.service.DescriptionBuilder; |
24 | 25 |
import eu.etaxonomy.cdm.common.CdmUtils; |
26 |
import eu.etaxonomy.cdm.model.agent.AgentBase; |
|
25 | 27 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
26 | 28 |
import eu.etaxonomy.cdm.model.common.Group; |
27 | 29 |
import eu.etaxonomy.cdm.model.common.IdentifiableEntity; |
... | ... | |
34 | 36 |
import eu.etaxonomy.cdm.model.common.RelationshipBase; |
35 | 37 |
import eu.etaxonomy.cdm.model.common.RelationshipTermBase; |
36 | 38 |
import eu.etaxonomy.cdm.model.common.Representation; |
39 |
import eu.etaxonomy.cdm.model.common.TimePeriod; |
|
37 | 40 |
import eu.etaxonomy.cdm.model.common.User; |
38 | 41 |
import eu.etaxonomy.cdm.model.description.CategoricalData; |
39 | 42 |
import eu.etaxonomy.cdm.model.description.CommonTaxonName; |
... | ... | |
62 | 65 |
import eu.etaxonomy.cdm.model.name.TypeDesignationBase; |
63 | 66 |
import eu.etaxonomy.cdm.model.name.TypeDesignationStatusBase; |
64 | 67 |
import eu.etaxonomy.cdm.model.occurrence.DeterminationEvent; |
68 |
import eu.etaxonomy.cdm.model.occurrence.GatheringEvent; |
|
65 | 69 |
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase; |
66 | 70 |
import eu.etaxonomy.cdm.model.taxon.Classification; |
67 | 71 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
... | ... | |
252 | 256 |
resultString = getCache((TaxonNode) element); |
253 | 257 |
}else if (element instanceof DeterminationEvent) { |
254 | 258 |
resultString = getCache((DeterminationEvent) element); |
259 |
}else if (element instanceof GatheringEvent){ |
|
260 |
resultString = getCache((GatheringEvent) element); |
|
255 | 261 |
}else if (element instanceof Marker) { |
256 | 262 |
Marker marker = (Marker) element; |
257 | 263 |
MarkerType type = marker.getMarkerType(); |
... | ... | |
275 | 281 |
} |
276 | 282 |
return resultString; |
277 | 283 |
} |
284 |
|
|
285 |
private static String getCache(GatheringEvent gatheringEvent){ |
|
286 |
String ALTITUDE_PREFIX = "alt. "; |
|
287 |
final String METER = "m"; |
|
288 |
|
|
289 |
String result = ""; |
|
290 |
|
|
291 |
//collector |
|
292 |
AgentBase<?> collector = CdmBase.deproxy(gatheringEvent.getCollector()); |
|
293 |
String collectorStr = collector == null? null : collector.getTitleCache(); |
|
294 |
result = CdmUtils.concat(", ", result, collectorStr); |
|
295 |
|
|
296 |
//gathering period |
|
297 |
TimePeriod gatheringPeriod = gatheringEvent.getTimeperiod(); |
|
298 |
result = CdmUtils.concat(", ", result, (gatheringPeriod == null? null : gatheringPeriod.toString())); |
|
299 |
|
|
300 |
//country |
|
301 |
String strCountry = null; |
|
302 |
NamedArea country = gatheringEvent.getCountry(); |
|
303 |
Representation repCountry = country == null ? null : country.getRepresentation(Language.DEFAULT()); |
|
304 |
strCountry = repCountry == null ? null: repCountry.getLabel(); |
|
305 |
result = CdmUtils.concat(", ", result, strCountry); |
|
306 |
|
|
307 |
//locality |
|
308 |
LanguageString locality = gatheringEvent.getLocality(); |
|
309 |
if (locality != null) { |
|
310 |
result = CdmUtils.concat(", ", result, locality.getText()); |
|
311 |
} |
|
312 |
|
|
313 |
//elevation |
|
314 |
String elevationStr; |
|
315 |
if (isNotBlank(gatheringEvent.getAbsoluteElevationText())){ |
|
316 |
elevationStr = gatheringEvent.getAbsoluteElevationText(); |
|
317 |
}else{ |
|
318 |
String text = gatheringEvent.getAbsoluteElevationText(); |
|
319 |
Integer min = gatheringEvent.getAbsoluteElevation(); |
|
320 |
Integer max = gatheringEvent.getAbsoluteElevationMax(); |
|
321 |
elevationStr = DerivedUnitFacade.distanceString(min, max, text, METER); |
|
322 |
} |
|
323 |
if (isNotBlank(elevationStr)){ |
|
324 |
result = CdmUtils.concat(", " , result, ALTITUDE_PREFIX); |
|
325 |
result += elevationStr; |
|
326 |
} |
|
327 |
|
|
328 |
//exact locality |
|
329 |
if (gatheringEvent.getExactLocation() != null){ |
|
330 |
String exactLocation = gatheringEvent.getExactLocation().toSexagesimalString(false, false); |
|
331 |
result = CdmUtils.concat(", ", result, exactLocation); |
|
332 |
} |
|
333 |
|
|
334 |
return result; |
|
335 |
} |
|
278 | 336 |
|
279 | 337 |
|
280 | 338 |
private static String getCache(DeterminationEvent detEvent) { |
Also available in: Unified diff
fix #7328 Add label provider for GatheringEvent in referencing objects view