1 | |
package org.kuali.rice.krms.framework.engine.result; |
2 | |
|
3 | |
import java.text.SimpleDateFormat; |
4 | |
import java.util.Date; |
5 | |
import java.util.EventObject; |
6 | |
|
7 | |
import org.kuali.rice.krms.api.ExecutionEnvironment; |
8 | |
import org.kuali.rice.krms.api.ResultEvent; |
9 | |
|
10 | |
public class BasicResult extends EventObject implements ResultEvent{ |
11 | |
private static final long serialVersionUID = -4124200802034785921L; |
12 | |
|
13 | |
protected String type; |
14 | |
protected Date timestamp; |
15 | |
protected ExecutionEnvironment environment; |
16 | 0 | protected Boolean result = null; |
17 | |
|
18 | |
public BasicResult(String eventType, Object source, ExecutionEnvironment environment, boolean result) { |
19 | 0 | this(eventType, source, environment); |
20 | 0 | this.result = new Boolean(result); |
21 | 0 | } |
22 | |
|
23 | |
public BasicResult(String eventType, Object source, ExecutionEnvironment environment) { |
24 | 0 | super(source); |
25 | 0 | this.type = eventType; |
26 | 0 | this.timestamp = new Date(); |
27 | 0 | this.environment = environment; |
28 | 0 | } |
29 | |
|
30 | |
@Override |
31 | |
public String getType() { |
32 | 0 | return type; |
33 | |
} |
34 | |
|
35 | |
@Override |
36 | |
public Date getTimestamp() { |
37 | 0 | return new Date(timestamp.getTime()); |
38 | |
} |
39 | |
|
40 | |
@Override |
41 | |
public ExecutionEnvironment getEnvironment(){ |
42 | 0 | return environment; |
43 | |
} |
44 | |
|
45 | |
@Override |
46 | |
public Boolean getResult(){ |
47 | 0 | return result; |
48 | |
} |
49 | |
|
50 | |
public String toString(){ |
51 | 0 | StringBuffer sb = new StringBuffer(); |
52 | 0 | SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH.mm.ss.SSS"); |
53 | 0 | sb.append(df.format(this.getTimestamp())); |
54 | 0 | sb.append(" EventType: "+ getType()); |
55 | 0 | sb.append(" ( "+ this.getSource().toString()); |
56 | 0 | if (this.getResult() != null){ |
57 | 0 | sb.append(" evaluated to: "+ this.getResult().toString()); |
58 | |
} |
59 | 0 | sb.append(" )"); |
60 | 0 | return sb.toString(); |
61 | |
} |
62 | |
|
63 | |
} |