Revision ca82cffd
Added by Katja Luther about 4 years ago
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/application/CdmApplicationController.java | ||
---|---|---|
32 | 32 |
import org.springframework.transaction.TransactionStatus; |
33 | 33 |
|
34 | 34 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
35 |
import eu.etaxonomy.cdm.api.longrunningService.ILongRunningTasksService; |
|
35 |
import eu.etaxonomy.cdm.api.service.longrunningService.ILongRunningTasksService;
|
|
36 | 36 |
import eu.etaxonomy.cdm.api.service.IAgentService; |
37 | 37 |
import eu.etaxonomy.cdm.api.service.IAnnotationService; |
38 | 38 |
import eu.etaxonomy.cdm.api.service.IClassificationService; |
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/application/CdmRepository.java | ||
---|---|---|
33 | 33 |
import org.springframework.transaction.support.DefaultTransactionDefinition; |
34 | 34 |
|
35 | 35 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
36 |
import eu.etaxonomy.cdm.api.longrunningService.ILongRunningTasksService; |
|
36 |
import eu.etaxonomy.cdm.api.service.longrunningService.ILongRunningTasksService;
|
|
37 | 37 |
import eu.etaxonomy.cdm.api.service.IAgentService; |
38 | 38 |
import eu.etaxonomy.cdm.api.service.IAnnotationService; |
39 | 39 |
import eu.etaxonomy.cdm.api.service.IClassificationService; |
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/application/ICdmRepository.java | ||
---|---|---|
14 | 14 |
import org.springframework.transaction.TransactionStatus; |
15 | 15 |
|
16 | 16 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
17 |
import eu.etaxonomy.cdm.api.longrunningService.ILongRunningTasksService; |
|
17 |
import eu.etaxonomy.cdm.api.service.longrunningService.ILongRunningTasksService;
|
|
18 | 18 |
import eu.etaxonomy.cdm.api.service.IAgentService; |
19 | 19 |
import eu.etaxonomy.cdm.api.service.IAnnotationService; |
20 | 20 |
import eu.etaxonomy.cdm.api.service.IClassificationService; |
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/longrunningService/ILongRunningTasksService.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2015 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
package eu.etaxonomy.cdm.api.longrunningService; |
|
10 |
|
|
11 |
import java.util.Collection; |
|
12 |
import java.util.Set; |
|
13 |
import java.util.UUID; |
|
14 |
|
|
15 |
import eu.etaxonomy.cdm.api.service.IDescriptiveDataSetService; |
|
16 |
import eu.etaxonomy.cdm.api.service.config.CacheUpdaterConfigurator; |
|
17 |
import eu.etaxonomy.cdm.api.service.config.DescriptionAggregationConfiguration; |
|
18 |
import eu.etaxonomy.cdm.api.service.config.ForSubtreeConfiguratorBase; |
|
19 |
import eu.etaxonomy.cdm.api.service.config.SortIndexUpdaterConfigurator; |
|
20 |
import eu.etaxonomy.cdm.common.monitor.IProgressMonitor; |
|
21 |
import eu.etaxonomy.cdm.model.description.DescriptiveDataSet; |
|
22 |
import eu.etaxonomy.cdm.persistence.dto.SpecimenNodeWrapper; |
|
23 |
|
|
24 |
/** |
|
25 |
* @author cmathew |
|
26 |
* @since 31 Jul 2015 |
|
27 |
* |
|
28 |
*/ |
|
29 |
public interface ILongRunningTasksService { |
|
30 |
|
|
31 |
|
|
32 |
/** |
|
33 |
* @param configurator |
|
34 |
* @return |
|
35 |
*/ |
|
36 |
public UUID monitLongRunningTask(ForSubtreeConfiguratorBase configurator); |
|
37 |
|
|
38 |
/** |
|
39 |
* @param configurator |
|
40 |
* @return |
|
41 |
*/ |
|
42 |
public UUID monitLongRunningTask(CacheUpdaterConfigurator configurator); |
|
43 |
|
|
44 |
|
|
45 |
/** |
|
46 |
* @param movingUuids |
|
47 |
* @param targetTreeNodeUuid |
|
48 |
* @param movingType |
|
49 |
* @param monitor |
|
50 |
* @return |
|
51 |
*/ |
|
52 |
UUID monitLongRunningTask(Set<UUID> movingUuids, UUID targetTreeNodeUuid, int movingType); |
|
53 |
|
|
54 |
/** |
|
55 |
* Monitored invocation of {@link IDescriptiveDataSetService#aggregate(UUID, IProgressMonitor)} |
|
56 |
* @param descriptiveDataSetUuid the data set which should be aggregated |
|
57 |
* @param config the aggregation configuration |
|
58 |
* @return the uuid of the monitor |
|
59 |
*/ |
|
60 |
public UUID aggregateDescriptiveDataSet(UUID descriptiveDataSetUuid, DescriptionAggregationConfiguration config); |
|
61 |
|
|
62 |
/** |
|
63 |
* Monitored invocation of {@link IDescriptiveDataSetService#addRowWrapperToDataset(Collection, UUID)} |
|
64 |
* @param wrapper the specimen wrapper to use for creating the row wrapper |
|
65 |
* @param datasetUuid the target dataset |
|
66 |
* @return the uuid of the monitor |
|
67 |
*/ |
|
68 |
public UUID addRowWrapperToDataset(Collection<SpecimenNodeWrapper> wrapper, UUID datasetUuid); |
|
69 |
|
|
70 |
/** |
|
71 |
* Monitored invocation of {@link IDescriptiveDataSetService#generatePolytomousKey(UUID, UUID))} |
|
72 |
* @param datasetUuid the data set |
|
73 |
* @param taxonUuid the taxonomic scope of the key |
|
74 |
* @return the uuid of the monitor |
|
75 |
*/ |
|
76 |
public UUID generatePolytomousKey(UUID datasetUuid, UUID taxonUuid); |
|
77 |
|
|
78 |
/** |
|
79 |
* Monitored invocation of {@link IDescriptiveDataSetService#getRowWrapper(DescriptiveDataSet, IProgressMonitor)} |
|
80 |
* @param descriptiveDataSetUuid the working set for which getRowWrapper() is invoked |
|
81 |
* @return the uuid of the monitor |
|
82 |
*/ |
|
83 |
public UUID monitGetRowWrapper(UUID descriptiveDataSetUuid); |
|
84 |
|
|
85 |
/** |
|
86 |
* @param configurator |
|
87 |
* @return |
|
88 |
*/ |
|
89 |
UUID monitLongRunningTask(SortIndexUpdaterConfigurator configurator); |
|
90 |
} |
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/longrunningService/LongRunningTasksServiceImpl.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2015 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
package eu.etaxonomy.cdm.api.longrunningService; |
|
10 |
|
|
11 |
import java.io.Serializable; |
|
12 |
import java.util.Collection; |
|
13 |
import java.util.Set; |
|
14 |
import java.util.UUID; |
|
15 |
|
|
16 |
import org.springframework.beans.factory.annotation.Autowired; |
|
17 |
import org.springframework.stereotype.Service; |
|
18 |
import org.springframework.transaction.annotation.Transactional; |
|
19 |
|
|
20 |
import eu.etaxonomy.cdm.api.service.IDescriptiveDataSetService; |
|
21 |
import eu.etaxonomy.cdm.api.service.IProgressMonitorService; |
|
22 |
import eu.etaxonomy.cdm.api.service.ITaxonNodeService; |
|
23 |
import eu.etaxonomy.cdm.api.service.UpdateResult; |
|
24 |
import eu.etaxonomy.cdm.api.service.config.CacheUpdaterConfigurator; |
|
25 |
import eu.etaxonomy.cdm.api.service.config.DescriptionAggregationConfiguration; |
|
26 |
import eu.etaxonomy.cdm.api.service.config.ForSubtreeConfiguratorBase; |
|
27 |
import eu.etaxonomy.cdm.api.service.config.PublishForSubtreeConfigurator; |
|
28 |
import eu.etaxonomy.cdm.api.service.config.SecundumForSubtreeConfigurator; |
|
29 |
import eu.etaxonomy.cdm.api.service.config.SortIndexUpdaterConfigurator; |
|
30 |
import eu.etaxonomy.cdm.api.service.util.CacheUpdater; |
|
31 |
import eu.etaxonomy.cdm.api.service.util.SortIndexUpdaterWrapper; |
|
32 |
import eu.etaxonomy.cdm.common.monitor.IRemotingProgressMonitor; |
|
33 |
import eu.etaxonomy.cdm.common.monitor.RemotingProgressMonitorThread; |
|
34 |
import eu.etaxonomy.cdm.persistence.dto.SpecimenNodeWrapper; |
|
35 |
|
|
36 |
/** |
|
37 |
* @author k.luther |
|
38 |
* @since 04 May 2018 |
|
39 |
* |
|
40 |
*/ |
|
41 |
@Service |
|
42 |
@Transactional(readOnly = false) |
|
43 |
public class LongRunningTasksServiceImpl implements ILongRunningTasksService{ |
|
44 |
@Autowired |
|
45 |
ITaxonNodeService taxonNodeService; |
|
46 |
|
|
47 |
@Autowired |
|
48 |
IDescriptiveDataSetService descriptiveDataSetService; |
|
49 |
|
|
50 |
@Autowired |
|
51 |
IProgressMonitorService progressMonitorService; |
|
52 |
|
|
53 |
@Autowired |
|
54 |
CacheUpdater updater; |
|
55 |
|
|
56 |
@Autowired |
|
57 |
SortIndexUpdaterWrapper sortIndexUpdater; |
|
58 |
|
|
59 |
@Override |
|
60 |
public UUID monitGetRowWrapper(UUID descriptiveDataSetUuid) { |
|
61 |
RemotingProgressMonitorThread monitorThread = new RemotingProgressMonitorThread() { |
|
62 |
@Override |
|
63 |
public Serializable doRun(IRemotingProgressMonitor monitor) { |
|
64 |
return descriptiveDataSetService.getRowWrapper(descriptiveDataSetUuid, monitor); |
|
65 |
} |
|
66 |
}; |
|
67 |
UUID uuid = progressMonitorService.registerNewRemotingMonitor(monitorThread); |
|
68 |
monitorThread.setPriority(3); |
|
69 |
monitorThread.start(); |
|
70 |
return uuid; |
|
71 |
} |
|
72 |
|
|
73 |
@Override |
|
74 |
public UUID aggregateDescriptiveDataSet(UUID descriptiveDataSetUuid, DescriptionAggregationConfiguration config){ |
|
75 |
RemotingProgressMonitorThread monitorThread = new RemotingProgressMonitorThread() { |
|
76 |
@Override |
|
77 |
public Serializable doRun(IRemotingProgressMonitor monitor) { |
|
78 |
UpdateResult updateResult = descriptiveDataSetService.aggregate(descriptiveDataSetUuid, config, monitor); |
|
79 |
for(Exception e : updateResult.getExceptions()) { |
|
80 |
monitor.addReport(e.getMessage()); |
|
81 |
} |
|
82 |
monitor.setResult(updateResult); |
|
83 |
return updateResult; |
|
84 |
|
|
85 |
} |
|
86 |
}; |
|
87 |
UUID uuid = progressMonitorService.registerNewRemotingMonitor(monitorThread); |
|
88 |
monitorThread.setPriority(2); |
|
89 |
monitorThread.start(); |
|
90 |
return uuid; |
|
91 |
} |
|
92 |
|
|
93 |
@Override |
|
94 |
public UUID addRowWrapperToDataset(Collection<SpecimenNodeWrapper> wrapper, UUID datasetUuid){ |
|
95 |
RemotingProgressMonitorThread monitorThread = new RemotingProgressMonitorThread() { |
|
96 |
@Override |
|
97 |
public Serializable doRun(IRemotingProgressMonitor monitor) { |
|
98 |
UpdateResult updateResult = descriptiveDataSetService.addRowWrapperToDataset(wrapper, datasetUuid); |
|
99 |
for(Exception e : updateResult.getExceptions()) { |
|
100 |
monitor.addReport(e.getMessage()); |
|
101 |
} |
|
102 |
monitor.setResult(updateResult); |
|
103 |
return updateResult; |
|
104 |
|
|
105 |
} |
|
106 |
}; |
|
107 |
UUID uuid = progressMonitorService.registerNewRemotingMonitor(monitorThread); |
|
108 |
monitorThread.setPriority(2); |
|
109 |
monitorThread.start(); |
|
110 |
return uuid; |
|
111 |
} |
|
112 |
|
|
113 |
@Override |
|
114 |
public UUID generatePolytomousKey(UUID datasetUuid, UUID taxonUuid){ |
|
115 |
RemotingProgressMonitorThread monitorThread = new RemotingProgressMonitorThread() { |
|
116 |
@Override |
|
117 |
public Serializable doRun(IRemotingProgressMonitor monitor) { |
|
118 |
UpdateResult updateResult = descriptiveDataSetService.generatePolytomousKey(datasetUuid, taxonUuid); |
|
119 |
for(Exception e : updateResult.getExceptions()) { |
|
120 |
monitor.addReport(e.getMessage()); |
|
121 |
} |
|
122 |
monitor.setResult(updateResult); |
|
123 |
return updateResult; |
|
124 |
|
|
125 |
} |
|
126 |
}; |
|
127 |
UUID uuid = progressMonitorService.registerNewRemotingMonitor(monitorThread); |
|
128 |
monitorThread.setPriority(2); |
|
129 |
monitorThread.start(); |
|
130 |
return uuid; |
|
131 |
} |
|
132 |
|
|
133 |
@Override |
|
134 |
public UUID monitLongRunningTask(ForSubtreeConfiguratorBase config) { |
|
135 |
|
|
136 |
RemotingProgressMonitorThread monitorThread = new RemotingProgressMonitorThread() { |
|
137 |
@Override |
|
138 |
public Serializable doRun(IRemotingProgressMonitor monitor) { |
|
139 |
UpdateResult result; |
|
140 |
config.setMonitor(monitor); |
|
141 |
|
|
142 |
result = updateData(config); |
|
143 |
for(Exception e : result.getExceptions()) { |
|
144 |
monitor.addReport(e.getMessage()); |
|
145 |
} |
|
146 |
monitor.setResult(result); |
|
147 |
return result; |
|
148 |
} |
|
149 |
}; |
|
150 |
UUID uuid = progressMonitorService.registerNewRemotingMonitor(monitorThread); |
|
151 |
monitorThread.setPriority(2); |
|
152 |
monitorThread.start(); |
|
153 |
return uuid; |
|
154 |
} |
|
155 |
|
|
156 |
private UpdateResult updateData(ForSubtreeConfiguratorBase config){ |
|
157 |
if (config instanceof SecundumForSubtreeConfigurator){ |
|
158 |
return taxonNodeService.setSecundumForSubtree((SecundumForSubtreeConfigurator)config); |
|
159 |
}else{ |
|
160 |
return taxonNodeService.setPublishForSubtree((PublishForSubtreeConfigurator) config); |
|
161 |
} |
|
162 |
} |
|
163 |
|
|
164 |
@Override |
|
165 |
public UUID monitLongRunningTask(Set<UUID> movingUuids, UUID targetTreeNodeUuid, int movingType) { |
|
166 |
|
|
167 |
RemotingProgressMonitorThread monitorThread = new RemotingProgressMonitorThread() { |
|
168 |
@Override |
|
169 |
public Serializable doRun(IRemotingProgressMonitor remotingMonitor) { |
|
170 |
UpdateResult result; |
|
171 |
|
|
172 |
result = taxonNodeService.moveTaxonNodes(movingUuids,targetTreeNodeUuid, movingType, remotingMonitor); |
|
173 |
for(Exception e : result.getExceptions()) { |
|
174 |
remotingMonitor.addReport(e.getMessage()); |
|
175 |
} |
|
176 |
remotingMonitor.setResult(result); |
|
177 |
return result; |
|
178 |
} |
|
179 |
}; |
|
180 |
UUID uuid = progressMonitorService.registerNewRemotingMonitor(monitorThread); |
|
181 |
monitorThread.setPriority(2); |
|
182 |
monitorThread.start(); |
|
183 |
return uuid; |
|
184 |
} |
|
185 |
|
|
186 |
/** |
|
187 |
* {@inheritDoc} |
|
188 |
*/ |
|
189 |
@Override |
|
190 |
public UUID monitLongRunningTask(CacheUpdaterConfigurator configurator) { |
|
191 |
RemotingProgressMonitorThread monitorThread = new RemotingProgressMonitorThread() { |
|
192 |
@Override |
|
193 |
public Serializable doRun(IRemotingProgressMonitor monitor) { |
|
194 |
UpdateResult result; |
|
195 |
|
|
196 |
configurator.setMonitor(monitor); |
|
197 |
|
|
198 |
result = updater.doInvoke(configurator); |
|
199 |
|
|
200 |
for(Exception e : result.getExceptions()) { |
|
201 |
monitor.addReport(e.getMessage()); |
|
202 |
} |
|
203 |
monitor.setResult(result); |
|
204 |
return result; |
|
205 |
} |
|
206 |
}; |
|
207 |
UUID uuid = progressMonitorService.registerNewRemotingMonitor(monitorThread); |
|
208 |
monitorThread.setPriority(2); |
|
209 |
monitorThread.start(); |
|
210 |
return uuid; |
|
211 |
} |
|
212 |
|
|
213 |
/** |
|
214 |
* {@inheritDoc} |
|
215 |
*/ |
|
216 |
@Override |
|
217 |
public UUID monitLongRunningTask(SortIndexUpdaterConfigurator configurator) { |
|
218 |
RemotingProgressMonitorThread monitorThread = new RemotingProgressMonitorThread() { |
|
219 |
@Override |
|
220 |
public Serializable doRun(IRemotingProgressMonitor monitor) { |
|
221 |
UpdateResult result; |
|
222 |
configurator.setMonitor(monitor); |
|
223 |
|
|
224 |
result = sortIndexUpdater.doInvoke(configurator); |
|
225 |
|
|
226 |
for(Exception e : result.getExceptions()) { |
|
227 |
monitor.addReport(e.getMessage()); |
|
228 |
} |
|
229 |
monitor.setResult(result); |
|
230 |
return result; |
|
231 |
} |
|
232 |
}; |
|
233 |
UUID uuid = progressMonitorService.registerNewRemotingMonitor(monitorThread); |
|
234 |
monitorThread.setPriority(2); |
|
235 |
monitorThread.start(); |
|
236 |
return uuid; |
|
237 |
} |
|
238 |
|
|
239 |
|
|
240 |
} |
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/longrunningService/ILongRunningTasksService.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2015 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
package eu.etaxonomy.cdm.api.service.longrunningService; |
|
10 |
|
|
11 |
import java.util.Collection; |
|
12 |
import java.util.Set; |
|
13 |
import java.util.UUID; |
|
14 |
|
|
15 |
import eu.etaxonomy.cdm.api.service.IDescriptiveDataSetService; |
|
16 |
import eu.etaxonomy.cdm.api.service.config.CacheUpdaterConfigurator; |
|
17 |
import eu.etaxonomy.cdm.api.service.config.DescriptionAggregationConfiguration; |
|
18 |
import eu.etaxonomy.cdm.api.service.config.ForSubtreeConfiguratorBase; |
|
19 |
import eu.etaxonomy.cdm.api.service.config.SortIndexUpdaterConfigurator; |
|
20 |
import eu.etaxonomy.cdm.common.monitor.IProgressMonitor; |
|
21 |
import eu.etaxonomy.cdm.model.description.DescriptiveDataSet; |
|
22 |
import eu.etaxonomy.cdm.persistence.dto.SpecimenNodeWrapper; |
|
23 |
|
|
24 |
/** |
|
25 |
* @author cmathew |
|
26 |
* @since 31 Jul 2015 |
|
27 |
* |
|
28 |
*/ |
|
29 |
public interface ILongRunningTasksService { |
|
30 |
|
|
31 |
|
|
32 |
/** |
|
33 |
* @param configurator |
|
34 |
* @return |
|
35 |
*/ |
|
36 |
public UUID monitLongRunningTask(ForSubtreeConfiguratorBase configurator); |
|
37 |
|
|
38 |
/** |
|
39 |
* @param configurator |
|
40 |
* @return |
|
41 |
*/ |
|
42 |
public UUID monitLongRunningTask(CacheUpdaterConfigurator configurator); |
|
43 |
|
|
44 |
|
|
45 |
/** |
|
46 |
* @param movingUuids |
|
47 |
* @param targetTreeNodeUuid |
|
48 |
* @param movingType |
|
49 |
* @param monitor |
|
50 |
* @return |
|
51 |
*/ |
|
52 |
UUID monitLongRunningTask(Set<UUID> movingUuids, UUID targetTreeNodeUuid, int movingType); |
|
53 |
|
|
54 |
/** |
|
55 |
* Monitored invocation of {@link IDescriptiveDataSetService#aggregate(UUID, IProgressMonitor)} |
|
56 |
* @param descriptiveDataSetUuid the data set which should be aggregated |
|
57 |
* @param config the aggregation configuration |
|
58 |
* @return the uuid of the monitor |
|
59 |
*/ |
|
60 |
public UUID aggregateDescriptiveDataSet(UUID descriptiveDataSetUuid, DescriptionAggregationConfiguration config); |
|
61 |
|
|
62 |
/** |
|
63 |
* Monitored invocation of {@link IDescriptiveDataSetService#addRowWrapperToDataset(Collection, UUID)} |
|
64 |
* @param wrapper the specimen wrapper to use for creating the row wrapper |
|
65 |
* @param datasetUuid the target dataset |
|
66 |
* @return the uuid of the monitor |
|
67 |
*/ |
|
68 |
public UUID addRowWrapperToDataset(Collection<SpecimenNodeWrapper> wrapper, UUID datasetUuid); |
|
69 |
|
|
70 |
/** |
|
71 |
* Monitored invocation of {@link IDescriptiveDataSetService#generatePolytomousKey(UUID, UUID))} |
|
72 |
* @param datasetUuid the data set |
|
73 |
* @param taxonUuid the taxonomic scope of the key |
|
74 |
* @return the uuid of the monitor |
|
75 |
*/ |
|
76 |
public UUID generatePolytomousKey(UUID datasetUuid, UUID taxonUuid); |
|
77 |
|
|
78 |
/** |
|
79 |
* Monitored invocation of {@link IDescriptiveDataSetService#getRowWrapper(DescriptiveDataSet, IProgressMonitor)} |
|
80 |
* @param descriptiveDataSetUuid the working set for which getRowWrapper() is invoked |
|
81 |
* @return the uuid of the monitor |
|
82 |
*/ |
|
83 |
public UUID monitGetRowWrapper(UUID descriptiveDataSetUuid); |
|
84 |
|
|
85 |
/** |
|
86 |
* @param configurator |
|
87 |
* @return |
|
88 |
*/ |
|
89 |
UUID monitLongRunningTask(SortIndexUpdaterConfigurator configurator); |
|
90 |
} |
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/longrunningService/LongRunningTasksService.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2015 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
package eu.etaxonomy.cdm.api.service.longrunningService; |
|
10 |
|
|
11 |
import java.io.Serializable; |
|
12 |
import java.util.Collection; |
|
13 |
import java.util.Set; |
|
14 |
import java.util.UUID; |
|
15 |
|
|
16 |
import org.springframework.beans.factory.annotation.Autowired; |
|
17 |
import org.springframework.stereotype.Service; |
|
18 |
import org.springframework.transaction.annotation.Transactional; |
|
19 |
|
|
20 |
import eu.etaxonomy.cdm.api.service.IDescriptiveDataSetService; |
|
21 |
import eu.etaxonomy.cdm.api.service.IProgressMonitorService; |
|
22 |
import eu.etaxonomy.cdm.api.service.ITaxonNodeService; |
|
23 |
import eu.etaxonomy.cdm.api.service.UpdateResult; |
|
24 |
import eu.etaxonomy.cdm.api.service.config.CacheUpdaterConfigurator; |
|
25 |
import eu.etaxonomy.cdm.api.service.config.DescriptionAggregationConfiguration; |
|
26 |
import eu.etaxonomy.cdm.api.service.config.ForSubtreeConfiguratorBase; |
|
27 |
import eu.etaxonomy.cdm.api.service.config.PublishForSubtreeConfigurator; |
|
28 |
import eu.etaxonomy.cdm.api.service.config.SecundumForSubtreeConfigurator; |
|
29 |
import eu.etaxonomy.cdm.api.service.config.SortIndexUpdaterConfigurator; |
|
30 |
import eu.etaxonomy.cdm.api.service.util.CacheUpdater; |
|
31 |
import eu.etaxonomy.cdm.api.service.util.SortIndexUpdaterWrapper; |
|
32 |
import eu.etaxonomy.cdm.common.monitor.IRemotingProgressMonitor; |
|
33 |
import eu.etaxonomy.cdm.common.monitor.RemotingProgressMonitorThread; |
|
34 |
import eu.etaxonomy.cdm.persistence.dto.SpecimenNodeWrapper; |
|
35 |
|
|
36 |
/** |
|
37 |
* @author k.luther |
|
38 |
* @since 04 May 2018 |
|
39 |
* |
|
40 |
*/ |
|
41 |
@Service("longRunningTasksService") |
|
42 |
@Transactional(readOnly = false) |
|
43 |
public class LongRunningTasksService implements ILongRunningTasksService{ |
|
44 |
@Autowired |
|
45 |
ITaxonNodeService taxonNodeService; |
|
46 |
|
|
47 |
@Autowired |
|
48 |
IDescriptiveDataSetService descriptiveDataSetService; |
|
49 |
|
|
50 |
@Autowired |
|
51 |
IProgressMonitorService progressMonitorService; |
|
52 |
|
|
53 |
@Autowired |
|
54 |
CacheUpdater updater; |
|
55 |
|
|
56 |
@Autowired |
|
57 |
SortIndexUpdaterWrapper sortIndexUpdater; |
|
58 |
|
|
59 |
@Override |
|
60 |
public UUID monitGetRowWrapper(UUID descriptiveDataSetUuid) { |
|
61 |
RemotingProgressMonitorThread monitorThread = new RemotingProgressMonitorThread() { |
|
62 |
@Override |
|
63 |
public Serializable doRun(IRemotingProgressMonitor monitor) { |
|
64 |
return descriptiveDataSetService.getRowWrapper(descriptiveDataSetUuid, monitor); |
|
65 |
} |
|
66 |
}; |
|
67 |
UUID uuid = progressMonitorService.registerNewRemotingMonitor(monitorThread); |
|
68 |
monitorThread.setPriority(3); |
|
69 |
monitorThread.start(); |
|
70 |
return uuid; |
|
71 |
} |
|
72 |
|
|
73 |
@Override |
|
74 |
public UUID aggregateDescriptiveDataSet(UUID descriptiveDataSetUuid, DescriptionAggregationConfiguration config){ |
|
75 |
RemotingProgressMonitorThread monitorThread = new RemotingProgressMonitorThread() { |
|
76 |
@Override |
|
77 |
public Serializable doRun(IRemotingProgressMonitor monitor) { |
|
78 |
UpdateResult updateResult = descriptiveDataSetService.aggregate(descriptiveDataSetUuid, config, monitor); |
|
79 |
for(Exception e : updateResult.getExceptions()) { |
|
80 |
monitor.addReport(e.getMessage()); |
|
81 |
} |
|
82 |
monitor.setResult(updateResult); |
|
83 |
return updateResult; |
|
84 |
|
|
85 |
} |
|
86 |
}; |
|
87 |
UUID uuid = progressMonitorService.registerNewRemotingMonitor(monitorThread); |
|
88 |
monitorThread.setPriority(2); |
|
89 |
monitorThread.start(); |
|
90 |
return uuid; |
|
91 |
} |
|
92 |
|
|
93 |
@Override |
|
94 |
public UUID addRowWrapperToDataset(Collection<SpecimenNodeWrapper> wrapper, UUID datasetUuid){ |
|
95 |
RemotingProgressMonitorThread monitorThread = new RemotingProgressMonitorThread() { |
|
96 |
@Override |
|
97 |
public Serializable doRun(IRemotingProgressMonitor monitor) { |
|
98 |
UpdateResult updateResult = descriptiveDataSetService.addRowWrapperToDataset(wrapper, datasetUuid); |
|
99 |
for(Exception e : updateResult.getExceptions()) { |
|
100 |
monitor.addReport(e.getMessage()); |
|
101 |
} |
|
102 |
monitor.setResult(updateResult); |
|
103 |
return updateResult; |
|
104 |
|
|
105 |
} |
|
106 |
}; |
|
107 |
UUID uuid = progressMonitorService.registerNewRemotingMonitor(monitorThread); |
|
108 |
monitorThread.setPriority(2); |
|
109 |
monitorThread.start(); |
|
110 |
return uuid; |
|
111 |
} |
|
112 |
|
|
113 |
@Override |
|
114 |
public UUID generatePolytomousKey(UUID datasetUuid, UUID taxonUuid){ |
|
115 |
RemotingProgressMonitorThread monitorThread = new RemotingProgressMonitorThread() { |
|
116 |
@Override |
|
117 |
public Serializable doRun(IRemotingProgressMonitor monitor) { |
|
118 |
UpdateResult updateResult = descriptiveDataSetService.generatePolytomousKey(datasetUuid, taxonUuid); |
|
119 |
for(Exception e : updateResult.getExceptions()) { |
|
120 |
monitor.addReport(e.getMessage()); |
|
121 |
} |
|
122 |
monitor.setResult(updateResult); |
|
123 |
return updateResult; |
|
124 |
|
|
125 |
} |
|
126 |
}; |
|
127 |
UUID uuid = progressMonitorService.registerNewRemotingMonitor(monitorThread); |
|
128 |
monitorThread.setPriority(2); |
|
129 |
monitorThread.start(); |
|
130 |
return uuid; |
|
131 |
} |
|
132 |
|
|
133 |
@Override |
|
134 |
public UUID monitLongRunningTask(ForSubtreeConfiguratorBase config) { |
|
135 |
|
|
136 |
RemotingProgressMonitorThread monitorThread = new RemotingProgressMonitorThread() { |
|
137 |
@Override |
|
138 |
public Serializable doRun(IRemotingProgressMonitor monitor) { |
|
139 |
UpdateResult result; |
|
140 |
config.setMonitor(monitor); |
|
141 |
|
|
142 |
result = updateData(config); |
|
143 |
for(Exception e : result.getExceptions()) { |
|
144 |
monitor.addReport(e.getMessage()); |
|
145 |
} |
|
146 |
monitor.setResult(result); |
|
147 |
return result; |
|
148 |
} |
|
149 |
}; |
|
150 |
UUID uuid = progressMonitorService.registerNewRemotingMonitor(monitorThread); |
|
151 |
monitorThread.setPriority(2); |
|
152 |
monitorThread.start(); |
|
153 |
return uuid; |
|
154 |
} |
|
155 |
|
|
156 |
private UpdateResult updateData(ForSubtreeConfiguratorBase config){ |
|
157 |
if (config instanceof SecundumForSubtreeConfigurator){ |
|
158 |
return taxonNodeService.setSecundumForSubtree((SecundumForSubtreeConfigurator)config); |
|
159 |
}else{ |
|
160 |
return taxonNodeService.setPublishForSubtree((PublishForSubtreeConfigurator) config); |
|
161 |
} |
|
162 |
} |
|
163 |
|
|
164 |
@Override |
|
165 |
public UUID monitLongRunningTask(Set<UUID> movingUuids, UUID targetTreeNodeUuid, int movingType) { |
|
166 |
|
|
167 |
RemotingProgressMonitorThread monitorThread = new RemotingProgressMonitorThread() { |
|
168 |
@Override |
|
169 |
public Serializable doRun(IRemotingProgressMonitor remotingMonitor) { |
|
170 |
UpdateResult result; |
|
171 |
|
|
172 |
result = taxonNodeService.moveTaxonNodes(movingUuids,targetTreeNodeUuid, movingType, remotingMonitor); |
|
173 |
for(Exception e : result.getExceptions()) { |
|
174 |
remotingMonitor.addReport(e.getMessage()); |
|
175 |
} |
|
176 |
remotingMonitor.setResult(result); |
|
177 |
return result; |
|
178 |
} |
|
179 |
}; |
|
180 |
UUID uuid = progressMonitorService.registerNewRemotingMonitor(monitorThread); |
|
181 |
monitorThread.setPriority(2); |
|
182 |
monitorThread.start(); |
|
183 |
return uuid; |
|
184 |
} |
|
185 |
|
|
186 |
/** |
|
187 |
* {@inheritDoc} |
|
188 |
*/ |
|
189 |
@Override |
|
190 |
public UUID monitLongRunningTask(CacheUpdaterConfigurator configurator) { |
|
191 |
RemotingProgressMonitorThread monitorThread = new RemotingProgressMonitorThread() { |
|
192 |
@Override |
|
193 |
public Serializable doRun(IRemotingProgressMonitor monitor) { |
|
194 |
UpdateResult result; |
|
195 |
|
|
196 |
configurator.setMonitor(monitor); |
|
197 |
|
|
198 |
result = updater.doInvoke(configurator); |
|
199 |
|
|
200 |
for(Exception e : result.getExceptions()) { |
|
201 |
monitor.addReport(e.getMessage()); |
|
202 |
} |
|
203 |
monitor.setResult(result); |
|
204 |
return result; |
|
205 |
} |
|
206 |
}; |
|
207 |
UUID uuid = progressMonitorService.registerNewRemotingMonitor(monitorThread); |
|
208 |
monitorThread.setPriority(2); |
|
209 |
monitorThread.start(); |
|
210 |
return uuid; |
|
211 |
} |
|
212 |
|
|
213 |
/** |
|
214 |
* {@inheritDoc} |
|
215 |
*/ |
|
216 |
@Override |
|
217 |
public UUID monitLongRunningTask(SortIndexUpdaterConfigurator configurator) { |
|
218 |
RemotingProgressMonitorThread monitorThread = new RemotingProgressMonitorThread() { |
|
219 |
@Override |
|
220 |
public Serializable doRun(IRemotingProgressMonitor monitor) { |
|
221 |
UpdateResult result; |
|
222 |
configurator.setMonitor(monitor); |
|
223 |
|
|
224 |
result = sortIndexUpdater.doInvoke(configurator); |
|
225 |
|
|
226 |
for(Exception e : result.getExceptions()) { |
|
227 |
monitor.addReport(e.getMessage()); |
|
228 |
} |
|
229 |
monitor.setResult(result); |
|
230 |
return result; |
|
231 |
} |
|
232 |
}; |
|
233 |
UUID uuid = progressMonitorService.registerNewRemotingMonitor(monitorThread); |
|
234 |
monitorThread.setPriority(2); |
|
235 |
monitorThread.start(); |
|
236 |
return uuid; |
|
237 |
} |
|
238 |
|
|
239 |
|
|
240 |
} |
cdmlib-services/src/main/resources/eu/etaxonomy/cdm/httpInvokerServices.xml | ||
---|---|---|
488 | 488 |
<bean id="httpLongRunningTasksService" |
489 | 489 |
class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter"> |
490 | 490 |
<property name="service"> |
491 |
<ref bean="longRunningTasksServiceImpl" />
|
|
491 |
<ref bean="longRunningTasksService" /> |
|
492 | 492 |
</property> |
493 | 493 |
<property name="serviceInterface"> |
494 |
<value>eu.etaxonomy.cdm.api.longrunningService.ILongRunningTasksService |
|
494 |
<value>eu.etaxonomy.cdm.api.service.longrunningService.ILongRunningTasksService
|
|
495 | 495 |
</value> |
496 | 496 |
</property> |
497 | 497 |
</bean> |
Also available in: Unified diff
move longrunningService to service