1
|
package eu.dnetlib.msro.workflows.nodes.mdstore;
|
2
|
|
3
|
import javax.annotation.Resource;
|
4
|
import javax.xml.ws.wsaddressing.W3CEndpointReference;
|
5
|
|
6
|
import eu.dnetlib.msro.workflows.util.WorkflowsConstants;
|
7
|
import org.apache.commons.logging.Log;
|
8
|
import org.apache.commons.logging.LogFactory;
|
9
|
|
10
|
import com.googlecode.sarasvati.Arc;
|
11
|
import com.googlecode.sarasvati.NodeToken;
|
12
|
|
13
|
import eu.dnetlib.data.mdstore.MDStoreService;
|
14
|
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
|
15
|
import eu.dnetlib.msro.rmi.MSROException;
|
16
|
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode;
|
17
|
|
18
|
public class FetchMDStoreRecordsJobNode extends SimpleJobNode {
|
19
|
|
20
|
private static final Log log = LogFactory.getLog(FetchMDStoreRecordsJobNode.class); // NOPMD by marko on 11/24/08 5:02 PM
|
21
|
|
22
|
@Resource
|
23
|
private UniqueServiceLocator serviceLocator;
|
24
|
|
25
|
private String mdId;
|
26
|
@Deprecated
|
27
|
/**
|
28
|
* @Deprecated: mdFormat not used by this job node.
|
29
|
*/
|
30
|
private String mdFormat;
|
31
|
private String eprParam;
|
32
|
|
33
|
@Override
|
34
|
protected String execute(final NodeToken token) throws Exception {
|
35
|
if (getMdId() == null) {
|
36
|
setMdId(token.getEnv().getAttribute("mdId"));
|
37
|
}
|
38
|
if (getMdFormat() == null) {
|
39
|
setMdFormat(token.getEnv().getAttribute("mdFormat"));
|
40
|
}
|
41
|
|
42
|
final Long dateFromFilter = token.getFullEnv().getAttribute("DateFromFilter", Long.class);
|
43
|
|
44
|
if (dateFromFilter!= null) {
|
45
|
log.info("From Filter activated, from: "+dateFromFilter);
|
46
|
}
|
47
|
|
48
|
final MDStoreService mdStoreService = serviceLocator.getService(MDStoreService.class, getMdId());
|
49
|
int size = mdStoreService.size(getMdId());
|
50
|
|
51
|
token.getEnv().setAttribute(WorkflowsConstants.MAIN_LOG_PREFIX + "sourceSize", size);
|
52
|
log.info(String.format("getting MDRecords from: %s, sourceSize: %s", getMdId(), size));
|
53
|
|
54
|
final String from = dateFromFilter != null ? "" + dateFromFilter : "";
|
55
|
final W3CEndpointReference epr = mdStoreService.deliverMDRecords(getMdId(), from, "", "");
|
56
|
if (epr == null) { throw new MSROException("unable to read MDRecords from: " + getMdId()); }
|
57
|
token.getEnv().setAttribute(getEprParam(), epr.toString());
|
58
|
return Arc.DEFAULT_ARC;
|
59
|
}
|
60
|
|
61
|
public String getMdId() {
|
62
|
return mdId;
|
63
|
}
|
64
|
|
65
|
public void setMdId(final String mdId) {
|
66
|
this.mdId = mdId;
|
67
|
}
|
68
|
|
69
|
@Deprecated
|
70
|
/**
|
71
|
* Deprecated: MdFormat is not used by this job node
|
72
|
*/
|
73
|
public String getMdFormat() {
|
74
|
return mdFormat;
|
75
|
}
|
76
|
@Deprecated
|
77
|
/**
|
78
|
* Deprecated: MdFormat is not used by this job node
|
79
|
*/
|
80
|
public void setMdFormat(final String mdFormat) {
|
81
|
this.mdFormat = mdFormat;
|
82
|
}
|
83
|
|
84
|
public String getEprParam() {
|
85
|
return eprParam;
|
86
|
}
|
87
|
|
88
|
public void setEprParam(final String eprParam) {
|
89
|
this.eprParam = eprParam;
|
90
|
}
|
91
|
}
|