1 |
34996
|
michele.ar
|
package eu.dnetlib.msro.openaireplus.workflows.nodes.contexts;
|
2 |
|
|
|
3 |
|
|
import javax.annotation.Resource;
|
4 |
|
|
|
5 |
|
|
import com.googlecode.sarasvati.Arc;
|
6 |
|
|
import com.googlecode.sarasvati.NodeToken;
|
7 |
|
|
import eu.dnetlib.enabling.resultset.client.ResultSetClientFactory;
|
8 |
|
|
import eu.dnetlib.msro.workflows.nodes.ProgressJobNode;
|
9 |
|
|
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode;
|
10 |
|
|
import eu.dnetlib.msro.workflows.resultset.ProcessCountingResultSetFactory;
|
11 |
|
|
import eu.dnetlib.msro.workflows.util.ProgressProvider;
|
12 |
|
|
import eu.dnetlib.msro.workflows.util.ResultsetProgressProvider;
|
13 |
48139
|
alessia.ba
|
import org.apache.commons.logging.Log;
|
14 |
|
|
import org.apache.commons.logging.LogFactory;
|
15 |
34996
|
michele.ar
|
|
16 |
|
|
public class ProcessContextsJobNode extends SimpleJobNode implements ProgressJobNode {
|
17 |
|
|
|
18 |
41483
|
claudio.at
|
private static final Log log = LogFactory.getLog(ProcessContextsJobNode.class);
|
19 |
|
|
|
20 |
34996
|
michele.ar
|
private String eprParam;
|
21 |
|
|
private String contextObj;
|
22 |
|
|
private ResultsetProgressProvider progressProvider;
|
23 |
|
|
private String contextId;
|
24 |
|
|
private String contextLabel;
|
25 |
|
|
private String contextType;
|
26 |
|
|
|
27 |
48139
|
alessia.ba
|
private String contextParams;
|
28 |
|
|
|
29 |
34996
|
michele.ar
|
@Resource
|
30 |
|
|
private ResultSetClientFactory resultSetClientFactory;
|
31 |
|
|
|
32 |
|
|
@Resource
|
33 |
|
|
private ProcessCountingResultSetFactory processCountingResultSetFactory;
|
34 |
|
|
|
35 |
|
|
@Override
|
36 |
|
|
protected String execute(final NodeToken token) throws Exception {
|
37 |
|
|
|
38 |
|
|
final String epr = token.getEnv().getAttribute(eprParam);
|
39 |
|
|
|
40 |
|
|
this.progressProvider = processCountingResultSetFactory.createProgressProvider(token.getProcess(), epr);
|
41 |
|
|
|
42 |
41483
|
claudio.at
|
final Iterable<String> iter = resultSetClientFactory.getClient(progressProvider.getEpr());
|
43 |
34996
|
michele.ar
|
|
44 |
48139
|
alessia.ba
|
final ContextDesc context = ContextUtils.getContext(iter, getContextId(), getContextLabel(), getContextType(), getContextParams());
|
45 |
34996
|
michele.ar
|
|
46 |
|
|
token.getEnv().setTransientAttribute(contextObj, context);
|
47 |
|
|
|
48 |
|
|
return Arc.DEFAULT_ARC;
|
49 |
|
|
}
|
50 |
|
|
|
51 |
|
|
public String getEprParam() {
|
52 |
|
|
return eprParam;
|
53 |
|
|
}
|
54 |
|
|
|
55 |
|
|
public void setEprParam(final String eprParam) {
|
56 |
|
|
this.eprParam = eprParam;
|
57 |
|
|
}
|
58 |
|
|
|
59 |
|
|
public String getContextObj() {
|
60 |
|
|
return contextObj;
|
61 |
|
|
}
|
62 |
|
|
|
63 |
|
|
public void setContextObj(final String contextObj) {
|
64 |
|
|
this.contextObj = contextObj;
|
65 |
|
|
}
|
66 |
|
|
|
67 |
|
|
@Override
|
68 |
|
|
public ProgressProvider getProgressProvider() {
|
69 |
|
|
return progressProvider;
|
70 |
|
|
}
|
71 |
|
|
|
72 |
|
|
public String getContextId() {
|
73 |
|
|
return contextId;
|
74 |
|
|
}
|
75 |
|
|
|
76 |
|
|
public void setContextId(final String contextId) {
|
77 |
|
|
this.contextId = contextId;
|
78 |
|
|
}
|
79 |
|
|
|
80 |
|
|
public String getContextLabel() {
|
81 |
|
|
return contextLabel;
|
82 |
|
|
}
|
83 |
|
|
|
84 |
|
|
public void setContextLabel(final String contextLabel) {
|
85 |
|
|
this.contextLabel = contextLabel;
|
86 |
|
|
}
|
87 |
|
|
|
88 |
|
|
public String getContextType() {
|
89 |
|
|
return contextType;
|
90 |
|
|
}
|
91 |
|
|
|
92 |
|
|
public void setContextType(final String contextType) {
|
93 |
|
|
this.contextType = contextType;
|
94 |
|
|
}
|
95 |
48139
|
alessia.ba
|
|
96 |
|
|
public String getContextParams() {
|
97 |
|
|
return contextParams;
|
98 |
|
|
}
|
99 |
|
|
|
100 |
|
|
public void setContextParams(final String contextParams) {
|
101 |
|
|
this.contextParams = contextParams;
|
102 |
|
|
}
|
103 |
34996
|
michele.ar
|
}
|