Revision 40094
Added by Michele Artini over 8 years ago
MdBuilderJobNode.java | ||
---|---|---|
3 | 3 |
import java.io.IOException; |
4 | 4 |
import java.net.URLEncoder; |
5 | 5 |
import java.util.List; |
6 |
|
|
7 | 6 |
import javax.xml.ws.wsaddressing.W3CEndpointReference; |
8 | 7 |
|
9 |
import org.antlr.stringtemplate.StringTemplate; |
|
10 |
import org.apache.commons.io.IOUtils; |
|
11 |
import org.apache.commons.logging.Log; |
|
12 |
import org.apache.commons.logging.LogFactory; |
|
13 |
import org.springframework.beans.factory.annotation.Required; |
|
14 |
import org.springframework.core.io.Resource; |
|
15 |
|
|
16 |
import com.googlecode.sarasvati.Arc; |
|
17 |
import com.googlecode.sarasvati.NodeToken; |
|
18 |
|
|
19 | 8 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException; |
20 | 9 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService; |
21 | 10 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
22 | 11 |
import eu.dnetlib.enabling.resultset.XSLTMappedResultSetFactory; |
23 | 12 |
import eu.dnetlib.enabling.resultset.client.utils.EPRUtils; |
24 | 13 |
import eu.dnetlib.msro.rmi.MSROException; |
14 |
import eu.dnetlib.msro.workflows.graph.Arc; |
|
15 |
import eu.dnetlib.msro.workflows.graph.Env; |
|
25 | 16 |
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode; |
17 |
import org.antlr.stringtemplate.StringTemplate; |
|
18 |
import org.apache.commons.io.IOUtils; |
|
19 |
import org.apache.commons.logging.Log; |
|
20 |
import org.apache.commons.logging.LogFactory; |
|
21 |
import org.springframework.beans.factory.annotation.Required; |
|
22 |
import org.springframework.core.io.Resource; |
|
26 | 23 |
|
27 | 24 |
public class MdBuilderJobNode extends SimpleJobNode { |
28 | 25 |
|
... | ... | |
41 | 38 |
private UniqueServiceLocator serviceLocator; |
42 | 39 |
|
43 | 40 |
@Override |
44 |
protected String execute(final NodeToken token) throws MSROException {
|
|
45 |
final String inputEpr = token.getEnv().getAttribute(inputEprParam);
|
|
41 |
protected String execute(final Env env) throws MSROException {
|
|
42 |
final String inputEpr = env.getAttribute(inputEprParam, String.class);
|
|
46 | 43 |
|
47 | 44 |
if ((inputEpr == null) || inputEpr.isEmpty()) throw new MSROException("InputEprParam (" + inputEprParam + ") not found in ENV"); |
48 | 45 |
StringTemplate st = null; |
... | ... | |
58 | 55 |
* it to ST. Else: a) try to get it from EXTRAFIELDS of the datasource b) try to get it from DATASOURCE_ORIGINAL_ID of the |
59 | 56 |
* datasource c) if any of the is present, then push to ST the datasourceId |
60 | 57 |
*/ |
61 |
if (token.getEnv().hasAttribute("namespacePrefix")) {
|
|
62 |
st.setAttribute("namespacePrefix", token.getEnv().getAttribute("namespacePrefix"));
|
|
58 |
if (env.hasAttribute("namespacePrefix")) {
|
|
59 |
st.setAttribute("namespacePrefix", env.getAttribute("namespacePrefix"));
|
|
63 | 60 |
} else { |
64 | 61 |
List<String> namespacePrefix; |
65 | 62 |
String xQuery = "/*[.//RESOURCE_IDENTIFIER/@value='" + datasourceId + "']//EXTRA_FIELDS/FIELD/value[../key='NamespacePrefix']/string()"; |
... | ... | |
79 | 76 |
|
80 | 77 |
final W3CEndpointReference epr = xsltMappedResultSetFactory.createMappedResultSet(new EPRUtils().getEpr(inputEpr), st.toString()); |
81 | 78 |
|
82 |
token.getEnv().setAttribute(outputEprParam, epr.toString());
|
|
79 |
env.setAttribute(outputEprParam, epr.toString());
|
|
83 | 80 |
|
84 | 81 |
return Arc.DEFAULT_ARC; |
85 | 82 |
} catch (ISLookUpException e) { |
... | ... | |
139 | 136 |
return xsltMappedResultSetFactory; |
140 | 137 |
} |
141 | 138 |
|
139 |
@Required |
|
140 |
public void setXsltMappedResultSetFactory(final XSLTMappedResultSetFactory xsltMappedResultSetFactory) { |
|
141 |
this.xsltMappedResultSetFactory = xsltMappedResultSetFactory; |
|
142 |
} |
|
143 |
|
|
142 | 144 |
public String getDatasourceId() { |
143 | 145 |
return datasourceId; |
144 | 146 |
} |
... | ... | |
155 | 157 |
this.datasourceInterface = datasourceInterface; |
156 | 158 |
} |
157 | 159 |
|
158 |
@Required |
|
159 |
public void setXsltMappedResultSetFactory(final XSLTMappedResultSetFactory xsltMappedResultSetFactory) { |
|
160 |
this.xsltMappedResultSetFactory = xsltMappedResultSetFactory; |
|
161 |
} |
|
162 |
|
|
163 | 160 |
public Resource getMdBuilderTemplateXslt() { |
164 | 161 |
return mdBuilderTemplateXslt; |
165 | 162 |
} |
Also available in: Unified diff
partial reimplementation of the wf engine