Changeset 181 for trunk/grails-app/services
- Timestamp:
- Nov 5, 2009, 4:01:35 AM (15 years ago)
- Location:
- trunk/grails-app/services
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/services/CreateDataService.groovy
r180 r181 410 410 def taskStatusInstance 411 411 412 taskStatusInstance = new TaskStatus(name:"Not Started") 412 taskStatusInstance = new TaskStatus(name:"Not Started") // #1 413 413 saveAndTest(taskStatusInstance) 414 414 415 taskStatusInstance = new TaskStatus(name:"In Progress") 415 taskStatusInstance = new TaskStatus(name:"In Progress") // #2 416 416 saveAndTest(taskStatusInstance) 417 417 418 taskStatusInstance = new TaskStatus(name:"Completed") 418 taskStatusInstance = new TaskStatus(name:"Completed") // #3 419 419 saveAndTest(taskStatusInstance) 420 420 } -
trunk/grails-app/services/TaskSearchService.groovy
r180 r181 19 19 ge("targetStartDate", dateUtilService.getToday()) 20 20 lt("targetStartDate", dateUtilService.getTomorrow()) 21 eq(" isActive", true)21 eq("trash", false) 22 22 } 23 23 } … … 37 37 ge("targetStartDate", dateUtilService.getToday()) 38 38 lt("targetStartDate", dateUtilService.getTomorrow()) 39 eq(" isActive", true)39 eq("trash", false) 40 40 } 41 41 } … … 54 54 ge("targetStartDate", dateUtilService.getToday()-7) 55 55 lt("targetStartDate", dateUtilService.getTomorrow()) 56 eq(" isActive", true)56 eq("trash", false) 57 57 } 58 58 } … … 72 72 ge("targetStartDate", dateUtilService.getToday()-7) 73 73 lt("targetStartDate", dateUtilService.getTomorrow()) 74 eq(" isActive", true)74 eq("trash", false) 75 75 } 76 76 } … … 90 90 ge("targetStartDate", dateUtilService.getToday()-7) 91 91 lt("targetStartDate", dateUtilService.getTomorrow()) 92 eq(" isActive", true)92 eq("trash", false) 93 93 } 94 94 } … … 108 108 ge("targetStartDate", dateUtilService.getToday()-7) 109 109 lt("targetStartDate", dateUtilService.getTomorrow()) 110 eq(" isActive", true)110 eq("trash", false) 111 111 } 112 112 } -
trunk/grails-app/services/TaskService.groovy
r180 r181 9 9 Task.withTransaction { status -> 10 10 def result = [:] 11 // Default status to "not started" if not supplied. 12 params.taskStatus = params.taskStatus ?: TaskStatus.get(1) 11 13 def taskInstance = new Task(params) 12 14 result.taskInstance = taskInstance … … 59 61 } 60 62 61 62 63 result.taskInstance.properties = params 63 64 … … 86 87 } // end update() 87 88 88 def complete() { 89 //TaskModificationType.get(4) 89 def complete(params) { 90 Task.withTransaction { status -> 91 def result = [:] 92 result.taskInstance = Task.get(params.id) 93 if(result.taskInstance) { 94 95 // Optimistic locking check. 96 if(params.version) { 97 def version = params.version.toLong() 98 if(result.taskInstance.version > version) { 99 status.setRollbackOnly() 100 result.taskInstance.errors.rejectValue("version", "task.optimistic.locking.failure", "Another user has updated this Task while you were editing.") 101 result.error = true 102 return result 103 } 104 } 105 106 result.taskInstance.taskStatus = TaskStatus.get(3) 107 108 if(result.taskInstance.save()) { 109 def taskModification = new TaskModification(person:Person.get(authenticateService.userDomain().id), 110 taskModificationType: TaskModificationType.get(4), 111 task: result.taskInstance) 112 if(taskModification.save()) { 113 // All went well. 114 return result 115 } 116 else { 117 status.setRollbackOnly() 118 result.taskInstance.errors.rejectValue("taskModifications", "task.modifications.failedToSave") 119 result.error = true 120 return result 121 } 122 } 123 } 124 // Something failed. 125 status.setRollbackOnly() 126 result.error = true 127 return result 128 129 } //end withTransaction 90 130 } // end complete() 91 131 92 def reopen() { 93 //TaskModificationType.get(5) 132 def reopen(params) { 133 Task.withTransaction { status -> 134 def result = [:] 135 result.taskInstance = Task.get(params.id) 136 if(result.taskInstance) { 137 138 // Optimistic locking check. 139 if(params.version) { 140 def version = params.version.toLong() 141 if(result.taskInstance.version > version) { 142 status.setRollbackOnly() 143 result.taskInstance.errors.rejectValue("version", "task.optimistic.locking.failure", "Another user has updated this Task while you were editing.") 144 result.error = true 145 return result 146 } 147 } 148 149 result.taskInstance.taskStatus = TaskStatus.get(2) 150 151 if(result.taskInstance.save()) { 152 def taskModification = new TaskModification(person:Person.get(authenticateService.userDomain().id), 153 taskModificationType: TaskModificationType.get(5), 154 task: result.taskInstance) 155 if(taskModification.save()) { 156 // All went well. 157 return result 158 } 159 else { 160 status.setRollbackOnly() 161 result.taskInstance.errors.rejectValue("taskModifications", "task.modifications.failedToSave") 162 result.error = true 163 return result 164 } 165 } 166 } 167 // Something failed. 168 status.setRollbackOnly() 169 result.error = true 170 return result 171 172 } //end withTransaction 94 173 } // end reopen() 95 174 96 def trash() { 97 //TaskModificationType.get(6) 175 def trash(params) { 176 Task.withTransaction { status -> 177 def result = [:] 178 result.taskInstance = Task.get(params.id) 179 if(result.taskInstance) { 180 181 // Optimistic locking check. 182 if(params.version) { 183 def version = params.version.toLong() 184 if(result.taskInstance.version > version) { 185 status.setRollbackOnly() 186 result.taskInstance.errors.rejectValue("version", "task.optimistic.locking.failure", "Another user has updated this Task while you were editing.") 187 result.error = true 188 return result 189 } 190 } 191 192 result.taskInstance.trash = true 193 194 if(result.taskInstance.save()) { 195 def taskModification = new TaskModification(person:Person.get(authenticateService.userDomain().id), 196 taskModificationType: TaskModificationType.get(6), 197 task: result.taskInstance) 198 if(taskModification.save()) { 199 // All went well. 200 return result 201 } 202 else { 203 status.setRollbackOnly() 204 result.taskInstance.errors.rejectValue("taskModifications", "task.modifications.failedToSave") 205 result.error = true 206 return result 207 } 208 } 209 } 210 // Something failed. 211 status.setRollbackOnly() 212 result.error = true 213 return result 214 215 } //end withTransaction 98 216 } // end trash() 99 217 100 def restore() { 101 //TaskModificationType.get(7) 218 def restore(params) { 219 Task.withTransaction { status -> 220 def result = [:] 221 result.taskInstance = Task.get(params.id) 222 if(result.taskInstance) { 223 224 // Optimistic locking check. 225 if(params.version) { 226 def version = params.version.toLong() 227 if(result.taskInstance.version > version) { 228 status.setRollbackOnly() 229 result.taskInstance.errors.rejectValue("version", "task.optimistic.locking.failure", "Another user has updated this Task while you were editing.") 230 result.error = true 231 return result 232 } 233 } 234 235 result.taskInstance.trash = false 236 237 if(result.taskInstance.save()) { 238 def taskModification = new TaskModification(person:Person.get(authenticateService.userDomain().id), 239 taskModificationType: TaskModificationType.get(7), 240 task: result.taskInstance) 241 if(taskModification.save()) { 242 // All went well. 243 return result 244 } 245 else { 246 status.setRollbackOnly() 247 result.taskInstance.errors.rejectValue("taskModifications", "task.modifications.failedToSave") 248 result.error = true 249 return result 250 } 251 } 252 } 253 // Something failed. 254 status.setRollbackOnly() 255 result.error = true 256 return result 257 258 } //end withTransaction 102 259 } // end restore() 103 260 104 def approve() { 105 //TaskModificationType.get(8) 261 def approve(params) { 262 Task.withTransaction { status -> 263 def result = [:] 264 result.taskInstance = Task.get(params.id) 265 if(result.taskInstance) { 266 267 // Optimistic locking check. 268 if(params.version) { 269 def version = params.version.toLong() 270 if(result.taskInstance.version > version) { 271 status.setRollbackOnly() 272 result.taskInstance.errors.rejectValue("version", "task.optimistic.locking.failure", "Another user has updated this Task while you were editing.") 273 result.error = true 274 return result 275 } 276 } 277 278 result.taskInstance.approved = true 279 280 if(result.taskInstance.save()) { 281 def taskModification = new TaskModification(person:Person.get(authenticateService.userDomain().id), 282 taskModificationType: TaskModificationType.get(8), 283 task: result.taskInstance) 284 if(taskModification.save()) { 285 // All went well. 286 return result 287 } 288 else { 289 status.setRollbackOnly() 290 result.taskInstance.errors.rejectValue("taskModifications", "task.modifications.failedToSave") 291 result.error = true 292 return result 293 } 294 } 295 } 296 // Something failed. 297 status.setRollbackOnly() 298 result.error = true 299 return result 300 301 } //end withTransaction 106 302 } // end approve() 107 303 108 def renegeApproval() { 109 //TaskModificationType.get(9) 304 def renegeApproval(params) { 305 Task.withTransaction { status -> 306 def result = [:] 307 result.taskInstance = Task.get(params.id) 308 if(result.taskInstance) { 309 310 // Optimistic locking check. 311 if(params.version) { 312 def version = params.version.toLong() 313 if(result.taskInstance.version > version) { 314 status.setRollbackOnly() 315 result.taskInstance.errors.rejectValue("version", "task.optimistic.locking.failure", "Another user has updated this Task while you were editing.") 316 result.error = true 317 return result 318 } 319 } 320 321 result.taskInstance.approved = false 322 323 if(result.taskInstance.save()) { 324 def taskModification = new TaskModification(person:Person.get(authenticateService.userDomain().id), 325 taskModificationType: TaskModificationType.get(9), 326 task: result.taskInstance) 327 if(taskModification.save()) { 328 // All went well. 329 return result 330 } 331 else { 332 status.setRollbackOnly() 333 result.taskInstance.errors.rejectValue("taskModifications", "task.modifications.failedToSave") 334 result.error = true 335 return result 336 } 337 } 338 } 339 // Something failed. 340 status.setRollbackOnly() 341 result.error = true 342 return result 343 344 } //end withTransaction 110 345 } // end renegeApproval() 111 346
Note: See TracChangeset
for help on using the changeset viewer.