View Javadoc
1   /*
2    * Copyright 2005-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  package org.kuali.ole.gl.businessobject;
17  
18  import java.sql.Date;
19  import java.util.Comparator;
20  import java.util.LinkedHashMap;
21  
22  import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
23  
24  public class OriginEntryGroup extends PersistableBusinessObjectBase {
25  
26      private static final String VALID_STRING = "Valid-";
27      private static final String INVALID_STRING = "Error-";
28      private static final String PROCESSED_STRING = "Process-";
29      private static final String NOT_PROCESSED_STRING = "Don't Process-";
30      private static final String SCRUB_STRING = "Scrub";
31      private static final String NO_SCRUB_STRING = "Don't Scrub";
32  
33      private Integer id;
34      private Date date;
35      private String sourceCode;
36      private Boolean valid;
37      private Boolean process;
38      private Boolean scrub;
39  
40      // This does not normally get populated. It only gets populated if
41      // getAllOriginEntryGroup() is called
42      private Integer rows = new Integer(0);
43  
44      private OriginEntrySource source;
45  
46      /**
47       * 
48       */
49      public OriginEntryGroup() {
50          super();
51      }
52  
53      protected LinkedHashMap toStringMapper_RICE20_REFACTORME() {
54          LinkedHashMap map = new LinkedHashMap();
55          map.put("id", id);
56          return map;
57      }
58  
59      public String getName() {
60          StringBuffer sb = new StringBuffer(this.getSourceCode());
61          sb.append(" ");
62          sb.append(source.getName());
63          sb.append(" (");
64          sb.append(rows);
65          sb.append(") ");
66          sb.append(this.getId());
67          sb.append(" ");
68          sb.append(this.getDate().toString());
69          sb.append(" ");
70          sb.append(valid ? VALID_STRING : INVALID_STRING);
71          sb.append(process ? PROCESSED_STRING : NOT_PROCESSED_STRING);
72          sb.append(scrub ? SCRUB_STRING : NO_SCRUB_STRING);
73          return sb.toString();
74      }
75  
76      public Integer getRows() {
77          return rows;
78      }
79  
80      public void setRows(Integer rows) {
81          this.rows = rows;
82      }
83  
84      public OriginEntrySource getSource() {
85          return source;
86      }
87  
88      public void setSource(OriginEntrySource oes) {
89          source = oes;
90      }
91  
92      public Date getDate() {
93          return date;
94      }
95  
96      public void setDate(Date date) {
97          this.date = date;
98      }
99  
100     public Integer getId() {
101         return id;
102     }
103 
104     public void setId(Integer id) {
105         this.id = id;
106     }
107 
108     public Boolean getProcess() {
109         return process;
110     }
111 
112     public void setProcess(Boolean process) {
113         this.process = process;
114     }
115 
116     public Boolean getScrub() {
117         return scrub;
118     }
119 
120     public void setScrub(Boolean scrub) {
121         this.scrub = scrub;
122     }
123 
124     public String getSourceCode() {
125         return sourceCode;
126     }
127 
128     public void setSourceCode(String sourceCode) {
129         this.sourceCode = sourceCode;
130     }
131 
132     public Boolean getValid() {
133         return valid;
134     }
135 
136     public void setValid(Boolean valid) {
137         this.valid = valid;
138     }
139     
140     /**
141      * An implementation of Comparator which compares origin entry groups by their source attribute
142      */
143     public static class GroupTypeComparator implements Comparator {
144         /**
145          * Constructs a GroupTypeComparator instance
146          */
147         public GroupTypeComparator() {
148         }
149 
150         /**
151          * Compares origin entry groups based on the alphabeticality of their source attributes
152          * 
153          * @param c1 the first origin entry group to compare
154          * @param c2 the origin entry group compared to
155          * @return a negative if c1's source is less than c2's, 0 if they are equal, a positive if c1's source is greater than c2's
156          * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
157          */
158         public int compare(Object c1, Object c2) {
159 
160             OriginEntryGroup oeg1 = (OriginEntryGroup) c1;
161             OriginEntryGroup oeg2 = (OriginEntryGroup) c2;
162 
163             String sort1 = oeg1.getSourceCode();
164             String sort2 = oeg2.getSourceCode();
165 
166             int c = sort1.compareTo(sort2);
167             if (c != 0) {
168                 return c;
169             }
170             return oeg1.getId().compareTo(oeg2.getId());
171         }
172     }
173 
174 }