Project

General

Profile

« Previous | Next » 

Revision 54390

updated resolver and Trying to allow mdstore plugin to print progress information on UI

View differences:

PluginAction.java
1 1
package eu.dnetlib.data.mdstore.modular.action;
2 2

  
3 3
import java.util.Map;
4
import java.util.concurrent.Executors;
4 5

  
5 6
import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
6 7
import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
......
9 10
import org.apache.commons.logging.LogFactory;
10 11
import org.springframework.beans.factory.annotation.Autowired;
11 12

  
13

  
14
class StatusThread extends Thread {
15
	boolean shouldUpdate = false;
16
	final BlackboardServerHandler handler;
17
	final BlackboardJob job;
18
	final long timeout;
19
	final MDStorePlugin currentPlugin;
20

  
21
	public StatusThread(final BlackboardServerHandler handler, final BlackboardJob job, final long timeout, final  MDStorePlugin currentPlugin) {
22
		this.job = job;
23
		this.handler = handler;
24
		this.timeout = timeout;
25
		this.currentPlugin = currentPlugin;
26
	}
27

  
28
	@Override
29
	public void run() {
30
		while (shouldUpdate) {
31
			job.getParameters().put("ongoingPercentage",currentPlugin.getStatus());
32
			handler.ongoing(job);
33
			try {
34
				sleep(timeout);
35
			} catch (InterruptedException e) {
36

  
37
			}
38
		}
39
	}
40

  
41
	public boolean isShouldUpdate() {
42
		return shouldUpdate;
43
	}
44

  
45
	public void setShouldUpdate(boolean shouldUpdate) {
46
		this.shouldUpdate = shouldUpdate;
47
	}
48
}
49

  
12 50
public class PluginAction extends AbstractMDStoreAction {
13 51

  
14 52
	private static final Log log = LogFactory.getLog(PluginAction.class);
......
27 65

  
28 66
		log.info("running MDStore plugin: " + name);
29 67

  
68
		final StatusThread st = new StatusThread(handler, job,20000, plugins.get(name));
69
		st.setShouldUpdate(true);
70
		st.start();
30 71
		plugins.get(name).run(getDao(), job.getParameters(), params -> {
72
			st.setShouldUpdate(false);
73

  
31 74
			job.getParameters().putAll(params);
32 75
			handler.done(job);
33 76
		});

Also available in: Unified diff