1
|
package eu.dnetlib.msro.workflows.nodes.repohi;
|
2
|
|
3
|
import java.util.Map;
|
4
|
|
5
|
import org.apache.commons.logging.Log;
|
6
|
import org.apache.commons.logging.LogFactory;
|
7
|
|
8
|
import com.googlecode.sarasvati.Engine;
|
9
|
import com.googlecode.sarasvati.NodeToken;
|
10
|
import com.googlecode.sarasvati.env.Env;
|
11
|
|
12
|
import eu.dnetlib.data.mdstore.MDStoreService;
|
13
|
import eu.dnetlib.enabling.locators.comparators.HandledDatastructuresComparator;
|
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 CreateMDStoreJobNode extends BlackboardJobNode {
|
19
|
|
20
|
private static final Log log = LogFactory.getLog(CreateMDStoreJobNode.class);
|
21
|
|
22
|
private String format;
|
23
|
private String layout;
|
24
|
private String interpretation;
|
25
|
private String outputPrefix = "mdstore";
|
26
|
|
27
|
@Override
|
28
|
protected String obtainServiceId(final NodeToken token) {
|
29
|
return getServiceLocator().getServiceId(MDStoreService.class, new HandledDatastructuresComparator());
|
30
|
}
|
31
|
|
32
|
@Override
|
33
|
protected void prepareJob(final BlackboardJob job, final NodeToken token) {
|
34
|
log.info("preparing blackboard job: " + getFormat());
|
35
|
|
36
|
job.setAction("CREATE");
|
37
|
job.getParameters().put("format", getFormat());
|
38
|
job.getParameters().put("interpretation", getInterpretation());
|
39
|
job.getParameters().put("layout", getLayout());
|
40
|
}
|
41
|
|
42
|
public String getFormat() {
|
43
|
return format;
|
44
|
}
|
45
|
|
46
|
public void setFormat(final String format) {
|
47
|
this.format = format;
|
48
|
}
|
49
|
|
50
|
public String getInterpretation() {
|
51
|
return interpretation;
|
52
|
}
|
53
|
|
54
|
public void setInterpretation(final String interpretation) {
|
55
|
this.interpretation = interpretation;
|
56
|
}
|
57
|
|
58
|
public String getLayout() {
|
59
|
return layout;
|
60
|
}
|
61
|
|
62
|
public void setLayout(final String layout) {
|
63
|
this.layout = layout;
|
64
|
}
|
65
|
|
66
|
public String getOutputPrefix() {
|
67
|
return outputPrefix;
|
68
|
}
|
69
|
|
70
|
public void setOutputPrefix(final String outputPrefix) {
|
71
|
this.outputPrefix = outputPrefix;
|
72
|
}
|
73
|
|
74
|
@Override
|
75
|
protected BlackboardWorkflowJobListener generateBlackboardListener(final Engine engine, final NodeToken token) {
|
76
|
return new BlackboardWorkflowJobListener(engine, token) {
|
77
|
|
78
|
@Override
|
79
|
protected void populateEnv(final Env env, final Map<String, String> responseParams) {
|
80
|
env.setAttribute(getOutputPrefix() + "format", format);
|
81
|
env.setAttribute(getOutputPrefix() + "layout", layout);
|
82
|
env.setAttribute(getOutputPrefix() + "interpretation", interpretation);
|
83
|
env.setAttribute(getOutputPrefix() + "id", responseParams.get("id"));
|
84
|
}
|
85
|
};
|
86
|
}
|
87
|
|
88
|
}
|