1
|
package eu.dnetlib.msro.workflows.nodes.repohi;
|
2
|
|
3
|
import java.util.Map;
|
4
|
|
5
|
import org.apache.commons.lang.StringUtils;
|
6
|
import org.apache.commons.logging.Log;
|
7
|
import org.apache.commons.logging.LogFactory;
|
8
|
|
9
|
import com.googlecode.sarasvati.Engine;
|
10
|
import com.googlecode.sarasvati.NodeToken;
|
11
|
import com.googlecode.sarasvati.env.Env;
|
12
|
|
13
|
import eu.dnetlib.data.objectstore.rmi.ObjectStoreService;
|
14
|
import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
|
15
|
import eu.dnetlib.msro.workflows.nodes.BlackboardJobNode;
|
16
|
import eu.dnetlib.msro.workflows.nodes.blackboard.BlackboardWorkflowJobListener;
|
17
|
|
18
|
public class CreateObjectStoreJobNode extends BlackboardJobNode {
|
19
|
|
20
|
private static final Log log = LogFactory.getLog(CreateObjectStoreJobNode.class);
|
21
|
|
22
|
private String interpretation;
|
23
|
private String outputPrefix = "objectStore_";
|
24
|
|
25
|
@Override
|
26
|
protected String obtainServiceId(final NodeToken token) {
|
27
|
return getServiceLocator().getServiceId(ObjectStoreService.class);
|
28
|
}
|
29
|
|
30
|
@Override
|
31
|
protected void prepareJob(final BlackboardJob job, final NodeToken token) {
|
32
|
log.info("preparing blackboard job for the creation of the objectStore ");
|
33
|
String basePath = token.getEnv().getAttribute("objectStoreBasePath");
|
34
|
job.setAction("CREATE");
|
35
|
job.getParameters().put("interpretation", interpretation);
|
36
|
if (!StringUtils.isEmpty(basePath)) {
|
37
|
job.getParameters().put("basePath", basePath);
|
38
|
}
|
39
|
}
|
40
|
|
41
|
public String getInterpretation() {
|
42
|
return interpretation;
|
43
|
}
|
44
|
|
45
|
public void setInterpretation(final String interpretation) {
|
46
|
this.interpretation = interpretation;
|
47
|
}
|
48
|
|
49
|
public String getOutputPrefix() {
|
50
|
return outputPrefix;
|
51
|
}
|
52
|
|
53
|
public void setOutputPrefix(final String outputPrefix) {
|
54
|
this.outputPrefix = outputPrefix;
|
55
|
}
|
56
|
|
57
|
@Override
|
58
|
protected BlackboardWorkflowJobListener generateBlackboardListener(final Engine engine, final NodeToken token) {
|
59
|
return new BlackboardWorkflowJobListener(engine, token) {
|
60
|
|
61
|
@Override
|
62
|
protected void populateEnv(final Env env, final Map<String, String> responseParams) {
|
63
|
|
64
|
env.setAttribute(getOutputPrefix() + "interpretation", interpretation);
|
65
|
env.setAttribute(getOutputPrefix() + "id", responseParams.get("objectStoreId"));
|
66
|
}
|
67
|
};
|
68
|
}
|
69
|
|
70
|
}
|