]> git.argeo.org Git - gpl/argeo-slc.git/blob - SlcExecutionStep.java
235b617e500f75cd6d95ae1265a86b4325eb1c68
[gpl/argeo-slc.git] / SlcExecutionStep.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.util.ArrayList;
20 import java.util.Date;
21 import java.util.List;
22 import java.util.StringTokenizer;
23 import java.util.UUID;
24
25 public class SlcExecutionStep {
26 public final static String TYPE_START = "START";
27 public final static String TYPE_END = "END";
28 public final static String TYPE_PHASE_START = "PHASE_START";
29 public final static String TYPE_PHASE_END = "PHASE_END";
30 public final static String TYPE_LOG = "LOG";
31
32 private String uuid = UUID.randomUUID().toString();
33 private String type;
34 private Date begin = new Date();
35 private List<String> logLines = new ArrayList<String>();
36
37 /** Empty constructor */
38 public SlcExecutionStep() {
39 }
40
41 /** Creates a step of type LOG. */
42 public SlcExecutionStep(String log) {
43 this(TYPE_LOG, log);
44 }
45
46 /** Creates a step of the given type. */
47 public SlcExecutionStep(String type, String log) {
48 this.type = type;
49 addLog(log);
50 }
51
52 public String getUuid() {
53 return uuid;
54 }
55
56 public void setUuid(String uuid) {
57 this.uuid = uuid;
58 }
59
60 public String getType() {
61 return type;
62 }
63
64 public void setType(String type) {
65 this.type = type;
66 }
67
68 public Date getBegin() {
69 return begin;
70 }
71
72 public void setBegin(Date begin) {
73 this.begin = begin;
74 }
75
76 public List<String> getLogLines() {
77 return logLines;
78 }
79
80 public void setLogLines(List<String> logLines) {
81 this.logLines = logLines;
82 }
83
84 public void addLog(String log) {
85 if (log == null)
86 return;
87
88 StringTokenizer st = new StringTokenizer(log, "\n");
89 while (st.hasMoreTokens())
90 logLines.add(st.nextToken());
91 }
92
93 @Override
94 public String toString() {
95 return getClass().getSimpleName() + "#" + uuid;
96 }
97
98 }