1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.kpme.core.calendar;
17
18 import java.sql.Time;
19 import java.util.ArrayList;
20 import java.util.List;
21
22 import com.google.common.collect.ImmutableList;
23 import org.apache.commons.lang.StringUtils;
24 import org.apache.commons.lang.builder.HashCodeBuilder;
25 import org.joda.time.DateTimeConstants;
26 import org.kuali.kpme.core.api.calendar.CalendarContract;
27 import org.kuali.kpme.core.calendar.entry.CalendarEntry;
28 import org.kuali.kpme.core.util.HrConstants;
29 import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
30
31 public class Calendar extends PersistableBusinessObjectBase implements CalendarContract {
32 public static final String CACHE_NAME = HrConstants.CacheNamespace.NAMESPACE_PREFIX + "Calendar";
33 public static final ImmutableList<String> EQUAL_TO_FIELDS = new ImmutableList.Builder<String>()
34 .add("calendarName")
35 .build();
36
37
38
39 private static final long serialVersionUID = 1L;
40
41 private String hrCalendarId;
42 private String calendarName;
43 private String calendarDescriptions;
44
45 private String flsaBeginDay;
46 private Time flsaBeginTime;
47 private String calendarTypes;
48 private int flsaBeginDayConstant = -1;
49
50
51 private List<CalendarEntry> calendarEntries = new ArrayList<CalendarEntry>();
52 public Calendar() {
53
54 }
55
56 public String getHrCalendarId() {
57 return hrCalendarId;
58 }
59
60
61
62 public void setHrCalendarId(String hrCalendarId) {
63 this.hrCalendarId = hrCalendarId;
64 }
65
66
67
68 public String getCalendarName() {
69 return calendarName;
70 }
71
72
73
74 public void setCalendarName(String calendarName) {
75 this.calendarName = calendarName;
76 }
77
78
79
80 public String getCalendarTypes() {
81 return calendarTypes;
82 }
83
84
85
86 public void setCalendarTypes(String calendarTypes) {
87 this.calendarTypes = calendarTypes;
88 }
89
90
91
92 public List<CalendarEntry> getCalendarEntries() {
93 return calendarEntries;
94 }
95
96
97
98 public void setCalendarEntries(List<CalendarEntry> calendarEntries) {
99 this.calendarEntries = calendarEntries;
100 }
101
102
103
104 public void setFlsaBeginDayConstant(int flsaBeginDayConstant) {
105 this.flsaBeginDayConstant = flsaBeginDayConstant;
106 }
107
108 public String getCalendarDescriptions() {
109 return calendarDescriptions;
110 }
111
112 public void setCalendarDescriptions(String calendarDescriptions) {
113 this.calendarDescriptions = calendarDescriptions;
114 }
115
116 public String getFlsaBeginDay() {
117 return flsaBeginDay;
118 }
119
120 public void setFlsaBeginDay(String flsaBeginDay) {
121 this.flsaBeginDay = flsaBeginDay;
122 this.setFlsaBeinDayConstant(flsaBeginDay);
123 }
124
125 public Time getFlsaBeginTime() {
126 return flsaBeginTime;
127 }
128
129 public void setFlsaBeginTime(Time flsaBeginTime) {
130 this.flsaBeginTime = flsaBeginTime;
131 }
132
133
134
135
136
137
138
139
140
141
142
143 private void setFlsaBeinDayConstant(String day) {
144 if (!StringUtils.isEmpty(day)) {
145 day = day.toLowerCase().trim();
146
147 if (day.startsWith("m")) {
148 this.flsaBeginDayConstant = DateTimeConstants.MONDAY;
149 } else if (day.startsWith("tu")) {
150 this.flsaBeginDayConstant = DateTimeConstants.TUESDAY;
151 } else if (day.startsWith("w")) {
152 this.flsaBeginDayConstant = DateTimeConstants.WEDNESDAY;
153 } else if (day.startsWith("th")) {
154 this.flsaBeginDayConstant = DateTimeConstants.THURSDAY;
155 } else if (day.startsWith("f")) {
156 this.flsaBeginDayConstant = DateTimeConstants.FRIDAY;
157 } else if (day.startsWith("sa")) {
158 this.flsaBeginDayConstant = DateTimeConstants.SATURDAY;
159 } else if (day.startsWith("su")) {
160 this.flsaBeginDayConstant = DateTimeConstants.SUNDAY;
161 }
162 }
163 }
164
165
166
167
168
169
170
171
172
173 public int getFlsaBeginDayConstant() {
174 if (flsaBeginDayConstant < 0) {
175 this.setFlsaBeinDayConstant(this.getFlsaBeginDay());
176 }
177 return flsaBeginDayConstant;
178 }
179
180 @Override
181 public int hashCode() {
182 return HashCodeBuilder.reflectionHashCode(this);
183 }
184
185 @Override
186 public boolean equals(Object o) {
187 if (o instanceof Calendar) {
188 Calendar pc = (Calendar)o;
189 return this.getHrCalendarId().compareTo(pc.getHrCalendarId()) == 0;
190 } else {
191 return false;
192 }
193 }
194 }