Project

General

Profile

1
package eu.dnetlib.domain.data;
2

    
3
import java.util.ArrayList;
4
import java.util.List;
5

    
6
public class RepositoryBlackboardMessage {
7
	private String id = "";
8
	private final Action action;
9
	private final ActionStatus actionStatus;
10
	private final List<String> parameters = new ArrayList<String>();
11

    
12
	public RepositoryBlackboardMessage(String id, Action action,
13
			ActionStatus actionStatus) {
14
		this.id = id;
15
		this.action = action;
16
		this.actionStatus = actionStatus;
17
	}
18

    
19
	public String getId() {
20
		return id;
21
	}
22

    
23
	public Action getAction() {
24
		return action;
25
	}
26

    
27
	public ActionStatus getActionStatus() {
28
		return actionStatus;
29
	}
30

    
31
	public List<String> getParameters() {
32
		return parameters;
33
	}
34

    
35
	public static enum Action {
36
		CREATE("CREATE"), DELETE("DELETE"), UPDATE("UPDATE"), MANAGE("MANAGE"), 
37
			RELEASE("RELEASE"), CANCEL("CANCEL");
38

    
39
		private final String value;
40

    
41
		Action(String value) {
42
			this.value = value;
43
		}
44

    
45
		public String getValue() {
46
			return this.value;
47
		}
48

    
49
		public static Action getAction(String str) {
50
			for (Action act : Action.values()) {
51
				if (act.getValue().equals(str))
52
					return act;
53
			}
54
			throw new IllegalArgumentException("cannot find Action " + str);
55
		}
56
	}
57

    
58
	public static enum ActionStatus {
59
		DONE("DONE"), ONGOING("ONGOING"), FAILED("FAILED"), WAITING("WAITING"), 
60
			ASSIGNED("ASSIGNED");
61

    
62
		private final String value;
63

    
64
		ActionStatus(String value) {
65
			this.value = value;
66
		}
67

    
68
		public String getValue() {
69
			return value;
70
		}
71

    
72
		public static ActionStatus getActionStatus(String str) {
73
			for (ActionStatus act : ActionStatus.values()) {
74
				if (act.getValue().equals(str))
75
					return act;
76
			}
77
			throw new IllegalArgumentException("cannot find ActionStatus "
78
					+ str);
79
		}
80
	}
81
}
(15-15/23)