1 package org.kuali.ole.sys.batch;
2
3 import java.util.ArrayList;
4 import java.util.List;
5
6
7
8
9 public final class FlatFileTransactionInformation {
10 public enum ResultCode { SUCCESS, FAILURE, ERROR, INCOMPLETE }
11 public enum EntryType { INFO,WARN, ERROR }
12
13 private String flatFileDataIdentifier;
14 private ResultCode result;
15 private List<String[]> messages;
16
17
18
19
20 public FlatFileTransactionInformation() {
21 this.messages = new ArrayList<String[]>();
22 }
23
24
25
26
27
28 public FlatFileTransactionInformation(String flatFileDataIdentifier) {
29 this.flatFileDataIdentifier = flatFileDataIdentifier;
30 this.result = ResultCode.INCOMPLETE;
31 this.messages = new ArrayList<String[]>();
32 }
33
34
35
36
37
38
39 public static String getEntryTypeString(EntryType type) {
40 if (type == null) return "UNKNOWN";
41 return type.name();
42 }
43
44
45
46
47
48
49 public static String getResultCodeString(ResultCode resultCode) {
50 if (resultCode == null) return "UNKNOWN";
51 return resultCode.name();
52 }
53
54
55
56
57 public ResultCode getResult() {
58 return result;
59 }
60
61
62
63
64 public String getResultString() {
65 return getResultCodeString(result);
66 }
67
68
69
70
71
72 private void setResult(ResultCode result) {
73 this.result = result;
74 }
75
76
77
78
79 public void setSuccessResult() {
80 this.result = ResultCode.SUCCESS;
81 }
82
83
84
85
86 public void setFailureResult() {
87 this.result = ResultCode.FAILURE;
88 }
89
90
91
92
93 public void setErrorResult() {
94 this.result = ResultCode.ERROR;
95 }
96
97
98
99
100 public String getFlatFileDataIdentifier() {
101 return flatFileDataIdentifier;
102 }
103
104
105
106
107
108 public void setFlatFileDataIdentifier(String flatFileDataIdentifier) {
109 this.flatFileDataIdentifier = flatFileDataIdentifier;
110 }
111
112
113
114
115 public List<String[]> getMessages() {
116 return messages;
117 }
118
119
120
121
122
123
124 private void addMessage(EntryType entryType, String message) {
125 this.messages.add(new String[] { getEntryTypeString(entryType), message });
126 }
127
128
129
130
131
132 public void addErrorMessage(String message) {
133 addMessage(EntryType.ERROR, message);
134 }
135
136
137
138
139
140 public void addInfoMessage(String message) {
141 addMessage(EntryType.INFO, message);
142 }
143
144
145
146
147
148 public void addWarnMessage(String message) {
149 addMessage(EntryType.WARN, message);
150 }
151 }