001 /* 002 * Copyright 2011 The Kuali Foundation. 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.kfs.module.ar.batch.report; 017 018 import java.util.ArrayList; 019 import java.util.List; 020 021 /** 022 * 023 * Represents one customer object from a batch file, and its results. 024 * 025 */ 026 public class CustomerLoadResult { 027 028 public enum ResultCode { SUCCESS, FAILURE, ERROR, INCOMPLETE } 029 public enum EntryType { INFO, ERROR } 030 031 private String filename; 032 private String customerName; 033 private ResultCode result; 034 private String workflowDocId; 035 036 private List<String[]> messages; 037 038 public CustomerLoadResult() { 039 this.messages = new ArrayList<String[]>(); 040 } 041 042 public CustomerLoadResult(String filename, String customerName) { 043 this.filename = filename; 044 this.customerName = customerName; 045 this.result = ResultCode.INCOMPLETE; 046 this.messages = new ArrayList<String[]>(); 047 } 048 049 public static String getEntryTypeString(EntryType type) { 050 String result = "UNKNOWN"; 051 switch (type) { 052 case INFO: result = "INFO"; break; 053 case ERROR: result = "ERROR"; break; 054 } 055 return result; 056 } 057 058 public static String getResultCodeString(ResultCode resultCode) { 059 String result = "UNKNOWN"; 060 switch (resultCode) { 061 case SUCCESS: result = "SUCCESS"; break; 062 case FAILURE: result = "FAILURES"; break; 063 case ERROR: result = "ERROR"; break; 064 case INCOMPLETE: result = "INCOMPLETE"; break; 065 } 066 return result; 067 } 068 069 public String getFilename() { 070 return filename; 071 } 072 073 public void setFilename(String filename) { 074 this.filename = filename; 075 } 076 077 public String getCustomerName() { 078 return customerName; 079 } 080 081 public void setCustomerName(String customerName) { 082 this.customerName = customerName; 083 } 084 085 public ResultCode getResult() { 086 return result; 087 } 088 089 public String getResultString() { 090 return getResultCodeString(result); 091 } 092 093 private void setResult(ResultCode result) { 094 this.result = result; 095 } 096 097 public void setSuccessResult() { 098 this.result = ResultCode.SUCCESS; 099 } 100 101 public void setFailureResult() { 102 this.result = ResultCode.FAILURE; 103 } 104 105 public void setErrorResult() { 106 this.result = ResultCode.ERROR; 107 } 108 109 public String getWorkflowDocId() { 110 return workflowDocId; 111 } 112 113 public void setWorkflowDocId(String workflowDocId) { 114 this.workflowDocId = workflowDocId; 115 } 116 117 public List<String[]> getMessages() { 118 return messages; 119 } 120 121 private void addMessage(EntryType entryType, String message) { 122 this.messages.add(new String[] { getEntryTypeString(entryType), message }); 123 } 124 125 public void addErrorMessage(String message) { 126 addMessage(EntryType.ERROR, message); 127 } 128 129 public void addInfoMessage(String message) { 130 addMessage(EntryType.INFO, message); 131 } 132 133 }