Project

General

Profile

Revision 32d09233

ID32d09233b0b82c7a8e5dd6d0275608ba0145ad6c
Parent 4bd6b5fc
Child be0fbb67

Added by Patrick Plitzner over 2 years ago

ref #7674 Add aggregated description to data set

View differences:

cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/longrunningService/ILongRunningTasksService.java
39 39
    UUID monitLongRunningTask(Set<UUID> movingUuids, UUID targetTreeNodeUuid, int movingType);
40 40

  
41 41

  
42
    public UUID aggregateComputedTaxonDescriptions(UUID taxonNodeUuid);
42
    public UUID aggregateComputedTaxonDescriptions(UUID taxonNodeUuid, UUID descriptiveDataSetUuid);
43 43
}
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/longrunningService/LongRunningTasksServiceImpl.java
45 45

  
46 46

  
47 47
    @Override
48
    public UUID aggregateComputedTaxonDescriptions(UUID taxonNodeUuid){
48
    public UUID aggregateComputedTaxonDescriptions(UUID taxonNodeUuid, UUID descriptiveDataSetUuid){
49 49
        RemotingProgressMonitorThread monitorThread = new RemotingProgressMonitorThread() {
50 50
            @Override
51 51
            public Serializable doRun(IRemotingProgressMonitor monitor) {
52
                UpdateResult updateResult = descriptionService.aggregateTaxonDescription(taxonNodeUuid, monitor);
52
                UpdateResult updateResult = descriptionService.aggregateTaxonDescription(taxonNodeUuid, descriptiveDataSetUuid, monitor);
53 53
                for(Exception e : updateResult.getExceptions()) {
54 54
                    monitor.addReport(e.getMessage());
55 55
                }
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/DescriptionServiceImpl.java
99 99

  
100 100
    protected IDescriptionElementDao descriptionElementDao;
101 101
    protected IFeatureTreeDao featureTreeDao;
102
    protected IDescriptiveDataSetDao descriptiveDataSetDao;
102 103
    protected IFeatureNodeDao featureNodeDao;
103 104
    protected IFeatureDao featureDao;
104 105
    protected ITermVocabularyDao vocabularyDao;
......
120 121
    }
121 122

  
122 123
    @Autowired
124
    protected void setDescriptiveDataSetDao(IDescriptiveDataSetDao descriptiveDataSetDao) {
125
        this.descriptiveDataSetDao = descriptiveDataSetDao;
126
    }
127

  
128
    @Autowired
123 129
    protected void setFeatureNodeDao(IFeatureNodeDao featureNodeDao) {
124 130
        this.featureNodeDao = featureNodeDao;
125 131
    }
......
853 859

  
854 860
    @Override
855 861
    @Transactional(readOnly=false)
856
    public UpdateResult aggregateTaxonDescription(UUID taxonNodeUuid, IRemotingProgressMonitor monitor){
862
    public UpdateResult aggregateTaxonDescription(UUID taxonNodeUuid, UUID descriptiveDataSetUuid,
863
            IRemotingProgressMonitor monitor){
857 864
        UpdateResult result = new UpdateResult();
858 865

  
859 866
        TaxonNode node = taxonNodeDao.load(taxonNodeUuid);
......
873 880
                        .forEach(computedDescription -> computedDescriptions.add(computedDescription)));
874 881

  
875 882
        UpdateResult aggregateDescription = aggregateDescription(taxon, computedDescriptions,
876
                "[Taxon Descriptions]"+taxon.getTitleCache());
883
                "[Taxon Descriptions]"+taxon.getTitleCache(), descriptiveDataSetUuid);
877 884
        result.includeResult(aggregateDescription);
878 885
        result.setCdmEntity(aggregateDescription.getCdmEntity());
879 886
        aggregateDescription.setCdmEntity(null);
......
881 888
    }
882 889

  
883 890
    @Override
884
    public UpdateResult aggregateDescription(UUID taxonUuid, List<UUID> descriptionUuids, String descriptionTitle) {
891
    public UpdateResult aggregateDescription(UUID taxonUuid, List<UUID> descriptionUuids, String descriptionTitle
892
            , UUID descriptiveDataSetUuid) {
885 893
        UpdateResult result = new UpdateResult();
886 894

  
887 895
        TaxonBase taxonBase = taxonDao.load(taxonUuid);
......
894 902

  
895 903
        List<DescriptionBase> descriptions = load(descriptionUuids, null);
896 904

  
897
        UpdateResult aggregateDescriptionResult = aggregateDescription(taxon, descriptions, descriptionTitle);
905
        UpdateResult aggregateDescriptionResult = aggregateDescription(taxon, descriptions, descriptionTitle, descriptiveDataSetUuid);
898 906
        result.setCdmEntity(aggregateDescriptionResult.getCdmEntity());
899 907
        aggregateDescriptionResult.setCdmEntity(null);
900 908
        result.includeResult(aggregateDescriptionResult);
......
902 910
    }
903 911

  
904 912
    @SuppressWarnings("unchecked")
905
    private UpdateResult aggregateDescription(Taxon taxon, List<? extends DescriptionBase> descriptions, String descriptionTitle) {
913
    private UpdateResult aggregateDescription(Taxon taxon, List<? extends DescriptionBase> descriptions, String descriptionTitle
914
            , UUID descriptiveDataSetUuid) {
906 915
        UpdateResult result = new UpdateResult();
907 916
        Map<Character, List<DescriptionElementBase>> featureToElementMap = new HashMap<>();
908 917

  
918
        DescriptiveDataSet dataSet = descriptiveDataSetDao.load(descriptiveDataSetUuid);
919
        if(dataSet==null){
920
            result.addException(new IllegalArgumentException("Could not find data set for uuid "+descriptiveDataSetUuid));
921
            result.setAbort();
922
            return result;
923
        }
924

  
909 925
        //extract all character description elements
910 926
        descriptions.forEach(description->{
911 927
            description.getElements()
......
928 944
        description.addMarker(Marker.NewInstance(MarkerType.COMPUTED(), true));
929 945
        IdentifiableSource source = IdentifiableSource.NewInstance(OriginalSourceType.Aggregation);
930 946
        description.addSource(source);
947
        description.addDescriptiveDataSet(dataSet);
931 948

  
932 949
        featureToElementMap.forEach((feature, elements)->{
933 950
            //aggregate categorical data
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/IDescriptionService.java
616 616
     * aggregated data will be stored
617 617
     * @param descriptionUuids the uuid of the descriptions that are aggregated
618 618
     * @param descriptionTitle the new title of the description
619
     * @param descriptiveDataSetUuid the uuid of the descriptive data set to which the
620
     * aggregated description will be added to
619 621
     * @return the result of the operation
620 622
     */
621
    public UpdateResult aggregateDescription(UUID taxonUuid, List<UUID> descriptionUuids, String descriptionTitle);
623
    public UpdateResult aggregateDescription(UUID taxonUuid, List<UUID> descriptionUuids, String descriptionTitle
624
            , UUID descriptiveDataSetUuid);
622 625

  
623 626
    /**
624 627
     * Aggregates all {@link TaxonDescription}s of all sub nodes that have a "computed" marker
625 628
     * @param taxonNodeUuid the parent taxon node
629
     * @param descriptiveDataSetUuid the uuid of the descriptive data set to which the
630
     * aggregated description will be added to
626 631
     * @param monitor the progress monitor
627 632
     * @return the update result
628 633
     */
629
    public UpdateResult aggregateTaxonDescription(UUID taxonNodeUuid, IRemotingProgressMonitor monitor);
634
    public UpdateResult aggregateTaxonDescription(UUID taxonNodeUuid, UUID descriptiveDataSetUuid,
635
            IRemotingProgressMonitor monitor);
630 636
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)