Index: /trunk/grails-app/services/TaskService.groovy
===================================================================
--- /trunk/grails-app/services/TaskService.groovy	(revision 201)
+++ /trunk/grails-app/services/TaskService.groovy	(revision 202)
@@ -1,4 +1,4 @@
-/*
-* Provides a service for the Task domain class.
+/**
+* Provides a service class for the Task domain class.
 *
 */
@@ -10,7 +10,7 @@
     def personService
 
-    /*
+    /**
     * Determines and returns a possible parent list
-    * @taskInstance The task to use when determining the possible parent list.
+    * @param taskInstance The task to use when determining the possible parent list.
     * @returns A list of the possible parents.
     */
@@ -26,7 +26,7 @@
     }
 
-    /*
+    /**
     * Creates a new task with the given params.
-    * @params The params to use when creating the new task.
+    * @param params The params to use when creating the new task.
     * @returns A map containing result.error=true (if any error) and result.taskInstance.
     */
@@ -69,6 +69,7 @@
     } // end create()
 
-    /*
+    /**
     * Creates a subTask copying attributes from the parentTask unless otherwise specified.
+    * The taskProcedure is only assigned to the sub task if given in params.
     * @param parentTask The parent task to get attributes from, also set as the parent.
     * @param params Overrides the parent task values if specified.
@@ -94,4 +95,6 @@
         p.targetStartDate = params.targetStartDate ?: parentTask.targetStartDate
         p.targetCompletionDate = params.targetCompletionDate ?: parentTask.targetCompletionDate
+
+        if(params.taskProcedure) p.taskProcedure = params.taskProcedure
 
                     //Set the assignedPersons
@@ -108,7 +111,7 @@
     } // end createSubTask()
 
-    /*
+    /**
     * Creates a new task entry.
-    * @params The params to use when creating the new entry.
+    * @param params The params to use when creating the new entry.
     * @returns A map containing result.error=true (if any error), result.entryInstance and result.taskId.
     */
@@ -180,4 +183,9 @@
     } // end create()
 
+    /**
+    * Updates an existing task.
+    * @param params The params to update for task with id of params.id.
+    * @returns A map containing result.error=true (if any error) and result.taskInstance.
+    */
     def update(params) {
         Task.withTransaction { status ->
@@ -223,4 +231,9 @@
     }  // end update()
 
+    /**
+    * Completes an existing task.
+    * @param params The params for task with id of params.id.
+    * @returns A map containing result.error=true (if any error) and result.taskInstance.
+    */
     def complete(params) {
         Task.withTransaction { status ->
@@ -241,9 +254,7 @@
 
                 result.taskInstance.taskStatus = TaskStatus.get(3)
-
-                if(result.taskInstance.save()) {
-
-                    result.taskInstance.taskRecurringSchedule?.enabled = false
-
+                result.taskInstance.taskRecurringSchedule?.enabled = false
+
+                if(result.taskInstance.save()) {
                     def taskModification = new TaskModification(person:personService.currentUser(),
                                                             taskModificationType: TaskModificationType.get(4),
@@ -270,4 +281,9 @@
     }  // end complete()
 
+    /**
+    * Reopens an existing task.
+    * @param params The params for task with id of params.id.
+    * @returns A map containing result.error=true (if any error) and result.taskInstance.
+    */
     def reopen(params) {
         Task.withTransaction { status ->
@@ -313,4 +329,9 @@
     }  // end reopen()
 
+    /**
+    * Move a task to the trash.
+    * @param params The params for task with id of params.id.
+    * @returns A map containing result.error=true (if any error) and result.taskInstance.
+    */
     def trash(params) {
         Task.withTransaction { status ->
@@ -331,9 +352,7 @@
 
                 result.taskInstance.trash = true
-
-                if(result.taskInstance.save()) {
-
-                    result.taskInstance.taskRecurringSchedule?.enabled = false
-
+                result.taskInstance.taskRecurringSchedule?.enabled = false
+
+                if(result.taskInstance.save()) {
                     def taskModification = new TaskModification(person:personService.currentUser(),
                                                             taskModificationType: TaskModificationType.get(6),
@@ -359,4 +378,9 @@
     }  // end trash()
 
+    /**
+    * Restore a task from the trash.
+    * @param params The params for task with id of params.id.
+    * @returns A map containing result.error=true (if any error) and result.taskInstance.
+    */
     def restore(params) {
         Task.withTransaction { status ->
@@ -402,4 +426,9 @@
     }  // end restore()
 
+    /**
+    * Approve a task.
+    * @param params The params for task with id of params.id.
+    * @returns A map containing result.error=true (if any error) and result.taskInstance.
+    */
     def approve(params) {
         Task.withTransaction { status ->
@@ -445,4 +474,9 @@
     }  // end approve()
 
+    /**
+    * Remove a previously given approval from a task.
+    * @param params The params for task with id of params.id.
+    * @returns A map containing result.error=true (if any error) and result.taskInstance.
+    */
     def renegeApproval(params) {
         Task.withTransaction { status ->
