Revision 37835994
Added by Andreas Müller about 1 year ago
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/portal/PortalDtoLoader.java | ||
---|---|---|
670 | 670 |
TreeNode<Feature, UUID> filteredRootNode; |
671 | 671 |
if (config.getFeatureTree() != null) { |
672 | 672 |
|
673 |
//TODO class cast
|
|
673 |
@SuppressWarnings({ "unchecked"})
|
|
674 | 674 |
TermTree<Feature> featureTree = repository.getTermTreeService().find(config.getFeatureTree()); |
675 | 675 |
filteredRootNode = filterFeatureNode(featureTree.getRoot(), existingFeatureUuids.keySet()); |
676 | 676 |
} else { |
... | ... | |
684 | 684 |
if (filteredRootNode != null && !filteredRootNode.getChildren().isEmpty()) { |
685 | 685 |
ContainerDto<FeatureDto> features = new ContainerDto<>(); |
686 | 686 |
for (TreeNode<Feature,UUID> node : filteredRootNode.getChildren()) { |
687 |
handleFeatureNode(config, featureMap, features, node); |
|
687 |
handleFeatureNode(config, featureMap, features, node, taxonPageDto);
|
|
688 | 688 |
} |
689 | 689 |
taxonPageDto.setTaxonFacts(features); |
690 | 690 |
} |
... | ... | |
706 | 706 |
//DIFFERENT |
707 | 707 |
// if (config.getFeatureTree() != null) { |
708 | 708 |
// |
709 |
// //TODO class cast
|
|
709 |
// @SuppressWarnings({ "unchecked"})
|
|
710 | 710 |
// TermTree<Feature> featureTree = repository.getTermTreeService().find(config.getFeatureTree()); |
711 | 711 |
// filteredRootNode = filterFeatureNode(featureTree.getRoot(), existingFeatureUuids.keySet()); |
712 | 712 |
// } else { |
... | ... | |
720 | 720 |
if (!filteredRootNode.getChildren().isEmpty()) { |
721 | 721 |
ContainerDto<FeatureDto> features = new ContainerDto<>(); |
722 | 722 |
for (TreeNode<Feature,UUID> node : filteredRootNode.getChildren()) { |
723 |
handleFeatureNode(config, featureMap, features, node); |
|
723 |
handleFeatureNode(config, featureMap, features, node, pageDto);
|
|
724 | 724 |
} |
725 | 725 |
//DIFFERENT |
726 | 726 |
nameDto.setNameFacts(features); |
... | ... | |
734 | 734 |
|
735 | 735 |
private void handleFeatureNode(TaxonPageDtoConfiguration config, |
736 | 736 |
Map<UUID, Set<DescriptionElementBase>> featureMap, ContainerDto<FeatureDto> features, |
737 |
TreeNode<Feature, UUID> node) { |
|
737 |
TreeNode<Feature, UUID> node, TaxonPageDto pageDto) {
|
|
738 | 738 |
|
739 | 739 |
Feature feature = node.getData(); |
740 | 740 |
//TODO locale |
... | ... | |
753 | 753 |
// -- Area| |
754 | 754 |
// --name |
755 | 755 |
// a bit like for distribution?? |
756 |
handleFact(featureDto, fact); |
|
756 |
handleFact(featureDto, fact, pageDto);
|
|
757 | 757 |
} |
758 | 758 |
} |
759 | 759 |
|
760 |
handleDistributions(config, featureDto, distributions); |
|
760 |
handleDistributions(config, featureDto, distributions, pageDto);
|
|
761 | 761 |
//TODO really needed? |
762 | 762 |
orderFacts(featureDto); |
763 | 763 |
|
764 | 764 |
//children |
765 | 765 |
ContainerDto<FeatureDto> childFeatures = new ContainerDto<>(); |
766 | 766 |
for (TreeNode<Feature,UUID> child : node.getChildren()) { |
767 |
handleFeatureNode(config, featureMap, childFeatures, child); |
|
767 |
handleFeatureNode(config, featureMap, childFeatures, child, pageDto);
|
|
768 | 768 |
} |
769 | 769 |
if (childFeatures.getCount() > 0) { |
770 | 770 |
featureDto.setSubFeatures(childFeatures); |
... | ... | |
897 | 897 |
} |
898 | 898 |
|
899 | 899 |
private void handleDistributions(TaxonPageDtoConfiguration config, FeatureDto featureDto, |
900 |
List<Distribution> distributions) { |
|
900 |
List<Distribution> distributions, TaxonPageDto pageDto) {
|
|
901 | 901 |
|
902 | 902 |
if (distributions.isEmpty()) { |
903 | 903 |
return; |
... | ... | |
933 | 933 |
distributionStatusColors = DistributionServiceUtilities.buildStatusColorMap( |
934 | 934 |
statusColorsString, repository.getTermService(), repository.getVocabularyService()); |
935 | 935 |
} catch (JsonProcessingException e) { |
936 |
logger.error("JsonProcessingException when reading distribution status colors");
|
|
936 |
pageDto.addMessage(MessagesDto.NewErrorInstance("JsonProcessingException when reading distribution status colors", e));
|
|
937 | 937 |
//TODO is null allowed? |
938 | 938 |
distributionStatusColors = null; |
939 | 939 |
} |
... | ... | |
970 | 970 |
} |
971 | 971 |
} |
972 | 972 |
|
973 |
private FactDtoBase handleFact(FeatureDto featureDto, DescriptionElementBase fact) { |
|
973 |
private FactDtoBase handleFact(FeatureDto featureDto, DescriptionElementBase fact, TaxonPageDto pageDto) {
|
|
974 | 974 |
//TODO locale |
975 | 975 |
Language localeLang = null; |
976 | 976 |
|
... | ... | |
1012 | 1012 |
} |
1013 | 1013 |
dto.setName(ctn.getName()); |
1014 | 1014 |
loadBaseData(ctn, dto); |
1015 |
//TODO sort all common names |
|
1015 |
//TODO sort all common names (not urgent as this is done by portal code)
|
|
1016 | 1016 |
result = dto; |
1017 | 1017 |
} else if (fact.isInstanceOf(IndividualsAssociation.class)) { |
1018 | 1018 |
IndividualsAssociation ia = CdmBase.deproxy(fact, IndividualsAssociation.class); |
... | ... | |
1087 | 1087 |
loadBaseData(td, factDto); |
1088 | 1088 |
result = factDto; |
1089 | 1089 |
}else { |
1090 |
// TODO |
|
1091 |
logger.warn("DescriptionElement type not yet handled: " + fact.getClass().getSimpleName()); |
|
1090 |
pageDto.addMessage(MessagesDto.NewWarnInstance("DescriptionElement type not yet handled: " + fact.getClass().getSimpleName())); |
|
1092 | 1091 |
return null; |
1093 | 1092 |
} |
1094 | 1093 |
result.setTimeperiod(fact.getTimeperiod() == null ? null : fact.getTimeperiod().toString()); |
Also available in: Unified diff
ref #10222 error handling and some javadoc