1 |
45395
|
michele.ar
|
package eu.dnetlib.msro.workers.aggregation.collect;
|
2 |
|
|
|
3 |
|
|
import java.io.StringReader;
|
4 |
|
|
import java.util.stream.Stream;
|
5 |
|
|
|
6 |
45576
|
michele.ar
|
import eu.dnetlib.clients.is.InformationServiceClient;
|
7 |
45395
|
michele.ar
|
import eu.dnetlib.msro.annotations.Direction;
|
8 |
|
|
import eu.dnetlib.msro.annotations.EnvParam;
|
9 |
|
|
import eu.dnetlib.msro.annotations.ProcessNode;
|
10 |
45576
|
michele.ar
|
import eu.dnetlib.msro.workers.aggregation.objects.InterfaceDescriptor;
|
11 |
45395
|
michele.ar
|
import eu.dnetlib.msro.workflows.graph.Arc;
|
12 |
|
|
import eu.dnetlib.msro.workflows.nodes.AbstractProcessNode;
|
13 |
46349
|
claudio.at
|
import org.dom4j.Document;
|
14 |
|
|
import org.dom4j.Node;
|
15 |
|
|
import org.dom4j.io.SAXReader;
|
16 |
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
17 |
|
|
import org.springframework.context.annotation.Scope;
|
18 |
|
|
import org.springframework.stereotype.Component;
|
19 |
45395
|
michele.ar
|
|
20 |
|
|
@Component
|
21 |
|
|
@Scope("prototype")
|
22 |
|
|
@ProcessNode("Collect")
|
23 |
|
|
public class CollectJobNode extends AbstractProcessNode {
|
24 |
|
|
|
25 |
|
|
@Autowired
|
26 |
45576
|
michele.ar
|
private InformationServiceClient isLookup;
|
27 |
45395
|
michele.ar
|
|
28 |
|
|
@Autowired
|
29 |
|
|
private MetadataCollector collector;
|
30 |
|
|
|
31 |
|
|
private String datasourceId;
|
32 |
|
|
private String datasourceInterface;
|
33 |
|
|
|
34 |
|
|
@EnvParam(value = "eprParam", direction = Direction.OUT, reference = true)
|
35 |
|
|
private Stream<String> outputStream;
|
36 |
|
|
|
37 |
|
|
@Override
|
38 |
|
|
protected String execute() throws Exception {
|
39 |
45576
|
michele.ar
|
final String profile = isLookup.getProfile(datasourceId);
|
40 |
45395
|
michele.ar
|
final Document doc = new SAXReader().read(new StringReader(profile));
|
41 |
|
|
final Node ifcNode = doc.selectSingleNode("//INTERFACE[@id='" + datasourceInterface + "']");
|
42 |
|
|
|
43 |
|
|
final InterfaceDescriptor interfaceDescriptor = InterfaceDescriptor.newInstance(ifcNode);
|
44 |
|
|
|
45 |
|
|
outputStream = collector.collect(interfaceDescriptor);
|
46 |
|
|
|
47 |
|
|
return Arc.DEFAULT_ARC;
|
48 |
|
|
}
|
49 |
|
|
|
50 |
|
|
public String getDatasourceId() {
|
51 |
|
|
return datasourceId;
|
52 |
|
|
}
|
53 |
|
|
|
54 |
|
|
public void setDatasourceId(final String datasourceId) {
|
55 |
|
|
this.datasourceId = datasourceId;
|
56 |
|
|
}
|
57 |
|
|
|
58 |
|
|
public String getDatasourceInterface() {
|
59 |
|
|
return datasourceInterface;
|
60 |
|
|
}
|
61 |
|
|
|
62 |
|
|
public void setDatasourceInterface(final String datasourceInterface) {
|
63 |
|
|
this.datasourceInterface = datasourceInterface;
|
64 |
|
|
}
|
65 |
|
|
|
66 |
|
|
public Stream<String> getOutputStream() {
|
67 |
|
|
return outputStream;
|
68 |
|
|
}
|
69 |
|
|
|
70 |
|
|
public void setOutputStream(final Stream<String> outputStream) {
|
71 |
|
|
this.outputStream = outputStream;
|
72 |
|
|
}
|
73 |
|
|
|
74 |
|
|
}
|