Project

General

Profile

1
package eu.dnetlib.msro.workflows.nodes.mdstore;
2

    
3
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
4
import eu.dnetlib.msro.workflows.graph.Arc;
5
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode;
6
import eu.dnetlib.msro.workflows.procs.Env;
7
import eu.dnetlib.rmi.common.ResultSet;
8
import eu.dnetlib.rmi.data.MDStoreService;
9
import eu.dnetlib.rmi.manager.MSROException;
10
import org.apache.commons.logging.Log;
11
import org.apache.commons.logging.LogFactory;
12
import org.springframework.beans.factory.annotation.Autowired;
13

    
14
public class FetchMDStoreRecordsJobNode extends SimpleJobNode {
15

    
16
	private static final Log log = LogFactory.getLog(FetchMDStoreRecordsJobNode.class); // NOPMD by marko on 11/24/08 5:02 PM
17

    
18
	@Autowired
19
	private UniqueServiceLocator serviceLocator;
20

    
21
	private String mdId;
22
	private String mdFormat;
23
	private String eprParam;
24

    
25
	@Override
26
	protected String execute(final Env env) throws Exception {
27
		if (getMdId() == null) {
28
			setMdId(env.getAttribute("mdId", String.class));
29
		}
30
		if (getMdFormat() == null) {
31
			setMdFormat(env.getAttribute("mdFormat", String.class));
32
		}
33

    
34
		log.info("getting MDRecords from: " + getMdId());
35
		final ResultSet<String> rs = this.serviceLocator.getService(MDStoreService.class, getMdId()).deliverMDRecords(getMdId(), "", "", "");
36
		if (rs == null) { throw new MSROException("unable to read MDRecords from: " + getMdId()); }
37
		env.setAttribute(getEprParam(), rs);
38
		return Arc.DEFAULT_ARC;
39
	}
40

    
41
	public String getMdId() {
42
		return this.mdId;
43
	}
44

    
45
	public void setMdId(final String mdId) {
46
		this.mdId = mdId;
47
	}
48

    
49
	public String getMdFormat() {
50
		return this.mdFormat;
51
	}
52

    
53
	public void setMdFormat(final String mdFormat) {
54
		this.mdFormat = mdFormat;
55
	}
56

    
57
	public String getEprParam() {
58
		return this.eprParam;
59
	}
60

    
61
	public void setEprParam(final String eprParam) {
62
		this.eprParam = eprParam;
63
	}
64
}
(3-3/7)