]> git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/process/SlcExecution.java
Introduce JMX agent
[gpl/argeo-slc.git] / runtime / org.argeo.slc.specs / src / main / java / org / argeo / slc / process / SlcExecution.java
1 package org.argeo.slc.process;
2
3 import java.io.Serializable;
4 import java.util.ArrayList;
5 import java.util.Date;
6 import java.util.List;
7 import java.util.Map;
8 import java.util.TreeMap;
9
10 public class SlcExecution implements Serializable {
11 private static final long serialVersionUID = 1L;
12 public final static String STATUS_NONE = "DEFAULT";
13 public final static String STATUS_SCHEDULED = "SCHEDULED";
14 public final static String STATUS_RUNNING = "RUNNING";
15 public final static String STATUS_FINISHED = "FINISHED";
16 public final static String STATUS_ERROR = "ERROR";
17 public final static String STATUS_CLEANED = "CLEANED";
18
19 public final static String UNKOWN_HOST = "UNKOWN_HOST";
20
21 private String uuid;
22 private String host;
23 private String user;
24 private String type;
25 private String status = STATUS_NONE;
26 private Map<String, String> attributes = new TreeMap<String, String>();
27
28 /** TODO: Synchronize */
29 private List<SlcExecutionStep> steps = new ArrayList<SlcExecutionStep>();
30 private List<RealizedFlow> realizedFlows = new ArrayList<RealizedFlow>();
31
32 /** Attachment uuid. */
33 private String realizedFlowsXml = null;
34
35 public List<RealizedFlow> getRealizedFlows() {
36 return realizedFlows;
37 }
38
39 public void setRealizedFlows(List<RealizedFlow> realizedFlows) {
40 this.realizedFlows = realizedFlows;
41 }
42
43 public List<SlcExecutionStep> getSteps() {
44 return steps;
45 }
46
47 public void setSteps(List<SlcExecutionStep> steps) {
48 this.steps = steps;
49 }
50
51 public String getUuid() {
52 return uuid;
53 }
54
55 public void setUuid(String uuid) {
56 this.uuid = uuid;
57 }
58
59 public String getHost() {
60 return host;
61 }
62
63 public void setHost(String host) {
64 this.host = host;
65 }
66
67 public String getUser() {
68 return user;
69 }
70
71 public void setUser(String user) {
72 this.user = user;
73 }
74
75 public String getType() {
76 return type;
77 }
78
79 public void setType(String type) {
80 this.type = type;
81 }
82
83 public String getStatus() {
84 return status;
85 }
86
87 public void setStatus(String status) {
88 this.status = status;
89 }
90
91 public SlcExecutionStep currentStep() {
92 synchronized (steps) {
93 if (steps.size() > 0)
94 return steps.get(steps.size() - 1);
95 else
96 return null;
97 }
98 }
99
100 @Override
101 public boolean equals(Object obj) {
102 if (obj instanceof SlcExecution) {
103 return getUuid().equals(((SlcExecution) obj).getUuid());
104 }
105 return false;
106 }
107
108 @Override
109 public int hashCode() {
110 return getUuid().hashCode();
111 }
112
113 public Map<String, String> getAttributes() {
114 return attributes;
115 }
116
117 public void setAttributes(Map<String, String> attributes) {
118 this.attributes = attributes;
119 }
120
121 public String toString() {
122 StringBuffer buf = new StringBuffer(getClass().getSimpleName());
123 buf.append('#').append(uuid);
124 buf.append(" status=").append(status);
125 buf.append(" attributes=").append(attributes);
126 return buf.toString();
127 }
128
129 public Date getStartDate() {
130 synchronized (steps) {
131 if (steps.size() == 0)
132 return null;
133 else
134 return steps.get(0).getBegin();
135 }
136 }
137
138 public Date getEndDate() {
139 if (!status.equals(STATUS_FINISHED) && !status.equals(STATUS_ERROR))
140 return null;
141
142 synchronized (steps) {
143 if (steps.size() == 0)
144 return null;
145 else
146 return steps.get(steps.size() - 1).getBegin();
147 }
148 }
149
150 /**
151 * Not (yet) a stable API, should not be relied upon!
152 *
153 * @return an id or an url allowing to retrieve the XML, not the XML itself!
154 */
155 public String getRealizedFlowsXml() {
156 return realizedFlowsXml;
157 }
158
159 /** Not (yet) a stable API, should not be relied upon! */
160 public void setRealizedFlowsXml(String realizedFlowsXml) {
161 this.realizedFlowsXml = realizedFlowsXml;
162 }
163
164 }