Project

General

Profile

1
package eu.dnetlib.msro.workflows.dedup;
2

    
3
import org.apache.commons.lang.StringUtils;
4
import org.apache.commons.logging.Log;
5
import org.apache.commons.logging.LogFactory;
6

    
7
import com.googlecode.sarasvati.Arc;
8
import com.googlecode.sarasvati.NodeToken;
9

    
10
import eu.dnetlib.msro.rmi.MSROException;
11
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode;
12

    
13
public class CheckDoneJobNode extends SimpleJobNode {
14

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

    
17
	private String param;
18

    
19
	private String exitArc;
20

    
21
	@Override
22
	protected String execute(final NodeToken token) throws Exception {
23

    
24
		if (StringUtils.isBlank(getParam())) throw new MSROException("cannot find param name, please set it on the workflow definition");
25

    
26
		final String simRels = token.getFullEnv().getAttribute(getParam());
27
		if (StringUtils.isBlank(simRels))
28
			throw new MSROException(String.format("cannot find param '%s' in workflow env", getParam()));
29

    
30
		if (Integer.parseInt(simRels) > 0) {
31
			log.info(String.format("found %s %s, continue with the next iteration", simRels, getParam()));
32
			return getExitArc();
33
		}
34
		log.info(String.format("found %s %s, done", simRels, getParam()));
35

    
36
		return Arc.DEFAULT_ARC;
37
	}
38

    
39
	public String getParam() {
40
		return param;
41
	}
42

    
43
	public void setParam(final String param) {
44
		this.param = param;
45
	}
46

    
47
	public String getExitArc() {
48
		return exitArc;
49
	}
50

    
51
	public void setExitArc(final String exitArc) {
52
		this.exitArc = exitArc;
53
	}
54

    
55
}
(2-2/15)