]> git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/process/SlcExecution.java
Add updateModule
[gpl/argeo-slc.git] / runtime / org.argeo.slc.specs / src / main / java / org / argeo / slc / process / SlcExecution.java
1 /*
2 * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package org.argeo.slc.process;
18
19 import java.io.Serializable;
20 import java.util.ArrayList;
21 import java.util.Date;
22 import java.util.List;
23 import java.util.Map;
24 import java.util.TreeMap;
25
26 public class SlcExecution implements Serializable {
27 private static final long serialVersionUID = -7607457971382118466L;
28 public final static String STATUS_NONE = "DEFAULT";
29 public final static String STATUS_SCHEDULED = "SCHEDULED";
30 public final static String STATUS_RUNNING = "RUNNING";
31 public final static String STATUS_FINISHED = "FINISHED";
32 public final static String STATUS_ERROR = "ERROR";
33 public final static String STATUS_CLEANED = "CLEANED";
34
35 public final static String UNKOWN_HOST = "UNKOWN_HOST";
36
37 private String uuid;
38 private String host;
39 private String user;
40 private String type;
41 private String status = STATUS_NONE;
42 private Map<String, String> attributes = new TreeMap<String, String>();
43
44 /** TODO: Synchronize */
45 private List<SlcExecutionStep> steps = new ArrayList<SlcExecutionStep>();
46 private List<RealizedFlow> realizedFlows = new ArrayList<RealizedFlow>();
47
48 /** Attachment uuid. */
49 private String realizedFlowsXml = null;
50
51 public List<RealizedFlow> getRealizedFlows() {
52 return realizedFlows;
53 }
54
55 public void setRealizedFlows(List<RealizedFlow> realizedFlows) {
56 this.realizedFlows = realizedFlows;
57 }
58
59 public List<SlcExecutionStep> getSteps() {
60 return steps;
61 }
62
63 public void setSteps(List<SlcExecutionStep> steps) {
64 this.steps = steps;
65 }
66
67 public String getUuid() {
68 return uuid;
69 }
70
71 public void setUuid(String uuid) {
72 this.uuid = uuid;
73 }
74
75 public String getHost() {
76 return host;
77 }
78
79 public void setHost(String host) {
80 this.host = host;
81 }
82
83 public String getUser() {
84 return user;
85 }
86
87 public void setUser(String user) {
88 this.user = user;
89 }
90
91 public String getType() {
92 return type;
93 }
94
95 public void setType(String type) {
96 this.type = type;
97 }
98
99 public String getStatus() {
100 return status;
101 }
102
103 public void setStatus(String status) {
104 this.status = status;
105 }
106
107 public SlcExecutionStep currentStep() {
108 synchronized (steps) {
109 if (steps.size() > 0)
110 return steps.get(steps.size() - 1);
111 else
112 return null;
113 }
114 }
115
116 @Override
117 public boolean equals(Object obj) {
118 if (obj instanceof SlcExecution) {
119 return getUuid().equals(((SlcExecution) obj).getUuid());
120 }
121 return false;
122 }
123
124 @Override
125 public int hashCode() {
126 return getUuid().hashCode();
127 }
128
129 public Map<String, String> getAttributes() {
130 return attributes;
131 }
132
133 public void setAttributes(Map<String, String> attributes) {
134 this.attributes = attributes;
135 }
136
137 public String toString() {
138 StringBuffer buf = new StringBuffer(getClass().getSimpleName());
139 buf.append('#').append(uuid);
140 buf.append(" status=").append(status);
141 buf.append(" attributes=").append(attributes);
142 return buf.toString();
143 }
144
145 public Date getStartDate() {
146 synchronized (steps) {
147 if (steps.size() == 0)
148 return null;
149 else
150 return steps.get(0).getTimestamp();
151 }
152 }
153
154 public Date getEndDate() {
155 if (!status.equals(STATUS_FINISHED) && !status.equals(STATUS_ERROR))
156 return null;
157
158 synchronized (steps) {
159 if (steps.size() == 0)
160 return null;
161 else
162 return steps.get(steps.size() - 1).getTimestamp();
163 }
164 }
165
166 /**
167 * Not (yet) a stable API, should not be relied upon!
168 *
169 * @return an id or an url allowing to retrieve the XML, not the XML itself!
170 */
171 public String getRealizedFlowsXml() {
172 return realizedFlowsXml;
173 }
174
175 /** Not (yet) a stable API, should not be relied upon! */
176 public void setRealizedFlowsXml(String realizedFlowsXml) {
177 this.realizedFlowsXml = realizedFlowsXml;
178 }
179
180 }