Changeset 203 for trunk/grails-app/controllers
- Timestamp:
- Nov 30, 2009, 10:28:58 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/TaskRecurringScheduleDetailedController.groovy
r199 r203 6 6 7 7 def dateUtilService 8 def taskRecurringScheduleService 8 9 9 10 def index = { redirect(action:list,params:params) } … … 112 113 113 114 def create = { 114 try { 115 def taskInstance = Task.get(params.taskInstance.id) 116 def taskRecurringScheduleInstance = new TaskRecurringSchedule() 117 taskRecurringScheduleInstance.task = taskInstance 118 return [taskRecurringScheduleInstance: taskRecurringScheduleInstance] 115 if(!params.task?.id || !Task.exists(params.task?.id)) { 116 flash.message = "Please select a task, then Create a Recurring Schedule for it." 117 redirect(controller:"taskDetailed", action:"search") 118 return 119 119 } 120 catch(Exception e) { 121 flash.message = "Please select a task, then Create a Recurring Schedule for it" 122 redirect(controller:"taskDetailed", action:"search") 123 } 120 def taskRecurringScheduleInstance = new TaskRecurringSchedule() 121 taskRecurringScheduleInstance.properties = params 122 return [taskRecurringScheduleInstance: taskRecurringScheduleInstance] 124 123 } // end create() 125 124 126 125 def save = { 127 def taskRecurringScheduleInstance = new TaskRecurringSchedule(params) 128 def taskInstance = Task.get(params.task.id) 126 def result = taskRecurringScheduleService.create(params) 129 127 130 if( taskInstance.taskRecurringSchedule) {131 flash.message = " This task already has a recurring schedule"132 redirect( controller:"taskDetailed", action:"show", id: params.task.id)128 if(!result.error) { 129 flash.message = "Recurring Schedule ${result.taskRecurringScheduleInstance.id} created." 130 redirect(action:show, id: result.taskRecurringScheduleInstance.id) 133 131 } 134 132 else { 135 136 if(taskRecurringScheduleInstance.nextTargetStartDate < dateUtilService.getToday()) { 137 taskRecurringScheduleInstance.errors.rejectValue("nextTargetStartDate", "taskRecurring.nextTargetStartDate.NotInTheFuture") 138 } 139 140 if(!taskRecurringScheduleInstance.hasErrors() && taskRecurringScheduleInstance.save(flush: true)) { 141 142 taskInstance.taskRecurringSchedule = taskRecurringScheduleInstance 143 144 if(taskInstance.save(flush: true)) { 145 flash.message = "Recurring Schedule ${taskRecurringScheduleInstance.id} created" 146 redirect(action:show,id:taskRecurringScheduleInstance.id) 147 } 148 else { 149 flash.message = "Task could not be saved and therefore the Recurring Schedule has been disgarded, cause unknown." 150 render(view:'create',model:[taskRecurringScheduleInstance:taskRecurringScheduleInstance]) 151 } 152 } 153 else { 154 render(view:'create',model:[taskRecurringScheduleInstance:taskRecurringScheduleInstance]) 155 } 133 render(view:'create',model:[taskRecurringScheduleInstance: result.taskRecurringScheduleInstance]) 156 134 } 157 158 135 } // end save() 159 136
Note: See TracChangeset
for help on using the changeset viewer.