View Javadoc
1   /*
2    * Copyright 2006 The Kuali Foundation
3    * 
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl2.php
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.kuali.ole.gl.businessobject;
18  
19  import java.util.LinkedHashMap;
20  
21  import org.apache.commons.lang.StringUtils;
22  import org.kuali.ole.sys.OLEPropertyConstants;
23  import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
24  
25  /**
26   * Represents a GLCP criteria
27   */
28  public class CorrectionCriteria extends PersistableBusinessObjectBase implements Comparable {
29  
30      private String documentNumber;
31      private Integer correctionChangeGroupLineNumber;
32      private Integer correctionCriteriaLineNumber;
33      private Integer correctionStartPosition;
34      private Integer correctionEndPosition;
35      private String correctionOperatorCode;
36      private String correctionFieldValue;
37      private String correctionFieldName;
38  
39      private CorrectionChangeGroup correctionChangeGroup;
40  
41      public CorrectionCriteria() {
42          super();
43  
44      }
45  
46      public CorrectionCriteria(String documentNumber, Integer correctionChangeGroupLineNumber, Integer correctionCriteriaLineNumber) {
47          this.documentNumber = documentNumber;
48          this.correctionChangeGroupLineNumber = correctionChangeGroupLineNumber;
49          this.correctionCriteriaLineNumber = correctionCriteriaLineNumber;
50      }
51  
52      public boolean isEmpty() {
53          return (versionNumber == null) && StringUtils.isEmpty(correctionFieldValue);
54      }
55  
56      public String getDocumentNumber() {
57          return documentNumber;
58      }
59  
60      public void setDocumentNumber(String documentNumber) {
61          this.documentNumber = documentNumber;
62      }
63  
64      public Integer getCorrectionChangeGroupLineNumber() {
65          return correctionChangeGroupLineNumber;
66      }
67  
68      public void setCorrectionChangeGroupLineNumber(Integer correctionChangeGroupLineNumber) {
69          this.correctionChangeGroupLineNumber = correctionChangeGroupLineNumber;
70      }
71  
72      public Integer getCorrectionCriteriaLineNumber() {
73          return correctionCriteriaLineNumber;
74      }
75  
76      public void setCorrectionCriteriaLineNumber(Integer correctionCriteriaLineNumber) {
77          this.correctionCriteriaLineNumber = correctionCriteriaLineNumber;
78      }
79  
80      public String getCorrectionOperatorCode() {
81          return correctionOperatorCode;
82      }
83  
84      public void setCorrectionOperatorCode(String correctionOperatorCode) {
85          this.correctionOperatorCode = correctionOperatorCode;
86      }
87  
88      public String getCorrectionFieldValue() {
89          return correctionFieldValue;
90      }
91  
92      public void setCorrectionFieldValue(String correctionFieldValue) {
93          this.correctionFieldValue = correctionFieldValue;
94      }
95  
96      public CorrectionChangeGroup getCorrectionChangeGroup() {
97          return correctionChangeGroup;
98      }
99  
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.krad.bo.BusinessObjectBase#toStringMapper()
145      */
146     protected LinkedHashMap toStringMapper_RICE20_REFACTORME() {
147         LinkedHashMap m = new LinkedHashMap();
148         m.put(OLEPropertyConstants.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 }