From: Andreas Müller Date: Wed, 6 Oct 2021 10:06:55 +0000 (+0200) Subject: ref #9510 adapt specimens holding description label (cont. II) X-Git-Tag: 5.27.0^2~39 X-Git-Url: https://dev.e-taxonomy.eu/gitweb/cdmlib.git/commitdiff_plain/5d1ef7fc5cc12d67c58d98e4ecb5093ec25c22a3 ref #9510 adapt specimens holding description label (cont. II) --- diff --git a/cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/DescriptiveDataSetService.java b/cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/DescriptiveDataSetService.java index 25e3c078eb..0714e99b63 100644 --- a/cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/DescriptiveDataSetService.java +++ b/cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/DescriptiveDataSetService.java @@ -276,7 +276,7 @@ public class DescriptiveDataSetService .findFirst().orElseGet(()->{ TaxonDescription td = TaxonDescription.NewInstance(taxon); td.addType(DescriptionType.INDIVIDUALS_ASSOCIATION); - td.setTitleCache("Specimens used by " + dataSet.getTitleCache() + " for " + taxon.getTitleCache(), true); + td.setTitleCache("Specimens used by " + dataSet.getTitleCache() + " for " + getTaxonLabel(taxon), true); return td;}); IndividualsAssociation association = IndividualsAssociation.NewInstance(specimen); @@ -369,6 +369,14 @@ public class DescriptiveDataSetService return result; } + private String getTaxonLabel(Taxon taxon) { + if (taxon.getName() != null){ + return taxon.getName().getTitleCache(); + }else{ + return taxon.getTitleCache(); + } + } + private SpecimenRowWrapperDTO createSpecimenRowWrapper(SpecimenDescription description, UUID taxonNodeUuid, UUID datasetUuid) { TaxonNode taxonNode = taxonNodeService.load(taxonNodeUuid); diff --git a/cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/description/StructuredDescriptionAggregationTest.java b/cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/description/StructuredDescriptionAggregationTest.java index ca8f58d730..56c5bf0a3a 100644 --- a/cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/description/StructuredDescriptionAggregationTest.java +++ b/cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/description/StructuredDescriptionAggregationTest.java @@ -548,10 +548,17 @@ public class StructuredDescriptionAggregationTest extends CdmTransactionalIntegr private SpecimenDescription createSpecimenDescription(DescriptiveDataSet dataSet, UUID taxonUuid, String specLabel, UUID specimenUuid ) { Taxon taxon = (Taxon)taxonService.find(taxonUuid); - TaxonDescription taxonDescription = TaxonDescription.NewInstance(taxon); DerivedUnit specimen = DerivedUnit.NewPreservedSpecimenInstance(); specimen.setTitleCache(specLabel, true); specimen.setUuid(specimenUuid); + TaxonDescription taxonDescription = taxon.getDescriptions(DescriptionType.INDIVIDUALS_ASSOCIATION).stream() + .findFirst() + .orElseGet(()->{ + TaxonDescription td = TaxonDescription.NewInstance(taxon); + td.addType(DescriptionType.INDIVIDUALS_ASSOCIATION); + td.setTitleCache("Specimens used by " + dataSet.getTitleCache() + " for " + getTaxonLabel(taxon), true); + return td;} + ); IndividualsAssociation individualsAssociation = IndividualsAssociation.NewInstance(specimen); // TODO this has to be discussed; currently the description with the InidividualsAssociation is // needed in the dataset for performance reasons @@ -563,6 +570,14 @@ public class StructuredDescriptionAggregationTest extends CdmTransactionalIntegr return specDesc; } + private String getTaxonLabel(Taxon taxon) { + if (taxon.getName() != null){ + return taxon.getName().getTitleCache(); + }else{ + return taxon.getTitleCache(); + } + } + private Feature createFeature(UUID uuid, String label, boolean isQuantitative) { Feature feature = Feature.NewInstance("", label, null); feature.setUuid(uuid);