Project

General

Profile

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.objectstore.rmi.ObjectStoreService;
13
import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
14
import eu.dnetlib.msro.workflows.nodes.BlackboardJobNode;
15
import eu.dnetlib.msro.workflows.nodes.blackboard.BlackboardWorkflowJobListener;
16

    
17
public class CreateObjectStoreJobNode extends BlackboardJobNode {
18

    
19
	private static final Log log = LogFactory.getLog(CreateObjectStoreJobNode.class);
20

    
21
	private String interpretation;
22
	private String outputPrefix = "objectStore_";
23

    
24
	@Override
25
	protected String obtainServiceId(final NodeToken token) {
26
		return getServiceLocator().getServiceId(ObjectStoreService.class);
27
	}
28

    
29
	@Override
30
	protected void prepareJob(final BlackboardJob job, final NodeToken token) {
31
		log.info("preparing blackboard job for the creation of the objectStore ");
32
		String basePath  = token.getEnv().getAttribute("objectStoreBasePath");
33
		job.setAction("CREATE");
34
		job.getParameters().put("interpretation", interpretation);
35
		job.getParameters().put("basePath", basePath);
36
	}
37

    
38
	public String getInterpretation() {
39
		return interpretation;
40
	}
41

    
42
	public void setInterpretation(final String interpretation) {
43
		this.interpretation = interpretation;
44
	}
45

    
46
	public String getOutputPrefix() {
47
		return outputPrefix;
48
	}
49

    
50
	public void setOutputPrefix(final String outputPrefix) {
51
		this.outputPrefix = outputPrefix;
52
	}
53

    
54
	@Override
55
	protected BlackboardWorkflowJobListener generateBlackboardListener(final Engine engine, final NodeToken token) {
56
		return new BlackboardWorkflowJobListener(engine, token) {
57

    
58
			@Override
59
			protected void populateEnv(final Env env, final Map<String, String> responseParams) {
60

    
61
				env.setAttribute(getOutputPrefix() + "interpretation", interpretation);
62
				env.setAttribute(getOutputPrefix() + "id", responseParams.get("objectStoreId"));
63
			}
64
		};
65
	}
66

    
67
}
(2-2/7)