1 |
26600
|
sandro.lab
|
package eu.dnetlib.msro.workflows.nodes.objectStore;
|
2 |
|
|
|
3 |
|
|
import javax.annotation.Resource;
|
4 |
|
|
import javax.xml.ws.wsaddressing.W3CEndpointReference;
|
5 |
|
|
|
6 |
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
7 |
|
|
import org.springframework.beans.factory.annotation.Required;
|
8 |
|
|
|
9 |
|
|
import com.google.common.collect.Iterables;
|
10 |
|
|
import com.googlecode.sarasvati.Arc;
|
11 |
|
|
import com.googlecode.sarasvati.NodeToken;
|
12 |
|
|
|
13 |
|
|
import eu.dnetlib.enabling.resultset.IterableResultSetFactory;
|
14 |
|
|
import eu.dnetlib.enabling.resultset.client.ResultSetClientFactory;
|
15 |
|
|
import eu.dnetlib.enabling.resultset.client.utils.EPRUtils;
|
16 |
|
|
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode;
|
17 |
|
|
import eu.dnetlib.msro.workflows.nodes.download.UrlExtractor;
|
18 |
|
|
|
19 |
|
|
// TODO: Auto-generated Javadoc
|
20 |
|
|
/**
|
21 |
|
|
* The Class RetrieveURLSJobNode.
|
22 |
|
|
*/
|
23 |
|
|
public class RetrieveURLSJobNode extends SimpleJobNode {
|
24 |
|
|
|
25 |
|
|
/** The epr param. */
|
26 |
|
|
private String inputEprParam;
|
27 |
|
|
|
28 |
|
|
/** The output epr param. */
|
29 |
|
|
private String outputEprParam;
|
30 |
|
|
|
31 |
|
|
/** The xpath. */
|
32 |
|
|
private String xpath;
|
33 |
|
|
|
34 |
|
|
/** The xpath metadata id. */
|
35 |
|
|
private String xpathMetadataId;
|
36 |
|
|
|
37 |
31406
|
sandro.lab
|
/** The xpath open access. */
|
38 |
|
|
private String xpathOpenAccess;
|
39 |
|
|
|
40 |
|
|
/** The xpath embargo date. */
|
41 |
|
|
private String xpathEmbargoDate;
|
42 |
|
|
|
43 |
26600
|
sandro.lab
|
/** The result set client factory. */
|
44 |
|
|
@Autowired
|
45 |
|
|
private ResultSetClientFactory resultSetClientFactory;
|
46 |
|
|
|
47 |
|
|
/** The result set factory. */
|
48 |
|
|
@Resource(name = "iterableResultSetFactory")
|
49 |
|
|
private IterableResultSetFactory resultSetFactory;
|
50 |
|
|
|
51 |
|
|
/*
|
52 |
|
|
* (non-Javadoc)
|
53 |
31406
|
sandro.lab
|
*
|
54 |
26600
|
sandro.lab
|
* @see eu.dnetlib.msro.workflows.nodes.SimpleJobNode#execute(com.googlecode.sarasvati.NodeToken)
|
55 |
|
|
*/
|
56 |
|
|
@Override
|
57 |
|
|
protected String execute(final NodeToken token) throws Exception {
|
58 |
|
|
final W3CEndpointReference inputEpr = (new EPRUtils()).getEpr(token.getEnv().getAttribute(inputEprParam));
|
59 |
|
|
Iterable<String> input = resultSetClientFactory.getClient(inputEpr);
|
60 |
31406
|
sandro.lab
|
Iterable<String> extractedUrls = Iterables.transform(input, new UrlExtractor(xpath, xpathMetadataId, xpathOpenAccess, xpathEmbargoDate));
|
61 |
26600
|
sandro.lab
|
W3CEndpointReference eprUrls = resultSetFactory.createIterableResultSet(extractedUrls);
|
62 |
|
|
token.getEnv().setAttribute(getOutputEprParam(), eprUrls.toString());
|
63 |
|
|
return Arc.DEFAULT_ARC;
|
64 |
|
|
}
|
65 |
|
|
|
66 |
|
|
/**
|
67 |
|
|
* Gets the xpath.
|
68 |
31406
|
sandro.lab
|
*
|
69 |
26600
|
sandro.lab
|
* @return the xpath
|
70 |
|
|
*/
|
71 |
|
|
public String getXpath() {
|
72 |
|
|
return xpath;
|
73 |
|
|
}
|
74 |
|
|
|
75 |
|
|
/**
|
76 |
|
|
* Sets the xpath.
|
77 |
31406
|
sandro.lab
|
*
|
78 |
26600
|
sandro.lab
|
* @param xpath
|
79 |
|
|
* the xpath to set
|
80 |
|
|
*/
|
81 |
|
|
public void setXpath(final String xpath) {
|
82 |
|
|
this.xpath = xpath;
|
83 |
|
|
}
|
84 |
|
|
|
85 |
|
|
/**
|
86 |
|
|
* Gets the xpath metadata id.
|
87 |
31406
|
sandro.lab
|
*
|
88 |
26600
|
sandro.lab
|
* @return the xpathMetadataId
|
89 |
|
|
*/
|
90 |
|
|
public String getXpathMetadataId() {
|
91 |
|
|
return xpathMetadataId;
|
92 |
|
|
}
|
93 |
|
|
|
94 |
|
|
/**
|
95 |
|
|
* Sets the xpath metadata id.
|
96 |
31406
|
sandro.lab
|
*
|
97 |
26600
|
sandro.lab
|
* @param xpathMetadataId
|
98 |
|
|
* the xpathMetadataId to set
|
99 |
|
|
*/
|
100 |
|
|
@Required
|
101 |
|
|
public void setXpathMetadataId(final String xpathMetadataId) {
|
102 |
|
|
this.xpathMetadataId = xpathMetadataId;
|
103 |
|
|
}
|
104 |
|
|
|
105 |
|
|
/**
|
106 |
|
|
* Gets the result set client factory.
|
107 |
31406
|
sandro.lab
|
*
|
108 |
26600
|
sandro.lab
|
* @return the resultSetClientFactory
|
109 |
|
|
*/
|
110 |
|
|
public ResultSetClientFactory getResultSetClientFactory() {
|
111 |
|
|
return resultSetClientFactory;
|
112 |
|
|
}
|
113 |
|
|
|
114 |
|
|
/**
|
115 |
|
|
* Sets the result set client factory.
|
116 |
31406
|
sandro.lab
|
*
|
117 |
26600
|
sandro.lab
|
* @param resultSetClientFactory
|
118 |
|
|
* the resultSetClientFactory to set
|
119 |
|
|
*/
|
120 |
|
|
public void setResultSetClientFactory(final ResultSetClientFactory resultSetClientFactory) {
|
121 |
|
|
this.resultSetClientFactory = resultSetClientFactory;
|
122 |
|
|
}
|
123 |
|
|
|
124 |
|
|
/**
|
125 |
|
|
* Gets the result set factory.
|
126 |
31406
|
sandro.lab
|
*
|
127 |
26600
|
sandro.lab
|
* @return the resultSetFactory
|
128 |
|
|
*/
|
129 |
|
|
public IterableResultSetFactory getResultSetFactory() {
|
130 |
|
|
return resultSetFactory;
|
131 |
|
|
}
|
132 |
|
|
|
133 |
|
|
/**
|
134 |
|
|
* Sets the result set factory.
|
135 |
31406
|
sandro.lab
|
*
|
136 |
26600
|
sandro.lab
|
* @param resultSetFactory
|
137 |
|
|
* the resultSetFactory to set
|
138 |
|
|
*/
|
139 |
|
|
public void setResultSetFactory(final IterableResultSetFactory resultSetFactory) {
|
140 |
|
|
this.resultSetFactory = resultSetFactory;
|
141 |
|
|
}
|
142 |
|
|
|
143 |
|
|
/**
|
144 |
|
|
* Gets the output epr param.
|
145 |
31406
|
sandro.lab
|
*
|
146 |
26600
|
sandro.lab
|
* @return the outputEprParam
|
147 |
|
|
*/
|
148 |
|
|
public String getOutputEprParam() {
|
149 |
|
|
return outputEprParam;
|
150 |
|
|
}
|
151 |
|
|
|
152 |
|
|
/**
|
153 |
|
|
* Sets the output epr param.
|
154 |
31406
|
sandro.lab
|
*
|
155 |
26600
|
sandro.lab
|
* @param outputEprParam
|
156 |
|
|
* the outputEprParam to set
|
157 |
|
|
*/
|
158 |
|
|
public void setOutputEprParam(final String outputEprParam) {
|
159 |
|
|
this.outputEprParam = outputEprParam;
|
160 |
|
|
}
|
161 |
|
|
|
162 |
|
|
/**
|
163 |
31406
|
sandro.lab
|
* Gets the input epr param.
|
164 |
|
|
*
|
165 |
26600
|
sandro.lab
|
* @return the inputEprParam
|
166 |
|
|
*/
|
167 |
|
|
public String getInputEprParam() {
|
168 |
|
|
return inputEprParam;
|
169 |
|
|
}
|
170 |
|
|
|
171 |
|
|
/**
|
172 |
31406
|
sandro.lab
|
* Sets the input epr param.
|
173 |
|
|
*
|
174 |
26600
|
sandro.lab
|
* @param inputEprParam
|
175 |
|
|
* the inputEprParam to set
|
176 |
|
|
*/
|
177 |
|
|
public void setInputEprParam(final String inputEprParam) {
|
178 |
|
|
this.inputEprParam = inputEprParam;
|
179 |
|
|
}
|
180 |
|
|
|
181 |
31406
|
sandro.lab
|
/**
|
182 |
|
|
* Gets the xpath open access.
|
183 |
|
|
*
|
184 |
|
|
* @return the xpath open access
|
185 |
|
|
*/
|
186 |
|
|
public String getXpathOpenAccess() {
|
187 |
|
|
return xpathOpenAccess;
|
188 |
|
|
}
|
189 |
|
|
|
190 |
|
|
/**
|
191 |
|
|
* Sets the xpath open access.
|
192 |
|
|
*
|
193 |
|
|
* @param xpathOpenAccess
|
194 |
|
|
* the new xpath open access
|
195 |
|
|
*/
|
196 |
|
|
public void setXpathOpenAccess(final String xpathOpenAccess) {
|
197 |
|
|
this.xpathOpenAccess = xpathOpenAccess;
|
198 |
|
|
}
|
199 |
|
|
|
200 |
|
|
/**
|
201 |
|
|
* Gets the xpath embargo date.
|
202 |
|
|
*
|
203 |
|
|
* @return the xpath embargo date
|
204 |
|
|
*/
|
205 |
|
|
public String getXpathEmbargoDate() {
|
206 |
|
|
return xpathEmbargoDate;
|
207 |
|
|
}
|
208 |
|
|
|
209 |
|
|
/**
|
210 |
|
|
* Sets the xpath embargo date.
|
211 |
|
|
*
|
212 |
|
|
* @param xpathEmbargoDate
|
213 |
|
|
* the new xpath embargo date
|
214 |
|
|
*/
|
215 |
|
|
public void setXpathEmbargoDate(final String xpathEmbargoDate) {
|
216 |
|
|
this.xpathEmbargoDate = xpathEmbargoDate;
|
217 |
|
|
}
|
218 |
|
|
|
219 |
26600
|
sandro.lab
|
}
|