Changeset 873 for trunk/grails-app/services/TaskService.groovy
- Timestamp:
- Mar 16, 2011, 9:50:39 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/services/TaskService.groovy
r851 r873 338 338 } 339 339 340 if(!taskInstance) 341 return fail(field:"task", code:"task.notFound") 342 343 if(taskInstance.taskStatus.id == 3) 344 return fail(field:"task", code:"task.operationNotPermittedOnCompleteTask") 345 346 // Check for authorisation on recurring tasks. 347 if(taskInstance.taskRecurringSchedule) { 348 if(!authenticateService.ifAnyGranted('ROLE_AppAdmin,ROLE_Manager,ROLE_TaskManager')) 349 return fail(field:"task", code:"task.operationNotPermittedOnRecurringTaskWithoutAuth") 350 } 340 // Check if we should create this entry. 341 def checkResult = checkCreateEntry(result.entryInstance) 342 if(checkResult.error) 343 return fail(field:"task", code: checkResult.error.code) 351 344 352 345 if(result.entryInstance.hasErrors() || !result.entryInstance.save()) … … 1065 1058 } // end saveImmediateCallout() 1066 1059 1060 /** 1061 * Check if we should create an entry. 1062 * @param entryInstance The entry to check. 1063 * @returns A map containing result.error (if any error) and result.taskInstance. 1064 */ 1065 def checkCreateEntry(entryInstance) { 1066 def result = [:] 1067 1068 def fail = { Map m -> 1069 result.error = [ code: m.code, args: [] ] 1070 return result 1071 } 1072 1073 def taskInstance = entryInstance.task 1074 if(!taskInstance) 1075 return fail(code:"task.notFound") 1076 1077 // Check for tashed task. 1078 if(taskInstance.trash) 1079 return fail(code:"task.operationNotPermittedOnTaskInTrash") 1080 1081 // Check for Complete task. 1082 if(taskInstance.taskStatus.id == 3) 1083 return fail(code: "task.operationNotPermittedOnCompleteTask") 1084 1085 // Check for recurring schedule. 1086 if(taskInstance.taskRecurringSchedule) 1087 return fail(code:"task.operationNotPermittedOnRecurringTask") 1088 1089 // Check for procedure and ensure we are creating a PM Entry. 1090 if(taskInstance.taskProcedureRevision && (entryInstance.entryType.id != 6) ) 1091 return fail(code:"task.createEntryNotPermittedOnTaskWithProcedure") 1092 1093 // Success. 1094 return result 1095 1096 } // checkCreateEntry() 1097 1067 1098 } // end TaskService
Note: See TracChangeset
for help on using the changeset viewer.