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