1
|
package eu.dnetlib.msro.workflows.nodes.mdstore;
|
2
|
|
3
|
import java.util.List;
|
4
|
|
5
|
import javax.annotation.Resource;
|
6
|
import javax.xml.ws.wsaddressing.W3CEndpointReference;
|
7
|
|
8
|
import org.springframework.beans.factory.annotation.Autowired;
|
9
|
|
10
|
import com.google.gson.Gson;
|
11
|
import com.googlecode.sarasvati.Arc;
|
12
|
import com.googlecode.sarasvati.NodeToken;
|
13
|
|
14
|
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
|
15
|
import eu.dnetlib.enabling.resultset.IterableResultSetFactory;
|
16
|
import eu.dnetlib.enabling.resultset.client.ResultSetClientFactory;
|
17
|
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode;
|
18
|
|
19
|
public class FetchMultipleMDStores extends SimpleJobNode {
|
20
|
|
21
|
@Resource
|
22
|
private UniqueServiceLocator serviceLocator;
|
23
|
|
24
|
private List<String> mdId;
|
25
|
private String mdFormat;
|
26
|
|
27
|
private String eprParam;
|
28
|
|
29
|
/** The result set factory. */
|
30
|
@Resource(name = "iterableResultSetFactory")
|
31
|
private IterableResultSetFactory resultSetFactory;
|
32
|
|
33
|
/** The result set client factory. */
|
34
|
@Autowired
|
35
|
private ResultSetClientFactory resultSetClientFactory;
|
36
|
|
37
|
@Override
|
38
|
protected String execute(final NodeToken token) throws Exception {
|
39
|
|
40
|
if (getMdId() == null) {
|
41
|
@SuppressWarnings("unchecked")
|
42
|
List<String> mdIds = new Gson().fromJson(token.getEnv().getAttribute("mdId"), List.class);
|
43
|
|
44
|
setMdId(mdIds);
|
45
|
}
|
46
|
if (getMdFormat() == null) {
|
47
|
setMdFormat(token.getEnv().getAttribute("mdFormat"));
|
48
|
}
|
49
|
MultipleMdStoreIterable iter = new MultipleMdStoreIterable(serviceLocator, getMdId(), resultSetClientFactory);
|
50
|
W3CEndpointReference eprUrls = resultSetFactory.createIterableResultSet(iter);
|
51
|
token.getEnv().setAttribute(getEprParam(), eprUrls.toString());
|
52
|
return Arc.DEFAULT_ARC;
|
53
|
}
|
54
|
|
55
|
public List<String> getMdId() {
|
56
|
return mdId;
|
57
|
}
|
58
|
|
59
|
public void setMdId(final List<String> mdId) {
|
60
|
this.mdId = mdId;
|
61
|
}
|
62
|
|
63
|
public String getMdFormat() {
|
64
|
return mdFormat;
|
65
|
}
|
66
|
|
67
|
public void setMdFormat(final String mdFormat) {
|
68
|
this.mdFormat = mdFormat;
|
69
|
}
|
70
|
|
71
|
public String getEprParam() {
|
72
|
return eprParam;
|
73
|
}
|
74
|
|
75
|
public void setEprParam(final String eprParam) {
|
76
|
this.eprParam = eprParam;
|
77
|
}
|
78
|
|
79
|
}
|