From 58a5b07132cc10fa0f3d0b5e9a733bd90918da70 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andreas=20M=C3=BCller?= Date: Tue, 2 Apr 2024 17:36:08 +0200 Subject: [PATCH] ref #10322 handle features with subfeatures correctly --- .../service/portal/PortalDtoFactLoader.java | 50 ++++++++++-------- .../portal/PortalDtoFactLoader_Old.java | 51 ++++++++++--------- 2 files changed, 56 insertions(+), 45 deletions(-) diff --git a/cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/portal/PortalDtoFactLoader.java b/cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/portal/PortalDtoFactLoader.java index 7946a65724..63367b29a2 100644 --- a/cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/portal/PortalDtoFactLoader.java +++ b/cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/portal/PortalDtoFactLoader.java @@ -875,36 +875,42 @@ public class PortalDtoFactLoader extends PortalDtoLoaderBase { Feature feature = node.getData(); UUID featureUuid = node.getNodeId(); Set facts = featureMap.get(featureUuid); + FeatureDto featureDto; if(facts == null){ - return; - } - - //TODO locale und früher - FeatureDto featureDto = new FeatureDto(feature.getUuid(), feature.getId(), feature.getLabel()); - features.addItem(featureDto); - - List distributions = new ArrayList<>(); - - // - for (FactDtoBase fact : facts){ - if (fact instanceof DistributionDto) { - distributions.add((DistributionDto)fact); + if (node.getChildren().isEmpty()) { + return; }else { - //TODO how to handle CommonNames, do we also want to have a data structure - //with Language| + //TODO locale und früher + featureDto = new FeatureDto(feature.getUuid(), feature.getId(), feature.getLabel()); + } + }else { + //TODO locale und früher + featureDto = new FeatureDto(feature.getUuid(), feature.getId(), feature.getLabel()); + + List distributions = new ArrayList<>(); + + // + for (FactDtoBase fact : facts){ + if (fact instanceof DistributionDto) { + distributions.add((DistributionDto)fact); + }else { + //TODO how to handle CommonNames, do we also want to have a data structure + //with Language| // -- Area| // --name - // a bit like for distribution?? + // a bit like for distribution?? + + //normal facts (usually 1 per feature or at least not hierarchically ordered) + featureDto.addFact(fact); + } - //normal facts (usually 1 per feature or at least not hierarchically ordered) - featureDto.addFact(fact); } + handleDistributions(config, featureDto, distributions, pageDto); + //TODO really needed? + orderFacts(featureDto); } - - handleDistributions(config, featureDto, distributions, pageDto); - //TODO really needed? - orderFacts(featureDto); + features.addItem(featureDto); //children ContainerDto childFeatures = new ContainerDto<>(); diff --git a/cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/portal/PortalDtoFactLoader_Old.java b/cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/portal/PortalDtoFactLoader_Old.java index 0b2eb100f6..2139dafafe 100644 --- a/cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/portal/PortalDtoFactLoader_Old.java +++ b/cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/portal/PortalDtoFactLoader_Old.java @@ -233,32 +233,38 @@ public class PortalDtoFactLoader_Old extends PortalDtoLoaderBase { TreeNode node, TaxonPageDto pageDto) { Feature feature = node.getData(); + FeatureDto featureDto; if(!featureMap.containsKey(feature.getUuid())){ - return; - } - //TODO locale - FeatureDto featureDto = new FeatureDto(feature.getUuid(), feature.getId(), feature.getLabel()); - features.addItem(featureDto); - - List distributions = new ArrayList<>(); - - // - for (DescriptionElementBase fact : featureMap.get(feature.getUuid())){ - if (fact.isInstanceOf(Distribution.class)) { - distributions.add(CdmBase.deproxy(fact, Distribution.class)); + if (node.getChildren().isEmpty()){ + return; }else { - //TODO how to handle CommonNames, do we also want to have a data structure - //with Language| + //TODO locale + featureDto = new FeatureDto(feature.getUuid(), feature.getId(), feature.getLabel()); + } + }else { + //TODO locale + featureDto = new FeatureDto(feature.getUuid(), feature.getId(), feature.getLabel()); + List distributions = new ArrayList<>(); + + // + for (DescriptionElementBase fact : featureMap.get(feature.getUuid())){ + if (fact.isInstanceOf(Distribution.class)) { + distributions.add(CdmBase.deproxy(fact, Distribution.class)); + }else { + //TODO how to handle CommonNames, do we also want to have a data structure + //with Language| // -- Area| // --name - // a bit like for distribution?? - handleFact(featureDto, fact, pageDto); + // a bit like for distribution?? + handleFact(featureDto, fact, pageDto); + } } - } - handleDistributions_old(config, featureDto, distributions, pageDto); - //TODO really needed? - orderFacts(featureDto); + handleDistributions_old(config, featureDto, distributions, pageDto); + //TODO really needed? + orderFacts(featureDto); + } + features.addItem(featureDto); //children ContainerDto childFeatures = new ContainerDto<>(); @@ -453,10 +459,9 @@ public class PortalDtoFactLoader_Old extends PortalDtoLoaderBase { } /** - * Recursive call to a feature tree's feature node in order to creates a tree structure + * Recursive call to a feature tree's feature node in order to create a tree structure * ordered in the same way as the according feature tree but only containing features - * that do really exist for the given taxon. If only a child node is required the parent - * node/feature is also considered to be required.
+ * that do really exist for the given taxon and ancestors of such features.
*/ //TODO 1 does this also work with old load? private TreeNode filterFeatureNode(TermNode featureNode, -- 2.34.1