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