1
|
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
|
/** The xpath open access. */
|
38
|
private String xpathOpenAccess;
|
39
|
|
40
|
/** The xpath embargo date. */
|
41
|
private String xpathEmbargoDate;
|
42
|
|
43
|
/** 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
|
*
|
54
|
* @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
|
Iterable<String> extractedUrls = Iterables.transform(input, new UrlExtractor(xpath, xpathMetadataId, xpathOpenAccess, xpathEmbargoDate));
|
61
|
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
|
*
|
69
|
* @return the xpath
|
70
|
*/
|
71
|
public String getXpath() {
|
72
|
return xpath;
|
73
|
}
|
74
|
|
75
|
/**
|
76
|
* Sets the xpath.
|
77
|
*
|
78
|
* @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
|
*
|
88
|
* @return the xpathMetadataId
|
89
|
*/
|
90
|
public String getXpathMetadataId() {
|
91
|
return xpathMetadataId;
|
92
|
}
|
93
|
|
94
|
/**
|
95
|
* Sets the xpath metadata id.
|
96
|
*
|
97
|
* @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
|
*
|
108
|
* @return the resultSetClientFactory
|
109
|
*/
|
110
|
public ResultSetClientFactory getResultSetClientFactory() {
|
111
|
return resultSetClientFactory;
|
112
|
}
|
113
|
|
114
|
/**
|
115
|
* Sets the result set client factory.
|
116
|
*
|
117
|
* @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
|
*
|
127
|
* @return the resultSetFactory
|
128
|
*/
|
129
|
public IterableResultSetFactory getResultSetFactory() {
|
130
|
return resultSetFactory;
|
131
|
}
|
132
|
|
133
|
/**
|
134
|
* Sets the result set factory.
|
135
|
*
|
136
|
* @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
|
*
|
146
|
* @return the outputEprParam
|
147
|
*/
|
148
|
public String getOutputEprParam() {
|
149
|
return outputEprParam;
|
150
|
}
|
151
|
|
152
|
/**
|
153
|
* Sets the output epr param.
|
154
|
*
|
155
|
* @param outputEprParam
|
156
|
* the outputEprParam to set
|
157
|
*/
|
158
|
public void setOutputEprParam(final String outputEprParam) {
|
159
|
this.outputEprParam = outputEprParam;
|
160
|
}
|
161
|
|
162
|
/**
|
163
|
* Gets the input epr param.
|
164
|
*
|
165
|
* @return the inputEprParam
|
166
|
*/
|
167
|
public String getInputEprParam() {
|
168
|
return inputEprParam;
|
169
|
}
|
170
|
|
171
|
/**
|
172
|
* Sets the input epr param.
|
173
|
*
|
174
|
* @param inputEprParam
|
175
|
* the inputEprParam to set
|
176
|
*/
|
177
|
public void setInputEprParam(final String inputEprParam) {
|
178
|
this.inputEprParam = inputEprParam;
|
179
|
}
|
180
|
|
181
|
/**
|
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
|
}
|