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 * Represents a GLCP criteria
027 */
028 public class CorrectionCriteria extends PersistableBusinessObjectBase implements Comparable {
029
030 private String documentNumber;
031 private Integer correctionChangeGroupLineNumber;
032 private Integer correctionCriteriaLineNumber;
033 private Integer correctionStartPosition;
034 private Integer correctionEndPosition;
035 private String correctionOperatorCode;
036 private String correctionFieldValue;
037 private String correctionFieldName;
038
039 private CorrectionChangeGroup correctionChangeGroup;
040
041 public CorrectionCriteria() {
042 super();
043
044 }
045
046 public CorrectionCriteria(String documentNumber, Integer correctionChangeGroupLineNumber, Integer correctionCriteriaLineNumber) {
047 this.documentNumber = documentNumber;
048 this.correctionChangeGroupLineNumber = correctionChangeGroupLineNumber;
049 this.correctionCriteriaLineNumber = correctionCriteriaLineNumber;
050 }
051
052 public boolean isEmpty() {
053 return (versionNumber == null) && StringUtils.isEmpty(correctionFieldValue);
054 }
055
056 public String getDocumentNumber() {
057 return documentNumber;
058 }
059
060 public void setDocumentNumber(String documentNumber) {
061 this.documentNumber = documentNumber;
062 }
063
064 public Integer getCorrectionChangeGroupLineNumber() {
065 return correctionChangeGroupLineNumber;
066 }
067
068 public void setCorrectionChangeGroupLineNumber(Integer correctionChangeGroupLineNumber) {
069 this.correctionChangeGroupLineNumber = correctionChangeGroupLineNumber;
070 }
071
072 public Integer getCorrectionCriteriaLineNumber() {
073 return correctionCriteriaLineNumber;
074 }
075
076 public void setCorrectionCriteriaLineNumber(Integer correctionCriteriaLineNumber) {
077 this.correctionCriteriaLineNumber = correctionCriteriaLineNumber;
078 }
079
080 public String getCorrectionOperatorCode() {
081 return correctionOperatorCode;
082 }
083
084 public void setCorrectionOperatorCode(String correctionOperatorCode) {
085 this.correctionOperatorCode = correctionOperatorCode;
086 }
087
088 public String getCorrectionFieldValue() {
089 return correctionFieldValue;
090 }
091
092 public void setCorrectionFieldValue(String correctionFieldValue) {
093 this.correctionFieldValue = correctionFieldValue;
094 }
095
096 public CorrectionChangeGroup getCorrectionChangeGroup() {
097 return correctionChangeGroup;
098 }
099
100 public void setCorrectionChangeGroup(CorrectionChangeGroup correctionChangeGroup) {
101 this.correctionChangeGroup = correctionChangeGroup;
102 }
103
104 public String getCorrectionFieldName() {
105 return correctionFieldName;
106 }
107
108 public void setCorrectionFieldName(String correctionFieldName) {
109 this.correctionFieldName = correctionFieldName;
110 }
111
112 /**
113 * Compares this object with another CorrectionCriteria based on document number,
114 * correction change group line number, and correction criteria line number
115 *
116 * @see java.lang.Comparable#compareTo(java.lang.Object)
117 */
118 public int compareTo(Object o) {
119 CorrectionCriteria cc = (CorrectionCriteria) o;
120
121 String thisFdocNbr = documentNumber == null ? "" : documentNumber;
122 String thatFdocNbr = cc.documentNumber == null ? "" : cc.documentNumber;
123 int c = thisFdocNbr.compareTo(thatFdocNbr);
124
125 if (c == 0) {
126 Integer thisGn = correctionChangeGroupLineNumber == null ? 0 : correctionChangeGroupLineNumber;
127 Integer thatGn = cc.correctionChangeGroupLineNumber == null ? 0 : cc.correctionChangeGroupLineNumber;
128 c = thisGn.compareTo(thatGn);
129 if (c == 0) {
130 Integer thisCln = correctionCriteriaLineNumber == null ? 0 : correctionCriteriaLineNumber;
131 Integer thatCln = correctionCriteriaLineNumber == null ? 0 : cc.correctionCriteriaLineNumber;
132 return c = thisCln.compareTo(thatCln);
133 }
134 else {
135 return c;
136 }
137 }
138 else {
139 return c;
140 }
141 }
142
143 /**
144 * @see org.kuali.rice.kns.bo.BusinessObjectBase#toStringMapper()
145 */
146 protected LinkedHashMap toStringMapper() {
147 LinkedHashMap m = new LinkedHashMap();
148 m.put(KFSPropertyConstants.DOCUMENT_NUMBER, this.documentNumber);
149 if (this.correctionChangeGroupLineNumber != null) {
150 m.put("correctionChangeGroupLineNumber", this.correctionChangeGroupLineNumber.toString());
151 }
152 if (this.correctionCriteriaLineNumber != null) {
153 m.put("correctionCriteriaLineNumber", this.correctionCriteriaLineNumber.toString());
154 }
155 return m;
156 }
157 }