2 * Copyright (C) 2017 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.taxeditor
.editor
.descriptiveDataSet
.matrix
.supplementalInfo
;
11 import org
.eclipse
.nebula
.widgets
.nattable
.data
.convert
.DisplayConverter
;
13 import eu
.etaxonomy
.cdm
.hibernate
.HibernateProxyHelper
;
14 import eu
.etaxonomy
.cdm
.model
.agent
.AgentBase
;
15 import eu
.etaxonomy
.cdm
.model
.location
.NamedArea
;
16 import eu
.etaxonomy
.cdm
.model
.occurrence
.FieldUnit
;
17 import eu
.etaxonomy
.cdm
.model
.occurrence
.GatheringEvent
;
18 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
21 * Converts the supplemental information (taxon and specimen data)
22 * belonging to a specimen description to a String.
28 public class SupplementalInfoDisplayConverter
extends DisplayConverter
{
30 public SupplementalInfoDisplayConverter() {
37 public Object
canonicalToDisplayValue(Object canonicalValue
) {
38 String displayValue
= "";
39 if(HibernateProxyHelper
.isInstanceOf(canonicalValue
, TaxonNode
.class)){
40 TaxonNode node
= (TaxonNode
)canonicalValue
;
41 displayValue
= node
.getTaxon().getName().getTitleCache();
43 else if(HibernateProxyHelper
.isInstanceOf(canonicalValue
, FieldUnit
.class)){
44 FieldUnit fieldUnit
= HibernateProxyHelper
.deproxy(canonicalValue
, FieldUnit
.class);
45 GatheringEvent gatheringEvent
= fieldUnit
.getGatheringEvent();
46 if(gatheringEvent
!=null){
47 AgentBase collector
= gatheringEvent
.getCollector();
48 if(collector
!=null && collector
.getTitleCache()!=null){
49 displayValue
+= collector
.getTitleCache()+" ";
51 String fieldNumber
= fieldUnit
.getFieldNumber();
52 if(fieldNumber
!=null){
53 displayValue
+= fieldNumber
;
57 else if(HibernateProxyHelper
.isInstanceOf(canonicalValue
, NamedArea
.class)){
58 displayValue
= HibernateProxyHelper
.deproxy(canonicalValue
, NamedArea
.class).getLabel();
61 if(displayValue
.isEmpty() && canonicalValue
!=null){
62 return canonicalValue
.toString();
71 public Object
displayToCanonicalValue(Object displayValue
) {