display own evnet for facilities.
@@ -2,6 +2,7 @@ | ||
2 | 2 | |
3 | 3 | import java.io.Serializable; |
4 | 4 | import java.sql.Timestamp; |
5 | +import java.util.ArrayList; | |
5 | 6 | import java.util.Date; |
6 | 7 | import java.util.List; |
7 | 8 |
@@ -8,6 +9,7 @@ | ||
8 | 9 | import jp.sf.pal.scheduler.SchedulerConstants; |
9 | 10 | import jp.sf.pal.scheduler.common.dxo.PagerDxo; |
10 | 11 | import jp.sf.pal.scheduler.common.util.PagingResultBeanWrapper; |
12 | +import jp.sf.pal.scheduler.db.allcommon.bhv.setup.ConditionBeanSetupper; | |
11 | 13 | import jp.sf.pal.scheduler.db.allcommon.cbean.PagingResultBean; |
12 | 14 | import jp.sf.pal.scheduler.db.cbean.EventScheduleCB; |
13 | 15 | import jp.sf.pal.scheduler.db.cbean.EventScheduleMappingCB; |
@@ -39,7 +41,7 @@ | ||
39 | 41 | private PagerDxo pagerDxo; |
40 | 42 | |
41 | 43 | public List<FacilityScheduleMapping> getFacilityScheduleMappingList( |
42 | - Integer facilityId, Date fromDate, Date toDate) { | |
44 | + Integer facilityId, Date fromDate, Date toDate, final String userId) { | |
43 | 45 | FacilityScheduleMappingCB cb = new FacilityScheduleMappingCB(); |
44 | 46 | |
45 | 47 | // setup |
@@ -54,7 +56,24 @@ | ||
54 | 56 | |
55 | 57 | cb.query().queryEventSchedule().addOrderBy_StartDate_Asc(); |
56 | 58 | |
57 | - return facilityScheduleMappingBhv.selectList(cb); | |
59 | + List<FacilityScheduleMapping> fsmList = facilityScheduleMappingBhv | |
60 | + .selectList(cb); | |
61 | + | |
62 | + if (userId != null) { | |
63 | + List<EventSchedule> esList = new ArrayList<EventSchedule>(); | |
64 | + for (FacilityScheduleMapping fsm : fsmList) { | |
65 | + esList.add(fsm.getEventSchedule()); | |
66 | + } | |
67 | + final ConditionBeanSetupper<EventScheduleMappingCB> setupper = new ConditionBeanSetupper<EventScheduleMappingCB>() { | |
68 | + public void setup(EventScheduleMappingCB cb) { | |
69 | + cb.query().setUserId_Equal(userId); | |
70 | + } | |
71 | + }; | |
72 | + eventScheduleBhv.loadEventScheduleMappingList(esList, setupper); | |
73 | + } | |
74 | + | |
75 | + // TODO performance | |
76 | + return fsmList; | |
58 | 77 | } |
59 | 78 | |
60 | 79 | public List<EventScheduleMapping> getPersonalScheduleMappingList( |
@@ -2,6 +2,7 @@ | ||
2 | 2 | |
3 | 3 | import java.io.Serializable; |
4 | 4 | import java.sql.Timestamp; |
5 | +import java.util.ArrayList; | |
5 | 6 | import java.util.Date; |
6 | 7 | import java.util.List; |
7 | 8 |
@@ -8,6 +9,7 @@ | ||
8 | 9 | import jp.sf.pal.scheduler.SchedulerConstants; |
9 | 10 | import jp.sf.pal.scheduler.common.dxo.PagerDxo; |
10 | 11 | import jp.sf.pal.scheduler.common.util.PagingResultBeanWrapper; |
12 | +import jp.sf.pal.scheduler.db.allcommon.bhv.setup.ConditionBeanSetupper; | |
11 | 13 | import jp.sf.pal.scheduler.db.allcommon.cbean.PagingResultBean; |
12 | 14 | import jp.sf.pal.scheduler.db.allcommon.cbean.UnionQuery; |
13 | 15 | import jp.sf.pal.scheduler.db.cbean.EventScheduleCB; |
@@ -40,7 +42,8 @@ | ||
40 | 42 | private PagerDxo pagerDxo; |
41 | 43 | |
42 | 44 | public List<FacilityScheduleMapping> getFacilityScheduleMappingList( |
43 | - final Integer facilityId, final Date fromDate, final Date toDate) { | |
45 | + final Integer facilityId, final Date fromDate, final Date toDate, | |
46 | + final String userId) { | |
44 | 47 | FacilityScheduleMappingCB cb = new FacilityScheduleMappingCB(); |
45 | 48 | |
46 | 49 | // setup |
@@ -66,7 +69,24 @@ | ||
66 | 69 | }); |
67 | 70 | cb.query().queryEventSchedule().addOrderBy_StartDate_Asc(); |
68 | 71 | |
69 | - return facilityScheduleMappingBhv.selectList(cb); | |
72 | + List<FacilityScheduleMapping> fsmList = facilityScheduleMappingBhv | |
73 | + .selectList(cb); | |
74 | + | |
75 | + if (userId != null) { | |
76 | + List<EventSchedule> esList = new ArrayList<EventSchedule>(); | |
77 | + for (FacilityScheduleMapping fsm : fsmList) { | |
78 | + esList.add(fsm.getEventSchedule()); | |
79 | + } | |
80 | + final ConditionBeanSetupper<EventScheduleMappingCB> setupper = new ConditionBeanSetupper<EventScheduleMappingCB>() { | |
81 | + public void setup(EventScheduleMappingCB cb) { | |
82 | + cb.query().setUserId_Equal(userId); | |
83 | + } | |
84 | + }; | |
85 | + eventScheduleBhv.loadEventScheduleMappingList(esList, setupper); | |
86 | + } | |
87 | + | |
88 | + // TODO performance | |
89 | + return fsmList; | |
70 | 90 | } |
71 | 91 | |
72 | 92 | public List<EventScheduleMapping> getPersonalScheduleMappingList( |
@@ -78,11 +78,12 @@ | ||
78 | 78 | eventInDayItems.add(new ArrayList<Map<String, Object>>(5)); |
79 | 79 | } |
80 | 80 | |
81 | + String userId = request.getRemoteUser(); | |
81 | 82 | Integer facilityId = Integer.parseInt(calendarForm.facilityId); |
82 | 83 | facility = facilityService.getFacility(facilityId); |
83 | 84 | List<FacilityScheduleMapping> ssmList = onetimeScheduleService |
84 | 85 | .getFacilityScheduleMappingList(facilityId, cal.getTime(), |
85 | - nextCal.getTime()); | |
86 | + nextCal.getTime(), userId); | |
86 | 87 | SchedulerUtil.createFacilityDayForOnetime(tYear, tMonth, tDate, |
87 | 88 | ssmList, eventInDayItems, allDayEventInDayItems); |
88 | 89 |
@@ -104,7 +105,7 @@ | ||
104 | 105 | |
105 | 106 | List<FacilityScheduleMapping> rsmList = repeatScheduleService |
106 | 107 | .getFacilityScheduleMappingList(facilityId, cal.getTime(), |
107 | - nextCal.getTime()); | |
108 | + nextCal.getTime(), userId); | |
108 | 109 | SchedulerUtil.createFacilityDayForRepeat(tYear, tMonth, tDate, tDay, |
109 | 110 | rsmList, eventInDayItems, allDayEventInDayItems); |
110 | 111 |
@@ -220,17 +221,18 @@ | ||
220 | 221 | allDayEventInWeekItems.add(new ArrayList<Map<String, Object>>(5)); |
221 | 222 | } |
222 | 223 | |
224 | + String userId = request.getRemoteUser(); | |
223 | 225 | Integer facilityId = Integer.parseInt(calendarForm.facilityId); |
224 | 226 | facility = facilityService.getFacility(facilityId); |
225 | 227 | List<FacilityScheduleMapping> fsmList1 = onetimeScheduleService |
226 | 228 | .getFacilityScheduleMappingList(facilityId, calendarList.get(0) |
227 | - .getTime(), calendarList.get(6).getTime()); | |
229 | + .getTime(), calendarList.get(6).getTime(), userId); | |
228 | 230 | SchedulerUtil.createFacilityWeekForOnetime(indexMap, fsmList1, |
229 | 231 | eventInWeekItems, allDayEventInWeekItems); |
230 | 232 | |
231 | 233 | List<FacilityScheduleMapping> fsmList2 = repeatScheduleService |
232 | 234 | .getFacilityScheduleMappingList(facilityId, calendarList.get(0) |
233 | - .getTime(), calendarList.get(6).getTime()); | |
235 | + .getTime(), calendarList.get(6).getTime(), userId); | |
234 | 236 | SchedulerUtil.createFacilityWeekForRepeat(indexMap, fsmList2, |
235 | 237 | eventInWeekItems, allDayEventInWeekItems, weekDayItems); |
236 | 238 |
@@ -271,17 +273,18 @@ | ||
271 | 273 | int endDateIndex = indexMap.get(lastYear + "-" + lastMonth + "-" |
272 | 274 | + lastDate); |
273 | 275 | |
276 | + String userId = request.getRemoteUser(); | |
274 | 277 | Integer facilityId = Integer.parseInt(calendarForm.facilityId); |
275 | 278 | facility = facilityService.getFacility(facilityId); |
276 | 279 | List<FacilityScheduleMapping> ssmList = onetimeScheduleService |
277 | 280 | .getFacilityScheduleMappingList(facilityId, startCal.getTime(), |
278 | - endCal.getTime()); | |
281 | + endCal.getTime(), userId); | |
279 | 282 | SchedulerUtil.createFacilityMonthForOnetime(firstDateIndex, |
280 | 283 | endDateIndex, indexMap, ssmList, calendarDayItems); |
281 | 284 | |
282 | 285 | List<FacilityScheduleMapping> rsmList = repeatScheduleService |
283 | 286 | .getFacilityScheduleMappingList(facilityId, startCal.getTime(), |
284 | - endCal.getTime()); | |
287 | + endCal.getTime(), userId); | |
285 | 288 | SchedulerUtil.createFacilityMonthForRepeat(firstDateIndex, |
286 | 289 | endDateIndex, indexMap, rsmList, calendarDayItems); |
287 | 290 |
@@ -387,15 +390,16 @@ | ||
387 | 390 | allDayEventInWeekItems.add(new ArrayList<Map<String, Object>>(5)); |
388 | 391 | } |
389 | 392 | |
393 | + String userId = request.getRemoteUser(); | |
390 | 394 | List<FacilityScheduleMapping> ssmList = onetimeScheduleService |
391 | 395 | .getFacilityScheduleMappingList(facility.getId(), startCal |
392 | - .getTime(), endCal.getTime()); | |
396 | + .getTime(), endCal.getTime(), userId); | |
393 | 397 | SchedulerUtil.createFacilityWeekForOnetime(indexMap, ssmList, |
394 | 398 | eventInWeekItems, allDayEventInWeekItems); |
395 | 399 | |
396 | 400 | List<FacilityScheduleMapping> rsmList = repeatScheduleService |
397 | 401 | .getFacilityScheduleMappingList(facility.getId(), startCal |
398 | - .getTime(), endCal.getTime()); | |
402 | + .getTime(), endCal.getTime(), userId); | |
399 | 403 | SchedulerUtil.createFacilityWeekForRepeat(indexMap, rsmList, |
400 | 404 | eventInWeekItems, allDayEventInWeekItems, weekDayItems); |
401 | 405 |
@@ -13,6 +13,7 @@ | ||
13 | 13 | import java.util.Set; |
14 | 14 | |
15 | 15 | import jp.sf.pal.scheduler.SchedulerConstants; |
16 | +import jp.sf.pal.scheduler.common.CommonConstants; | |
16 | 17 | import jp.sf.pal.scheduler.common.util.CalendarUtil; |
17 | 18 | import jp.sf.pal.scheduler.common.util.ConfigUtil; |
18 | 19 | import jp.sf.pal.scheduler.common.util.DateUtil; |
@@ -283,7 +284,7 @@ | ||
283 | 284 | |
284 | 285 | public static Map<String, Object> createEvent(EventSchedule eventSchedule, |
285 | 286 | boolean start, boolean end) { |
286 | - Map<String, Object> map = new HashMap<String, Object>(6); | |
287 | + Map<String, Object> map = new HashMap<String, Object>(7); | |
287 | 288 | map.put("id", eventSchedule.getId().toString()); |
288 | 289 | map.put("title", eventSchedule.getTitle()); |
289 | 290 | map.put("secret", eventSchedule.getSecret()); |
@@ -305,6 +306,12 @@ | ||
305 | 306 | map.put("repeat", "true"); |
306 | 307 | map.put("type", ((EventSchedule) eventSchedule).getType()); |
307 | 308 | } |
309 | + if (eventSchedule.getEventScheduleMappingList() != null | |
310 | + && !eventSchedule.getEventScheduleMappingList().isEmpty()) { | |
311 | + map.put("open", CommonConstants.TRUE); | |
312 | + } else { | |
313 | + map.put("open", CommonConstants.FALSE); | |
314 | + } | |
308 | 315 | |
309 | 316 | return map; |
310 | 317 | } |
@@ -312,7 +319,7 @@ | ||
312 | 319 | public static Map<String, Object> createEventWithCurrentDate( |
313 | 320 | EventSchedule eventSchedule, boolean start, boolean end, |
314 | 321 | String currentDate) { |
315 | - Map<String, Object> map = new HashMap<String, Object>(9); | |
322 | + Map<String, Object> map = new HashMap<String, Object>(10); | |
316 | 323 | map.put("id", eventSchedule.getId().toString()); |
317 | 324 | map.put("title", eventSchedule.getTitle()); |
318 | 325 | map.put("secret", eventSchedule.getSecret()); |
@@ -334,6 +341,12 @@ | ||
334 | 341 | map.put("repeat", "true"); |
335 | 342 | map.put("type", ((EventSchedule) eventSchedule).getType()); |
336 | 343 | } |
344 | + if (eventSchedule.getEventScheduleMappingList() != null | |
345 | + && !eventSchedule.getEventScheduleMappingList().isEmpty()) { | |
346 | + map.put("open", CommonConstants.TRUE); | |
347 | + } else { | |
348 | + map.put("open", CommonConstants.FALSE); | |
349 | + } | |
337 | 350 | |
338 | 351 | // set target date |
339 | 352 | // TODO needs null check? |