1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.sys.service.impl;
17
18 import org.apache.log4j.Logger;
19 import org.kuali.ole.sys.businessobject.UniversityDate;
20 import org.kuali.ole.sys.context.SpringContext;
21 import org.kuali.ole.sys.dataaccess.UniversityDateDao;
22 import org.kuali.ole.sys.service.NonTransactional;
23 import org.kuali.ole.sys.service.UniversityDateService;
24 import org.kuali.ole.sys.util.KfsDateUtils;
25 import org.kuali.rice.core.api.datetime.DateTimeService;
26 import org.kuali.rice.krad.service.BusinessObjectService;
27 import org.springframework.cache.annotation.Cacheable;
28
29
30
31
32
33
34 @NonTransactional
35 public class UniversityDateServiceImpl implements UniversityDateService {
36
37 private static final Logger LOG = Logger.getLogger(UniversityDateServiceImpl.class);
38
39 protected UniversityDateDao universityDateDao;
40 protected DateTimeService dateTimeService;
41
42
43
44
45
46
47
48
49 @Override
50 public UniversityDate getCurrentUniversityDate() {
51 java.util.Date now = dateTimeService.getCurrentDate();
52 return SpringContext.getBean(BusinessObjectService.class).findBySinglePrimaryKey(UniversityDate.class, new java.sql.Date( KfsDateUtils.clearTimeFields(now).getTime() ));
53 }
54
55
56
57
58
59
60
61
62 @Override
63 public Integer getCurrentFiscalYear() {
64 java.util.Date now = dateTimeService.getCurrentDate();
65
66 return getFiscalYear(KfsDateUtils.clearTimeFields(now));
67 }
68
69
70
71
72
73
74
75
76
77 @Override
78 @Cacheable(value=UniversityDate.CACHE_NAME, key="'{FiscalYear}'+#p0")
79 public Integer getFiscalYear(java.util.Date date) {
80 if (date == null) {
81 throw new IllegalArgumentException("invalid (null) date");
82 }
83 UniversityDate uDate = SpringContext.getBean(BusinessObjectService.class).findBySinglePrimaryKey(UniversityDate.class, new java.sql.Date( KfsDateUtils.clearTimeFields(date).getTime() ) );
84 return (uDate == null) ? null : uDate.getUniversityFiscalYear();
85 }
86
87
88
89
90
91
92
93
94
95 @Override
96 @Cacheable(value=UniversityDate.CACHE_NAME, key="'{FirstDateOfFiscalYear}'+#p0")
97 public java.util.Date getFirstDateOfFiscalYear(Integer fiscalYear) {
98 UniversityDate uDate = universityDateDao.getFirstFiscalYearDate(fiscalYear);
99 return (uDate == null) ? null : uDate.getUniversityDate();
100 }
101
102
103
104
105
106
107
108
109
110 @Override
111 @Cacheable(value=UniversityDate.CACHE_NAME, key="'{LastDateOfFiscalYear}'+#p0")
112 public java.util.Date getLastDateOfFiscalYear(Integer fiscalYear) {
113 UniversityDate uDate = universityDateDao.getLastFiscalYearDate(fiscalYear);
114 return (uDate == null) ? null : uDate.getUniversityDate();
115 }
116
117 public void setUniversityDateDao(UniversityDateDao universityDateDao) {
118 this.universityDateDao = universityDateDao;
119 }
120 public void setDateTimeService(DateTimeService dateTimeService) {
121 this.dateTimeService = dateTimeService;
122 }
123
124 }