1
|
package eu.dnetlib.msro.workflows.nodes.collect;
|
2
|
|
3
|
import java.io.StringReader;
|
4
|
|
5
|
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
|
6
|
import eu.dnetlib.msro.workflows.graph.Arc;
|
7
|
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode;
|
8
|
import eu.dnetlib.msro.workflows.procs.Env;
|
9
|
import eu.dnetlib.rmi.common.ResultSet;
|
10
|
import eu.dnetlib.rmi.data.CollectorService;
|
11
|
import eu.dnetlib.rmi.data.InterfaceDescriptor;
|
12
|
import eu.dnetlib.rmi.enabling.ISLookUpService;
|
13
|
import jdk.nashorn.api.scripting.ScriptUtils;
|
14
|
import org.apache.commons.lang3.StringUtils;
|
15
|
import org.dom4j.Document;
|
16
|
import org.dom4j.Node;
|
17
|
import org.dom4j.io.SAXReader;
|
18
|
import org.springframework.beans.factory.annotation.Autowired;
|
19
|
|
20
|
public class DateRangeCollectRecordsJobNode extends SimpleJobNode {
|
21
|
|
22
|
@Autowired
|
23
|
private UniqueServiceLocator serviceLocator;
|
24
|
|
25
|
private String datasourceId;
|
26
|
private String datasourceInterface;
|
27
|
private String eprParam;
|
28
|
private String fromDateParam;
|
29
|
private String untilDateParam;
|
30
|
private String from;
|
31
|
private String until;
|
32
|
|
33
|
@Override
|
34
|
protected String execute(final Env env) throws Exception {
|
35
|
final String profile = this.serviceLocator.getService(ISLookUpService.class).getResourceProfile(this.datasourceId);
|
36
|
final Document doc = new SAXReader().read(new StringReader(profile));
|
37
|
final Node ifcNode = doc.selectSingleNode("//INTERFACE[@id='" + this.datasourceInterface + "']");
|
38
|
|
39
|
final String fromDate = StringUtils.isNoneBlank(from) ? from : env.getAttribute(getFromDateParam(), String.class);
|
40
|
final String untilDate = StringUtils.isNoneBlank(until) ? until : env.getAttribute(getUntilDateParam(), String.class);
|
41
|
|
42
|
final InterfaceDescriptor interfaceDescriptor = InterfaceDescriptor.newInstance(ifcNode);
|
43
|
|
44
|
final ResultSet<String> rs = this.serviceLocator.getService(CollectorService.class).dateRangeCollect(interfaceDescriptor, fromDate, untilDate);
|
45
|
|
46
|
env.setAttribute(getEprParam(), rs);
|
47
|
|
48
|
return Arc.DEFAULT_ARC;
|
49
|
}
|
50
|
|
51
|
public String getFromDateParam() {
|
52
|
return this.fromDateParam;
|
53
|
}
|
54
|
|
55
|
public void setFromDateParam(final String fromDateParam) {
|
56
|
this.fromDateParam = fromDateParam;
|
57
|
}
|
58
|
|
59
|
public String getUntilDateParam() {
|
60
|
return this.untilDateParam;
|
61
|
}
|
62
|
|
63
|
public void setUntilDateParam(final String untilDateParam) {
|
64
|
this.untilDateParam = untilDateParam;
|
65
|
}
|
66
|
|
67
|
public String getDatasourceId() {
|
68
|
return this.datasourceId;
|
69
|
}
|
70
|
|
71
|
public void setDatasourceId(final String datasourceId) {
|
72
|
this.datasourceId = datasourceId;
|
73
|
}
|
74
|
|
75
|
public String getDatasourceInterface() {
|
76
|
return this.datasourceInterface;
|
77
|
}
|
78
|
|
79
|
public void setDatasourceInterface(final String datasourceInterface) {
|
80
|
this.datasourceInterface = datasourceInterface;
|
81
|
}
|
82
|
|
83
|
public String getEprParam() {
|
84
|
return this.eprParam;
|
85
|
}
|
86
|
|
87
|
public void setEprParam(final String eprParam) {
|
88
|
this.eprParam = eprParam;
|
89
|
}
|
90
|
|
91
|
public String getFrom() {
|
92
|
return from;
|
93
|
}
|
94
|
|
95
|
public void setFrom(String from) {
|
96
|
this.from = from;
|
97
|
}
|
98
|
|
99
|
public String getUntil() {
|
100
|
return until;
|
101
|
}
|
102
|
|
103
|
public void setUntil(String until) {
|
104
|
this.until = until;
|
105
|
}
|
106
|
}
|