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 017 package org.kuali.kfs.gl.businessobject; 018 019 import java.util.LinkedHashMap; 020 021 import org.apache.commons.lang.StringUtils; 022 import org.kuali.kfs.sys.KFSPropertyConstants; 023 import org.kuali.rice.kns.bo.PersistableBusinessObjectBase; 024 025 /** 026 * A class that represents a change to any origin entry that was altered within a GLCP Document 027 */ 028 public class CorrectionChange extends PersistableBusinessObjectBase implements Comparable { 029 030 private String documentNumber; 031 private Integer correctionChangeGroupLineNumber; 032 private Integer correctionChangeLineNumber; 033 private Integer correctionStartPosition; 034 private Integer correctionEndPosition; 035 private String correctionFieldValue; 036 private String correctionFieldName; 037 038 public CorrectionChange() { 039 super(); 040 041 } 042 043 public CorrectionChange(String documentNumber, Integer correctionChangeGroupLineNumber, Integer correctionChangeLineNumber) { 044 super(); 045 this.documentNumber = documentNumber; 046 this.correctionChangeGroupLineNumber = correctionChangeGroupLineNumber; 047 this.correctionChangeLineNumber = correctionChangeLineNumber; 048 } 049 050 public boolean isEmpty() { 051 return (versionNumber == null) && StringUtils.isEmpty(correctionFieldValue); 052 } 053 054 public String getDocumentNumber() { 055 return documentNumber; 056 } 057 058 public void setDocumentNumber(String documentNumber) { 059 this.documentNumber = documentNumber; 060 } 061 062 063 public Integer getCorrectionChangeGroupLineNumber() { 064 return correctionChangeGroupLineNumber; 065 } 066 067 public void setCorrectionChangeGroupLineNumber(Integer correctionChangeGroupLineNumber) { 068 this.correctionChangeGroupLineNumber = correctionChangeGroupLineNumber; 069 } 070 071 public Integer getCorrectionChangeLineNumber() { 072 return correctionChangeLineNumber; 073 } 074 075 public void setCorrectionChangeLineNumber(Integer correctionChangeLineNumber) { 076 this.correctionChangeLineNumber = correctionChangeLineNumber; 077 } 078 079 public String getCorrectionFieldValue() { 080 return correctionFieldValue; 081 } 082 083 public void setCorrectionFieldValue(String correctionFieldValue) { 084 this.correctionFieldValue = correctionFieldValue; 085 } 086 087 public String getCorrectionFieldName() { 088 return correctionFieldName; 089 } 090 091 public void setCorrectionFieldName(String correctionFieldName) { 092 this.correctionFieldName = correctionFieldName; 093 } 094 095 public int compareTo(Object o) { 096 CorrectionChange cc = (CorrectionChange) o; 097 098 String thisFdocNbr = documentNumber == null ? "" : documentNumber; 099 String thatFdocNbr = cc.documentNumber == null ? "" : cc.documentNumber; 100 int c = thisFdocNbr.compareTo(thatFdocNbr); 101 102 if (c == 0) { 103 Integer thisGn = correctionChangeGroupLineNumber == null ? 0 : correctionChangeGroupLineNumber; 104 Integer thatGn = cc.correctionChangeGroupLineNumber == null ? 0 : cc.correctionChangeGroupLineNumber; 105 c = thisGn.compareTo(thatGn); 106 if (c == 0) { 107 Integer thisCln = correctionChangeLineNumber == null ? 0 : correctionChangeLineNumber; 108 Integer thatCln = correctionChangeLineNumber == null ? 0 : cc.correctionChangeLineNumber; 109 return c = thisCln.compareTo(thatCln); 110 } 111 else { 112 return c; 113 } 114 } 115 else { 116 return c; 117 } 118 } 119 120 /** 121 * @see org.kuali.rice.kns.bo.BusinessObjectBase#toStringMapper() 122 */ 123 protected LinkedHashMap toStringMapper() { 124 LinkedHashMap m = new LinkedHashMap(); 125 m.put(KFSPropertyConstants.DOCUMENT_NUMBER, this.documentNumber); 126 if (this.correctionChangeGroupLineNumber != null) { 127 m.put("correctionChangeGroupLineNumber", this.correctionChangeGroupLineNumber.toString()); 128 } 129 if (this.correctionChangeLineNumber != null) { 130 m.put("correctionChangeLineNumber", this.correctionChangeLineNumber.toString()); 131 } 132 return m; 133 } 134 135 }