[pal-cvs 3948] [1683] allow you to update a target event and later.

svnno****@sourc***** svnno****@sourc*****
2009年 1月 20日 (火) 15:46:17 JST


Revision: 1683
          http://svn.sourceforge.jp/view?root=pal&view=rev&rev=1683
Author:   shinsuke
Date:     2009-01-20 15:46:16 +0900 (Tue, 20 Jan 2009)

Log Message:
-----------
allow you to update a target event and later.

Modified Paths:
--------------
    scheduler/trunk/src/main/java/jp/sf/pal/scheduler/action/user/facility/RepeatScheduleAction.java
    scheduler/trunk/src/main/java/jp/sf/pal/scheduler/action/user/schedule/RepeatScheduleAction.java
    scheduler/trunk/src/main/webapp/WEB-INF/view/user/facility/repeatSchedule/confirm.jsp
    scheduler/trunk/src/main/webapp/WEB-INF/view/user/schedule/repeatSchedule/confirm.jsp


-------------- next part --------------
Modified: scheduler/trunk/src/main/java/jp/sf/pal/scheduler/action/user/facility/RepeatScheduleAction.java
===================================================================
--- scheduler/trunk/src/main/java/jp/sf/pal/scheduler/action/user/facility/RepeatScheduleAction.java	2009-01-20 05:47:24 UTC (rev 1682)
+++ scheduler/trunk/src/main/java/jp/sf/pal/scheduler/action/user/facility/RepeatScheduleAction.java	2009-01-20 06:46:16 UTC (rev 1683)
@@ -305,6 +305,52 @@
     }
 
     @Execute(validator = true, input = "edit.jsp")
