View Javadoc
1   /*
2    * The Kuali Financial System, a comprehensive financial management system for higher education.
3    * 
4    * Copyright 2005-2014 The Kuali Foundation
5    * 
6    * This program is free software: you can redistribute it and/or modify
7    * it under the terms of the GNU Affero General Public License as
8    * published by the Free Software Foundation, either version 3 of the
9    * License, or (at your option) any later version.
10   * 
11   * This program is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   * GNU Affero General Public License for more details.
15   * 
16   * You should have received a copy of the GNU Affero General Public License
17   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18   */
19  package org.kuali.kfs.module.ar.batch.report;
20  
21  import java.util.ArrayList;
22  import java.util.List;
23  
24  /**
25   * 
26   * Represents one lockbox object from a batch file, and its results.
27   * 
28   */
29  
30  public class LockboxLoadResult {
31  	public enum ResultCode { SUCCESS, FAILURE, ERROR, INCOMPLETE }
32      public enum EntryType { INFO, ERROR } 
33  
34      private String filename;
35      private String lockboxNumber;
36      private ResultCode result;
37      
38      private List<String[]> messages;
39      
40      public LockboxLoadResult() {
41          this.messages = new ArrayList<String[]>();
42      }
43      
44      public LockboxLoadResult(String filename, String lockboxNumber) {
45          this.filename = filename;
46          this.lockboxNumber = lockboxNumber;
47          this.result = ResultCode.INCOMPLETE;
48          this.messages = new ArrayList<String[]>();
49      }
50      
51      public static String getEntryTypeString(EntryType type) {
52          String result = "UNKNOWN";
53          switch (type) {
54              case INFO: result = "INFO"; break;
55              case ERROR: result = "ERROR"; break;
56          }
57          return result;
58      }
59      
60      public static String getResultCodeString(ResultCode resultCode) {
61          String result = "UNKNOWN";
62          switch (resultCode) {
63              case SUCCESS: result = "SUCCESS"; break;
64              case FAILURE: result = "FAILURES"; break;
65              case ERROR: result = "ERROR"; break;
66              case INCOMPLETE: result = "INCOMPLETE"; break;
67          }
68          return result;
69      }
70      
71      public String getFilename() {
72          return filename;
73      }
74      
75      public void setFilename(String filename) {
76          this.filename = filename;
77      }
78      
79      public ResultCode getResult() {
80          return result;
81      }
82      
83      public String getResultString() {
84          return getResultCodeString(result);
85      }
86      
87      private void setResult(ResultCode result) {
88          this.result = result;
89      }
90      
91      public void setSuccessResult() {
92          this.result = ResultCode.SUCCESS;
93      }
94      
95      public void setFailureResult() {
96          this.result = ResultCode.FAILURE;
97      }
98      
99      public void setErrorResult() {
100         this.result = ResultCode.ERROR;
101     }
102         
103     public String getLockboxNumber() {
104 		return lockboxNumber;
105 	}
106 
107 	public void setLockboxNumber(String lockboxNumber) {
108 		this.lockboxNumber = lockboxNumber;
109 	}
110 
111 	public List<String[]> getMessages() {
112         return messages;
113     }
114     
115     private void addMessage(EntryType entryType, String message) {
116         this.messages.add(new String[] { getEntryTypeString(entryType), message });
117     }
118     
119     public void addErrorMessage(String message) {
120         addMessage(EntryType.ERROR, message);
121     }
122     
123     public void addInfoMessage(String message) {
124         addMessage(EntryType.INFO, message);
125     }
126 	
127 }