]> git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/process/SlcExecution.java
Fix parameters not properly passed
[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 import org.argeo.slc.execution.ExecutionProcess;
27
28 /** @deprecated use other implementations of {@link ExecutionProcess} */
29 public class SlcExecution implements ExecutionProcess, Serializable {
30 private static final long serialVersionUID = -7607457971382118466L;
31
32 public final static String UNKOWN_HOST = "UNKOWN_HOST";
33
34 private String uuid;
35 private String host;
36 private String user;
37 private String type;
38 private String status = NEW;
39 private Map<String, String> attributes = new TreeMap<String, String>();
40
41 /** TODO: Synchronize */
42 private List<SlcExecutionStep> steps = new ArrayList<SlcExecutionStep>();
43 private List<RealizedFlow> realizedFlows = new ArrayList<RealizedFlow>();
44
45 /** Attachment uuid. */
46 private String realizedFlowsXml = null;
47
48 public List<RealizedFlow> getRealizedFlows() {
49 return realizedFlows;
50 }
51
52 public void setRealizedFlows(List<RealizedFlow> realizedFlows) {
53 this.realizedFlows = realizedFlows;
54 }
55
56 public List<SlcExecutionStep> getSteps() {
57 return steps;
58 }
59
60 public void setSteps(List<SlcExecutionStep> steps) {
61 this.steps = steps;
62 }
63
64 public String getUuid() {
65 return uuid;
66 }
67
68 public void setUuid(String uuid) {
69 this.uuid = uuid;
70 }
71
72 public String getHost() {
73 return host;
74 }
75
76 public void setHost(String host) {
77 this.host = host;
78 }
79
80 public String getUser() {
81 return user;
82 }
83
84 public void setUser(String user) {
85 this.user = user;
86 }
87
88 public String getType() {
89 return type;
90 }
91
92 public void setType(String type) {
93 this.type = type;
94 }
95
96 public String getStatus() {
97 return status;
98 }
99
100 public void setStatus(String status) {
101 this.status = status;
102 }
103
104 public SlcExecutionStep currentStep() {
105 synchronized (steps) {
106 if (steps.size() > 0)
107 return steps.get(steps.size() - 1);
108 else
109 return null;
110 }
111 }
112
113 @Override
114 public boolean equals(Object obj) {
115 if (obj instanceof SlcExecution) {
116 return getUuid().equals(((SlcExecution) obj).getUuid());
117 }
118 return false;
119 }
120
121 @Override
122 public int hashCode() {
123 return getUuid().hashCode();
124 }
125
126 public Map<String, String> getAttributes() {
127 return attributes;
128 }
129
130 public void setAttributes(Map<String, String> attributes) {
131 this.attributes = attributes;
132 }
133
134 public String toString() {
135 StringBuffer buf = new StringBuffer(getClass().getSimpleName());
136 buf.append('#').append(uuid);
137 buf.append(" status=").append(status);
138 buf.append(" attributes=").append(attributes);
139 return buf.toString();
140 }
141
142 public Date getStartDate() {
143 synchronized (steps) {
144 if (steps.size() == 0)
145 return null;
146 else
147 return steps.get(0).getTimestamp();
148 }
149 }
150
151 public Date getEndDate() {
152 if (!status.equals(COMPLETED) && !status.equals(ERROR))
153 return null;
154
155 synchronized (steps) {
156 if (steps.size() == 0)
157 return null;
158 else
159 return steps.get(steps.size() - 1).getTimestamp();
160 }
161 }
162
163 /**
164 * Not (yet) a stable API, should not be relied upon!
165 *
166 * @return an id or an url allowing to retrieve the XML, not the XML itself!
167 */
168 public String getRealizedFlowsXml() {
169 return realizedFlowsXml;
170 }
171
172 /** Not (yet) a stable API, should not be relied upon! */
173 public void setRealizedFlowsXml(String realizedFlowsXml) {
174 this.realizedFlowsXml = realizedFlowsXml;
175 }
176
177 }