+    public String updateitandlater() {
+        if (!SchedulerUtil.compare(repeatScheduleForm.getStartDate(),
+                repeatScheduleForm.getStartTime(), repeatScheduleForm
+                        .getEndDate(), repeatScheduleForm.getEndTime())) {
+            throw new ActionMessagesException("errors.invalid_end_date");
+        }
+        try {
+            int ty = Integer.parseInt(repeatScheduleForm.tYear);
+            int tm = Integer.parseInt(repeatScheduleForm.tMonth);
+            int td = Integer.parseInt(repeatScheduleForm.tDate);
+            Date d1 = DateUtil.get(ty - 1900, tm - 1, td - 1);
+            EventSchedule prevEventSchedule = getEventSchedule();
+            prevEventSchedule.setEndDate(d1);
+            repeatScheduleService.store(prevEventSchedule);
+
+            repeatScheduleForm.mode = CommonConstants.CREATE_MODE;
+            Date d2 = DateUtil.get(ty - 1900, tm - 1, td);
+            EventSchedule eventSchedule = createEventSchedule();
+            eventSchedule.setStartDate(d2);
+            eventSchedule.setParentId(prevEventSchedule.getId());
+            repeatScheduleService.store(eventSchedule);
+
+            SAStrutsUtil.addMessage(request,
+                    "success.update_eventSchedule_and_later");
+
+            repeatScheduleForm.id = eventSchedule.getId().toString();
+
+            repeatScheduleForm.mode = CommonConstants.CONFIRM_MODE;
+
+            // update edit page
+            loadDetailsPageParameters();
+
+            loadEventSchedule();
+
+            return "confirm.jsp";
+        } catch (ActionMessagesException e) {
+            log.error(e.getMessage(), e);
+            throw e;
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            throw new ActionMessagesException(
+                    "errors.failed_to_update_eventSchedule");
+        }
+    }
+
+    @Execute(validator = true, input = "edit.jsp")
     public String update() {
         if (!SchedulerUtil.compare(repeatScheduleForm.getStartDate(),
                 repeatScheduleForm.getStartTime(), repeatScheduleForm
@@ -598,6 +644,15 @@
         return eventSchedule;
     }
 
+    private EventSchedule getEventSchedule() {
+        String userId = request.getRemoteUser();
+        EventSchedule eventSchedule = repeatScheduleService.getEventSchedule(
+                Long.parseLong(repeatScheduleForm.id), null);
+        eventSchedule.setUpdatedBy(userId);
+
+        return eventSchedule;
+    }
+
     private EventSchedule createDeletedEventSchedule(EventSchedule eventSchedule) {
         String userId = request.getRemoteUser();
         EventSchedule deletedEventSchedule = new EventSchedule();

Modified: scheduler/trunk/src/main/java/jp/sf/pal/scheduler/action/user/schedule/RepeatScheduleAction.java
===================================================================
--- scheduler/trunk/src/main/java/jp/sf/pal/scheduler/action/user/schedule/RepeatScheduleAction.java	2009-01-20 05:47:24 UTC (rev 1682)
+++ scheduler/trunk/src/main/java/jp/sf/pal/scheduler/action/user/schedule/RepeatScheduleAction.java	2009-01-20 06:46:16 UTC (rev 1683)
@@ -298,6 +298,52 @@
     }
 
     @Execute(validator = true, input = "edit.jsp")
+    public String updateitandlater() {
+        if (!SchedulerUtil.compare(repeatScheduleForm.getStartDate(),
+                repeatScheduleForm.getStartTime(), repeatScheduleForm
+                        .getEndDate(), repeatScheduleForm.getEndTime())) {
+            throw new ActionMessagesException("errors.invalid_end_date");
+        }
+        try {
+            int ty = Integer.parseInt(repeatScheduleForm.tYear);
+            int tm = Integer.parseInt(repeatScheduleForm.tMonth);
+            int td = Integer.parseInt(repeatScheduleForm.tDate);
+            Date d1 = DateUtil.get(ty - 1900, tm - 1, td - 1);
+            EventSchedule prevEventSchedule = getEventSchedule();
+            prevEventSchedule.setEndDate(d1);
+            repeatScheduleService.store(prevEventSchedule);
+
+            repeatScheduleForm.mode = CommonConstants.CREATE_MODE;
+            Date d2 = DateUtil.get(ty - 1900, tm - 1, td);
+            EventSchedule eventSchedule = createEventSchedule();
+            eventSchedule.setStartDate(d2);
+            eventSchedule.setParentId(prevEventSchedule.getId());
+            repeatScheduleService.store(eventSchedule);
+
+            SAStrutsUtil.addMessage(request,
+                    "success.update_eventSchedule_and_later");
+
+            repeatScheduleForm.id = eventSchedule.getId().toString();
+
+            repeatScheduleForm.mode = CommonConstants.CONFIRM_MODE;
+
+            // update edit page
+            loadDetailsPageParameters();
+
+            loadEventSchedule();
+
+            return "confirm.jsp";
+        } catch (ActionMessagesException e) {
+            log.error(e.getMessage(), e);
+            throw e;
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            throw new ActionMessagesException(
+                    "errors.failed_to_update_eventSchedule");
+        }
+    }
+
+    @Execute(validator = true, input = "edit.jsp")
     public String update() {
         if (!SchedulerUtil.compare(repeatScheduleForm.getStartDate(),
                 repeatScheduleForm.getStartTime(), repeatScheduleForm
@@ -590,6 +636,15 @@
         return eventSchedule;
     }
 
+    private EventSchedule getEventSchedule() {
+        String userId = request.getRemoteUser();
+        EventSchedule eventSchedule = repeatScheduleService.getEventSchedule(
+                Long.parseLong(repeatScheduleForm.id), null);
+        eventSchedule.setUpdatedBy(userId);
+
+        return eventSchedule;
+    }
+
     private EventSchedule createDeletedEventSchedule(EventSchedule eventSchedule) {
         String userId = request.getRemoteUser();
         EventSchedule deletedEventSchedule = new EventSchedule();

Modified: scheduler/trunk/src/main/webapp/WEB-INF/view/user/facility/repeatSchedule/confirm.jsp
===================================================================
--- scheduler/trunk/src/main/webapp/WEB-INF/view/user/facility/repeatSchedule/confirm.jsp	2009-01-20 05:47:24 UTC (rev 1682)
+++ scheduler/trunk/src/main/webapp/WEB-INF/view/user/facility/repeatSchedule/confirm.jsp	2009-01-20 06:46:16 UTC (rev 1683)
@@ -159,6 +159,7 @@
         </c:if>
         <c:if test="${mode == 2}">
             <input type="submit" name="update" value="<bean:message key="labels.update"/>"/>
+            <input type="submit" name="updateitandlater" value="<bean:message key="labels.update_it_and_later"/>"/>
             <input type="submit" name="editagain" value="<bean:message key="labels.back"/>"/>
         </c:if>
         <c:if test="${mode == 3}">

Modified: scheduler/trunk/src/main/webapp/WEB-INF/view/user/schedule/repeatSchedule/confirm.jsp
===================================================================
--- scheduler/trunk/src/main/webapp/WEB-INF/view/user/schedule/repeatSchedule/confirm.jsp	2009-01-20 05:47:24 UTC (rev 1682)
+++ scheduler/trunk/src/main/webapp/WEB-INF/view/user/schedule/repeatSchedule/confirm.jsp	2009-01-20 06:46:16 UTC (rev 1683)
@@ -158,6 +158,7 @@
         </c:if>
         <c:if test="${mode == 2}">
             <input type="submit" name="update" value="<bean:message key="labels.update"/>"/>
+            <input type="submit" name="updateitandlater" value="<bean:message key="labels.update_it_and_later"/>"/>
             <input type="submit" name="editagain" value="<bean:message key="labels.back"/>"/>
         </c:if>
         <c:if test="${mode == 3}">


pal-cvs メーリングリストの案内