]> git.argeo.org Git - gpl/argeo-slc.git/blob - org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionStep.java
Upgrade all classpaths to Java 11
[gpl/argeo-slc.git] / org.argeo.slc.api / src / org / argeo / slc / execution / ExecutionStep.java
1 package org.argeo.slc.execution;
2
3 import java.io.Serializable;
4 import java.util.Date;
5
6 /**
7 * An atomic step to be notified in during an {@link ExecutionProcess}. Can be a
8 * log or the start/end of a phase, etc.
9 */
10 public class ExecutionStep implements Serializable {
11 private static final long serialVersionUID = 798640526532912161L;
12
13 public final static String PHASE_START = "PHASE_START";
14 public final static String PHASE_END = "PHASE_END";
15 public final static String ERROR = "ERROR";
16 public final static String WARNING = "WARNING";
17 public final static String INFO = "INFO";
18 public final static String DEBUG = "DEBUG";
19 public final static String TRACE = "TRACE";
20
21 /** @deprecated */
22 public final static String START = "START";
23 /** @deprecated */
24 public final static String END = "END";
25
26 // TODO make the fields final and private when we don't need POJO support
27 // anymore (that
28 // is when SlcExecutionStep is removed)
29 protected String type;
30 protected String thread;
31 protected Date timestamp;
32 protected String log;
33
34 private String location;
35
36 /** Empty constructor */
37 public ExecutionStep() {
38 Thread currentThread = Thread.currentThread();
39 thread = currentThread.getName();
40 }
41
42 /** Creates a step at the current date */
43 public ExecutionStep(String location, String type, String log) {
44 this(location, new Date(), type, log);
45 }
46
47 /** Creates a step of the given type. */
48 public ExecutionStep(String location, Date timestamp, String type,
49 String log) {
50 this(location, timestamp, type, log, Thread.currentThread().getName());
51 }
52
53 public ExecutionStep(String location, Date timestamp, String type,
54 String log, String thread) {
55 this.location = location;
56 this.type = type;
57 this.timestamp = timestamp;
58 this.thread = thread;
59 this.log = addLog(log);
60 }
61
62 public String getType() {
63 return type;
64 }
65
66 public Date getTimestamp() {
67 return timestamp;
68 }
69
70 public String getThread() {
71 return thread;
72 }
73
74 /**
75 * Return the string that should be stored in the log field. Can be null if
76 * another mechanism is used to store log lines.
77 */
78 protected String addLog(String log) {
79 return log;
80 }
81
82 public String getLog() {
83 return log;
84 }
85
86 @Override
87 public String toString() {
88 return "Execution step, thread=" + thread + ", type=" + type;
89 }
90
91 /** Typically the logging category */
92 public String getLocation() {
93 return location;
94 }
95
96 }