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