1
|
package eu.dnetlib.msro.openaireplus.workflows.nodes;
|
2
|
|
3
|
import javax.xml.ws.wsaddressing.W3CEndpointReference;
|
4
|
|
5
|
import com.googlecode.sarasvati.Arc;
|
6
|
import com.googlecode.sarasvati.NodeToken;
|
7
|
import eu.dnetlib.enabling.database.rmi.DatabaseService;
|
8
|
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
|
9
|
import eu.dnetlib.enabling.resultset.XSLTMappedResultSetFactory;
|
10
|
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode;
|
11
|
import org.antlr.stringtemplate.StringTemplate;
|
12
|
import org.apache.commons.io.IOUtils;
|
13
|
import org.apache.commons.logging.Log;
|
14
|
import org.apache.commons.logging.LogFactory;
|
15
|
import org.springframework.core.io.ClassPathResource;
|
16
|
import org.springframework.core.io.Resource;
|
17
|
|
18
|
public class FindComplianceRepositoriesJobNode extends SimpleJobNode {
|
19
|
|
20
|
private String dbName;
|
21
|
|
22
|
// The following files are in "dnet-openaireplus-datasource-manager-service" module
|
23
|
private final Resource sqlSelectDatasourcesTmpl = new ClassPathResource("/eu/dnetlib/enabling/datasources/getDatasources.sql.st");
|
24
|
private final Resource xsltFile = new ClassPathResource("/eu/dnetlib/enabling/datasources/repo_2_is.xslt");
|
25
|
|
26
|
private String eprParam = "repoEpr";
|
27
|
|
28
|
@javax.annotation.Resource
|
29
|
private UniqueServiceLocator serviceLocator;
|
30
|
|
31
|
private XSLTMappedResultSetFactory xsltMappedResultSetFactory;
|
32
|
|
33
|
private static final Log log = LogFactory.getLog(FindComplianceRepositoriesJobNode.class); // NOPMD by marko on 11/24/08 5:02 PM
|
34
|
|
35
|
@Override
|
36
|
protected String execute(final NodeToken token) throws Exception {
|
37
|
final StringTemplate st = new StringTemplate(IOUtils.toString(sqlSelectDatasourcesTmpl.getInputStream()));
|
38
|
// st.setAttribute(
|
39
|
// "condition",
|
40
|
// "datasourceclass = 'entityregistry' OR (openairecompatibilityclass IS NOT null AND openairecompatibilityclass != 'UNKNOWN' AND openairecompatibilityclass != 'notCompatible')");
|
41
|
final String sql = st.toString();
|
42
|
final String xslt = IOUtils.toString(xsltFile.getInputStream());
|
43
|
|
44
|
log.debug("Executing query: " + sql);
|
45
|
|
46
|
final W3CEndpointReference epr = serviceLocator.getService(DatabaseService.class).searchSQL(dbName, sql);
|
47
|
final W3CEndpointReference mapped = xsltMappedResultSetFactory.createMappedResultSet(epr, xslt);
|
48
|
|
49
|
token.getEnv().setTransientAttribute(getEprParam(), mapped);
|
50
|
|
51
|
return Arc.DEFAULT_ARC;
|
52
|
}
|
53
|
|
54
|
public String getDbName() {
|
55
|
return dbName;
|
56
|
}
|
57
|
|
58
|
public void setDbName(final String dbName) {
|
59
|
this.dbName = dbName;
|
60
|
}
|
61
|
|
62
|
public XSLTMappedResultSetFactory getXsltMappedResultSetFactory() {
|
63
|
return xsltMappedResultSetFactory;
|
64
|
}
|
65
|
|
66
|
public void setXsltMappedResultSetFactory(final XSLTMappedResultSetFactory xsltMappedResultSetFactory) {
|
67
|
this.xsltMappedResultSetFactory = xsltMappedResultSetFactory;
|
68
|
}
|
69
|
|
70
|
public String getEprParam() {
|
71
|
return eprParam;
|
72
|
}
|
73
|
|
74
|
public void setEprParam(final String eprParam) {
|
75
|
this.eprParam = eprParam;
|
76
|
}
|
77
|
|
78
|
}
|