1 |
42186
|
michele.ar
|
package eu.dnetlib.msro.workflows.nodes.oai;
|
2 |
|
|
|
3 |
|
|
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
|
4 |
|
|
import eu.dnetlib.msro.workflows.graph.Arc;
|
5 |
|
|
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode;
|
6 |
|
|
import eu.dnetlib.msro.workflows.procs.Env;
|
7 |
|
|
import eu.dnetlib.rmi.enabling.ISRegistryService;
|
8 |
42621
|
sandro.lab
|
import org.apache.commons.lang3.StringUtils;
|
9 |
|
|
import org.apache.commons.logging.Log;
|
10 |
|
|
import org.apache.commons.logging.LogFactory;
|
11 |
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
12 |
42186
|
michele.ar
|
|
13 |
|
|
/**
|
14 |
|
|
* The Class PrepareOaiDataJobNode.
|
15 |
|
|
*/
|
16 |
|
|
public class SetCurrentOAIDBJobNode extends SimpleJobNode {
|
17 |
|
|
|
18 |
|
|
/** The Constant log. */
|
19 |
|
|
private static final Log log = LogFactory.getLog(SetCurrentOAIDBJobNode.class); // NOPMD by marko on 11/24/08 5:02 PM
|
20 |
|
|
|
21 |
|
|
/** The service locator. */
|
22 |
42621
|
sandro.lab
|
@Autowired
|
23 |
42186
|
michele.ar
|
private UniqueServiceLocator serviceLocator;
|
24 |
|
|
|
25 |
|
|
/** Target mongo database name. **/
|
26 |
|
|
private String oaiDBName;
|
27 |
|
|
/** Name of the env property where to put the value of oaiDBName. **/
|
28 |
|
|
private String oaiDBNameParam;
|
29 |
|
|
|
30 |
|
|
private String xpathToCurrentDB = "//RESOURCE_PROFILE[.//RESOURCE_TYPE/@value = 'OAIPublisherConfigurationDSResourceType']//CONFIGURATION/CURRENTDB";
|
31 |
|
|
|
32 |
|
|
protected String getTheDBName(final Env env) {
|
33 |
|
|
if (StringUtils.isNotBlank(this.oaiDBName)) {
|
34 |
|
|
return this.oaiDBName;
|
35 |
|
|
} else {
|
36 |
|
|
return env.getAttribute(this.oaiDBNameParam, String.class);
|
37 |
|
|
}
|
38 |
|
|
}
|
39 |
|
|
|
40 |
|
|
/*
|
41 |
|
|
* (non-Javadoc)
|
42 |
|
|
*
|
43 |
|
|
* @see eu.dnetlib.msro.workflows.nodes.SimpleJobNode#execute(com.googlecode.sarasvati.NodeToken)
|
44 |
|
|
*/
|
45 |
|
|
@Override
|
46 |
|
|
protected String execute(final Env env) throws Exception {
|
47 |
|
|
final String dbToSet = getTheDBName(env);
|
48 |
|
|
log.fatal("Setting OAI Publisher to use db " + dbToSet);
|
49 |
|
|
final String xUpdate = "update value " + this.xpathToCurrentDB + " with '" + dbToSet + "'";
|
50 |
|
|
this.serviceLocator.getService(ISRegistryService.class).executeXUpdate(xUpdate);
|
51 |
|
|
return Arc.DEFAULT_ARC;
|
52 |
|
|
}
|
53 |
|
|
|
54 |
|
|
public String getOaiDBName() {
|
55 |
|
|
return this.oaiDBName;
|
56 |
|
|
}
|
57 |
|
|
|
58 |
|
|
public void setOaiDBName(final String oaiDBName) {
|
59 |
|
|
this.oaiDBName = oaiDBName;
|
60 |
|
|
}
|
61 |
|
|
|
62 |
|
|
public String getOaiDBNameParam() {
|
63 |
|
|
return this.oaiDBNameParam;
|
64 |
|
|
}
|
65 |
|
|
|
66 |
|
|
public void setOaiDBNameParam(final String oaiDBNameParam) {
|
67 |
|
|
this.oaiDBNameParam = oaiDBNameParam;
|
68 |
|
|
}
|
69 |
|
|
|
70 |
|
|
public String getXpathToCurrentDB() {
|
71 |
|
|
return this.xpathToCurrentDB;
|
72 |
|
|
}
|
73 |
|
|
|
74 |
|
|
public void setXpathToCurrentDB(final String xpathToCurrentDB) {
|
75 |
|
|
this.xpathToCurrentDB = xpathToCurrentDB;
|
76 |
|
|
|
77 |
|
|
}
|
78 |
|
|
}
|