set holiday color.
@@ -6,12 +6,9 @@ | ||
6 | 6 | |
7 | 7 | public class ConfigForm implements Serializable { |
8 | 8 | |
9 | - private static final long serialVersionUID = -8652826957783721623L; | |
9 | + private static final long serialVersionUID = 5428451370958739560L; | |
10 | 10 | |
11 | 11 | @Required(target = "update") |
12 | - public String roleAvailable; | |
12 | + public String holidays; | |
13 | 13 | |
14 | - @Required(target = "update") | |
15 | - public String groupAvailable; | |
16 | - | |
17 | 14 | } |
@@ -2,10 +2,6 @@ | ||
2 | 2 | |
3 | 3 | public class SchedulerConstants { |
4 | 4 | |
5 | - public static final String ROLE_AVAILABLE = "features.role"; | |
6 | - | |
7 | - public static final String GROUP_AVAILABLE = "features.group"; | |
8 | - | |
9 | 5 | public static final String ONETIME_SCHEDULE = "ONETIME"; |
10 | 6 | |
11 | 7 | public static final String ROLE_PREFIX = "role::"; |
@@ -12,4 +8,13 @@ | ||
12 | 8 | |
13 | 9 | public static final String GROUP_PREFIX = "group::"; |
14 | 10 | |
11 | + public static final String SCHEDULER_HOLIDAYS = "scheduler.holidays"; | |
12 | + | |
13 | + public static final String HOLIDAY_COLOR = "#FFCCCC"; | |
14 | + | |
15 | + public static final String SUNDAY_COLOR = "#FFCCCC"; | |
16 | + | |
17 | + public static final String SATURDAY_COLOR = "#CCFFFF"; | |
18 | + | |
19 | + public static final String TODAY_COLOR = "#CCFFCC"; | |
15 | 20 | } |
@@ -1,6 +1,8 @@ | ||
1 | 1 | package jp.sf.pal.scheduler.action; |
2 | 2 | |
3 | 3 | import java.io.Serializable; |
4 | +import java.util.HashSet; | |
5 | +import java.util.Set; | |
4 | 6 | |
5 | 7 | import javax.servlet.http.HttpServletRequest; |
6 | 8 |
@@ -8,8 +10,10 @@ | ||
8 | 10 | import jp.sf.pal.scheduler.common.util.ConfigUtil; |
9 | 11 | import jp.sf.pal.scheduler.common.util.SAStrutsUtil; |
10 | 12 | import jp.sf.pal.scheduler.form.ConfigForm; |
13 | +import jp.sf.pal.scheduler.util.SchedulerUtil; | |
11 | 14 | |
12 | 15 | import org.apache.commons.configuration.ConfigurationException; |
16 | +import org.apache.commons.lang.StringUtils; | |
13 | 17 | import org.apache.commons.logging.Log; |
14 | 18 | import org.apache.commons.logging.LogFactory; |
15 | 19 | import org.seasar.struts.annotation.ActionForm; |
@@ -28,10 +32,8 @@ | ||
28 | 32 | private transient HttpServletRequest request; |
29 | 33 | |
30 | 34 | protected String displayIndex() { |
31 | - configForm.roleAvailable = ConfigUtil.getString( | |
32 | - SchedulerConstants.ROLE_AVAILABLE, "true"); | |
33 | - configForm.groupAvailable = ConfigUtil.getString( | |
34 | - SchedulerConstants.GROUP_AVAILABLE, "true"); | |
35 | + configForm.holidays = ConfigUtil.getString( | |
36 | + SchedulerConstants.SCHEDULER_HOLIDAYS, ""); | |
35 | 37 | return "index.jsp"; |
36 | 38 | } |
37 | 39 |
@@ -44,10 +46,22 @@ | ||
44 | 46 | @Execute(validator = false, input = "index.jsp") |
45 | 47 | public String update() { |
46 | 48 | ConfigUtil.init(request); |
47 | - ConfigUtil.setProperty(SchedulerConstants.ROLE_AVAILABLE, | |
48 | - configForm.roleAvailable); | |
49 | - ConfigUtil.setProperty(SchedulerConstants.GROUP_AVAILABLE, | |
50 | - configForm.groupAvailable); | |
49 | + ConfigUtil.setProperty(SchedulerConstants.SCHEDULER_HOLIDAYS, | |
50 | + configForm.holidays); | |
51 | + | |
52 | + if (configForm.holidays == null) { | |
53 | + configForm.holidays = ""; | |
54 | + } | |
55 | + | |
56 | + Set<String> holidaySet = new HashSet<String>(); | |
57 | + String[] holidays = configForm.holidays.split("\n"); | |
58 | + for (int i = 0; i < holidays.length; i++) { | |
59 | + if (!StringUtils.isEmpty(holidays[i])) { | |
60 | + holidaySet.add(holidays[i].trim()); | |
61 | + } | |
62 | + } | |
63 | + SchedulerUtil.setHolidaySet(holidaySet); | |
64 | + | |
51 | 65 | try { |
52 | 66 | ConfigUtil.save(); |
53 | 67 | SAStrutsUtil.addMessage(request, "success.update_config"); |
@@ -10,6 +10,7 @@ | ||
10 | 10 | |
11 | 11 | import javax.servlet.http.HttpServletRequest; |
12 | 12 | |
13 | +import jp.sf.pal.scheduler.SchedulerConstants; | |
13 | 14 | import jp.sf.pal.scheduler.common.util.CalendarUtil; |
14 | 15 | import jp.sf.pal.scheduler.common.util.ConfigUtil; |
15 | 16 | import jp.sf.pal.scheduler.db.exentity.Facility; |
@@ -45,6 +46,8 @@ | ||
45 | 46 | |
46 | 47 | public int maxCols; |
47 | 48 | |
49 | + public String dayColor; | |
50 | + | |
48 | 51 | public Facility facility; |
49 | 52 | |
50 | 53 | @ActionForm |
@@ -124,6 +127,31 @@ | ||
124 | 127 | } |
125 | 128 | } |
126 | 129 | |
130 | + // day color | |
131 | + StringBuilder sb = new StringBuilder(); | |
132 | + sb.append(tYear).append("-"); | |
133 | + if (tMonth < 10) { | |
134 | + sb.append("0").append(tMonth); | |
135 | + } else { | |
136 | + sb.append(tMonth); | |
137 | + } | |
138 | + sb.append("-"); | |
139 | + if (tDate < 10) { | |
140 | + sb.append("0").append(tDate); | |
141 | + } else { | |
142 | + sb.append(tDate); | |
143 | + } | |
144 | + if (tDay == 1) { | |
145 | + // sunday | |
146 | + dayColor = SchedulerConstants.SUNDAY_COLOR; | |
147 | + } else if (SchedulerUtil.getHolidaySet().contains(sb.toString())) { | |
148 | + // holiday | |
149 | + dayColor = SchedulerConstants.HOLIDAY_COLOR; | |
150 | + } else if (tDay == 7) { | |
151 | + // saturday | |
152 | + dayColor = SchedulerConstants.SATURDAY_COLOR; | |
153 | + } | |
154 | + | |
127 | 155 | return "facilityday.jsp"; |
128 | 156 | } |
129 | 157 |
@@ -144,13 +172,38 @@ | ||
144 | 172 | int year = CalendarUtil.getYear(cal); |
145 | 173 | int month = CalendarUtil.getMonth(cal) + 1; |
146 | 174 | int date = CalendarUtil.getDate(cal); |
175 | + int dayOfWeek = CalendarUtil.getDay(cal); | |
147 | 176 | |
148 | - Map<String, Object> map = new HashMap<String, Object>(5); | |
177 | + Map<String, Object> map = new HashMap<String, Object>(6); | |
149 | 178 | map.put("displayedDate", sdf.format(cal.getTime())); |
150 | - map.put("dayOfWeek", String.valueOf(CalendarUtil.getDay(cal))); | |
179 | + map.put("dayOfWeek", String.valueOf(dayOfWeek)); | |
151 | 180 | map.put("date", String.valueOf(date)); |
152 | 181 | map.put("month", String.valueOf(month)); |
153 | 182 | map.put("year", String.valueOf(year)); |
183 | + // day color | |
184 | + StringBuilder sb = new StringBuilder(); | |
185 | + sb.append(year).append("-"); | |
186 | + if (month < 10) { | |
187 | + sb.append("0").append(month); | |
188 | + } else { | |
189 | + sb.append(month); | |
190 | + } | |
191 | + sb.append("-"); | |
192 | + if (date < 10) { | |
193 | + sb.append("0").append(date); | |
194 | + } else { | |
195 | + sb.append(date); | |
196 | + } | |
197 | + if (dayOfWeek == 1) { | |
198 | + // sunday | |
199 | + map.put("color", SchedulerConstants.SUNDAY_COLOR); | |
200 | + } else if (SchedulerUtil.getHolidaySet().contains(sb.toString())) { | |
201 | + // holiday | |
202 | + map.put("color", SchedulerConstants.HOLIDAY_COLOR); | |
203 | + } else if (dayOfWeek == 7) { | |
204 | + // saturday | |
205 | + map.put("color", SchedulerConstants.SATURDAY_COLOR); | |
206 | + } | |
154 | 207 | weekDayItems.add(map); |
155 | 208 | cal = CalendarUtil.getNext(cal); |
156 | 209 |
@@ -246,13 +299,38 @@ | ||
246 | 299 | int year = CalendarUtil.getYear(cal); |
247 | 300 | int month = CalendarUtil.getMonth(cal) + 1; |
248 | 301 | int date = CalendarUtil.getDate(cal); |
302 | + int dayOfWeek = CalendarUtil.getDay(cal); | |
249 | 303 | |
250 | - Map<String, Object> map = new HashMap<String, Object>(5); | |
304 | + Map<String, Object> map = new HashMap<String, Object>(6); | |
251 | 305 | map.put("displayedDate", sdf.format(cal.getTime())); |
252 | - map.put("dayOfWeek", String.valueOf(CalendarUtil.getDay(cal))); | |
306 | + map.put("dayOfWeek", String.valueOf(dayOfWeek)); | |
253 | 307 | map.put("date", String.valueOf(date)); |
254 | 308 | map.put("month", String.valueOf(month)); |
255 | 309 | map.put("year", String.valueOf(year)); |
310 | + // day color | |
311 | + StringBuilder sb = new StringBuilder(); | |
312 | + sb.append(year).append("-"); | |
313 | + if (month < 10) { | |
314 | + sb.append("0").append(month); | |
315 | + } else { | |
316 | + sb.append(month); | |
317 | + } | |
318 | + sb.append("-"); | |
319 | + if (date < 10) { | |
320 | + sb.append("0").append(date); | |
321 | + } else { | |
322 | + sb.append(date); | |
323 | + } | |
324 | + if (dayOfWeek == 1) { | |
325 | + // sunday | |
326 | + map.put("color", SchedulerConstants.SUNDAY_COLOR); | |
327 | + } else if (SchedulerUtil.getHolidaySet().contains(sb.toString())) { | |
328 | + // holiday | |
329 | + map.put("color", SchedulerConstants.HOLIDAY_COLOR); | |
330 | + } else if (dayOfWeek == 7) { | |
331 | + // saturday | |
332 | + map.put("color", SchedulerConstants.SATURDAY_COLOR); | |
333 | + } | |
256 | 334 | weekDayItems.add(map); |
257 | 335 | cal = CalendarUtil.getNext(cal); |
258 | 336 |
@@ -47,6 +47,8 @@ | ||
47 | 47 | |
48 | 48 | public int maxCols; |
49 | 49 | |
50 | + public String dayColor; | |
51 | + | |
50 | 52 | @ActionForm |
51 | 53 | private CalendarForm calendarForm; |
52 | 54 |
@@ -121,6 +123,31 @@ | ||
121 | 123 | } |
122 | 124 | } |
123 | 125 | |
126 | + // day color | |
127 | + StringBuilder sb = new StringBuilder(); | |
128 | + sb.append(tYear).append("-"); | |
129 | + if (tMonth < 10) { | |
130 | + sb.append("0").append(tMonth); | |
131 | + } else { | |
132 | + sb.append(tMonth); | |
133 | + } | |
134 | + sb.append("-"); | |
135 | + if (tDate < 10) { | |
136 | + sb.append("0").append(tDate); | |
137 | + } else { | |
138 | + sb.append(tDate); | |
139 | + } | |
140 | + if (tDay == 1) { | |
141 | + // sunday | |
142 | + dayColor = SchedulerConstants.SUNDAY_COLOR; | |
143 | + } else if (SchedulerUtil.getHolidaySet().contains(sb.toString())) { | |
144 | + // holiday | |
145 | + dayColor = SchedulerConstants.HOLIDAY_COLOR; | |
146 | + } else if (tDay == 7) { | |
147 | + // saturday | |
148 | + dayColor = SchedulerConstants.SATURDAY_COLOR; | |
149 | + } | |
150 | + | |
124 | 151 | return "personalday.jsp"; |
125 | 152 | } |
126 | 153 |
@@ -142,14 +169,40 @@ | ||
142 | 169 | int year = CalendarUtil.getYear(cal); |
143 | 170 | int month = CalendarUtil.getMonth(cal) + 1; |
144 | 171 | int date = CalendarUtil.getDate(cal); |
172 | + int dayOfWeek = CalendarUtil.getDay(cal); | |
145 | 173 | |
146 | - Map<String, Object> map = new HashMap<String, Object>(5); | |
174 | + Map<String, Object> map = new HashMap<String, Object>(6); | |
147 | 175 | map.put("displayedDate", sdf.format(cal.getTime())); |
148 | - map.put("dayOfWeek", String.valueOf(CalendarUtil.getDay(cal))); | |
176 | + map.put("dayOfWeek", String.valueOf(dayOfWeek)); | |
149 | 177 | map.put("date", String.valueOf(date)); |
150 | 178 | map.put("month", String.valueOf(month)); |
151 | 179 | map.put("year", String.valueOf(year)); |
180 | + // day color | |
181 | + StringBuilder sb = new StringBuilder(); | |
182 | + sb.append(year).append("-"); | |
183 | + if (month < 10) { | |
184 | + sb.append("0").append(month); | |
185 | + } else { | |
186 | + sb.append(month); | |
187 | + } | |
188 | + sb.append("-"); | |
189 | + if (date < 10) { | |
190 | + sb.append("0").append(date); | |
191 | + } else { | |
192 | + sb.append(date); | |
193 | + } | |
194 | + if (dayOfWeek == 1) { | |
195 | + // sunday | |
196 | + map.put("color", SchedulerConstants.SUNDAY_COLOR); | |
197 | + } else if (SchedulerUtil.getHolidaySet().contains(sb.toString())) { | |
198 | + // holiday | |
199 | + map.put("color", SchedulerConstants.HOLIDAY_COLOR); | |
200 | + } else if (dayOfWeek == 7) { | |
201 | + // saturday | |
202 | + map.put("color", SchedulerConstants.SATURDAY_COLOR); | |
203 | + } | |
152 | 204 | weekDayItems.add(map); |
205 | + | |
153 | 206 | cal = CalendarUtil.getNext(cal); |
154 | 207 | |
155 | 208 | indexMap.put(year + "-" + month + "-" + date, i); |
@@ -254,13 +307,38 @@ | ||
254 | 307 | int year = CalendarUtil.getYear(cal); |
255 | 308 | int month = CalendarUtil.getMonth(cal) + 1; |
256 | 309 | int date = CalendarUtil.getDate(cal); |
310 | + int dayOfWeek = CalendarUtil.getDay(cal); | |
257 | 311 | |
258 | - Map<String, Object> map = new HashMap<String, Object>(5); | |
312 | + Map<String, Object> map = new HashMap<String, Object>(6); | |
259 | 313 | map.put("displayedDate", sdf.format(cal.getTime())); |
260 | - map.put("dayOfWeek", String.valueOf(CalendarUtil.getDay(cal))); | |
314 | + map.put("dayOfWeek", String.valueOf(dayOfWeek)); | |
261 | 315 | map.put("date", String.valueOf(date)); |
262 | 316 | map.put("month", String.valueOf(month)); |
263 | 317 | map.put("year", String.valueOf(year)); |
318 | + // day color | |
319 | + StringBuilder sb = new StringBuilder(); | |
320 | + sb.append(year).append("-"); | |
321 | + if (month < 10) { | |
322 | + sb.append("0").append(month); | |
323 | + } else { | |
324 | + sb.append(month); | |
325 | + } | |
326 | + sb.append("-"); | |
327 | + if (date < 10) { | |
328 | + sb.append("0").append(date); | |
329 | + } else { | |
330 | + sb.append(date); | |
331 | + } | |
332 | + if (dayOfWeek == 1) { | |
333 | + // sunday | |
334 | + map.put("color", SchedulerConstants.SUNDAY_COLOR); | |
335 | + } else if (SchedulerUtil.getHolidaySet().contains(sb.toString())) { | |
336 | + // holiday | |
337 | + map.put("color", SchedulerConstants.HOLIDAY_COLOR); | |
338 | + } else if (dayOfWeek == 7) { | |
339 | + // saturday | |
340 | + map.put("color", SchedulerConstants.SATURDAY_COLOR); | |
341 | + } | |
264 | 342 | weekDayItems.add(map); |
265 | 343 | cal = CalendarUtil.getNext(cal); |
266 | 344 |
@@ -5,20 +5,25 @@ | ||
5 | 5 | import java.util.Calendar; |
6 | 6 | import java.util.Date; |
7 | 7 | import java.util.HashMap; |
8 | +import java.util.HashSet; | |
8 | 9 | import java.util.LinkedList; |
9 | 10 | import java.util.List; |
10 | 11 | import java.util.Map; |
12 | +import java.util.Set; | |
11 | 13 | |
12 | 14 | import jp.sf.pal.scheduler.SchedulerConstants; |
13 | 15 | import jp.sf.pal.scheduler.common.util.CalendarUtil; |
16 | +import jp.sf.pal.scheduler.common.util.ConfigUtil; | |
14 | 17 | import jp.sf.pal.scheduler.common.util.DateUtil; |
15 | 18 | import jp.sf.pal.scheduler.db.exentity.EventSchedule; |
16 | 19 | import jp.sf.pal.scheduler.db.exentity.EventScheduleMapping; |
17 | 20 | import jp.sf.pal.scheduler.db.exentity.FacilityScheduleMapping; |
18 | 21 | |
22 | +import org.apache.commons.lang.StringUtils; | |
19 | 23 | import org.seasar.struts.exception.ActionMessagesException; |
20 | 24 | |
21 | 25 | public class SchedulerUtil { |
26 | + private static Set<String> holidaySet; | |
22 | 27 | |
23 | 28 | public static boolean compare(String yyyymmdd1, String HHmm1, |
24 | 29 | String yyyymmdd2, String HHmm2) { |
@@ -116,6 +121,7 @@ | ||
116 | 121 | calendarDayItems.add(createCalendarDayItem(cal, targetYear, |
117 | 122 | targetMonth, targetDate, true)); |
118 | 123 | cal = CalendarUtil.getNext(cal); |
124 | + | |
119 | 125 | } |
120 | 126 | |
121 | 127 | // create a next month |
@@ -146,7 +152,7 @@ | ||
146 | 152 | int month = CalendarUtil.getMonth(cal) + 1; |
147 | 153 | int dayOfMonth = CalendarUtil.getDate(cal); |
148 | 154 | int dayOfWeek = CalendarUtil.getDay(cal); |
149 | - Map<String, Object> map = new HashMap<String, Object>(6); | |
155 | + Map<String, Object> map = new HashMap<String, Object>(7); | |
150 | 156 | map.put("year", String.valueOf(year)); |
151 | 157 | map.put("month", String.valueOf(month)); |
152 | 158 | map.put("dayOfMonth", String.valueOf(dayOfMonth)); |
@@ -157,6 +163,31 @@ | ||
157 | 163 | } else { |
158 | 164 | map.put("target", "false"); |
159 | 165 | } |
166 | + // day color | |
167 | + StringBuilder sb = new StringBuilder(); | |
168 | + sb.append(year); | |
169 | + sb.append("-"); | |
170 | + if (month < 10) { | |
171 | + sb.append("0").append(month); | |
172 | + } else { | |
173 | + sb.append(month); | |
174 | + } | |
175 | + sb.append("-"); | |
176 | + if (dayOfMonth < 10) { | |
177 | + sb.append("0").append(dayOfMonth); | |
178 | + } else { | |
179 | + sb.append(dayOfMonth); | |
180 | + } | |
181 | + if (dayOfWeek == 1) { | |
182 | + // sunday | |
183 | + map.put("color", SchedulerConstants.SUNDAY_COLOR); | |
184 | + } else if (getHolidaySet().contains(sb.toString())) { | |
185 | + // holiday | |
186 | + map.put("color", SchedulerConstants.HOLIDAY_COLOR); | |
187 | + } else if (dayOfWeek == 7) { | |
188 | + // saturday | |
189 | + map.put("color", SchedulerConstants.SATURDAY_COLOR); | |
190 | + } | |
160 | 191 | return map; |
161 | 192 | } |
162 | 193 |
@@ -971,4 +1002,29 @@ | ||
971 | 1002 | } |
972 | 1003 | } |
973 | 1004 | } |
1005 | + | |
1006 | + public static void setHolidaySet(Set<String> holidaySet) { | |
1007 | + if (SchedulerUtil.holidaySet != null) { | |
1008 | + synchronized (SchedulerUtil.holidaySet) { | |
1009 | + SchedulerUtil.holidaySet = holidaySet; | |
1010 | + } | |
1011 | + } else { | |
1012 | + SchedulerUtil.holidaySet = holidaySet; | |
1013 | + } | |
1014 | + } | |
1015 | + | |
1016 | + public static Set<String> getHolidaySet() { | |
1017 | + if (holidaySet == null) { | |
1018 | + Set<String> hSet = new HashSet<String>(); | |
1019 | + String[] holidays = ConfigUtil.getString( | |
1020 | + SchedulerConstants.SCHEDULER_HOLIDAYS, "").split("\n"); | |
1021 | + for (int i = 0; i < holidays.length; i++) { | |
1022 | + if (!StringUtils.isEmpty(holidays[i])) { | |
1023 | + hSet.add(holidays[i].trim()); | |
1024 | + } | |
1025 | + } | |
1026 | + holidaySet = hSet; | |
1027 | + } | |
1028 | + return holidaySet; | |
1029 | + } | |
974 | 1030 | } |
@@ -1,10 +1,11 @@ | ||
1 | 1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | 2 | <portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0" xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"> |
3 | -<!-- | |
4 | 3 | <portlet> |
4 | + <description>Edit configurations.</description> | |
5 | + <description xml:lang="ja">設定を編集します。</description> | |
5 | 6 | <portlet-name>SchedulerConfig</portlet-name> |
6 | 7 | <display-name>Scheduler: Scheduler Configuration</display-name> |
7 | - <description>Edit configurations.</description> | |
8 | + <display-name xml:lang="ja">スケジュール: 設定</display-name> | |
8 | 9 | <portlet-class>org.seasar.struts.portlet.SAStrutsPortlet</portlet-class> |
9 | 10 | <init-param> |
10 | 11 | <name>viewPage</name> |
@@ -17,13 +18,13 @@ | ||
17 | 18 | </supports> |
18 | 19 | <supported-locale>en</supported-locale> |
19 | 20 | <supported-locale>ja</supported-locale> |
21 | + <resource-bundle>jp.sf.pal.scheduler.resources.SchedulerConfig</resource-bundle> | |
20 | 22 | <portlet-info> |
21 | - <title>Scheduler Configuration</title> | |
23 | + <title>Scheduler Config</title> | |
22 | 24 | <short-title>Config</short-title> |
23 | - <keywords>Scheduler,URL</keywords> | |
25 | + <keywords>Scheduler</keywords> | |
24 | 26 | </portlet-info> |
25 | 27 | </portlet> |
26 | - --> | |
27 | 28 | <portlet> |
28 | 29 | <description>Manage facilities.</description> |
29 | 30 | <description xml:lang="ja">施設情報を管理します。</description> |