1
|
package eu.dnetlib.msro.workflows.nodes.objectStore;
|
2
|
|
3
|
import java.util.function.Function;
|
4
|
import java.util.stream.StreamSupport;
|
5
|
|
6
|
import org.springframework.beans.factory.annotation.Autowired;
|
7
|
import org.springframework.beans.factory.annotation.Required;
|
8
|
|
9
|
import eu.dnetlib.enabling.resultset.client.ResultSetClient;
|
10
|
import eu.dnetlib.enabling.resultset.factory.ResultSetFactory;
|
11
|
import eu.dnetlib.msro.workflows.graph.Arc;
|
12
|
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode;
|
13
|
import eu.dnetlib.msro.workflows.nodes.download.UrlExtractor;
|
14
|
import eu.dnetlib.msro.workflows.procs.Env;
|
15
|
import eu.dnetlib.rmi.common.ResultSet;
|
16
|
|
17
|
// TODO: Auto-generated Javadoc
|
18
|
|
19
|
/**
|
20
|
* The Class RetrieveURLSJobNode.
|
21
|
*/
|
22
|
public class RetrieveURLSJobNode extends SimpleJobNode {
|
23
|
|
24
|
/**
|
25
|
* The epr param.
|
26
|
*/
|
27
|
private String inputEprParam;
|
28
|
|
29
|
/**
|
30
|
* The output epr param.
|
31
|
*/
|
32
|
private String outputEprParam;
|
33
|
|
34
|
/**
|
35
|
* The xpath.
|
36
|
*/
|
37
|
private String xpath;
|
38
|
|
39
|
/**
|
40
|
* The xpath metadata id.
|
41
|
*/
|
42
|
private String xpathMetadataId;
|
43
|
|
44
|
/**
|
45
|
* The xpath open access.
|
46
|
*/
|
47
|
private String xpathOpenAccess;
|
48
|
|
49
|
/**
|
50
|
* The xpath embargo date.
|
51
|
*/
|
52
|
private String xpathEmbargoDate;
|
53
|
|
54
|
/**
|
55
|
* The result set factory.
|
56
|
*/
|
57
|
@Autowired
|
58
|
private ResultSetFactory resultSetFactory;
|
59
|
@Autowired
|
60
|
private ResultSetClient resultSetClient;
|
61
|
|
62
|
@Override
|
63
|
protected String execute(final Env env) throws Exception {
|
64
|
final ResultSet<?> rsIn = env.getAttribute(this.inputEprParam, ResultSet.class);
|
65
|
final Iterable<String> input = this.resultSetClient.iter(rsIn, String.class);
|
66
|
|
67
|
final Function<String, String> mapper = new UrlExtractor(this.xpath, this.xpathMetadataId, this.xpathOpenAccess, this.xpathEmbargoDate);
|
68
|
|
69
|
final ResultSet<String> rsUrls = this.resultSetFactory.createResultSet(() -> StreamSupport.stream(input.spliterator(), false).map(mapper).iterator());;
|
70
|
|
71
|
env.setAttribute(getOutputEprParam(), rsUrls);
|
72
|
|
73
|
return Arc.DEFAULT_ARC;
|
74
|
}
|
75
|
|
76
|
/**
|
77
|
* Gets the xpath.
|
78
|
*
|
79
|
* @return the xpath
|
80
|
*/
|
81
|
public String getXpath() {
|
82
|
return this.xpath;
|
83
|
}
|
84
|
|
85
|
/**
|
86
|
* Sets the xpath.
|
87
|
*
|
88
|
* @param xpath
|
89
|
* the xpath to set
|
90
|
*/
|
91
|
public void setXpath(final String xpath) {
|
92
|
this.xpath = xpath;
|
93
|
}
|
94
|
|
95
|
/**
|
96
|
* Gets the xpath metadata id.
|
97
|
*
|
98
|
* @return the xpathMetadataId
|
99
|
*/
|
100
|
public String getXpathMetadataId() {
|
101
|
return this.xpathMetadataId;
|
102
|
}
|
103
|
|
104
|
/**
|
105
|
* Sets the xpath metadata id.
|
106
|
*
|
107
|
* @param xpathMetadataId
|
108
|
* the xpathMetadataId to set
|
109
|
*/
|
110
|
@Required
|
111
|
public void setXpathMetadataId(final String xpathMetadataId) {
|
112
|
this.xpathMetadataId = xpathMetadataId;
|
113
|
}
|
114
|
|
115
|
/**
|
116
|
* Gets the output epr param.
|
117
|
*
|
118
|
* @return the outputEprParam
|
119
|
*/
|
120
|
public String getOutputEprParam() {
|
121
|
return this.outputEprParam;
|
122
|
}
|
123
|
|
124
|
/**
|
125
|
* Sets the output epr param.
|
126
|
*
|
127
|
* @param outputEprParam
|
128
|
* the outputEprParam to set
|
129
|
*/
|
130
|
public void setOutputEprParam(final String outputEprParam) {
|
131
|
this.outputEprParam = outputEprParam;
|
132
|
}
|
133
|
|
134
|
/**
|
135
|
* Gets the input epr param.
|
136
|
*
|
137
|
* @return the inputEprParam
|
138
|
*/
|
139
|
public String getInputEprParam() {
|
140
|
return this.inputEprParam;
|
141
|
}
|
142
|
|
143
|
/**
|
144
|
* Sets the input epr param.
|
145
|
*
|
146
|
* @param inputEprParam
|
147
|
* the inputEprParam to set
|
148
|
*/
|
149
|
public void setInputEprParam(final String inputEprParam) {
|
150
|
this.inputEprParam = inputEprParam;
|
151
|
}
|
152
|
|
153
|
/**
|
154
|
* Gets the xpath open access.
|
155
|
*
|
156
|
* @return the xpath open access
|
157
|
*/
|
158
|
public String getXpathOpenAccess() {
|
159
|
return this.xpathOpenAccess;
|
160
|
}
|
161
|
|
162
|
/**
|
163
|
* Sets the xpath open access.
|
164
|
*
|
165
|
* @param xpathOpenAccess
|
166
|
* the new xpath open access
|
167
|
*/
|
168
|
public void setXpathOpenAccess(final String xpathOpenAccess) {
|
169
|
this.xpathOpenAccess = xpathOpenAccess;
|
170
|
}
|
171
|
|
172
|
/**
|
173
|
* Gets the xpath embargo date.
|
174
|
*
|
175
|
* @return the xpath embargo date
|
176
|
*/
|
177
|
public String getXpathEmbargoDate() {
|
178
|
return this.xpathEmbargoDate;
|
179
|
}
|
180
|
|
181
|
/**
|
182
|
* Sets the xpath embargo date.
|
183
|
*
|
184
|
* @param xpathEmbargoDate
|
185
|
* the new xpath embargo date
|
186
|
*/
|
187
|
public void setXpathEmbargoDate(final String xpathEmbargoDate) {
|
188
|
this.xpathEmbargoDate = xpathEmbargoDate;
|
189
|
}
|
190
|
|
191
|
}
|