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   * A class that represents a change to any origin entry that was altered within a GLCP Document
27   */
28  public class CorrectionChange extends PersistableBusinessObjectBase implements Comparable {
29  
30      private String documentNumber;
31      private Integer correctionChangeGroupLineNumber;
32      private Integer correctionChangeLineNumber;
33      private Integer correctionStartPosition;
34      private Integer correctionEndPosition;
35      private String correctionFieldValue;
36      private String correctionFieldName;
37  
38      public CorrectionChange() {
39          super();
40  
41      }
42  
43      public CorrectionChange(String documentNumber, Integer correctionChangeGroupLineNumber, Integer correctionChangeLineNumber) {
44          super();
45          this.documentNumber = documentNumber;
46          this.correctionChangeGroupLineNumber = correctionChangeGroupLineNumber;
47          this.correctionChangeLineNumber = correctionChangeLineNumber;
48      }
49  
50      public boolean isEmpty() {
51          return (versionNumber == null) && StringUtils.isEmpty(correctionFieldValue);
52      }
53  
54      public String getDocumentNumber() {
55          return documentNumber;
56      }
57  
58      public void setDocumentNumber(String documentNumber) {
59          this.documentNumber = documentNumber;
60      }
61  
62  
63      public Integer getCorrectionChangeGroupLineNumber() {
64          return correctionChangeGroupLineNumber;
65      }
66  
67      public void setCorrectionChangeGroupLineNumber(Integer correctionChangeGroupLineNumber) {
68          this.correctionChangeGroupLineNumber = correctionChangeGroupLineNumber;
69      }
70  
71      public Integer getCorrectionChangeLineNumber() {
72          return correctionChangeLineNumber;
73      }
74  
75      public void setCorrectionChangeLineNumber(Integer correctionChangeLineNumber) {
76          this.correctionChangeLineNumber = correctionChangeLineNumber;
77      }
78  
79      public String getCorrectionFieldValue() {
80          return correctionFieldValue;
81      }
82  
83      public void setCorrectionFieldValue(String correctionFieldValue) {
84          this.correctionFieldValue = correctionFieldValue;
85      }
86  
87      public String getCorrectionFieldName() {
88          return correctionFieldName;
89      }
90  
91      public void setCorrectionFieldName(String correctionFieldName) {
92          this.correctionFieldName = correctionFieldName;
93      }
94  
95      public int compareTo(Object o) {
96          CorrectionChange cc = (CorrectionChange) o;
97  
98          String thisFdocNbr = documentNumber == null ? "" : documentNumber;
99          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.krad.bo.BusinessObjectBase#toStringMapper()
122      */
123     protected LinkedHashMap toStringMapper_RICE20_REFACTORME() {
124         LinkedHashMap m = new LinkedHashMap();
125         m.put(OLEPropertyConstants.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 }