1 |
26600
|
sandro.lab
|
package eu.dnetlib.msro.workflows.nodes.mdstore;
|
2 |
|
|
|
3 |
32746
|
andrea.man
|
import javax.annotation.Resource;
|
4 |
26600
|
sandro.lab
|
import javax.xml.ws.wsaddressing.W3CEndpointReference;
|
5 |
|
|
|
6 |
43295
|
claudio.at
|
import eu.dnetlib.msro.workflows.util.WorkflowsConstants;
|
7 |
31660
|
claudio.at
|
import org.apache.commons.logging.Log;
|
8 |
|
|
import org.apache.commons.logging.LogFactory;
|
9 |
26600
|
sandro.lab
|
|
10 |
|
|
import com.googlecode.sarasvati.Arc;
|
11 |
|
|
import com.googlecode.sarasvati.NodeToken;
|
12 |
|
|
|
13 |
|
|
import eu.dnetlib.data.mdstore.MDStoreService;
|
14 |
32639
|
michele.ar
|
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
|
15 |
31660
|
claudio.at
|
import eu.dnetlib.msro.rmi.MSROException;
|
16 |
26600
|
sandro.lab
|
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode;
|
17 |
|
|
|
18 |
|
|
public class FetchMDStoreRecordsJobNode extends SimpleJobNode {
|
19 |
|
|
|
20 |
31660
|
claudio.at
|
private static final Log log = LogFactory.getLog(FetchMDStoreRecordsJobNode.class); // NOPMD by marko on 11/24/08 5:02 PM
|
21 |
|
|
|
22 |
32746
|
andrea.man
|
@Resource
|
23 |
32639
|
michele.ar
|
private UniqueServiceLocator serviceLocator;
|
24 |
26600
|
sandro.lab
|
|
25 |
|
|
private String mdId;
|
26 |
44448
|
alessia.ba
|
@Deprecated
|
27 |
|
|
/**
|
28 |
|
|
* @Deprecated: mdFormat not used by this job node.
|
29 |
|
|
*/
|
30 |
26600
|
sandro.lab
|
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 |
50598
|
sandro.lab
|
final Long dateFromFilter = token.getFullEnv().getAttribute("DateFromFilter", Long.class);
|
43 |
|
|
|
44 |
|
|
if (dateFromFilter!= null) {
|
45 |
52037
|
alessia.ba
|
log.info("From Filter activated, from: "+dateFromFilter);
|
46 |
50598
|
sandro.lab
|
}
|
47 |
|
|
|
48 |
43295
|
claudio.at
|
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 |
43309
|
claudio.at
|
log.info(String.format("getting MDRecords from: %s, sourceSize: %s", getMdId(), size));
|
53 |
43295
|
claudio.at
|
|
54 |
52040
|
alessia.ba
|
final String from = dateFromFilter != null ? "" + dateFromFilter : "";
|
55 |
|
|
final W3CEndpointReference epr = mdStoreService.deliverMDRecords(getMdId(), from, "", "");
|
56 |
32639
|
michele.ar
|
if (epr == null) { throw new MSROException("unable to read MDRecords from: " + getMdId()); }
|
57 |
26600
|
sandro.lab
|
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 |
44448
|
alessia.ba
|
@Deprecated
|
70 |
|
|
/**
|
71 |
|
|
* Deprecated: MdFormat is not used by this job node
|
72 |
|
|
*/
|
73 |
26600
|
sandro.lab
|
public String getMdFormat() {
|
74 |
|
|
return mdFormat;
|
75 |
|
|
}
|
76 |
44448
|
alessia.ba
|
@Deprecated
|
77 |
|
|
/**
|
78 |
|
|
* Deprecated: MdFormat is not used by this job node
|
79 |
|
|
*/
|
80 |
26600
|
sandro.lab
|
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 |
|
|
}
|