1
|
package eu.dnetlib.msro.workflows.nodes.mdstore;
|
2
|
|
3
|
import java.util.List;
|
4
|
|
5
|
import com.google.gson.Gson;
|
6
|
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
|
7
|
import eu.dnetlib.enabling.resultset.client.ResultSetClient;
|
8
|
import eu.dnetlib.enabling.resultset.factory.ResultSetFactory;
|
9
|
import eu.dnetlib.msro.workflows.graph.Arc;
|
10
|
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode;
|
11
|
import eu.dnetlib.msro.workflows.procs.Env;
|
12
|
import eu.dnetlib.rmi.common.ResultSet;
|
13
|
import org.apache.commons.logging.Log;
|
14
|
import org.apache.commons.logging.LogFactory;
|
15
|
import org.springframework.beans.factory.annotation.Autowired;
|
16
|
|
17
|
public class FetchMultipleMDStores extends SimpleJobNode {
|
18
|
|
19
|
private static final Log log = LogFactory.getLog(FetchMultipleMDStores.class); // NOPMD by marko on 11/24/08 5:02 PM
|
20
|
|
21
|
@Autowired
|
22
|
private UniqueServiceLocator serviceLocator;
|
23
|
|
24
|
private List<String> mdId;
|
25
|
|
26
|
private String eprParam;
|
27
|
|
28
|
@Autowired
|
29
|
private ResultSetFactory resultSetFactory;
|
30
|
|
31
|
@Autowired
|
32
|
private ResultSetClient resultSetClient;
|
33
|
|
34
|
@Override
|
35
|
protected String execute(final Env env) throws Exception {
|
36
|
|
37
|
if (getMdId() == null) {
|
38
|
final String mdIdsJson = env.getAttribute("mdId", String.class);
|
39
|
@SuppressWarnings("unchecked")
|
40
|
final List<String> mdIds = new Gson().fromJson(mdIdsJson, List.class);
|
41
|
log.info(String.format("fetching records for %s mdstores", mdIds.size()));
|
42
|
if (log.isDebugEnabled()) {
|
43
|
log.debug(String.format("fetching records for mdstores: %s", mdIdsJson));
|
44
|
}
|
45
|
setMdId(mdIds);
|
46
|
}
|
47
|
|
48
|
final MultipleMdStoreIterable iter = new MultipleMdStoreIterable(this.serviceLocator, getMdId(), this.resultSetClient);
|
49
|
final ResultSet<String> rs = this.resultSetFactory.createResultSet(iter);
|
50
|
env.setAttribute(getEprParam(), rs);
|
51
|
|
52
|
return Arc.DEFAULT_ARC;
|
53
|
}
|
54
|
|
55
|
public List<String> getMdId() {
|
56
|
return this.mdId;
|
57
|
}
|
58
|
|
59
|
public void setMdId(final List<String> mdId) {
|
60
|
this.mdId = mdId;
|
61
|
}
|
62
|
|
63
|
public String getEprParam() {
|
64
|
return this.eprParam;
|
65
|
}
|
66
|
|
67
|
public void setEprParam(final String eprParam) {
|
68
|
this.eprParam = eprParam;
|
69
|
}
|
70
|
|
71
|
}
|