Changeset 203 for trunk/grails-app/services
- Timestamp:
- Nov 30, 2009, 10:28:58 PM (15 years ago)
- Location:
- trunk/grails-app/services
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/services/TaskRecurringScheduleService.groovy
r199 r203 6 6 def taskService 7 7 8 /** 9 * Generate all enabled recurring tasks. 10 */ 8 11 def generateAll() { 9 12 10 /// @todo: disable recurringSchedule when moving a task to trash.11 13 def taskRecurringScheduleList = TaskRecurringSchedule.findAllByEnabled(true) 12 14 … … 17 19 p.targetStartDate = it.nextTargetStartDate 18 20 p.targetCompletionDate = it.nextTargetCompletionDate 21 if(it.task.taskProcedure) p.taskProcedure = it.task.taskProcedure 19 22 def result = taskService.createSubTask(it.task, p) 20 23 if( !result.error ) { … … 26 29 } 27 30 else { 28 log.error result 31 log.error "Sub task generation for recurring schedule ${it.id} failed." 32 log.error result.taskInstance.errors 29 33 } 30 34 } … … 33 37 } 34 38 39 /** 40 * Creates a new recurring schedule for a task with the given params. 41 * @param params The params to use when creating the new recurring schedule. 42 * @returns A map containing result.error=true (if any error) and result.taskRecurringScheduleInstance and result.taskId. 43 */ 44 def create(params) { 45 TaskRecurringSchedule.withTransaction { status -> 46 def result = [:] 47 48 def fail = { Object[] args -> 49 status.setRollbackOnly() 50 if(args.size() == 2) result.taskRecurringScheduleInstance.errors.rejectValue(args[0], args[1]) 51 result.error = true 52 return result 53 } 54 55 result.taskRecurringScheduleInstance = new TaskRecurringSchedule(params) 56 result.taskId = result.taskRecurringScheduleInstance.task.id 57 58 if(!result.taskRecurringScheduleInstance.validate()) 59 return fail() 60 61 def taskInstance = Task.lock(result.taskId) 62 63 if(!taskInstance) 64 return fail('task', "task.notFound") 65 66 if(taskInstance.taskRecurringSchedule) 67 return fail('task', "tast.taskRecurringSchedule.alreadyExists") 68 69 if(taskInstance.taskStatus.id == 3) 70 return fail('task', "task.operationNotPermittedOnCompleteTask") 71 72 if(taskInstance.trash) 73 return fail('task', "task.operationNotPermittedOnTaskInTrash") 74 75 if(result.taskRecurringScheduleInstance.nextTargetStartDate < dateUtilService.getToday()) 76 return fail("nextTargetStartDate", "taskRecurring.nextTargetStartDate.NotInTheFuture") 77 78 taskInstance.taskRecurringSchedule = result.taskRecurringScheduleInstance 79 80 if(!result.taskRecurringScheduleInstance.save() || !taskInstance.save()) 81 return fail() 82 83 // All went well if we get to here. 84 return result 85 86 } //end withTransaction 87 } // end create() 88 35 89 } // end of class -
trunk/grails-app/services/TaskService.groovy
r202 r203 11 11 12 12 /** 13 * Determines and returns a possible parent list 13 * Determines and returns a possible parent list for a task. 14 14 * @param taskInstance The task to use when determining the possible parent list. 15 15 * @returns A list of the possible parents. … … 123 123 124 124 if(result.entryInstance.validate()) { 125 def taskInstance = Task.lock(result.entryInstance.task.id)126 125 result.taskId = result.entryInstance.task.id 126 def taskInstance = Task.lock(result.taskId) 127 127 128 128 if(!taskInstance) { 129 129 status.setRollbackOnly() 130 result.entryInstance.errors.rejectValue('task', " entry.task.notFound")130 result.entryInstance.errors.rejectValue('task', "task.notFound") 131 131 result.error = true 132 132 return result … … 150 150 if(!taskModification.save()) { 151 151 status.setRollbackOnly() 152 taskInstance.errors.rejectValue("task", " entry.task.failedToSaveTaskModification")152 taskInstance.errors.rejectValue("task", "task.modifications.failedToSave") 153 153 result.error = true 154 154 return result … … 160 160 if(!taskInstance.save()) { 161 161 status.setRollbackOnly() 162 result.entryInstance.errors.rejectValue("task", " entry.task.failedToSave")162 result.entryInstance.errors.rejectValue("task", "task.failedToSave") 163 163 result.error = true 164 164 return result
Note: See TracChangeset
for help on using the changeset viewer.