1
|
package eu.dnetlib.msro.eagle.workflows.nodes.transform.editions;
|
2
|
|
3
|
import java.util.HashMap;
|
4
|
import java.util.Map;
|
5
|
|
6
|
import javax.xml.ws.wsaddressing.W3CEndpointReference;
|
7
|
|
8
|
import com.googlecode.sarasvati.Arc;
|
9
|
import com.googlecode.sarasvati.NodeToken;
|
10
|
|
11
|
import eu.dnetlib.enabling.resultset.MappedResultSetFactory;
|
12
|
import eu.dnetlib.enabling.resultset.client.utils.EPRUtils;
|
13
|
import eu.dnetlib.msro.rmi.MSROException;
|
14
|
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode;
|
15
|
|
16
|
/**
|
17
|
* This class is intended to process records coming in MDStore compliant form (with header)
|
18
|
* and apply the xslt located at http://sourceforge.net/projects/epidoc/files/Example%20Stylesheets/
|
19
|
* to the <metadata> blocks of each record.
|
20
|
* @author Andrea Mannocci
|
21
|
*
|
22
|
*/
|
23
|
public class ApplyEditionXsltJobNode extends SimpleJobNode {
|
24
|
|
25
|
private String inputEprParam;
|
26
|
private String outputEprParam;
|
27
|
private String xsltPath;
|
28
|
|
29
|
private MappedResultSetFactory mappedResultSetFactory;
|
30
|
private final Map<String, String> xsltParams = new HashMap<String, String>();
|
31
|
|
32
|
@Override
|
33
|
protected String execute(final NodeToken token) throws Exception {
|
34
|
final String inputEpr = token.getEnv().getAttribute(inputEprParam);
|
35
|
if ((inputEpr == null) || inputEpr.isEmpty()) throw new MSROException("InputEprParam (" + inputEprParam + ") not found in ENV");
|
36
|
|
37
|
|
38
|
for (String name : token.getFullEnv().getAttributeNames()) {
|
39
|
xsltParams.put(name, token.getFullEnv().getAttribute(name));
|
40
|
}
|
41
|
for (String name : token.getEnv().getAttributeNames()) {
|
42
|
xsltParams.put(name, token.getEnv().getAttribute(name));
|
43
|
}
|
44
|
|
45
|
xsltParams.putAll(parseJsonParameters(token));
|
46
|
|
47
|
final W3CEndpointReference epr = mappedResultSetFactory.createMappedResultSet(new EPRUtils().getEpr(inputEpr),
|
48
|
new EditionXsltUnaryFunction(xsltPath, xsltParams));
|
49
|
|
50
|
token.getEnv().setAttribute(outputEprParam, epr.toString());
|
51
|
|
52
|
return Arc.DEFAULT_ARC;
|
53
|
}
|
54
|
|
55
|
public String getInputEprParam() {
|
56
|
return inputEprParam;
|
57
|
}
|
58
|
|
59
|
public void setInputEprParam(String inputEprParam) {
|
60
|
this.inputEprParam = inputEprParam;
|
61
|
}
|
62
|
|
63
|
public String getOutputEprParam() {
|
64
|
return outputEprParam;
|
65
|
}
|
66
|
|
67
|
public void setOutputEprParam(String outputEprParam) {
|
68
|
this.outputEprParam = outputEprParam;
|
69
|
}
|
70
|
|
71
|
public String getXsltPath() {
|
72
|
return xsltPath;
|
73
|
}
|
74
|
|
75
|
public void setXsltPath(String xsltPath) {
|
76
|
this.xsltPath = xsltPath;
|
77
|
}
|
78
|
|
79
|
public MappedResultSetFactory getMappedResultSetFactory() {
|
80
|
return mappedResultSetFactory;
|
81
|
}
|
82
|
|
83
|
public void setMappedResultSetFactory(
|
84
|
MappedResultSetFactory mappedResultSetFactory) {
|
85
|
this.mappedResultSetFactory = mappedResultSetFactory;
|
86
|
}
|
87
|
|
88
|
}
|