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 org.dom4j.Document;
|
14
|
import org.dom4j.Node;
|
15
|
import org.dom4j.io.SAXReader;
|
16
|
import org.springframework.beans.factory.annotation.Autowired;
|
17
|
|
18
|
public class CollectRecordsJobNode extends SimpleJobNode {
|
19
|
|
20
|
@Autowired
|
21
|
private UniqueServiceLocator serviceLocator;
|
22
|
|
23
|
private String datasourceId;
|
24
|
private String datasourceInterface;
|
25
|
private String eprParam;
|
26
|
|
27
|
@Override
|
28
|
protected String execute(final Env env) throws Exception {
|
29
|
final String profile = this.serviceLocator.getService(ISLookUpService.class).getResourceProfile(this.datasourceId);
|
30
|
final Document doc = new SAXReader().read(new StringReader(profile));
|
31
|
final Node ifcNode = doc.selectSingleNode("//INTERFACE[@id='" + this.datasourceInterface + "']");
|
32
|
|
33
|
final InterfaceDescriptor interfaceDescriptor = InterfaceDescriptor.newInstance(ifcNode);
|
34
|
|
35
|
final ResultSet<String> rs = this.serviceLocator.getService(CollectorService.class).collect(interfaceDescriptor);
|
36
|
|
37
|
env.setAttribute(getEprParam(), rs);
|
38
|
|
39
|
return Arc.DEFAULT_ARC;
|
40
|
}
|
41
|
|
42
|
public String getDatasourceId() {
|
43
|
return this.datasourceId;
|
44
|
}
|
45
|
|
46
|
public void setDatasourceId(final String datasourceId) {
|
47
|
this.datasourceId = datasourceId;
|
48
|
}
|
49
|
|
50
|
public String getDatasourceInterface() {
|
51
|
return this.datasourceInterface;
|
52
|
}
|
53
|
|
54
|
public void setDatasourceInterface(final String datasourceInterface) {
|
55
|
this.datasourceInterface = datasourceInterface;
|
56
|
}
|
57
|
|
58
|
public String getEprParam() {
|
59
|
return this.eprParam;
|
60
|
}
|
61
|
|
62
|
public void setEprParam(final String eprParam) {
|
63
|
this.eprParam = eprParam;
|
64
|
}
|
65
|
|
66
|
}
|