]> git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/process/SlcExecution.java
Remote shutdown
[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 public List<RealizedFlow> getRealizedFlows() {
33 return realizedFlows;
34 }
35
36 public void setRealizedFlows(List<RealizedFlow> realizedFlows) {
37 this.realizedFlows = realizedFlows;
38 }
39
40 public List<SlcExecutionStep> getSteps() {
41 return steps;
42 }
43
44 public void setSteps(List<SlcExecutionStep> steps) {
45 this.steps = steps;
46 }
47
48 public String getUuid() {
49 return uuid;
50 }
51
52 public void setUuid(String uuid) {
53 this.uuid = uuid;
54 }
55
56 public String getHost() {
57 return host;
58 }
59
60 public void setHost(String host) {
61 this.host = host;
62 }
63
64 public String getUser() {
65 return user;
66 }
67
68 public void setUser(String user) {
69 this.user = user;
70 }
71
72 public String getType() {
73 return type;
74 }
75
76 public void setType(String type) {
77 this.type = type;
78 }
79
80 public String getStatus() {
81 return status;
82 }
83
84 public void setStatus(String status) {
85 this.status = status;
86 }
87
88 public SlcExecutionStep currentStep() {
89 synchronized (steps) {
90 if (steps.size() > 0)
91 return steps.get(steps.size() - 1);
92 else
93 return null;
94 }
95 }
96
97 @Override
98 public boolean equals(Object obj) {
99 if (obj instanceof SlcExecution) {
100 return getUuid().equals(((SlcExecution) obj).getUuid());
101 }
102 return false;
103 }
104
105 @Override
106 public int hashCode() {
107 return getUuid().hashCode();
108 }
109
110 public Map<String, String> getAttributes() {
111 return attributes;
112 }
113
114 public void setAttributes(Map<String, String> attributes) {
115 this.attributes = attributes;
116 }
117
118 public String toString() {
119 StringBuffer buf = new StringBuffer(getClass().getSimpleName());
120 buf.append('#').append(uuid);
121 buf.append(" status=").append(status);
122 buf.append(" attributes=").append(attributes);
123 return buf.toString();
124 }
125
126 public Date getStartDate() {
127 synchronized (steps) {
128 if (steps.size() == 0)
129 return null;
130 else
131 return steps.get(0).getBegin();
132 }
133 }
134
135 public Date getEndDate() {
136 if (!status.equals(STATUS_FINISHED) && !status.equals(STATUS_ERROR))
137 return null;
138
139 synchronized (steps) {
140 if (steps.size() == 0)
141 return null;
142 else
143 return steps.get(steps.size() - 1).getBegin();
144 }
145 }
146 }