1 |
26600
|
sandro.lab
|
package eu.dnetlib.msro.openaireplus.workflows.nodes;
|
2 |
|
|
|
3 |
45335
|
claudio.at
|
import java.util.stream.Collectors;
|
4 |
26600
|
sandro.lab
|
import javax.xml.ws.wsaddressing.W3CEndpointReference;
|
5 |
|
|
|
6 |
45335
|
claudio.at
|
import com.googlecode.sarasvati.NodeToken;
|
7 |
|
|
import eu.dnetlib.enabling.database.rmi.DatabaseService;
|
8 |
|
|
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
|
9 |
|
|
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
|
10 |
|
|
import eu.dnetlib.enabling.resultset.IterableResultSetFactory;
|
11 |
|
|
import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
|
12 |
|
|
import eu.dnetlib.miscutils.functional.xml.ApplyXslt;
|
13 |
|
|
import eu.dnetlib.msro.workflows.nodes.BlackboardJobNode;
|
14 |
26600
|
sandro.lab
|
import org.apache.commons.io.IOUtils;
|
15 |
45335
|
claudio.at
|
import org.springframework.beans.factory.annotation.Autowired;
|
16 |
26600
|
sandro.lab
|
import org.springframework.beans.factory.annotation.Required;
|
17 |
45335
|
claudio.at
|
import org.springframework.core.io.ClassPathResource;
|
18 |
26600
|
sandro.lab
|
import org.springframework.core.io.Resource;
|
19 |
|
|
|
20 |
45335
|
claudio.at
|
public class UpdateVocabularyEntriesJobNode extends BlackboardJobNode {
|
21 |
26600
|
sandro.lab
|
|
22 |
45335
|
claudio.at
|
@Autowired
|
23 |
|
|
private UniqueServiceLocator serviceLocator;
|
24 |
26600
|
sandro.lab
|
|
25 |
45335
|
claudio.at
|
@Autowired
|
26 |
|
|
private IterableResultSetFactory resultSetFactory;
|
27 |
26600
|
sandro.lab
|
|
28 |
45335
|
claudio.at
|
private Resource xquery;
|
29 |
26600
|
sandro.lab
|
|
30 |
45335
|
claudio.at
|
private String xsltClasspath;
|
31 |
26600
|
sandro.lab
|
|
32 |
45335
|
claudio.at
|
private String db;
|
33 |
26600
|
sandro.lab
|
|
34 |
|
|
@Override
|
35 |
45335
|
claudio.at
|
protected String obtainServiceId(final NodeToken token) {
|
36 |
|
|
return getServiceLocator().getServiceId(DatabaseService.class);
|
37 |
26600
|
sandro.lab
|
}
|
38 |
|
|
|
39 |
45335
|
claudio.at
|
@Override
|
40 |
|
|
protected void prepareJob(final BlackboardJob job, final NodeToken token) throws Exception {
|
41 |
26600
|
sandro.lab
|
|
42 |
45335
|
claudio.at
|
final ApplyXslt t = new ApplyXslt(new ClassPathResource(xsltClasspath));
|
43 |
|
|
|
44 |
|
|
final W3CEndpointReference epr =
|
45 |
|
|
resultSetFactory.createIterableResultSet(
|
46 |
|
|
serviceLocator.getService(ISLookUpService.class).quickSearchProfile(IOUtils.toString(getXquery().getInputStream()))
|
47 |
|
|
.stream().map(t::evaluate).collect(Collectors.toList()));
|
48 |
|
|
|
49 |
|
|
job.setAction("IMPORT");
|
50 |
|
|
job.getParameters().put("db", db);
|
51 |
|
|
job.getParameters().put("epr", epr.toString());
|
52 |
26600
|
sandro.lab
|
}
|
53 |
|
|
|
54 |
|
|
public Resource getXquery() {
|
55 |
|
|
return xquery;
|
56 |
|
|
}
|
57 |
|
|
|
58 |
|
|
@Required
|
59 |
|
|
public void setXquery(final Resource xquery) {
|
60 |
|
|
this.xquery = xquery;
|
61 |
|
|
}
|
62 |
|
|
|
63 |
45335
|
claudio.at
|
public String getXsltClasspath() {
|
64 |
|
|
return xsltClasspath;
|
65 |
|
|
}
|
66 |
|
|
|
67 |
|
|
public void setXsltClasspath(final String xsltClasspath) {
|
68 |
|
|
this.xsltClasspath = xsltClasspath;
|
69 |
|
|
}
|
70 |
|
|
|
71 |
|
|
public String getDb() {
|
72 |
|
|
return db;
|
73 |
|
|
}
|
74 |
|
|
|
75 |
|
|
public void setDb(final String db) {
|
76 |
|
|
this.db = db;
|
77 |
|
|
}
|
78 |
|
|
|
79 |
26600
|
sandro.lab
|
}
|