1
|
package eu.dnetlib.msro.workflows.nodes.mdstore;
|
2
|
|
3
|
import java.util.Map;
|
4
|
|
5
|
import com.googlecode.sarasvati.Engine;
|
6
|
import com.googlecode.sarasvati.NodeToken;
|
7
|
import com.googlecode.sarasvati.env.Env;
|
8
|
import eu.dnetlib.data.mdstore.MDStoreService;
|
9
|
import eu.dnetlib.enabling.resultset.rmi.ResultSetException;
|
10
|
import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
|
11
|
import eu.dnetlib.msro.workflows.nodes.BlackboardJobNode;
|
12
|
import eu.dnetlib.msro.workflows.nodes.ProgressJobNode;
|
13
|
import eu.dnetlib.msro.workflows.nodes.blackboard.BlackboardWorkflowJobListener;
|
14
|
import eu.dnetlib.msro.workflows.resultset.ProcessCountingResultSetFactory;
|
15
|
import eu.dnetlib.msro.workflows.util.ProgressProvider;
|
16
|
import eu.dnetlib.msro.workflows.util.ResultsetProgressProvider;
|
17
|
import eu.dnetlib.msro.workflows.util.WorkflowsConstants;
|
18
|
import org.apache.commons.logging.Log;
|
19
|
import org.apache.commons.logging.LogFactory;
|
20
|
import org.springframework.beans.factory.annotation.Required;
|
21
|
|
22
|
public class StoreMDStoreRecordsJobNode extends BlackboardJobNode implements ProgressJobNode {
|
23
|
|
24
|
private static final Log log = LogFactory.getLog(StoreMDStoreRecordsJobNode.class); // NOPMD by marko on 11/24/08 5:02 PM
|
25
|
|
26
|
private String eprParam;
|
27
|
private String mdId;
|
28
|
private String storingType;
|
29
|
private ProcessCountingResultSetFactory processCountingResultSetFactory;
|
30
|
private ResultsetProgressProvider progressProvider;
|
31
|
|
32
|
@Override
|
33
|
protected String obtainServiceId(final NodeToken token) {
|
34
|
return getServiceLocator().getServiceId(MDStoreService.class, mdId);
|
35
|
}
|
36
|
|
37
|
@Override
|
38
|
protected void prepareJob(final BlackboardJob job, final NodeToken token) throws ResultSetException {
|
39
|
job.setAction("FEED");
|
40
|
|
41
|
final String eprS = token.getEnv().getAttribute(getEprParam());
|
42
|
|
43
|
this.progressProvider = processCountingResultSetFactory.createProgressProvider(token.getProcess(), eprS);
|
44
|
|
45
|
final String overrideStoringType = token.getFullEnv().getAttribute("transformationType");
|
46
|
|
47
|
job.getParameters().put("epr", progressProvider.getEpr().toString());
|
48
|
job.getParameters().put("storingType", overrideStoringType!= null? overrideStoringType: getStoringType());
|
49
|
job.getParameters().put("mdId", getMdId());
|
50
|
}
|
51
|
|
52
|
@Override
|
53
|
protected BlackboardWorkflowJobListener generateBlackboardListener(final Engine engine, final NodeToken token) {
|
54
|
return new BlackboardWorkflowJobListener(engine, token) {
|
55
|
|
56
|
@Override
|
57
|
protected void populateEnv(final Env env, final Map<String, String> responseParams) {
|
58
|
log.info("New mdstore size : " + responseParams.get("mdstoreSize"));
|
59
|
log.info("Number of write operations: " + responseParams.get("writeOps"));
|
60
|
env.setAttribute(WorkflowsConstants.MAIN_LOG_PREFIX + "sinkSize", responseParams.get("mdstoreSize"));
|
61
|
env.setAttribute(WorkflowsConstants.MAIN_LOG_PREFIX + "processedSize", responseParams.get("writeOps"));
|
62
|
}
|
63
|
};
|
64
|
}
|
65
|
|
66
|
public String getEprParam() {
|
67
|
return eprParam;
|
68
|
}
|
69
|
|
70
|
public void setEprParam(final String eprParam) {
|
71
|
this.eprParam = eprParam;
|
72
|
}
|
73
|
|
74
|
public String getMdId() {
|
75
|
return mdId;
|
76
|
}
|
77
|
|
78
|
public void setMdId(final String mdId) {
|
79
|
this.mdId = mdId;
|
80
|
}
|
81
|
|
82
|
public String getStoringType() {
|
83
|
return storingType;
|
84
|
}
|
85
|
|
86
|
public void setStoringType(final String storingType) {
|
87
|
this.storingType = storingType;
|
88
|
}
|
89
|
|
90
|
public ProcessCountingResultSetFactory getProcessCountingResultSetFactory() {
|
91
|
return processCountingResultSetFactory;
|
92
|
}
|
93
|
|
94
|
@Required
|
95
|
public void setProcessCountingResultSetFactory(final ProcessCountingResultSetFactory processCountingResultSetFactory) {
|
96
|
this.processCountingResultSetFactory = processCountingResultSetFactory;
|
97
|
}
|
98
|
|
99
|
@Override
|
100
|
public ProgressProvider getProgressProvider() {
|
101
|
return progressProvider;
|
102
|
}
|
103
|
|
104
|
}
|