View Javadoc

1   /**
2    * Copyright 2004-2012 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.hr.time.calendar;
17  
18  import java.sql.Date;
19  import java.sql.Time;
20  
21  import javax.persistence.Transient;
22  
23  import org.joda.time.DateTime;
24  import org.joda.time.LocalDateTime;
25  import org.kuali.hr.core.KPMEConstants;
26  import org.kuali.hr.time.service.base.TkServiceLocator;
27  import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
28  
29  /**
30   * This class uses java.sql.Time and java.sql.Date because for each respective component
31   * we are only interested in a partial Date or Time, that is for example:
32   * <p/>
33   * 3:55 pm   (at any date)
34   * 6/22/2010 (at any time)
35   *
36   * Make sure you are aware of whether or not you need a Local Relative time or
37   * an absolute server time.
38   *
39   * Local Relative Time Methods: (Time/Date without Timezone)
40   *
41   * LocalDateTime : getBeginLocalDateTime()
42   * LocalDateTime : getEndLocalDateTime()
43   *
44   * Absolute Methods:
45   *
46   * java.util.Date : getEndPeriodDateTime()
47   * java.util.Date : getBeginPeriodDateTime()
48   *
49   */
50  public class CalendarEntries extends PersistableBusinessObjectBase implements Comparable<CalendarEntries>{
51      public static final String CACHE_NAME = KPMEConstants.APPLICATION_NAMESPACE_CODE + "/" + "CalendarEntries";
52      /**
53       *
54       */
55      private static final long serialVersionUID = 1L;
56  
57      private String hrCalendarEntriesId;
58      private String hrCalendarId;
59      private String calendarName;
60  
61      private java.util.Date beginPeriodDateTime;
62  
63      private java.util.Date endPeriodDateTime;
64  
65      @Transient
66      private java.sql.Date beginPeriodDate;
67      @Transient
68      private java.sql.Date endPeriodDate;
69      @Transient
70      private Time beginPeriodTime;
71      @Transient
72      private Time endPeriodTime;
73  
74      private Date batchInitiateDate;
75      private Time batchInitiateTime;
76  
77      //this property is for the batch job
78      //that runs at the end of pay period
79      private Date batchEndPayPeriodDate;
80      private Time batchEndPayPeriodTime;
81  
82      private Date batchEmployeeApprovalDate;
83      private Time batchEmployeeApprovalTime;
84  
85      private Date batchSupervisorApprovalDate;
86      private Time batchSupervisorApprovalTime;
87  
88      private Calendar calendarObj;
89  
90  
91      /**
92       * Provides the Begin Period time without timezone information, used
93       * for relative calculations.
94       *
95       * @return A LocalDateTime representation of the begin period date/time.
96       */
97      public LocalDateTime getBeginLocalDateTime() {
98          return (new DateTime(this.getBeginPeriodDateTime())).toLocalDateTime();
99      }
100 
101     /**
102      * Provides the End Period time without timezone information, used
103      * for relative calculations.
104      *
105      * @return A LocalDateTime representation of the end period date/time.
106      */
107     public LocalDateTime getEndLocalDateTime() {
108         return (new DateTime(this.getEndPeriodDateTime())).toLocalDateTime();
109     }
110 
111     public String getHrCalendarId() {
112         calendarObj = TkServiceLocator.getCalendarService().getCalendarByGroup(this.getCalendarName());
113         if (calendarObj != null) {
114             this.setHrCalendarId(calendarObj.getHrCalendarId());
115         }
116         return hrCalendarId;
117     }
118 
119     public void setHrCalendarId(String hrCalendarId) {
120         this.hrCalendarId = hrCalendarId;
121     }
122 
123     public String getHrCalendarEntriesId() {
124 		return hrCalendarEntriesId;
125 	}
126 
127 	public void setHrCalendarEntriesId(String hrCalendarEntriesId) {
128 		this.hrCalendarEntriesId = hrCalendarEntriesId;
129 	}
130 
131 	public String getCalendarName() {
132 		return calendarName;
133 	}
134 
135 	public void setCalendarName(String calendarName) {
136 		this.calendarName = calendarName;
137 	}
138 
139 	public java.util.Date getBeginPeriodDateTime() {
140         return beginPeriodDateTime;
141     }
142 
143     public void setBeginPeriodDateTime(java.util.Date beginPeriodDateTime) {
144         this.beginPeriodDateTime = beginPeriodDateTime;
145         if (beginPeriodDateTime != null) {
146             setBeginPeriodDate(new java.sql.Date(beginPeriodDateTime.getTime()));
147             setBeginPeriodTime(new java.sql.Time(beginPeriodDateTime.getTime()));
148         }
149     }
150 
151     public java.util.Date getEndPeriodDateTime() {
152         return endPeriodDateTime;
153     }
154 
155     public void setEndPeriodDateTime(java.util.Date endPeriodDateTime) {
156         this.endPeriodDateTime = endPeriodDateTime;
157         if (endPeriodDateTime != null) {
158             setEndPeriodDate(new java.sql.Date(endPeriodDateTime.getTime()));
159             setEndPeriodTime(new java.sql.Time(endPeriodDateTime.getTime()));
160         }
161     }
162 
163     public java.sql.Date getBeginPeriodDate() {
164     	if(beginPeriodDate == null && this.getBeginPeriodDateTime() != null) {
165     		setBeginPeriodDate(new java.sql.Date(this.getBeginPeriodDateTime().getTime()));
166     	}
167         return beginPeriodDate;
168     }
169 
170     public void setBeginPeriodDate(java.sql.Date beginPeriodDate) {
171         this.beginPeriodDate = beginPeriodDate;
172     }
173 
174     public java.sql.Date getEndPeriodDate() {
175     	if(endPeriodDate == null && this.getEndPeriodDateTime() != null) {
176     		setEndPeriodDate(new java.sql.Date(this.getEndPeriodDateTime().getTime()));
177     	}
178         return endPeriodDate;
179     }
180 
181     public void setEndPeriodDate(java.sql.Date endPeriodDate) {
182         this.endPeriodDate = endPeriodDate;
183     }
184 
185     public Time getBeginPeriodTime() {
186         return beginPeriodTime;
187     }
188 
189     public void setBeginPeriodTime(Time beginPeriodTime) {
190         this.beginPeriodTime = beginPeriodTime;
191     }
192 
193     public Time getEndPeriodTime() {
194         return endPeriodTime;
195     }
196 
197     public void setEndPeriodTime(Time endPeriodTime) {
198         this.endPeriodTime = endPeriodTime;
199     }
200 
201     public Date getBatchInitiateDate() {
202         return batchInitiateDate;
203     }
204 
205     public void setBatchInitiateDate(Date batchInitiateDate) {
206         this.batchInitiateDate = batchInitiateDate;
207     }
208 
209     public Time getBatchInitiateTime() {
210         return batchInitiateTime;
211     }
212 
213     public void setBatchInitiateTime(Time batchInitiateTime) {
214         this.batchInitiateTime = batchInitiateTime;
215     }
216 
217     public Date getBatchEndPayPeriodDate() {
218         return batchEndPayPeriodDate;
219     }
220 
221     public void setBatchEndPayPeriodDate(Date batchEndPayPeriodDate) {
222         this.batchEndPayPeriodDate = batchEndPayPeriodDate;
223     }
224 
225     public Time getBatchEndPayPeriodTime() {
226         return batchEndPayPeriodTime;
227     }
228 
229     public void setBatchEndPayPeriodTime(Time batchEndPayPeriodTime) {
230         this.batchEndPayPeriodTime = batchEndPayPeriodTime;
231     }
232 
233     public Date getBatchEmployeeApprovalDate() {
234         return batchEmployeeApprovalDate;
235     }
236 
237     public void setBatchEmployeeApprovalDate(Date batchEmployeeApprovalDate) {
238         this.batchEmployeeApprovalDate = batchEmployeeApprovalDate;
239     }
240 
241     public Time getBatchEmployeeApprovalTime() {
242         return batchEmployeeApprovalTime;
243     }
244 
245     public void setBatchEmployeeApprovalTime(Time batchEmployeeApprovalTime) {
246         this.batchEmployeeApprovalTime = batchEmployeeApprovalTime;
247     }
248 
249     public Date getBatchSupervisorApprovalDate() {
250         return batchSupervisorApprovalDate;
251     }
252 
253     public void setBatchSupervisorApprovalDate(Date batchSupervisorApprovalDate) {
254         this.batchSupervisorApprovalDate = batchSupervisorApprovalDate;
255     }
256 
257     public Time getBatchSupervisorApprovalTime() {
258         return batchSupervisorApprovalTime;
259     }
260 
261     public void setBatchSupervisorApprovalTime(Time batchSupervisorApprovalTime) {
262         this.batchSupervisorApprovalTime = batchSupervisorApprovalTime;
263     }
264 
265 	public Calendar getCalendarObj() {
266 		return calendarObj;
267 	}
268 
269 	public void setCalendarObj(Calendar calendarObj) {
270 		this.calendarObj = calendarObj;
271 	}
272 
273     public int compareTo(CalendarEntries pce) {
274         return this.getBeginPeriodDate().compareTo(pce.getBeginPeriodDate());
275     }
276 
277 }