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 org.apache.commons.lang.StringUtils; 019 020 public class CustomerLoadBatchError { 021 022 private String customerName; 023 private String propertyName; 024 private Class<?> propertyClass; 025 private String value; 026 private String description; 027 028 /** 029 * 030 * Default constructor with all internal fields defaulting to empty-string or null. 031 */ 032 public CustomerLoadBatchError() { 033 this.customerName = ""; 034 this.propertyName = ""; 035 this.propertyClass = null; 036 this.value = ""; 037 this.description = ""; 038 } 039 040 /** 041 * 042 * Constructor to initialize with just the customerName. 043 * @param customerName The customer name of the document being imported. 044 */ 045 public CustomerLoadBatchError(String customerName) { 046 this.customerName = customerName; 047 } 048 049 /** 050 * 051 * Constructs a CustomerLoadBatchError.java. 052 * @param customerName The customer name of the document being imported. 053 * @param propertyName The name of the property on the Customer BO. 054 * @param propertyClass The class of the property named by propertyName. 055 * @param value The original value of the field from the batch import document. 056 * @param description The description of the error that occurred. 057 */ 058 public CustomerLoadBatchError(String customerName, String propertyName, Class<?> propertyClass, String value, String description) { 059 this.customerName = customerName; 060 this.propertyName = propertyName; 061 this.propertyClass = propertyClass; 062 this.value = value; 063 this.description = description; 064 } 065 066 public String toString() { 067 return "[" + customerName + "] " + 068 ("class java.lang.Object".equals(propertyClass.toString()) || propertyClass == null ? "" : "(" + propertyClass.toString() + ") ") + 069 (StringUtils.isBlank(propertyName) ? "" : getPropertyNameLastElement() + ": ") + 070 (StringUtils.isBlank(value) || "N/A".equalsIgnoreCase(value) ? "" : "'" + value + "' - ") + 071 description; 072 } 073 074 public String getPropertyNameLastElement() { 075 if (StringUtils.isBlank(propertyName)) return propertyName; 076 077 String[] propertyNameElements = propertyName.split("\\."); 078 if (propertyNameElements.length <= 0) { 079 return propertyName; 080 } 081 else { 082 return propertyNameElements[propertyNameElements.length - 1]; 083 } 084 085 } 086 087 public String getCustomerName() { 088 return customerName; 089 } 090 091 public void setCustomerName(String customerName) { 092 this.customerName = customerName; 093 } 094 095 public String getPropertyName() { 096 return propertyName; 097 } 098 099 public void setPropertyName(String propertyName) { 100 this.propertyName = propertyName; 101 } 102 103 public Class<?> getPropertyClass() { 104 return propertyClass; 105 } 106 107 public void setPropertyClass(Class<?> propertyClass) { 108 this.propertyClass = propertyClass; 109 } 110 111 public String getValue() { 112 return value; 113 } 114 115 public void setValue(String value) { 116 this.value = value; 117 } 118 119 public String getDescription() { 120 return description; 121 } 122 123 public void setDescription(String description) { 124 this.description = description; 125 } 126 127 }