d0e40abf68006e300d5f00fde9c6d83fca3e0a93
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / model / DescriptionHelper.java
1 // $Id$
2 /**
3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
6 *
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.
9 */
10
11 package eu.etaxonomy.taxeditor.model;
12
13 import java.lang.reflect.InvocationTargetException;
14 import java.lang.reflect.Method;
15 import java.util.Arrays;
16 import java.util.List;
17 import java.util.Set;
18
19 import org.apache.commons.lang.StringUtils;
20 import org.hibernate.LazyInitializationException;
21
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.SpecimenOrObservationBase;
65 import eu.etaxonomy.cdm.model.taxon.Classification;
66 import eu.etaxonomy.cdm.model.taxon.SynonymRelationship;
67 import eu.etaxonomy.cdm.model.taxon.Taxon;
68 import eu.etaxonomy.cdm.model.taxon.TaxonNode;
69 import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
70 import eu.etaxonomy.taxeditor.store.CdmStore;
71
72 /**
73 * <p>DescriptionHelper class.</p>
74 *
75 * @author p.ciardelli
76 * @author n.hoffmann
77 * @created 02.04.2009
78 */
79 public class DescriptionHelper {
80
81 /**
82 * Returns whatever the element's title cache equivalent is,
83 * depending on its class.
84 *
85 * @param element a {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase} object.
86 * @param language a {@link eu.etaxonomy.cdm.model.common.Language} object.
87 * @return a {@link java.lang.String} object.
88 */
89 public static String getCache(DescriptionElementBase element,
90 Language language) {
91
92 String mainElementLabel= null;
93 DescriptionBase<?> descr = element.getInDescription();
94 if (descr != null){
95 if (descr.isInstanceOf(TaxonDescription.class)){
96 Taxon taxon = CdmBase.deproxy(descr, TaxonDescription.class).getTaxon();
97 if (taxon != null){
98 mainElementLabel = taxon.getTitleCache();
99 }
100 }else if (descr.isInstanceOf(SpecimenDescription.class)){
101 SpecimenOrObservationBase<?> specimen = CdmBase.deproxy(descr, SpecimenDescription.class).getDescribedSpecimenOrObservation();
102 if (specimen != null){
103 mainElementLabel = specimen.getTitleCache();
104 }
105 }else if (descr.isInstanceOf(TaxonNameDescription.class)){
106 TaxonNameBase<?, ?> name = CdmBase.deproxy(descr, TaxonNameDescription.class).getTaxonName();
107 if (name != null){
108 mainElementLabel = name.getTitleCache();
109 }
110 }
111 }
112
113 String cache = null;
114 if (element instanceof TextData) {
115 cache = ((TextData) element).getText(language);
116 }
117 if (element instanceof CommonTaxonName) {
118 cache = ((CommonTaxonName) element).getName();
119 }
120 if (element instanceof TaxonInteraction) {
121 Taxon taxon2 = ((TaxonInteraction) element).getTaxon2();
122 if(taxon2 != null && taxon2.getName() != null){
123 cache = taxon2.getName().getTitleCache();
124 }else{
125 cache = "No taxon chosen";
126 }
127
128 }
129 if (element instanceof Distribution) {
130 Distribution distribution = (Distribution) element;
131
132 NamedArea area = distribution.getArea();
133 if(area != null){
134 cache = area.getLabel();
135
136 PresenceAbsenceTerm status = distribution.getStatus();
137 if (status == null){
138 cache += ", no status";
139 }else {
140 cache += ", " + status.getLabel();
141 }
142 }
143 }
144 String result = cache == null ? "" : cache;
145 if (StringUtils.isNotBlank(mainElementLabel)){
146 result = CdmUtils.concat(" ", result, "(" + mainElementLabel + ")");
147 }
148 return result;
149 }
150
151 /**
152 * Returns whatever the element's title cache equivalent is,
153 * depending on its class, using the default language.
154 *
155 * @param element a {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase} object.
156 * @return a {@link java.lang.String} object.
157 */
158 public static String getCache(DescriptionElementBase element) {
159 return getCache(element, CdmStore.getDefaultLanguage());
160 }
161
162 /**
163 * Set whatever the element's title cache equivalent is,
164 * depending on its class.
165 *
166 * @param element a {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase} object.
167 * @param value a {@link java.lang.String} object.
168 * @param language a {@link eu.etaxonomy.cdm.model.common.Language} object.
169 */
170 public static void setCache(DescriptionElementBase element,
171 String value, Language language) {
172 if (element instanceof TextData) {
173 ((TextData) element).putText(language, value);
174 return;
175 }else if (element instanceof CommonTaxonName) {
176 ((CommonTaxonName) element).setName(value);
177 return;
178 }else if (element instanceof TaxonInteraction) {
179
180 }else if(element instanceof Distribution){
181 MessagingUtils.warn(DescriptionHelper.class, "trying to set cache on distribution, don't know what to do at the moment.");
182 return;
183 }else{
184 MessagingUtils.warn(DescriptionHelper.class, "No matching subclass found for DescriptionElementBase object, 'cache' not set.");
185 }
186 }
187
188 /**
189 * Set whatever the element's title cache equivalent is,
190 * depending on its class, using the default language.
191 *
192 * @param element a {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase} object.
193 * @param value a {@link java.lang.String} object.
194 */
195 public static void setCache(DescriptionElementBase element,
196 String value) {
197 setCache(element, value, CdmStore.getDefaultLanguage());
198 }
199
200
201 /**
202 * <p>getObjectDescription</p>
203 *
204 * @param element a {@link java.lang.Object} object.
205 * @return a {@link java.lang.String} object.
206 */
207 public static String getObjectDescription(Object element) {
208 if (element instanceof IdentifiableEntity) {
209 try{
210 return ((IdentifiableEntity) element).getTitleCache();
211 }catch(LazyInitializationException e){
212 String result = "No Session to initialize title cache for IdentifiableEntity";
213 MessagingUtils.error(DescriptionHelper.class, result, e);
214 return "TODO: " + result;
215 }
216 }else if (element instanceof OriginalSourceBase) {
217 try{
218 OriginalSourceBase<?> originalSource = (OriginalSourceBase<?>) element;
219 // ISourceable sourcedObject = originalSource.getSourcedObj();
220 //due to #5743 the bidirectionality for sourced object had to be removed
221 String sourceObjectTitle = "sourced object data not available (#5743)";
222 // if(sourcedObject instanceof IIdentifiableEntity){
223 // sourceObjectTitle = ((IdentifiableEntity) sourcedObject).getTitleCache();
224 // }else if(sourcedObject instanceof DescriptionElementBase){
225 // sourceObjectTitle = "Element for description: " + ((DescriptionElementBase) sourcedObject).getInDescription().getTitleCache();
226 // }else{
227 // throw new IllegalStateException("Unknown ISourceable object for given OriginalSourceBase");
228 // }
229
230 return CdmUtils.concat("; ", new String[]{originalSource.getIdNamespace(), originalSource.getIdInSource(), sourceObjectTitle});
231 }catch(LazyInitializationException e){
232 String result = "Error initializing title cache for ISourceable of an OriginalSourceBase";
233 MessagingUtils.error(DescriptionHelper.class, result, e);
234 return "TODO: " + result;
235 }
236 }else if (element instanceof LanguageStringBase) {
237 return ((LanguageStringBase) element).getText();
238 }else if (element instanceof DescriptionElementBase) {
239 return getCache((DescriptionElementBase) element);
240 }else if (element instanceof RelationshipBase<?, ?, ?>) {
241 return getCache((RelationshipBase<?, ?, ?>) element);
242 }else if (element instanceof TypeDesignationBase<?>) {
243 return getCache((TypeDesignationBase<?>) element);
244 }else if (element instanceof HomotypicalGroup) {
245 return getCache((HomotypicalGroup) element);
246 }else if (element instanceof TaxonNode) {
247 return getCache((TaxonNode) element);
248 }else if (element instanceof Marker) {
249 Marker marker = (Marker) element;
250 MarkerType type = marker.getMarkerType();
251 return (type == null ? "- no marker type -" : marker.getMarkerType().getLabel()) + " (" + marker.getFlag() + ")";
252 }else if (element instanceof User) {
253 User user = (User) element;
254 return user.getUsername();
255 }else if (element instanceof Group) {
256 Group group = (Group) element;
257 return group.getName();
258 }else{
259 // TODO write return texts for HomotypicalGroup, etc.
260 return element.toString();
261 }
262 }
263
264
265 private static String getCache(TaxonNode taxonNode) {
266 String result = "";
267 Classification classification = taxonNode.getClassification();
268 if (classification != null){
269 String classificationStr = classification.getName() == null ? "" : classification.getName().getText();
270 result = CdmUtils.concat("" , result, classificationStr);
271 if (StringUtils.isBlank(result)){
272 result = classification.toString();
273 }
274 }
275 String parentStr;
276 TaxonNode parentNode = taxonNode.getParent();
277 if (parentNode == null){
278 parentStr = "no parent";
279 }else{
280 Taxon parentTaxon = parentNode.getTaxon();
281 if (parentTaxon == null){
282 parentStr = "no parent taxon";
283 }else{
284 TaxonNameBase<?,?> parentName = parentTaxon.getName();
285 if (parentName == null){
286 parentStr = parentTaxon.getTitleCache();
287 }else{
288 parentStr = parentName.getTitleCache();
289 }
290 }
291 }
292 result = CdmUtils.concat(": ", result, parentStr);
293
294 return null;
295 }
296
297 private static String getCache(TypeDesignationBase<?> designation) {
298 designation = CdmBase.deproxy(designation);
299 TypeDesignationStatusBase<?> status = designation.getTypeStatus();
300 Set<TaxonNameBase> from;
301 IdentifiableEntity<?> to;
302 from = designation.getTypifiedNames();
303 if (designation.isInstanceOf(SpecimenTypeDesignation.class)){
304 to = ((SpecimenTypeDesignation)designation).getTypeSpecimen();
305 }else if (designation.isInstanceOf(NameTypeDesignation.class)){
306 to = ((NameTypeDesignation)designation).getTypeName();
307 }else{
308 throw new RuntimeException("Type Designation class not supported: " + designation.getClass().getName());
309 }
310 String typeLabel = null;
311 if (status != null){
312 Representation typeRepr = status.getPreferredRepresentation(CdmStore.getDefaultLanguage());
313 if (typeRepr != null){
314 typeLabel = typeRepr.getAbbreviatedLabel();
315 }
316 if (StringUtils.isBlank(typeLabel) && typeRepr != null){
317 typeLabel = typeRepr.getLabel();
318 }
319 if (StringUtils.isBlank(typeLabel) ){
320 typeLabel = status.getSymbol();
321 }
322 if (StringUtils.isBlank(typeLabel)){
323 typeLabel = status.getTitleCache();
324 }
325 }
326 if (StringUtils.isBlank(typeLabel)){
327 typeLabel = "->";
328 }
329 String fromString = "";
330 for (TaxonNameBase<?,?> name : from){
331 CdmUtils.concat(",", fromString, name.getTitleCache());
332 }
333 String result = CdmUtils.concat(" ", new String[]{from == null ? null : fromString,
334 typeLabel, to == null? null : to.getTitleCache()});
335 return result;
336 }
337
338 private static String getCache(RelationshipBase<?, ?, ?> rel) {
339 rel = CdmBase.deproxy(rel);
340 RelationshipTermBase<?> type = rel.getType();
341 IdentifiableEntity<?> from;
342 IdentifiableEntity<?> to;
343 if (rel.isInstanceOf(SynonymRelationship.class)){
344 from = ((SynonymRelationship)rel).getSynonym();
345 to = ((SynonymRelationship)rel).getAcceptedTaxon();
346 }else if (rel.isInstanceOf(NameRelationship.class)){
347 from = ((NameRelationship)rel).getFromName();
348 to = ((NameRelationship)rel).getToName();
349 }else if (rel.isInstanceOf(HybridRelationship.class)){
350 from = ((HybridRelationship)rel).getParentName();
351 to = ((HybridRelationship)rel).getHybridName();
352 }else if (rel.isInstanceOf(TaxonRelationship.class)){
353 from = ((TaxonRelationship)rel).getFromTaxon();
354 to = ((TaxonRelationship)rel).getToTaxon();
355 }else{
356 try {
357 Method fromMethod = rel.getClass().getMethod("getRelatedFrom");
358 Method toMethod = rel.getClass().getMethod("getRelatedFrom");
359 fromMethod.setAccessible(true);
360 toMethod.setAccessible(true);
361 from = (IdentifiableEntity<?>)fromMethod.invoke(rel);
362 to = (IdentifiableEntity<?>)toMethod.invoke(rel);
363 } catch (NoSuchMethodException e) {
364 throw new RuntimeException(e);
365 } catch (SecurityException e) {
366 throw new RuntimeException(e);
367 } catch (IllegalAccessException e) {
368 throw new RuntimeException(e);
369 } catch (IllegalArgumentException e) {
370 throw new RuntimeException(e);
371 } catch (InvocationTargetException e) {
372 throw new RuntimeException(e);
373 }
374
375 }
376 String typeLabel = null;
377 if (type != null){
378 Representation typeRepr = type.getPreferredRepresentation(CdmStore.getDefaultLanguage());
379 if (typeRepr != null){
380 typeLabel = typeRepr.getAbbreviatedLabel();
381 }
382 if (StringUtils.isBlank(typeLabel) && typeRepr != null){
383 typeLabel = typeRepr.getLabel();
384 }
385 if (StringUtils.isBlank(typeLabel) ){
386 typeLabel = type.getSymbol();
387 }
388 if (StringUtils.isBlank(typeLabel)){
389 typeLabel = type.getTitleCache();
390 }
391 }
392 if (StringUtils.isBlank(typeLabel)){
393 typeLabel = "->";
394 }
395 String result = CdmUtils.concat(" ", new String[]{from == null ? null : from.getTitleCache(),
396 typeLabel, to == null? null : to.getTitleCache()});
397 return result;
398 }
399
400
401 private static String getCache(HomotypicalGroup hg) {
402 String result = "";
403 for (TaxonNameBase<?,?> tnb : hg.getTypifiedNames()){
404 result = CdmUtils.concat(", ", result, tnb.getTitleCache());
405 }
406 if (StringUtils.isBlank(result)){
407 result = "No typified names";
408 }
409 return result;
410 }
411
412 /**
413 * <p>getObjectClassname</p>
414 *
415 * @param element a {@link java.lang.Object} object.
416 * @return a {@link java.lang.String} object.
417 */
418 public static String getObjectClassname(Object element) {
419 return element.getClass().getSimpleName();
420 }
421
422 /**
423 * <p>getFeatureNodeContainerText</p>
424 *
425 * @param element a {@link eu.etaxonomy.taxeditor.model.FeatureNodeContainer} object.
426 * @return a {@link java.lang.String} object.
427 */
428 public static String getFeatureNodeContainerText(FeatureNodeContainer element) {
429 String result = null;
430 if(element.getFeatureNode() != null && element.getFeatureNode().getFeature() != null){
431 result = element.getFeatureNode().getFeature().getLabel(CdmStore.getDefaultLanguage());
432 } else{
433 return "No label set";
434 }
435 if (result == null){
436 result = element.getFeatureNode().getFeature().getLabel();
437 }
438 return result;
439 }
440
441 /**
442 * <p>getQuantitativeDataText</p>
443 *
444 * @param element a {@link eu.etaxonomy.cdm.model.description.QuantitativeData} object.
445 * @return a {@link java.lang.String} object.
446 */
447 public static String getQuantitativeDataText(QuantitativeData element) {
448 TextData textData = quantitativeDescriptionBuilder.build(element, getLanguageList());
449
450 return textData.getText(CdmStore.getDefaultLanguage());
451 }
452
453 /**
454 * <p>getCategoricalDataText</p>
455 *
456 * @param element a {@link eu.etaxonomy.cdm.model.description.CategoricalData} object.
457 * @return a {@link java.lang.String} object.
458 */
459 public static String getCategoricalDataText(CategoricalData element) {
460 TextData textData = categoricalDescriptionBuilder.build(element, getLanguageList());
461
462 return textData.getText(CdmStore.getDefaultLanguage());
463 }
464
465 private static List<Language> getLanguageList(){
466 return Arrays.asList(new Language[]{CdmStore.getDefaultLanguage()});
467 }
468
469 private static DescriptionBuilder<QuantitativeData> quantitativeDescriptionBuilder = new DefaultQuantitativeDescriptionBuilder();
470 private static DescriptionBuilder<CategoricalData> categoricalDescriptionBuilder = new DefaultCategoricalDescriptionBuilder();
471
472
473 /**
474 * <p>getDistributionText</p>
475 *
476 * @param element a {@link eu.etaxonomy.cdm.model.description.Distribution} object.
477 * @return a {@link java.lang.String} object.
478 */
479 public static String getDistributionText(Distribution element) {
480
481 String text = "EMPTY";
482
483 Distribution distribution = element;
484
485 NamedArea area = distribution.getArea();
486 if(area != null){
487
488 text = NamedArea.labelWithLevel(area, CdmStore.getDefaultLanguage());
489
490 PresenceAbsenceTerm status = distribution.getStatus();
491
492 if (status != null) {
493 text += ", " + status.getLabel();
494 }else{
495 text += ", NO STATUS";
496 }
497 }
498 return text;
499 }
500
501 /**
502 * <p>getImageText</p>
503 *
504 * @param media a {@link eu.etaxonomy.cdm.model.media.Media} object.
505 * @return a {@link java.lang.String} object.
506 */
507 public static String getImageText(Media media) {
508 LanguageString title = media.getTitle(CdmStore.getDefaultLanguage());
509 if (title != null) {
510 return title.getText();
511 }
512 return "No title.";
513 }
514
515
516
517 /**
518 * <p>getElementText</p>
519 *
520 * @param element a {@link eu.etaxonomy.cdm.model.description.TextData} object.
521 * @return a {@link java.lang.String} object.
522 */
523 public static String getElementText(TextData element) {
524 String text = null;
525 if(element.getFeature().equals(Feature.CITATION())){
526 text = "";
527 for(DescriptionElementSource source : element.getSources()){
528 if(source.getCitation() != null){
529 text += source.getCitation().getTitleCache();
530 }
531 if(source.getNameUsedInSource() != null){
532 text += " [ " + source.getNameUsedInSource().getTitleCache() + " ]";
533 }
534 }
535 if(CdmUtils.isEmpty(text)){
536 text = "No sources provided";
537 }
538 }else{
539 List<Language> languages = Arrays.asList(new Language[]{CdmStore.getDefaultLanguage()});
540 LanguageString languageString = element.getPreferredLanguageString(languages);
541 text = languageString != null ? languageString.getText() : null;
542 }
543 return CdmUtils.isEmpty(text) ? "No text provided" : text;
544 }
545
546 /**
547 * <p>getTaxonInteractionText</p>
548 *
549 * @param element a {@link eu.etaxonomy.cdm.model.description.TaxonInteraction} object.
550 * @return a {@link java.lang.String} object.
551 */
552 public static String getTaxonInteractionText(TaxonInteraction element) {
553 String text = "";
554 Taxon taxon2 = element.getTaxon2();
555 if(taxon2 != null && taxon2.getName() != null){
556 text = taxon2.getName().getTitleCache();
557 }else{
558 text = "No taxon chosen";
559 }
560
561 return text;
562 }
563
564 /**
565 * <p>getCommonNameText</p>
566 *
567 * @param commonName a {@link eu.etaxonomy.cdm.model.description.CommonTaxonName} object.
568 * @return a {@link java.lang.String} object.
569 */
570 public static String getCommonNameText(CommonTaxonName commonName) {
571 String name = commonName.getName();
572 if (name == null || name.length() == 0) {
573 name = "No name provided";
574 }
575 Language language = commonName.getLanguage();
576 if (language == null) {
577 name += " (No language provided)";
578 } else {
579 name += " (" + language.getDescription() + ")";
580 }
581 return name;
582 }
583
584 /**
585 * <p>getDescriptionText</p>
586 *
587 * @param element a {@link eu.etaxonomy.cdm.model.description.DescriptionBase} object.
588 * @return a {@link java.lang.String} object.
589 */
590 public static String getDescriptionText(DescriptionBase element) {
591 String text = element.getTitleCache();
592 if (text == null || text.length() == 0) {
593 text = "No label provided";
594 }
595
596 return text;
597 }
598
599 /**
600 * <p>getIndividualsAssociationText</p>
601 *
602 * @param element a {@link eu.etaxonomy.cdm.model.description.IndividualsAssociation} object.
603 * @return a {@link java.lang.String} object.
604 */
605 public static String getIndividualsAssociationText(IndividualsAssociation element) {
606 SpecimenOrObservationBase derivedUnit = element.getAssociatedSpecimenOrObservation();
607 if(derivedUnit != null){
608 return derivedUnit.getTitleCache();
609 }
610 return "No unit chosen";
611 }
612
613 /**
614 * <p>getLabel</p>
615 *
616 * @param element a {@link java.lang.Object} object.
617 * @return a {@link java.lang.String} object.
618 */
619 public static String getLabel(Object element){
620 String noLabelString = "[no label]";
621 if (element instanceof FeatureNodeContainer){
622 return getFeatureNodeContainerText((FeatureNodeContainer) element);
623 }
624 else if (element instanceof DescriptionBase) {
625 return getDescriptionText((DescriptionBase) element);
626 }
627 else if(element instanceof CategoricalData){
628 String categoricalDataText = getCategoricalDataText((CategoricalData) element);
629 if(categoricalDataText==null || categoricalDataText.isEmpty()){
630 categoricalDataText = noLabelString;
631 }
632 return categoricalDataText;
633 }
634 else if (element instanceof CommonTaxonName) {
635 return getCommonNameText((CommonTaxonName) element);
636 }
637 else if (element instanceof Distribution) {
638 return getDistributionText((Distribution) element);
639 }
640 else if (element instanceof IndividualsAssociation) {
641 return getIndividualsAssociationText((IndividualsAssociation) element);
642 }
643 else if (element instanceof QuantitativeData) {
644 String quantitativeDataText = getQuantitativeDataText((QuantitativeData) element);
645 if(quantitativeDataText==null || quantitativeDataText.isEmpty()){
646 quantitativeDataText = noLabelString;
647 }
648 return quantitativeDataText;
649 }
650 else if (element instanceof TaxonInteraction) {
651 return getTaxonInteractionText((TaxonInteraction) element);
652 }
653 else if (element instanceof TextData) {
654 return getElementText((TextData) element);
655 }
656 else{
657 return element.toString();
658 }
659 }
660 }