001 /** 002 * Copyright 2004-2013 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.util.Date; 019 020 import org.joda.time.DateTime; 021 import org.joda.time.LocalDate; 022 import org.joda.time.LocalDateTime; 023 import org.joda.time.LocalTime; 024 import org.kuali.hr.core.KPMEConstants; 025 import org.kuali.hr.time.service.base.TkServiceLocator; 026 import org.kuali.rice.krad.bo.PersistableBusinessObjectBase; 027 028 /** 029 * This class uses java.sql.Time and java.sql.Date because for each respective component 030 * we are only interested in a partial Date or Time, that is for example: 031 * <p/> 032 * 3:55 pm (at any date) 033 * 6/22/2010 (at any time) 034 * 035 * Make sure you are aware of whether or not you need a Local Relative time or 036 * an absolute server time. 037 * 038 * Local Relative Time Methods: (Time/Date without Timezone) 039 * 040 * LocalDateTime : getBeginLocalDateTime() 041 * LocalDateTime : getEndLocalDateTime() 042 * 043 * Absolute Methods: 044 * 045 * java.util.Date : getEndPeriodDateTime() 046 * java.util.Date : getBeginPeriodDateTime() 047 * 048 */ 049 public class CalendarEntries extends PersistableBusinessObjectBase implements Comparable<CalendarEntries>{ 050 051 private static final long serialVersionUID = -1977756526579659122L; 052 053 public static final String CACHE_NAME = KPMEConstants.APPLICATION_NAMESPACE_CODE + "/" + "CalendarEntries"; 054 055 private String hrCalendarEntriesId; 056 private String hrCalendarId; 057 private String calendarName; 058 059 private Date beginPeriodDateTime; 060 private Date endPeriodDateTime; 061 private Date batchInitiateDateTime; 062 private Date batchEndPayPeriodDateTime; 063 private Date batchEmployeeApprovalDateTime; 064 private Date batchSupervisorApprovalDateTime; 065 066 private Calendar calendarObj; 067 068 public String getHrCalendarId() { 069 calendarObj = TkServiceLocator.getCalendarService().getCalendarByGroup(this.getCalendarName()); 070 if (calendarObj != null) { 071 this.setHrCalendarId(calendarObj.getHrCalendarId()); 072 } 073 return hrCalendarId; 074 } 075 076 public void setHrCalendarId(String hrCalendarId) { 077 this.hrCalendarId = hrCalendarId; 078 } 079 080 public String getHrCalendarEntriesId() { 081 return hrCalendarEntriesId; 082 } 083 084 public void setHrCalendarEntriesId(String hrCalendarEntriesId) { 085 this.hrCalendarEntriesId = hrCalendarEntriesId; 086 } 087 088 public String getCalendarName() { 089 return calendarName; 090 } 091 092 public void setCalendarName(String calendarName) { 093 this.calendarName = calendarName; 094 } 095 096 public Date getBeginPeriodDateTime() { 097 return beginPeriodDateTime; 098 } 099 100 public void setBeginPeriodDateTime(Date beginPeriodDateTime) { 101 this.beginPeriodDateTime = beginPeriodDateTime; 102 } 103 104 /** 105 * Provides the Begin Period time without timezone information, used for relative calculations. 106 * 107 * @return A LocalDateTime representation of the begin period date/time. 108 */ 109 public LocalDateTime getBeginLocalDateTime() { 110 return new DateTime(beginPeriodDateTime).toLocalDateTime(); 111 } 112 113 public java.sql.Date getBeginPeriodDate() { 114 java.sql.Date beginPeriodDate = null; 115 116 if (beginPeriodDateTime != null) { 117 beginPeriodDate = new java.sql.Date(beginPeriodDateTime.getTime()); 118 } 119 120 return beginPeriodDate; 121 } 122 123 public void setBeginPeriodDate(java.sql.Date beginPeriodDate) { 124 DateTime dateTime = new DateTime(beginPeriodDateTime); 125 LocalDate localDate = new LocalDate(beginPeriodDate); 126 LocalTime localTime = new LocalTime(beginPeriodDateTime); 127 beginPeriodDateTime = localDate.toDateTime(localTime, dateTime.getZone()).toDate(); 128 } 129 130 public java.sql.Time getBeginPeriodTime() { 131 java.sql.Time beginPeriodTime = null; 132 133 if (beginPeriodDateTime != null) { 134 beginPeriodTime = new java.sql.Time(beginPeriodDateTime.getTime()); 135 } 136 137 return beginPeriodTime; 138 } 139 140 public void setBeginPeriodTime(java.sql.Time beginPeriodTime) { 141 DateTime dateTime = new DateTime(beginPeriodDateTime); 142 LocalDate localDate = new LocalDate(beginPeriodDateTime); 143 LocalTime localTime = new LocalTime(beginPeriodTime); 144 beginPeriodDateTime = localDate.toDateTime(localTime, dateTime.getZone()).toDate(); 145 } 146 147 public java.util.Date getEndPeriodDateTime() { 148 return endPeriodDateTime; 149 } 150 151 public void setEndPeriodDateTime(Date endPeriodDateTime) { 152 this.endPeriodDateTime = endPeriodDateTime; 153 } 154 155 /** 156 * Provides the End Period time without timezone information, used for relative calculations. 157 * 158 * @return A LocalDateTime representation of the end period date/time. 159 */ 160 public LocalDateTime getEndLocalDateTime() { 161 return new DateTime(endPeriodDateTime).toLocalDateTime(); 162 } 163 164 public java.sql.Date getEndPeriodDate() { 165 java.sql.Date endPeriodDate = null; 166 167 if (endPeriodDateTime != null) { 168 endPeriodDate = new java.sql.Date(endPeriodDateTime.getTime()); 169 } 170 171 return endPeriodDate; 172 } 173 174 public void setEndPeriodDate(java.sql.Date endPeriodDate) { 175 DateTime dateTime = new DateTime(endPeriodDateTime); 176 LocalDate localDate = new LocalDate(endPeriodDate); 177 LocalTime localTime = new LocalTime(endPeriodDateTime); 178 endPeriodDateTime = localDate.toDateTime(localTime, dateTime.getZone()).toDate(); 179 } 180 181 public java.sql.Time getEndPeriodTime() { 182 java.sql.Time endPeriodTime = null; 183 184 if (endPeriodDateTime != null) { 185 endPeriodTime = new java.sql.Time(endPeriodDateTime.getTime()); 186 } 187 188 return endPeriodTime; 189 } 190 191 public void setEndPeriodTime(java.sql.Time endPeriodDate) { 192 DateTime dateTime = new DateTime(endPeriodDateTime); 193 LocalDate localDate = new LocalDate(endPeriodDateTime); 194 LocalTime localTime = new LocalTime(endPeriodDate); 195 endPeriodDateTime = localDate.toDateTime(localTime, dateTime.getZone()).toDate(); 196 } 197 198 public Date getBatchInitiateDateTime() { 199 return batchInitiateDateTime; 200 } 201 202 public void setBatchInitiateDateTime(Date batchInitiateDateTime) { 203 this.batchInitiateDateTime = batchInitiateDateTime; 204 } 205 206 public java.sql.Date getBatchInitiateDate() { 207 java.sql.Date batchInitiateDate = null; 208 209 if (batchInitiateDateTime != null) { 210 batchInitiateDate = new java.sql.Date(batchInitiateDateTime.getTime()); 211 } 212 213 return batchInitiateDate; 214 } 215 216 public void setBatchInitiateDate(java.sql.Date batchInitiateDate) { 217 DateTime dateTime = new DateTime(batchInitiateDateTime); 218 LocalDate localDate = new LocalDate(batchInitiateDate); 219 LocalTime localTime = new LocalTime(batchInitiateDateTime); 220 batchInitiateDateTime = localDate.toDateTime(localTime, dateTime.getZone()).toDate(); 221 } 222 223 public java.sql.Time getBatchInitiateTime() { 224 java.sql.Time batchInitiateTime = null; 225 226 if (batchInitiateDateTime != null) { 227 batchInitiateTime = new java.sql.Time(batchInitiateDateTime.getTime()); 228 } 229 230 return batchInitiateTime; 231 } 232 233 public void setBatchInitiateTime(java.sql.Time batchInitiateDate) { 234 DateTime dateTime = new DateTime(batchInitiateDateTime); 235 LocalDate localDate = new LocalDate(batchInitiateDateTime); 236 LocalTime localTime = new LocalTime(batchInitiateDate); 237 batchInitiateDateTime = localDate.toDateTime(localTime, dateTime.getZone()).toDate(); 238 } 239 240 public Date getBatchEndPayPeriodDateTime() { 241 return batchEndPayPeriodDateTime; 242 } 243 244 public void setBatchEndPayPeriodDateTime(Date batchEndPayPeriodDateTime) { 245 this.batchEndPayPeriodDateTime = batchEndPayPeriodDateTime; 246 } 247 248 public java.sql.Date getBatchEndPayPeriodDate() { 249 java.sql.Date batchEndPayPeriodDate = null; 250 251 if (batchEndPayPeriodDateTime != null) { 252 batchEndPayPeriodDate = new java.sql.Date(batchEndPayPeriodDateTime.getTime()); 253 } 254 255 return batchEndPayPeriodDate; 256 } 257 258 public void setBatchEndPayPeriodDate(java.sql.Date batchEndPayPeriodDate) { 259 DateTime dateTime = new DateTime(batchEndPayPeriodDateTime); 260 LocalDate localDate = new LocalDate(batchEndPayPeriodDate); 261 LocalTime localTime = new LocalTime(batchEndPayPeriodDateTime); 262 batchEndPayPeriodDateTime = localDate.toDateTime(localTime, dateTime.getZone()).toDate(); 263 } 264 265 public java.sql.Time getBatchEndPayPeriodTime() { 266 java.sql.Time batchEndPayPeriodTime = null; 267 268 if (batchEndPayPeriodDateTime != null) { 269 batchEndPayPeriodTime = new java.sql.Time(batchEndPayPeriodDateTime.getTime()); 270 } 271 272 return batchEndPayPeriodTime; 273 } 274 275 public void setBatchEndPayPeriodTime(java.sql.Time batchEndPayPeriodDate) { 276 DateTime dateTime = new DateTime(batchEndPayPeriodDateTime); 277 LocalDate localDate = new LocalDate(batchEndPayPeriodDateTime); 278 LocalTime localTime = new LocalTime(batchEndPayPeriodDate); 279 batchEndPayPeriodDateTime = localDate.toDateTime(localTime, dateTime.getZone()).toDate(); 280 } 281 282 public Date getBatchEmployeeApprovalDateTime() { 283 return batchEmployeeApprovalDateTime; 284 } 285 286 public void setBatchEmployeeApprovalDateTime(Date batchEmployeeApprovalDateTime) { 287 this.batchEmployeeApprovalDateTime = batchEmployeeApprovalDateTime; 288 } 289 290 public java.sql.Date getBatchEmployeeApprovalDate() { 291 java.sql.Date batchEmployeeApprovalDate = null; 292 293 if (batchEmployeeApprovalDateTime != null) { 294 batchEmployeeApprovalDate = new java.sql.Date(batchEmployeeApprovalDateTime.getTime()); 295 } 296 297 return batchEmployeeApprovalDate; 298 } 299 300 public void setBatchEmployeeApprovalDate(java.sql.Date batchEmployeeApprovalDate) { 301 DateTime dateTime = new DateTime(batchEmployeeApprovalDateTime); 302 LocalDate localDate = new LocalDate(batchEmployeeApprovalDate); 303 LocalTime localTime = new LocalTime(batchEmployeeApprovalDateTime); 304 batchEmployeeApprovalDateTime = localDate.toDateTime(localTime, dateTime.getZone()).toDate(); 305 } 306 307 public java.sql.Time getBatchEmployeeApprovalTime() { 308 java.sql.Time batchEmployeeApprovalTime = null; 309 310 if (batchEmployeeApprovalDateTime != null) { 311 batchEmployeeApprovalTime = new java.sql.Time(batchEmployeeApprovalDateTime.getTime()); 312 } 313 314 return batchEmployeeApprovalTime; 315 } 316 317 public void setBatchEmployeeApprovalTime(java.sql.Time batchEmployeeApprovalDate) { 318 DateTime dateTime = new DateTime(batchEmployeeApprovalDateTime); 319 LocalDate localDate = new LocalDate(batchEmployeeApprovalDateTime); 320 LocalTime localTime = new LocalTime(batchEmployeeApprovalDate); 321 batchEmployeeApprovalDateTime = localDate.toDateTime(localTime, dateTime.getZone()).toDate(); 322 } 323 324 public Date getBatchSupervisorApprovalDateTime() { 325 return batchSupervisorApprovalDateTime; 326 } 327 328 public void setBatchSupervisorApprovalDateTime(Date batchSupervisorApprovalDateTime) { 329 this.batchSupervisorApprovalDateTime = batchSupervisorApprovalDateTime; 330 } 331 332 public java.sql.Date getBatchSupervisorApprovalDate() { 333 java.sql.Date batchSupervisorApprovalDate = null; 334 335 if (batchSupervisorApprovalDateTime != null) { 336 batchSupervisorApprovalDate = new java.sql.Date(batchSupervisorApprovalDateTime.getTime()); 337 } 338 339 return batchSupervisorApprovalDate; 340 } 341 342 public void setBatchSupervisorApprovalDate(java.sql.Date batchSupervisorApprovalDate) { 343 DateTime dateTime = new DateTime(batchSupervisorApprovalDateTime); 344 LocalDate localDate = new LocalDate(batchSupervisorApprovalDate); 345 LocalTime localTime = new LocalTime(batchSupervisorApprovalDateTime); 346 batchSupervisorApprovalDateTime = localDate.toDateTime(localTime, dateTime.getZone()).toDate(); 347 } 348 349 public java.sql.Time getBatchSupervisorApprovalTime() { 350 java.sql.Time batchSupervisorApprovalTime = null; 351 352 if (batchSupervisorApprovalDateTime != null) { 353 batchSupervisorApprovalTime = new java.sql.Time(batchSupervisorApprovalDateTime.getTime()); 354 } 355 356 return batchSupervisorApprovalTime; 357 } 358 359 public void setBatchSupervisorApprovalTime(java.sql.Time batchSupervisorApprovalDate) { 360 DateTime dateTime = new DateTime(batchSupervisorApprovalDateTime); 361 LocalDate localDate = new LocalDate(batchSupervisorApprovalDateTime); 362 LocalTime localTime = new LocalTime(batchSupervisorApprovalDate); 363 batchSupervisorApprovalDateTime = localDate.toDateTime(localTime, dateTime.getZone()).toDate(); 364 } 365 366 public Calendar getCalendarObj() { 367 return calendarObj; 368 } 369 370 public void setCalendarObj(Calendar calendarObj) { 371 this.calendarObj = calendarObj; 372 } 373 374 public int compareTo(CalendarEntries pce) { 375 return this.getBeginPeriodDate().compareTo(pce.getBeginPeriodDate()); 376 } 377 378 }