Revision 40094
Added by Michele Artini over 8 years ago
ApplyXsltJobNode.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import java.util.HashMap; |
4 | 4 |
import java.util.Map; |
5 |
|
|
6 | 5 |
import javax.xml.ws.wsaddressing.W3CEndpointReference; |
7 | 6 |
|
8 |
import org.springframework.beans.factory.annotation.Required; |
|
9 |
import org.springframework.core.io.ClassPathResource; |
|
10 |
|
|
11 |
import com.googlecode.sarasvati.Arc; |
|
12 |
import com.googlecode.sarasvati.NodeToken; |
|
13 |
|
|
14 | 7 |
import eu.dnetlib.enabling.resultset.XSLTMappedResultSetFactory; |
15 | 8 |
import eu.dnetlib.enabling.resultset.client.utils.EPRUtils; |
16 | 9 |
import eu.dnetlib.msro.rmi.MSROException; |
10 |
import eu.dnetlib.msro.workflows.graph.Arc; |
|
11 |
import eu.dnetlib.msro.workflows.graph.Env; |
|
17 | 12 |
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode; |
13 |
import org.springframework.beans.factory.annotation.Required; |
|
14 |
import org.springframework.core.io.ClassPathResource; |
|
18 | 15 |
|
19 | 16 |
public class ApplyXsltJobNode extends SimpleJobNode { |
20 | 17 |
|
... | ... | |
25 | 22 |
private XSLTMappedResultSetFactory xsltMappedResultSetFactory; |
26 | 23 |
|
27 | 24 |
@Override |
28 |
protected String execute(final NodeToken token) throws Exception {
|
|
29 |
final String inputEpr = token.getEnv().getAttribute(inputEprParam);
|
|
25 |
protected String execute(final Env env) throws Exception {
|
|
26 |
final String inputEpr = env.getAttribute(inputEprParam, String.class);
|
|
30 | 27 |
if ((inputEpr == null) || inputEpr.isEmpty()) throw new MSROException("InputEprParam (" + inputEprParam + ") not found in ENV"); |
31 | 28 |
|
32 | 29 |
final Map<String, String> xsltParams = new HashMap<String, String>(); |
33 | 30 |
|
34 |
for (String name : token.getFullEnv().getAttributeNames()) {
|
|
35 |
xsltParams.put(name.replaceAll(":", "_"), token.getFullEnv().getAttribute(name));
|
|
31 |
for (Map.Entry<String, Object> e : env.getAttributes().entrySet()) {
|
|
32 |
xsltParams.put(e.getKey().replaceAll(":", "_"), e.getValue().toString());
|
|
36 | 33 |
} |
37 |
for (String name : token.getEnv().getAttributeNames()) { |
|
38 |
xsltParams.put(name.replaceAll(":", "_"), token.getEnv().getAttribute(name)); |
|
34 |
|
|
35 |
for (Map.Entry<String, Object> e : parseJsonParameters(env).entrySet()) { |
|
36 |
xsltParams.put(e.getKey(), e.getValue().toString()); |
|
39 | 37 |
} |
40 |
|
|
41 |
xsltParams.putAll(parseJsonParameters(token)); |
|
42 |
|
|
38 |
|
|
43 | 39 |
final W3CEndpointReference epr = xsltMappedResultSetFactory.createMappedResultSet(new EPRUtils().getEpr(inputEpr), |
44 | 40 |
(new ClassPathResource(xsltClasspath)), xsltParams); |
45 | 41 |
|
46 |
token.getEnv().setAttribute(outputEprParam, epr.toString());
|
|
42 |
env.setAttribute(outputEprParam, epr.toString());
|
|
47 | 43 |
|
48 | 44 |
return Arc.DEFAULT_ARC; |
49 | 45 |
} |
Also available in: Unified diff
partial reimplementation of the wf engine