+ public TaxonDescription findDefaultTaxonDescription(UUID descriptiveDataSetUuid, UUID taxonNodeUuid, boolean create){
+ DescriptiveDataSet dataSet = load(descriptiveDataSetUuid);
+ TaxonNode taxonNode = taxonNodeService.load(taxonNodeUuid, Arrays.asList("taxon", "taxon.descriptions", "taxon.descriptions.markers"));
+ Set<DescriptionBase> dataSetDescriptions = dataSet.getDescriptions();
+ //filter out COMPUTED descriptions
+ List<TaxonDescription> nonComputedDescriptions = taxonNode.getTaxon().getDescriptions().stream()
+ .filter(desc -> desc.getMarkers().stream()
+ .anyMatch(marker -> marker.getMarkerType().equals(MarkerType.COMPUTED())))
+ .collect(Collectors.toList());
+ for (TaxonDescription taxonDescription : nonComputedDescriptions) {
+ for (DescriptionBase description : dataSetDescriptions) {
+ if(description.getUuid().equals(taxonDescription.getUuid())){
+ return taxonDescription;
+ }
+ }
+ }
+ if(!create){
+ return null;
+ }
+ //description not yet added to dataset -> create a new one
+ TaxonDescription newTaxonDescription = TaxonDescription.NewInstance(taxonNode.getTaxon());
+ newTaxonDescription.setTitleCache("Dataset "+dataSet.getLabel()+": "+newTaxonDescription.generateTitle(), true); //$NON-NLS-2$
+ dataSet.getDescriptiveSystem().getDistinctFeatures().forEach(wsFeature->{
+ if(wsFeature.isSupportsCategoricalData()){
+ newTaxonDescription.addElement(CategoricalData.NewInstance(wsFeature));
+ }
+ else if(wsFeature.isSupportsQuantitativeData()){
+ newTaxonDescription.addElement(QuantitativeData.NewInstance(wsFeature));
+ }
+ });
+ return newTaxonDescription;
+ }
+
+ @Override
+ public SpecimenDescription findSpecimenDescription(UUID descriptiveDataSetUuid, UUID specimenUuid){