001 /**
002 * Copyright 2004-2012 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.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/ecl2.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 package org.kuali.hr.time.calendar;
017
018 import java.sql.Date;
019 import java.sql.Time;
020
021 import javax.persistence.Transient;
022
023 import org.joda.time.DateTime;
024 import org.joda.time.LocalDateTime;
025 import org.kuali.hr.core.KPMEConstants;
026 import org.kuali.hr.time.service.base.TkServiceLocator;
027 import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
028
029 /**
030 * This class uses java.sql.Time and java.sql.Date because for each respective component
031 * we are only interested in a partial Date or Time, that is for example:
032 * <p/>
033 * 3:55 pm (at any date)
034 * 6/22/2010 (at any time)
035 *
036 * Make sure you are aware of whether or not you need a Local Relative time or
037 * an absolute server time.
038 *
039 * Local Relative Time Methods: (Time/Date without Timezone)
040 *
041 * LocalDateTime : getBeginLocalDateTime()
042 * LocalDateTime : getEndLocalDateTime()
043 *
044 * Absolute Methods:
045 *
046 * java.util.Date : getEndPeriodDateTime()
047 * java.util.Date : getBeginPeriodDateTime()
048 *
049 */
050 public class CalendarEntries extends PersistableBusinessObjectBase implements Comparable<CalendarEntries>{
051 public static final String CACHE_NAME = KPMEConstants.APPLICATION_NAMESPACE_CODE + "/" + "CalendarEntries";
052 /**
053 *
054 */
055 private static final long serialVersionUID = 1L;
056
057 private String hrCalendarEntriesId;
058 private String hrCalendarId;
059 private String calendarName;
060
061 private java.util.Date beginPeriodDateTime;
062
063 private java.util.Date endPeriodDateTime;
064
065 @Transient
066 private java.sql.Date beginPeriodDate;
067 @Transient
068 private java.sql.Date endPeriodDate;
069 @Transient
070 private Time beginPeriodTime;
071 @Transient
072 private Time endPeriodTime;
073
074 private Date batchInitiateDate;
075 private Time batchInitiateTime;
076
077 //this property is for the batch job
078 //that runs at the end of pay period
079 private Date batchEndPayPeriodDate;
080 private Time batchEndPayPeriodTime;
081
082 private Date batchEmployeeApprovalDate;
083 private Time batchEmployeeApprovalTime;
084
085 private Date batchSupervisorApprovalDate;
086 private Time batchSupervisorApprovalTime;
087
088 private Calendar calendarObj;
089
090
091 /**
092 * Provides the Begin Period time without timezone information, used
093 * for relative calculations.
094 *
095 * @return A LocalDateTime representation of the begin period date/time.
096 */
097 public LocalDateTime getBeginLocalDateTime() {
098 return (new DateTime(this.getBeginPeriodDateTime())).toLocalDateTime();
099 }
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 }