1
|
package eu.dnetlib.msro.workflows.nodes;
|
2
|
|
3
|
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
|
4
|
import eu.dnetlib.enabling.resultset.factory.ResultSetFactory;
|
5
|
import eu.dnetlib.miscutils.functional.xml.ApplyXslt;
|
6
|
import eu.dnetlib.msro.workflows.graph.Arc;
|
7
|
import eu.dnetlib.msro.workflows.procs.Env;
|
8
|
import eu.dnetlib.rmi.common.ResultSet;
|
9
|
import eu.dnetlib.rmi.data.DatabaseService;
|
10
|
import org.antlr.stringtemplate.StringTemplate;
|
11
|
import org.apache.commons.io.IOUtils;
|
12
|
import org.apache.commons.logging.Log;
|
13
|
import org.apache.commons.logging.LogFactory;
|
14
|
import org.springframework.beans.factory.annotation.Autowired;
|
15
|
import org.springframework.core.io.ClassPathResource;
|
16
|
import org.springframework.core.io.Resource;
|
17
|
|
18
|
public class FindComplianceRepositoriesJobNode extends SimpleJobNode {
|
19
|
|
20
|
private static final Log log = LogFactory.getLog(FindComplianceRepositoriesJobNode.class); // NOPMD by marko on 11/24/08 5:02 PM
|
21
|
// The following files are in "dnet-openaireplus-datasource-manager-service" module
|
22
|
private final Resource sqlSelectDatasourcesTmpl = new ClassPathResource("/eu/dnetlib/enabling/datasources/getDatasources.sql.st");
|
23
|
private final Resource xsltFile = new ClassPathResource("/eu/dnetlib/enabling/datasources/repo_2_is.xslt");
|
24
|
private String dbName;
|
25
|
private String eprParam = "repoEpr";
|
26
|
@Autowired
|
27
|
private UniqueServiceLocator serviceLocator;
|
28
|
@Autowired
|
29
|
private ResultSetFactory resultSetFactory;
|
30
|
|
31
|
@Override
|
32
|
protected String execute(final Env env) throws Exception {
|
33
|
final StringTemplate st = new StringTemplate(IOUtils.toString(this.sqlSelectDatasourcesTmpl.getInputStream()));
|
34
|
// st.setAttribute(
|
35
|
// "condition",
|
36
|
// "datasourceclass = 'entityregistry' OR (openairecompatibilityclass IS NOT null AND openairecompatibilityclass != 'UNKNOWN' AND
|
37
|
// openairecompatibilityclass != 'notCompatible')");
|
38
|
final String sql = st.toString();
|
39
|
|
40
|
log.debug("Executing query: " + sql);
|
41
|
|
42
|
final ResultSet<String> rs = this.serviceLocator.getService(DatabaseService.class).searchSQL(this.dbName, sql);
|
43
|
final ResultSet<String> mapped = this.resultSetFactory.map(rs, String.class, new ApplyXslt(this.xsltFile));
|
44
|
|
45
|
env.setAttribute(getEprParam(), mapped);
|
46
|
|
47
|
return Arc.DEFAULT_ARC;
|
48
|
}
|
49
|
|
50
|
public String getDbName() {
|
51
|
return this.dbName;
|
52
|
}
|
53
|
|
54
|
public void setDbName(final String dbName) {
|
55
|
this.dbName = dbName;
|
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
|
}
|