Changeset 186 for trunk/grails-app/services
- Timestamp:
- Nov 15, 2009, 1:50:18 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/services/TaskService.groovy
r182 r186 36 36 } // end create() 37 37 38 def start() { 39 //TaskModificationType.get(2) 40 } // end start() 38 def createEntry(params) { 39 Task.withTransaction { status -> 40 def result = [:] 41 result.entryInstance = new Entry(params) 42 result.entryInstance.enteredBy = personService.currentUser() 43 44 if(result.entryInstance.validate()) { 45 def taskInstance = Task.lock(result.entryInstance.task.id) 46 result.taskId = result.entryInstance.task.id 47 48 if(!taskInstance) { 49 status.setRollbackOnly() 50 result.entryInstance.errors.rejectValue('task', "entry.task.notFound") 51 result.error = true 52 return result 53 } 54 55 if(taskInstance.taskStatus.id == 3) { 56 status.setRollbackOnly() 57 result.entryInstance.errors.rejectValue('task', "entry.task.taskIsComplete") 58 result.error = true 59 return result 60 } 61 62 // If task status is "Not Started" and entry type is "Work Done" then we create the started modification and set the status. 63 if(taskInstance.taskStatus.id == 1 && result.entryInstance.entryType.id == 2) { 64 65 // Create the "Started" task modification, this provides the "Actual started date". 66 def taskModification = new TaskModification(person: personService.currentUser(), 67 taskModificationType: TaskModificationType.get(2), 68 task: taskInstance) 69 70 if(!taskModification.save()) { 71 status.setRollbackOnly() 72 taskInstance.errors.rejectValue("task", "entry.task.failedToSaveTaskModification") 73 result.error = true 74 return result 75 } 76 77 // Set task status to "In progress". 78 taskInstance.taskStatus = TaskStatus.get(2) 79 80 if(!taskInstance.save()) { 81 status.setRollbackOnly() 82 result.entryInstance.errors.rejectValue("task", "entry.task.failedToSave") 83 result.error = true 84 return result 85 } 86 } 87 88 if(!result.entryInstance.save()) { 89 status.setRollbackOnly() 90 result.error = true 91 return result 92 } 93 94 // All went well if we get to here. 95 return result 96 } 97 else { 98 result.error = true 99 return result 100 } 101 102 } //end withTransaction 103 } // end create() 41 104 42 105 def update(params) {
Note: See TracChangeset
for help on using the changeset viewer.