Project

General

Profile

Revision 0f14b608

ID0f14b608394cfaa52df6f0ceae51c1b8ac496c18
Parent 0ceb2225
Child 2d006ce7

Added by Patrick Plitzner about 2 years ago

ref #7597 Use LongRunningTaskService for taxon aggregation

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

  
42
    public UUID aggregateComputedTaxonDescriptions(UUID taxonNodeUuid);
43 43
}
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/longrunningService/LongRunningTasksServiceImpl.java
16 16
import org.springframework.stereotype.Service;
17 17
import org.springframework.transaction.annotation.Transactional;
18 18

  
19
import eu.etaxonomy.cdm.api.service.IDescriptionService;
19 20
import eu.etaxonomy.cdm.api.service.IProgressMonitorService;
20 21
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
21 22
import eu.etaxonomy.cdm.api.service.UpdateResult;
......
37 38
    ITaxonNodeService taxonNodeService;
38 39

  
39 40
    @Autowired
41
    IDescriptionService descriptionService;
42

  
43
    @Autowired
40 44
    IProgressMonitorService progressMonitorService;
41 45

  
42 46

  
43 47
    @Override
48
    public UUID aggregateComputedTaxonDescriptions(UUID taxonNodeUuid){
49
        RemotingProgressMonitorThread monitorThread = new RemotingProgressMonitorThread() {
50
            @Override
51
            public Serializable doRun(IRemotingProgressMonitor monitor) {
52
                UpdateResult updateResult = descriptionService.aggregateTaxonDescription(taxonNodeUuid, monitor);
53
                for(Exception e : updateResult.getExceptions()) {
54
                    monitor.addReport(e.getMessage());
55
                }
56
                monitor.setResult(updateResult);
57
                return updateResult;
58

  
59
            }
60
        };
61
        UUID uuid = progressMonitorService.registerNewRemotingMonitor(monitorThread);
62
        monitorThread.setPriority(2);
63
        monitorThread.start();
64
        return uuid;
65
    }
66

  
67
    @Override
44 68
    public UUID monitLongRunningTask(ForSubtreeConfiguratorBase config) {
45 69

  
46 70
        RemotingProgressMonitorThread monitorThread = new RemotingProgressMonitorThread() {
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/DescriptionServiceImpl.java
9 9

  
10 10
package eu.etaxonomy.cdm.api.service;
11 11

  
12
import java.io.Serializable;
13 12
import java.util.ArrayList;
14 13
import java.util.Arrays;
15 14
import java.util.Collection;
......
33 32
import eu.etaxonomy.cdm.api.utility.DescriptionUtility;
34 33
import eu.etaxonomy.cdm.common.monitor.IProgressMonitor;
35 34
import eu.etaxonomy.cdm.common.monitor.IRemotingProgressMonitor;
36
import eu.etaxonomy.cdm.common.monitor.RemotingProgressMonitorThread;
37 35
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
38 36
import eu.etaxonomy.cdm.model.common.Annotation;
39 37
import eu.etaxonomy.cdm.model.common.AnnotationType;
......
854 852
    }
855 853

  
856 854
    @Override
857
    public UUID aggregateComputedTaxonDescriptions(UUID taxonNodeUuid){
858
        RemotingProgressMonitorThread monitorThread = new RemotingProgressMonitorThread() {
859
            @Override
860
            public Serializable doRun(IRemotingProgressMonitor monitor) {
861
                return aggregateTaxonDescription(taxonNodeUuid, monitor);
862
            }
863
        };
864
        UUID uuid = progressMonitorService.registerNewRemotingMonitor(monitorThread);
865
        monitorThread.setPriority(3);
866
        monitorThread.start();
867
        return uuid;
868
    }
869

  
870
    private UpdateResult aggregateTaxonDescription(UUID taxonNodeUuid, IRemotingProgressMonitor monitor){
855
    @Transactional(readOnly=false)
856
    public UpdateResult aggregateTaxonDescription(UUID taxonNodeUuid, IRemotingProgressMonitor monitor){
871 857
        UpdateResult result = new UpdateResult();
872 858

  
873 859
        TaxonNode node = taxonNodeDao.load(taxonNodeUuid);
......
961 947
                description.addElement(aggregate);
962 948
            }
963 949
        });
964
        result.setCdmEntity(taxon);
950
        result.addUpdatedObject(taxon);
951
        result.setCdmEntity(description);
965 952
        return result;
966 953
    }
967 954

  
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/IDescriptionService.java
17 17

  
18 18
import eu.etaxonomy.cdm.api.service.pager.Pager;
19 19
import eu.etaxonomy.cdm.api.utility.DescriptionUtility;
20
import eu.etaxonomy.cdm.common.monitor.IRemotingProgressMonitor;
20 21
import eu.etaxonomy.cdm.model.common.Annotation;
21 22
import eu.etaxonomy.cdm.model.common.DefinedTerm;
22 23
import eu.etaxonomy.cdm.model.common.Language;
......
622 623
    /**
623 624
     * Aggregates all {@link TaxonDescription}s of all sub nodes that have a "computed" marker
624 625
     * @param taxonNodeUuid the parent taxon node
625
     * @return the uuid of the progress monitor
626
     * @param monitor the progress monitor
627
     * @return the update result
626 628
     */
627
    public UUID aggregateComputedTaxonDescriptions(UUID taxonNodeUuid);
629
    public UpdateResult aggregateTaxonDescription(UUID taxonNodeUuid, IRemotingProgressMonitor monitor);
628 630
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)