Revision 73d33afe
Added by Andreas Müller almost 4 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/DescriptionHelper.java | ||
---|---|---|
213 | 213 |
setCache(element, value, CdmStore.getDefaultLanguage()); |
214 | 214 |
} |
215 | 215 |
|
216 |
|
|
217 |
/** |
|
218 |
* <p>getObjectDescription</p> |
|
219 |
* |
|
220 |
* @param element a {@link java.lang.Object} object. |
|
221 |
* @return a {@link java.lang.String} object. |
|
222 |
*/ |
|
223 | 216 |
public static String getObjectDescription(Object element) { |
224 | 217 |
String resultString = null; |
225 | 218 |
if (element instanceof IdentifiableEntity) { |
... | ... | |
342 | 335 |
return result; |
343 | 336 |
} |
344 | 337 |
|
345 |
|
|
346 | 338 |
private static String getCache(DeterminationEvent detEvent) { |
347 | 339 |
//taxon |
348 | 340 |
String taxonStr = null; |
... | ... | |
358 | 350 |
taxonStr = "no or unlabled taxon"; |
359 | 351 |
} |
360 | 352 |
|
361 |
|
|
362 | 353 |
//unit |
363 | 354 |
SpecimenOrObservationBase<?> unit = detEvent.getIdentifiedUnit(); |
364 | 355 |
String unitStr; |
... | ... | |
528 | 519 |
return result; |
529 | 520 |
} |
530 | 521 |
|
531 |
/** |
|
532 |
* <p>getObjectClassname</p> |
|
533 |
* |
|
534 |
* @param element a {@link java.lang.Object} object. |
|
535 |
* @return a {@link java.lang.String} object. |
|
536 |
*/ |
|
537 | 522 |
public static String getObjectClassname(Object element) { |
538 | 523 |
return element.getClass().getSimpleName(); |
539 | 524 |
} |
540 | 525 |
|
541 |
/** |
|
542 |
* <p>getFeatureNodeContainerText</p> |
|
543 |
* |
|
544 |
* @param element a {@link eu.etaxonomy.taxeditor.model.FeatureNodeContainer} object. |
|
545 |
* @return a {@link java.lang.String} object. |
|
546 |
*/ |
|
547 | 526 |
public static String getFeatureNodeContainerText(FeatureNodeContainer element) { |
548 | 527 |
String result = null; |
549 | 528 |
if(element.getFeatureNode() != null && element.getFeatureNode().getTerm() != null){ |
... | ... | |
557 | 536 |
return result; |
558 | 537 |
} |
559 | 538 |
|
560 |
/** |
|
561 |
* <p>getQuantitativeDataText</p> |
|
562 |
* |
|
563 |
* @param element a {@link eu.etaxonomy.cdm.model.description.QuantitativeData} object. |
|
564 |
* @return a {@link java.lang.String} object. |
|
565 |
*/ |
|
566 | 539 |
public static String getQuantitativeDataText(QuantitativeData element) { |
567 | 540 |
QuantitativeDataFormatter formatter = new QuantitativeDataFormatter(null, null); |
568 | 541 |
String label = formatter.doFormat(element); |
... | ... | |
570 | 543 |
return label; |
571 | 544 |
} |
572 | 545 |
|
573 |
/** |
|
574 |
* <p>getCategoricalDataText</p> |
|
575 |
* |
|
576 |
* @param element a {@link eu.etaxonomy.cdm.model.description.CategoricalData} object. |
|
577 |
* @return a {@link java.lang.String} object. |
|
578 |
*/ |
|
579 | 546 |
public static String getCategoricalDataText(CategoricalData element) { |
580 | 547 |
TextData textData = categoricalDescriptionBuilder.build(element, getLanguageList()); |
581 | 548 |
|
... | ... | |
591 | 558 |
public static final String NO_LABEL_STRING = "[no label]"; |
592 | 559 |
|
593 | 560 |
|
594 |
/** |
|
595 |
* <p>getDistributionText</p> |
|
596 |
* |
|
597 |
* @param element a {@link eu.etaxonomy.cdm.model.description.Distribution} object. |
|
598 |
* @return a {@link java.lang.String} object. |
|
599 |
*/ |
|
600 | 561 |
public static String getDistributionText(Distribution element) { |
601 | 562 |
|
602 | 563 |
String text = "EMPTY"; |
... | ... | |
619 | 580 |
return text; |
620 | 581 |
} |
621 | 582 |
|
622 |
/** |
|
623 |
* <p>getImageText</p> |
|
624 |
* |
|
625 |
* @param media a {@link eu.etaxonomy.cdm.model.media.Media} object. |
|
626 |
* @return a {@link java.lang.String} object. |
|
627 |
*/ |
|
628 | 583 |
public static String getImageText(Media media) { |
629 | 584 |
LanguageString title = media.getTitle(CdmStore.getDefaultLanguage()); |
630 | 585 |
if (title != null) { |
... | ... | |
633 | 588 |
return "No title."; |
634 | 589 |
} |
635 | 590 |
|
636 |
|
|
637 |
|
|
638 |
/** |
|
639 |
* <p>getElementText</p> |
|
640 |
* |
|
641 |
* @param element a {@link eu.etaxonomy.cdm.model.description.TextData} object. |
|
642 |
* @return a {@link java.lang.String} object. |
|
643 |
*/ |
|
644 | 591 |
public static String getElementText(TextData element) { |
645 | 592 |
String text = null; |
646 | 593 |
if(element.getFeature().equals(Feature.CITATION())){ |
... | ... | |
664 | 611 |
return isBlank(text) ? "No text provided" : text; |
665 | 612 |
} |
666 | 613 |
|
667 |
/** |
|
668 |
* <p>getTaxonInteractionText</p> |
|
669 |
* |
|
670 |
* @param element a {@link eu.etaxonomy.cdm.model.description.TaxonInteraction} object. |
|
671 |
* @return a {@link java.lang.String} object. |
|
672 |
*/ |
|
673 | 614 |
public static String getTaxonInteractionText(TaxonInteraction element) { |
674 | 615 |
String text = ""; |
675 | 616 |
Taxon taxon2 = element.getTaxon2(); |
... | ... | |
682 | 623 |
return text; |
683 | 624 |
} |
684 | 625 |
|
685 |
/** |
|
686 |
* <p>getCommonNameText</p> |
|
687 |
* |
|
688 |
* @param commonName a {@link eu.etaxonomy.cdm.model.description.CommonTaxonName} object. |
|
689 |
* @return a {@link java.lang.String} object. |
|
690 |
*/ |
|
691 | 626 |
public static String getCommonNameText(CommonTaxonName commonName) { |
692 | 627 |
String name = commonName.getName(); |
693 | 628 |
if (name == null || name.length() == 0) { |
... | ... | |
702 | 637 |
return name; |
703 | 638 |
} |
704 | 639 |
|
705 |
/** |
|
706 |
* <p>getDescriptionText</p> |
|
707 |
* |
|
708 |
* @param element a {@link eu.etaxonomy.cdm.model.description.DescriptionBase} object. |
|
709 |
* @return a {@link java.lang.String} object. |
|
710 |
*/ |
|
711 | 640 |
public static String getDescriptionText(DescriptionBase element) { |
712 | 641 |
String text = element.getTitleCache(); |
713 | 642 |
if (text == null || text.length() == 0) { |
... | ... | |
717 | 646 |
return text; |
718 | 647 |
} |
719 | 648 |
|
720 |
/** |
|
721 |
* <p>getIndividualsAssociationText</p> |
|
722 |
* |
|
723 |
* @param element a {@link eu.etaxonomy.cdm.model.description.IndividualsAssociation} object. |
|
724 |
* @return a {@link java.lang.String} object. |
|
725 |
*/ |
|
726 | 649 |
public static String getIndividualsAssociationText(IndividualsAssociation element) { |
727 |
SpecimenOrObservationBase derivedUnit = element.getAssociatedSpecimenOrObservation(); |
|
650 |
SpecimenOrObservationBase<?> derivedUnit = element.getAssociatedSpecimenOrObservation();
|
|
728 | 651 |
if(derivedUnit != null){ |
729 | 652 |
return derivedUnit.getTitleCache(); |
730 | 653 |
} |
731 | 654 |
return "No unit chosen"; |
732 | 655 |
} |
733 | 656 |
|
734 |
/** |
|
735 |
* <p>getLabel</p> |
|
736 |
* |
|
737 |
* @param element a {@link java.lang.Object} object. |
|
738 |
* @return a {@link java.lang.String} object. |
|
739 |
*/ |
|
740 | 657 |
public static String getLabel(Object element){ |
741 | 658 |
if (element instanceof FeatureNodeContainer){ |
742 | 659 |
return getFeatureNodeContainerText((FeatureNodeContainer) element); |
743 | 660 |
} |
744 | 661 |
else if (element instanceof DescriptionBase) { |
745 |
return getDescriptionText((DescriptionBase) element); |
|
662 |
return getDescriptionText((DescriptionBase<?>) element);
|
|
746 | 663 |
} |
747 | 664 |
else if(element instanceof CategoricalData){ |
748 | 665 |
String categoricalDataText = getCategoricalDataText((CategoricalData) element); |
... | ... | |
781 | 698 |
} |
782 | 699 |
} |
783 | 700 |
|
784 |
/** |
|
785 |
* @param element |
|
786 |
* @return |
|
787 |
*/ |
|
788 | 701 |
private static String getTemporalDataText(TemporalData element) { |
789 | 702 |
ExtendedTimePeriod period = element.getPeriod(); |
790 | 703 |
Partial end = period.getEnd()==null?null:period.getEnd().without(DateTimeFieldType.year()); |
Also available in: Unified diff
cleanup