]> git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/process/SlcExecutionStep.java
Refactor runtime
[gpl/argeo-slc.git] / runtime / org.argeo.slc.specs / src / main / java / org / argeo / slc / process / SlcExecutionStep.java
1 package org.argeo.slc.process;
2
3 import java.util.ArrayList;
4 import java.util.Date;
5 import java.util.List;
6 import java.util.StringTokenizer;
7 import java.util.UUID;
8
9 public class SlcExecutionStep {
10 public final static String TYPE_START = "START";
11 public final static String TYPE_END = "END";
12 public final static String TYPE_PHASE_START = "PHASE_START";
13 public final static String TYPE_PHASE_END = "PHASE_END";
14 public final static String TYPE_LOG = "LOG";
15
16 private String uuid = UUID.randomUUID().toString();
17 private String type;
18 private Date begin = new Date();
19 private List<String> logLines = new ArrayList<String>();
20
21 /** Empty constructor */
22 public SlcExecutionStep() {
23 }
24
25 /** Creates a step of type LOG. */
26 public SlcExecutionStep(String log) {
27 this(TYPE_LOG, log);
28 }
29
30 /** Creates a step of the given type. */
31 public SlcExecutionStep(String type, String log) {
32 this.type = type;
33 addLog(log);
34 }
35
36 public String getUuid() {
37 return uuid;
38 }
39
40 public void setUuid(String uuid) {
41 this.uuid = uuid;
42 }
43
44 public String getType() {
45 return type;
46 }
47
48 public void setType(String type) {
49 this.type = type;
50 }
51
52 public Date getBegin() {
53 return begin;
54 }
55
56 public void setBegin(Date begin) {
57 this.begin = begin;
58 }
59
60 public List<String> getLogLines() {
61 return logLines;
62 }
63
64 public void setLogLines(List<String> logLines) {
65 this.logLines = logLines;
66 }
67
68 public void addLog(String log) {
69 if (log == null)
70 return;
71
72 StringTokenizer st = new StringTokenizer(log, "\n");
73 while (st.hasMoreTokens())
74 logLines.add(st.nextToken());
75 }
76
77 @Override
78 public String toString() {
79 return getClass().getSimpleName() + "#" + uuid;
80 }
81
82 }