]> git.argeo.org Git - gpl/argeo-slc.git/blob - org.argeo.slc.core/src/main/java/org/argeo/slc/core/process/SlcExecutionStep.java
Replace test result id by UUID
[gpl/argeo-slc.git] / org.argeo.slc.core / src / main / java / org / argeo / slc / core / process / SlcExecutionStep.java
1 package org.argeo.slc.core.process;
2
3 import java.io.IOException;
4 import java.io.StringReader;
5 import java.io.StringWriter;
6 import java.util.Date;
7 import java.util.List;
8 import java.util.UUID;
9 import java.util.Vector;
10
11 import org.apache.commons.io.IOUtils;
12
13 public class SlcExecutionStep {
14 private String uuid;
15 private String type;
16 private Date begin;
17 private List<String> logLines = new Vector<String>();
18
19 /** Empty constructor */
20 public SlcExecutionStep() {
21 }
22
23 public SlcExecutionStep(String type, String log) {
24 this.type = type;
25 this.begin = new Date();
26 this.uuid = UUID.randomUUID().toString();
27 addLog(log);
28 }
29
30 public String getUuid() {
31 return uuid;
32 }
33
34 public void setUuid(String uuid) {
35 this.uuid = uuid;
36 }
37
38 public String getType() {
39 return type;
40 }
41
42 public void setType(String type) {
43 this.type = type;
44 }
45
46 public Date getBegin() {
47 return begin;
48 }
49
50 public void setBegin(Date begin) {
51 this.begin = begin;
52 }
53
54 public List<String> getLogLines() {
55 return logLines;
56 }
57
58 public void setLogLines(List<String> logLines) {
59 this.logLines = logLines;
60 }
61
62 public String logAsString() {
63 StringWriter writer = new StringWriter();
64 String log = writer.toString();
65 IOUtils.closeQuietly(writer);
66 return log;
67 }
68
69 public void addLog(String log) {
70 try {
71 List<String> lines = IOUtils.readLines(new StringReader(log));
72 logLines.addAll(lines);
73 } catch (IOException e) {
74 throw new RuntimeException("Cannot add log", e);
75 }
76 }
77
78 }