3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
11 package eu
.etaxonomy
.taxeditor
.model
;
13 import java
.lang
.reflect
.InvocationTargetException
;
14 import java
.lang
.reflect
.Method
;
15 import java
.util
.Arrays
;
16 import java
.util
.List
;
19 import org
.apache
.commons
.lang
.StringUtils
;
20 import org
.hibernate
.LazyInitializationException
;
22 import eu
.etaxonomy
.cdm
.api
.service
.DefaultCategoricalDescriptionBuilder
;
23 import eu
.etaxonomy
.cdm
.api
.service
.DefaultQuantitativeDescriptionBuilder
;
24 import eu
.etaxonomy
.cdm
.api
.service
.DescriptionBuilder
;
25 import eu
.etaxonomy
.cdm
.common
.CdmUtils
;
26 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
27 import eu
.etaxonomy
.cdm
.model
.common
.Group
;
28 import eu
.etaxonomy
.cdm
.model
.common
.IdentifiableEntity
;
29 import eu
.etaxonomy
.cdm
.model
.common
.Language
;
30 import eu
.etaxonomy
.cdm
.model
.common
.LanguageString
;
31 import eu
.etaxonomy
.cdm
.model
.common
.LanguageStringBase
;
32 import eu
.etaxonomy
.cdm
.model
.common
.Marker
;
33 import eu
.etaxonomy
.cdm
.model
.common
.MarkerType
;
34 import eu
.etaxonomy
.cdm
.model
.common
.OriginalSourceBase
;
35 import eu
.etaxonomy
.cdm
.model
.common
.RelationshipBase
;
36 import eu
.etaxonomy
.cdm
.model
.common
.RelationshipTermBase
;
37 import eu
.etaxonomy
.cdm
.model
.common
.Representation
;
38 import eu
.etaxonomy
.cdm
.model
.common
.User
;
39 import eu
.etaxonomy
.cdm
.model
.description
.CategoricalData
;
40 import eu
.etaxonomy
.cdm
.model
.description
.CommonTaxonName
;
41 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionBase
;
42 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionElementBase
;
43 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionElementSource
;
44 import eu
.etaxonomy
.cdm
.model
.description
.Distribution
;
45 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
46 import eu
.etaxonomy
.cdm
.model
.description
.IndividualsAssociation
;
47 import eu
.etaxonomy
.cdm
.model
.description
.PresenceAbsenceTerm
;
48 import eu
.etaxonomy
.cdm
.model
.description
.QuantitativeData
;
49 import eu
.etaxonomy
.cdm
.model
.description
.SpecimenDescription
;
50 import eu
.etaxonomy
.cdm
.model
.description
.TaxonDescription
;
51 import eu
.etaxonomy
.cdm
.model
.description
.TaxonInteraction
;
52 import eu
.etaxonomy
.cdm
.model
.description
.TaxonNameDescription
;
53 import eu
.etaxonomy
.cdm
.model
.description
.TextData
;
54 import eu
.etaxonomy
.cdm
.model
.location
.NamedArea
;
55 import eu
.etaxonomy
.cdm
.model
.media
.Media
;
56 import eu
.etaxonomy
.cdm
.model
.name
.HomotypicalGroup
;
57 import eu
.etaxonomy
.cdm
.model
.name
.HybridRelationship
;
58 import eu
.etaxonomy
.cdm
.model
.name
.NameRelationship
;
59 import eu
.etaxonomy
.cdm
.model
.name
.NameTypeDesignation
;
60 import eu
.etaxonomy
.cdm
.model
.name
.SpecimenTypeDesignation
;
61 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
62 import eu
.etaxonomy
.cdm
.model
.name
.TypeDesignationBase
;
63 import eu
.etaxonomy
.cdm
.model
.name
.TypeDesignationStatusBase
;
64 import eu
.etaxonomy
.cdm
.model
.occurrence
.DeterminationEvent
;
65 import eu
.etaxonomy
.cdm
.model
.occurrence
.SpecimenOrObservationBase
;
66 import eu
.etaxonomy
.cdm
.model
.taxon
.Classification
;
67 import eu
.etaxonomy
.cdm
.model
.taxon
.SynonymRelationship
;
68 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
69 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonBase
;
70 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
71 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationship
;
72 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
75 * <p>DescriptionHelper class.</p>
81 public class DescriptionHelper
{
84 * Returns whatever the element's title cache equivalent is,
85 * depending on its class.
87 * @param element a {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase} object.
88 * @param language a {@link eu.etaxonomy.cdm.model.common.Language} object.
89 * @return a {@link java.lang.String} object.
91 public static String
getCache(DescriptionElementBase element
,
94 String mainElementLabel
= null;
95 DescriptionBase
<?
> descr
= element
.getInDescription();
97 if (descr
.isInstanceOf(TaxonDescription
.class)){
98 Taxon taxon
= CdmBase
.deproxy(descr
, TaxonDescription
.class).getTaxon();
100 mainElementLabel
= taxon
.getTitleCache();
102 }else if (descr
.isInstanceOf(SpecimenDescription
.class)){
103 SpecimenOrObservationBase
<?
> specimen
= CdmBase
.deproxy(descr
, SpecimenDescription
.class).getDescribedSpecimenOrObservation();
104 if (specimen
!= null){
105 mainElementLabel
= specimen
.getTitleCache();
107 }else if (descr
.isInstanceOf(TaxonNameDescription
.class)){
108 TaxonNameBase
<?
, ?
> name
= CdmBase
.deproxy(descr
, TaxonNameDescription
.class).getTaxonName();
110 mainElementLabel
= name
.getTitleCache();
116 if (element
instanceof TextData
) {
117 cache
= ((TextData
) element
).getText(language
);
119 if (element
instanceof CommonTaxonName
) {
120 cache
= ((CommonTaxonName
) element
).getName();
122 if (element
instanceof TaxonInteraction
) {
123 Taxon taxon2
= ((TaxonInteraction
) element
).getTaxon2();
124 if(taxon2
!= null && taxon2
.getName() != null){
125 cache
= taxon2
.getName().getTitleCache();
127 cache
= "No taxon chosen";
131 if (element
instanceof Distribution
) {
132 Distribution distribution
= (Distribution
) element
;
134 NamedArea area
= distribution
.getArea();
136 cache
= area
.getLabel();
138 PresenceAbsenceTerm status
= distribution
.getStatus();
140 cache
+= ", no status";
142 cache
+= ", " + status
.getLabel();
146 String result
= cache
== null ?
"" : cache
;
147 if (StringUtils
.isNotBlank(mainElementLabel
)){
148 result
= CdmUtils
.concat(" ", result
, "(" + mainElementLabel
+ ")");
154 * Returns whatever the element's title cache equivalent is,
155 * depending on its class, using the default language.
157 * @param element a {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase} object.
158 * @return a {@link java.lang.String} object.
160 public static String
getCache(DescriptionElementBase element
) {
161 return getCache(element
, CdmStore
.getDefaultLanguage());
165 * Set whatever the element's title cache equivalent is,
166 * depending on its class.
168 * @param element a {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase} object.
169 * @param value a {@link java.lang.String} object.
170 * @param language a {@link eu.etaxonomy.cdm.model.common.Language} object.
172 public static void setCache(DescriptionElementBase element
,
173 String value
, Language language
) {
174 if (element
instanceof TextData
) {
175 ((TextData
) element
).putText(language
, value
);
177 }else if (element
instanceof CommonTaxonName
) {
178 ((CommonTaxonName
) element
).setName(value
);
180 }else if (element
instanceof TaxonInteraction
) {
182 }else if(element
instanceof Distribution
){
183 MessagingUtils
.warn(DescriptionHelper
.class, "trying to set cache on distribution, don't know what to do at the moment.");
186 MessagingUtils
.warn(DescriptionHelper
.class, "No matching subclass found for DescriptionElementBase object, 'cache' not set.");
191 * Set whatever the element's title cache equivalent is,
192 * depending on its class, using the default language.
194 * @param element a {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase} object.
195 * @param value a {@link java.lang.String} object.
197 public static void setCache(DescriptionElementBase element
,
199 setCache(element
, value
, CdmStore
.getDefaultLanguage());
204 * <p>getObjectDescription</p>
206 * @param element a {@link java.lang.Object} object.
207 * @return a {@link java.lang.String} object.
209 public static String
getObjectDescription(Object element
) {
210 if (element
instanceof IdentifiableEntity
) {
212 return ((IdentifiableEntity
) element
).getTitleCache();
213 }catch(LazyInitializationException e
){
214 String result
= "No Session to initialize title cache for IdentifiableEntity";
215 MessagingUtils
.error(DescriptionHelper
.class, result
, e
);
216 return "TODO: " + result
;
218 }else if (element
instanceof OriginalSourceBase
) {
220 OriginalSourceBase
<?
> originalSource
= (OriginalSourceBase
<?
>) element
;
221 // ISourceable sourcedObject = originalSource.getSourcedObj();
222 //due to #5743 the bidirectionality for sourced object had to be removed
223 String sourceObjectTitle
= "sourced object data not available (#5743)";
224 // if(sourcedObject instanceof IIdentifiableEntity){
225 // sourceObjectTitle = ((IdentifiableEntity) sourcedObject).getTitleCache();
226 // }else if(sourcedObject instanceof DescriptionElementBase){
227 // sourceObjectTitle = "Element for description: " + ((DescriptionElementBase) sourcedObject).getInDescription().getTitleCache();
229 // throw new IllegalStateException("Unknown ISourceable object for given OriginalSourceBase");
232 return CdmUtils
.concat("; ", new String
[]{originalSource
.getIdNamespace(), originalSource
.getIdInSource(), sourceObjectTitle
});
233 }catch(LazyInitializationException e
){
234 String result
= "Error initializing title cache for ISourceable of an OriginalSourceBase";
235 MessagingUtils
.error(DescriptionHelper
.class, result
, e
);
236 return "TODO: " + result
;
238 }else if (element
instanceof LanguageStringBase
) {
239 return ((LanguageStringBase
) element
).getText();
240 }else if (element
instanceof DescriptionElementBase
) {
241 return getCache((DescriptionElementBase
) element
);
242 }else if (element
instanceof RelationshipBase
<?
, ?
, ?
>) {
243 return getCache((RelationshipBase
<?
, ?
, ?
>) element
);
244 }else if (element
instanceof TypeDesignationBase
<?
>) {
245 return getCache((TypeDesignationBase
<?
>) element
);
246 }else if (element
instanceof HomotypicalGroup
) {
247 return getCache((HomotypicalGroup
) element
);
248 }else if (element
instanceof TaxonNode
) {
249 return getCache((TaxonNode
) element
);
250 }else if (element
instanceof DeterminationEvent
) {
251 return getCache((DeterminationEvent
) element
);
252 }else if (element
instanceof Marker
) {
253 Marker marker
= (Marker
) element
;
254 MarkerType type
= marker
.getMarkerType();
255 return (type
== null ?
"- no marker type -" : marker
.getMarkerType().getLabel()) + " (" + marker
.getFlag() + ")";
256 }else if (element
instanceof User
) {
257 User user
= (User
) element
;
258 return user
.getUsername();
259 }else if (element
instanceof Group
) {
260 Group group
= (Group
) element
;
261 return group
.getName();
263 // TODO write return texts for HomotypicalGroup, etc.
264 return element
.toString();
269 private static String
getCache(DeterminationEvent detEvent
) {
271 String taxonStr
= "no taxon";
272 TaxonNameBase
<?
,?
> taxonName
= detEvent
.getTaxonName();
273 TaxonBase
<?
> taxon
= detEvent
.getTaxon();
274 if (taxonName
!= null){
275 taxonStr
= taxonName
.getTitleCache();
276 }else if (taxon
!= null){
277 taxonStr
= taxon
.getTitleCache();
280 String unitStr
= "no unit";
281 SpecimenOrObservationBase
<?
> unit
= detEvent
.getIdentifiedUnit();
283 unitStr
= unit
.getTitleCache();
286 String result
= CdmUtils
.concat(" determined as ", unitStr
, taxonStr
);
291 private static String
getCache(TaxonNode taxonNode
) {
293 Classification classification
= taxonNode
.getClassification();
294 if (classification
!= null){
295 String classificationStr
= classification
.getName() == null ?
"" : classification
.getName().getText();
296 result
= CdmUtils
.concat("" , result
, classificationStr
);
297 if (StringUtils
.isBlank(result
)){
298 result
= classification
.toString();
302 TaxonNode parentNode
= taxonNode
.getParent();
303 if (parentNode
== null){
304 parentStr
= "no parent";
306 Taxon parentTaxon
= parentNode
.getTaxon();
307 if (parentTaxon
== null){
308 parentStr
= "no parent taxon";
310 TaxonNameBase
<?
,?
> parentName
= parentTaxon
.getName();
311 if (parentName
== null){
312 parentStr
= parentTaxon
.getTitleCache();
314 parentStr
= parentName
.getTitleCache();
318 result
= CdmUtils
.concat(": ", result
, parentStr
);
323 private static String
getCache(TypeDesignationBase
<?
> designation
) {
324 designation
= CdmBase
.deproxy(designation
);
325 TypeDesignationStatusBase
<?
> status
= designation
.getTypeStatus();
326 Set
<TaxonNameBase
> from
;
327 IdentifiableEntity
<?
> to
;
328 from
= designation
.getTypifiedNames();
329 if (designation
.isInstanceOf(SpecimenTypeDesignation
.class)){
330 to
= ((SpecimenTypeDesignation
)designation
).getTypeSpecimen();
331 }else if (designation
.isInstanceOf(NameTypeDesignation
.class)){
332 to
= ((NameTypeDesignation
)designation
).getTypeName();
334 throw new RuntimeException("Type Designation class not supported: " + designation
.getClass().getName());
336 String typeLabel
= null;
338 Representation typeRepr
= status
.getPreferredRepresentation(CdmStore
.getDefaultLanguage());
339 if (typeRepr
!= null){
340 typeLabel
= typeRepr
.getAbbreviatedLabel();
342 if (StringUtils
.isBlank(typeLabel
) && typeRepr
!= null){
343 typeLabel
= typeRepr
.getLabel();
345 if (StringUtils
.isBlank(typeLabel
) ){
346 typeLabel
= status
.getSymbol();
348 if (StringUtils
.isBlank(typeLabel
)){
349 typeLabel
= status
.getTitleCache();
352 if (StringUtils
.isBlank(typeLabel
)){
355 String fromString
= "";
356 for (TaxonNameBase
<?
,?
> name
: from
){
357 CdmUtils
.concat(",", fromString
, name
.getTitleCache());
359 String result
= CdmUtils
.concat(" ", new String
[]{from
== null ?
null : fromString
,
360 typeLabel
, to
== null?
null : to
.getTitleCache()});
364 private static String
getCache(RelationshipBase
<?
, ?
, ?
> rel
) {
365 rel
= CdmBase
.deproxy(rel
);
366 RelationshipTermBase
<?
> type
= rel
.getType();
367 IdentifiableEntity
<?
> from
;
368 IdentifiableEntity
<?
> to
;
369 if (rel
.isInstanceOf(SynonymRelationship
.class)){
370 from
= ((SynonymRelationship
)rel
).getSynonym();
371 to
= ((SynonymRelationship
)rel
).getAcceptedTaxon();
372 }else if (rel
.isInstanceOf(NameRelationship
.class)){
373 from
= ((NameRelationship
)rel
).getFromName();
374 to
= ((NameRelationship
)rel
).getToName();
375 }else if (rel
.isInstanceOf(HybridRelationship
.class)){
376 from
= ((HybridRelationship
)rel
).getParentName();
377 to
= ((HybridRelationship
)rel
).getHybridName();
378 }else if (rel
.isInstanceOf(TaxonRelationship
.class)){
379 from
= ((TaxonRelationship
)rel
).getFromTaxon();
380 to
= ((TaxonRelationship
)rel
).getToTaxon();
383 Method fromMethod
= rel
.getClass().getMethod("getRelatedFrom");
384 Method toMethod
= rel
.getClass().getMethod("getRelatedFrom");
385 fromMethod
.setAccessible(true);
386 toMethod
.setAccessible(true);
387 from
= (IdentifiableEntity
<?
>)fromMethod
.invoke(rel
);
388 to
= (IdentifiableEntity
<?
>)toMethod
.invoke(rel
);
389 } catch (NoSuchMethodException
| SecurityException
| IllegalAccessException
390 | IllegalArgumentException
| InvocationTargetException e
) {
391 throw new RuntimeException(e
);
394 String typeLabel
= null;
396 Representation typeRepr
= type
.getPreferredRepresentation(CdmStore
.getDefaultLanguage());
397 if (typeRepr
!= null){
398 typeLabel
= typeRepr
.getAbbreviatedLabel();
400 if (StringUtils
.isBlank(typeLabel
) && typeRepr
!= null){
401 typeLabel
= typeRepr
.getLabel();
403 if (StringUtils
.isBlank(typeLabel
) ){
404 typeLabel
= type
.getSymbol();
406 if (StringUtils
.isBlank(typeLabel
)){
407 typeLabel
= type
.getTitleCache();
410 if (StringUtils
.isBlank(typeLabel
)){
413 String result
= CdmUtils
.concat(" ", new String
[]{from
== null ?
null : from
.getTitleCache(),
414 typeLabel
, to
== null?
null : to
.getTitleCache()});
419 private static String
getCache(HomotypicalGroup hg
) {
421 for (TaxonNameBase
<?
,?
> tnb
: hg
.getTypifiedNames()){
422 result
= CdmUtils
.concat(", ", result
, tnb
.getTitleCache());
424 if (StringUtils
.isBlank(result
)){
425 result
= "No typified names";
431 * <p>getObjectClassname</p>
433 * @param element a {@link java.lang.Object} object.
434 * @return a {@link java.lang.String} object.
436 public static String
getObjectClassname(Object element
) {
437 return element
.getClass().getSimpleName();
441 * <p>getFeatureNodeContainerText</p>
443 * @param element a {@link eu.etaxonomy.taxeditor.model.FeatureNodeContainer} object.
444 * @return a {@link java.lang.String} object.
446 public static String
getFeatureNodeContainerText(FeatureNodeContainer element
) {
447 String result
= null;
448 if(element
.getFeatureNode() != null && element
.getFeatureNode().getFeature() != null){
449 result
= element
.getFeatureNode().getFeature().getLabel(CdmStore
.getDefaultLanguage());
451 return "No label set";
454 result
= element
.getFeatureNode().getFeature().getLabel();
460 * <p>getQuantitativeDataText</p>
462 * @param element a {@link eu.etaxonomy.cdm.model.description.QuantitativeData} object.
463 * @return a {@link java.lang.String} object.
465 public static String
getQuantitativeDataText(QuantitativeData element
) {
466 TextData textData
= quantitativeDescriptionBuilder
.build(element
, getLanguageList());
468 return textData
.getText(CdmStore
.getDefaultLanguage());
472 * <p>getCategoricalDataText</p>
474 * @param element a {@link eu.etaxonomy.cdm.model.description.CategoricalData} object.
475 * @return a {@link java.lang.String} object.
477 public static String
getCategoricalDataText(CategoricalData element
) {
478 TextData textData
= categoricalDescriptionBuilder
.build(element
, getLanguageList());
480 return textData
.getText(CdmStore
.getDefaultLanguage());
483 private static List
<Language
> getLanguageList(){
484 return Arrays
.asList(new Language
[]{CdmStore
.getDefaultLanguage()});
487 private static DescriptionBuilder
<QuantitativeData
> quantitativeDescriptionBuilder
= new DefaultQuantitativeDescriptionBuilder();
488 private static DescriptionBuilder
<CategoricalData
> categoricalDescriptionBuilder
= new DefaultCategoricalDescriptionBuilder();
492 * <p>getDistributionText</p>
494 * @param element a {@link eu.etaxonomy.cdm.model.description.Distribution} object.
495 * @return a {@link java.lang.String} object.
497 public static String
getDistributionText(Distribution element
) {
499 String text
= "EMPTY";
501 Distribution distribution
= element
;
503 NamedArea area
= distribution
.getArea();
506 text
= NamedArea
.labelWithLevel(area
, CdmStore
.getDefaultLanguage());
508 PresenceAbsenceTerm status
= distribution
.getStatus();
510 if (status
!= null) {
511 text
+= ", " + status
.getLabel();
513 text
+= ", NO STATUS";
520 * <p>getImageText</p>
522 * @param media a {@link eu.etaxonomy.cdm.model.media.Media} object.
523 * @return a {@link java.lang.String} object.
525 public static String
getImageText(Media media
) {
526 LanguageString title
= media
.getTitle(CdmStore
.getDefaultLanguage());
528 return title
.getText();
536 * <p>getElementText</p>
538 * @param element a {@link eu.etaxonomy.cdm.model.description.TextData} object.
539 * @return a {@link java.lang.String} object.
541 public static String
getElementText(TextData element
) {
543 if(element
.getFeature().equals(Feature
.CITATION())){
545 for(DescriptionElementSource source
: element
.getSources()){
546 if(source
.getCitation() != null){
547 text
+= source
.getCitation().getTitleCache();
549 if(source
.getNameUsedInSource() != null){
550 text
+= " [ " + source
.getNameUsedInSource().getTitleCache() + " ]";
553 if(CdmUtils
.isEmpty(text
)){
554 text
= "No sources provided";
557 List
<Language
> languages
= Arrays
.asList(new Language
[]{CdmStore
.getDefaultLanguage()});
558 LanguageString languageString
= element
.getPreferredLanguageString(languages
);
559 text
= languageString
!= null ? languageString
.getText() : null;
561 return CdmUtils
.isEmpty(text
) ?
"No text provided" : text
;
565 * <p>getTaxonInteractionText</p>
567 * @param element a {@link eu.etaxonomy.cdm.model.description.TaxonInteraction} object.
568 * @return a {@link java.lang.String} object.
570 public static String
getTaxonInteractionText(TaxonInteraction element
) {
572 Taxon taxon2
= element
.getTaxon2();
573 if(taxon2
!= null && taxon2
.getName() != null){
574 text
= taxon2
.getName().getTitleCache();
576 text
= "No taxon chosen";
583 * <p>getCommonNameText</p>
585 * @param commonName a {@link eu.etaxonomy.cdm.model.description.CommonTaxonName} object.
586 * @return a {@link java.lang.String} object.
588 public static String
getCommonNameText(CommonTaxonName commonName
) {
589 String name
= commonName
.getName();
590 if (name
== null || name
.length() == 0) {
591 name
= "No name provided";
593 Language language
= commonName
.getLanguage();
594 if (language
== null) {
595 name
+= " (No language provided)";
597 name
+= " (" + language
.getDescription() + ")";
603 * <p>getDescriptionText</p>
605 * @param element a {@link eu.etaxonomy.cdm.model.description.DescriptionBase} object.
606 * @return a {@link java.lang.String} object.
608 public static String
getDescriptionText(DescriptionBase element
) {
609 String text
= element
.getTitleCache();
610 if (text
== null || text
.length() == 0) {
611 text
= "No label provided";
618 * <p>getIndividualsAssociationText</p>
620 * @param element a {@link eu.etaxonomy.cdm.model.description.IndividualsAssociation} object.
621 * @return a {@link java.lang.String} object.
623 public static String
getIndividualsAssociationText(IndividualsAssociation element
) {
624 SpecimenOrObservationBase derivedUnit
= element
.getAssociatedSpecimenOrObservation();
625 if(derivedUnit
!= null){
626 return derivedUnit
.getTitleCache();
628 return "No unit chosen";
634 * @param element a {@link java.lang.Object} object.
635 * @return a {@link java.lang.String} object.
637 public static String
getLabel(Object element
){
638 String noLabelString
= "[no label]";
639 if (element
instanceof FeatureNodeContainer
){
640 return getFeatureNodeContainerText((FeatureNodeContainer
) element
);
642 else if (element
instanceof DescriptionBase
) {
643 return getDescriptionText((DescriptionBase
) element
);
645 else if(element
instanceof CategoricalData
){
646 String categoricalDataText
= getCategoricalDataText((CategoricalData
) element
);
647 if(categoricalDataText
==null || categoricalDataText
.isEmpty()){
648 categoricalDataText
= noLabelString
;
650 return categoricalDataText
;
652 else if (element
instanceof CommonTaxonName
) {
653 return getCommonNameText((CommonTaxonName
) element
);
655 else if (element
instanceof Distribution
) {
656 return getDistributionText((Distribution
) element
);
658 else if (element
instanceof IndividualsAssociation
) {
659 return getIndividualsAssociationText((IndividualsAssociation
) element
);
661 else if (element
instanceof QuantitativeData
) {
662 String quantitativeDataText
= getQuantitativeDataText((QuantitativeData
) element
);
663 if(quantitativeDataText
==null || quantitativeDataText
.isEmpty()){
664 quantitativeDataText
= noLabelString
;
666 return quantitativeDataText
;
668 else if (element
instanceof TaxonInteraction
) {
669 return getTaxonInteractionText((TaxonInteraction
) element
);
671 else if (element
instanceof TextData
) {
672 return getElementText((TextData
) element
);
675 return element
.toString();