1
|
package eu.dnetlib.msro.worker.nodes.transform;
|
2
|
|
3
|
import java.util.HashMap;
|
4
|
import java.util.Map;
|
5
|
|
6
|
import javax.annotation.Resource;
|
7
|
|
8
|
import org.springframework.core.io.ClassPathResource;
|
9
|
|
10
|
import com.googlecode.sarasvati.Arc;
|
11
|
import com.googlecode.sarasvati.NodeToken;
|
12
|
|
13
|
import eu.dnetlib.data.resultSet.ResultSetFactory;
|
14
|
import eu.dnetlib.miscutils.ApplyXslt;
|
15
|
import eu.dnetlib.msro.worker.nodes.SimpleJobNode;
|
16
|
import eu.dnetlib.rmi.objects.resultSet.ResultSet;
|
17
|
import eu.dnetlib.rmi.soap.exceptions.ManagerServiceException;
|
18
|
|
19
|
public class ApplyXsltJobNode extends SimpleJobNode {
|
20
|
|
21
|
private String inputResultSetParam;
|
22
|
private String outputResultSetParam;
|
23
|
private String xsltClasspath;
|
24
|
|
25
|
@Resource
|
26
|
private ResultSetFactory resultSetFactory;
|
27
|
|
28
|
@Override
|
29
|
protected String execute(final NodeToken token) throws Exception {
|
30
|
@SuppressWarnings("unchecked")
|
31
|
final ResultSet<String> inputRs = (ResultSet<String>) token.getEnv().getTransientAttribute(inputResultSetParam);
|
32
|
if (inputRs == null) { throw new ManagerServiceException("InputEprParam (" + inputResultSetParam + ") not found in ENV"); }
|
33
|
|
34
|
final Map<String, String> xsltParams = new HashMap<String, String>();
|
35
|
|
36
|
for (String name : token.getFullEnv().getAttributeNames()) {
|
37
|
xsltParams.put(name.replaceAll(":", "_"), token.getFullEnv().getAttribute(name));
|
38
|
}
|
39
|
for (String name : token.getEnv().getAttributeNames()) {
|
40
|
xsltParams.put(name.replaceAll(":", "_"), token.getEnv().getAttribute(name));
|
41
|
}
|
42
|
|
43
|
xsltParams.putAll(parseJsonParameters(token));
|
44
|
|
45
|
final ResultSet<String> outputRs = resultSetFactory.transform(inputRs, new ApplyXslt(new ClassPathResource(xsltClasspath), xsltParams));
|
46
|
|
47
|
token.getEnv().setAttribute(outputResultSetParam, outputRs.toString());
|
48
|
|
49
|
return Arc.DEFAULT_ARC;
|
50
|
}
|
51
|
|
52
|
public String getXsltClasspath() {
|
53
|
return xsltClasspath;
|
54
|
}
|
55
|
|
56
|
public void setXsltClasspath(final String xsltClasspath) {
|
57
|
this.xsltClasspath = xsltClasspath;
|
58
|
}
|
59
|
|
60
|
public String getInputResultSetParam() {
|
61
|
return inputResultSetParam;
|
62
|
}
|
63
|
|
64
|
public void setInputResultSetParam(final String inputResultSetParam) {
|
65
|
this.inputResultSetParam = inputResultSetParam;
|
66
|
}
|
67
|
|
68
|
public String getOutputResultSetParam() {
|
69
|
return outputResultSetParam;
|
70
|
}
|
71
|
|
72
|
public void setOutputResultSetParam(final String outputResultSetParam) {
|
73
|
this.outputResultSetParam = outputResultSetParam;
|
74
|
}
|
75
|
|
76
|
}
|