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