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
.api
.service
.dto
.RowWrapperDTO
;
14 import eu
.etaxonomy
.cdm
.hibernate
.HibernateProxyHelper
;
15 import eu
.etaxonomy
.cdm
.model
.agent
.AgentBase
;
16 import eu
.etaxonomy
.cdm
.model
.location
.NamedArea
;
17 import eu
.etaxonomy
.cdm
.model
.occurrence
.FieldUnit
;
18 import eu
.etaxonomy
.cdm
.model
.occurrence
.GatheringEvent
;
19 import eu
.etaxonomy
.cdm
.persistence
.dto
.DescriptionBaseDto
;
20 import eu
.etaxonomy
.cdm
.persistence
.dto
.TaxonNodeDto
;
23 * Converts the supplemental information (taxon and specimen data)
24 * belonging to a specimen description to a String.
29 public class SupplementalInfoDisplayConverter
extends DisplayConverter
{
31 public SupplementalInfoDisplayConverter() {
35 public Object
canonicalToDisplayValue(Object canonicalValue
) {
36 String displayValue
= "";
37 if(canonicalValue
instanceof TaxonNodeDto
){
38 TaxonNodeDto node
= (TaxonNodeDto
)canonicalValue
;
39 displayValue
= node
.getTitleCache();
41 else if(HibernateProxyHelper
.isInstanceOf(canonicalValue
, FieldUnit
.class)){
42 FieldUnit fieldUnit
= HibernateProxyHelper
.deproxy(canonicalValue
, FieldUnit
.class);
43 GatheringEvent gatheringEvent
= fieldUnit
.getGatheringEvent();
44 if(gatheringEvent
!=null){
45 AgentBase collector
= gatheringEvent
.getCollector();
46 if(collector
!=null && collector
.getTitleCache()!=null){
47 displayValue
+= collector
.getTitleCache()+" ";
49 String fieldNumber
= fieldUnit
.getFieldNumber();
50 if(fieldNumber
!=null){
51 displayValue
+= fieldNumber
;
55 else if(HibernateProxyHelper
.isInstanceOf(canonicalValue
, NamedArea
.class)){
56 displayValue
= HibernateProxyHelper
.deproxy(canonicalValue
, NamedArea
.class).getLabel();
57 }else if (canonicalValue
instanceof RowWrapperDTO
){
58 displayValue
= ((RowWrapperDTO
)canonicalValue
).getDescription().getTitleCache();
59 }else if (canonicalValue
instanceof DescriptionBaseDto
){
60 displayValue
= ((DescriptionBaseDto
)canonicalValue
).getTitleCache();
63 if(displayValue
.isEmpty() && canonicalValue
!=null){
64 return canonicalValue
.toString();
70 public Object
displayToCanonicalValue(Object displayValue
) {
71 return displayValue
== null?
null : displayValue
.toString();