Changeset 196 for trunk/grails-app/services
- Timestamp:
- Nov 24, 2009, 7:57:30 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/services/TaskService.groovy
r191 r196 1 /* 2 * Provides a service for the Task domain class. 3 * 4 */ 1 5 class TaskService { 2 6 … … 6 10 def personService 7 11 12 /* 13 * Determines and returns a possible parent list 14 * @taskInstance The task to use when determining the possible parent list. 15 * @returns A list of the possible parents. 16 */ 17 def possibleParentList(taskInstance) { 18 def criteria = taskInstance.createCriteria() 19 def possibleParentList = criteria { 20 and { 21 notEqual('trash', true) 22 notEqual('id', taskInstance.id) 23 taskInstance.subTasks.each() { notEqual('id', it.id) } 24 } 25 } 26 } 27 28 /* 29 * Creates a new task with the given params. 30 * @params The params to use when creating the new task. 31 * @returns A map containing result.error=true (if any error) and result.taskInstance. 32 */ 8 33 def create(params) { 9 34 Task.withTransaction { status -> … … 13 38 def taskInstance = new Task(params) 14 39 result.taskInstance = taskInstance 40 41 if(result.taskInstance.parentTask?.trash) { 42 status.setRollbackOnly() 43 result.taskInstance.errors.rejectValue("parentTask", "task.operationNotPermittedOnTaskInTrash") 44 result.error = true 45 return result 46 } 15 47 16 48 if(taskInstance.save()) { … … 26 58 } 27 59 60 // If we get here all went well. 28 61 return result 29 62 } … … 36 69 } // end create() 37 70 71 /* 72 * Creates a subTask copying attributes from the parentTask unless otherwise specified. 73 * @param parentTask The parent task to get attributes from, also set as the parent. 74 * @param params Overrides the parent task values if specified. 75 * @returns A map containing result.error=true (if any error) and result.taskInstance. 76 */ 77 def createSubTask(parentTask, params = [:]) { 78 79 def result = [:] 80 81 //Make our new Task a subTask and set the required properites. 82 def p = [:] 83 p.parentTask = parentTask 84 p.description = params.description ?: parentTask.description 85 p.comment = params.comment ?: parentTask.comment 86 87 p.taskGroup = params.taskGroup ?: parentTask.taskGroup 88 p.taskStatus = TaskStatus.get(1) // A new subTask must always be "Not Started". 89 p.taskPriority = parentTask.taskPriority 90 p.taskType = params.taskType ?: parentTask.taskType 91 p.leadPerson = params.leadPerson ?: parentTask.leadPerson 92 p.primaryAsset = params.primaryAsset ?: parentTask.primaryAsset 93 94 p.targetStartDate = params.targetStartDate ?: parentTask.targetStartDate 95 p.targetCompletionDate = params.targetCompletionDate ?: parentTask.targetCompletionDate 96 97 //Set the assignedPersons 98 // taskInstance.assignedPersons.each() { 99 // 100 // def assignedPerson = new AssignedPerson(person: it.person, 101 // task: subTaskInstance, 102 // estimatedHour: it.estimatedHour, 103 // estimatedMinute: it.estimatedMinute).save() 104 // } 105 106 result = create(p) 107 108 } // end createSubTask() 109 110 /* 111 * Creates a new task entry. 112 * @params The params to use when creating the new entry. 113 * @returns A map containing result.error=true (if any error), result.entryInstance and result.taskId. 114 */ 38 115 def createEntry(params) { 39 116 Task.withTransaction { status ->
Note: See TracChangeset
for help on using the changeset viewer.