Changeset 202 for trunk


Ignore:
Timestamp:
Nov 30, 2009, 1:26:18 AM (15 years ago)
Author:
gav
Message:

Some commenting and tweak to disable recurring schedule when completing or moving a task to trash.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/services/TaskService.groovy

    r201 r202  
    1 /*
    2 * Provides a service for the Task domain class.
     1/**
     2* Provides a service class for the Task domain class.
    33*
    44*/
     
    1010    def personService
    1111
    12     /*
     12    /**
    1313    * Determines and returns a possible parent list
    14     * @taskInstance The task to use when determining the possible parent list.
     14    * @param taskInstance The task to use when determining the possible parent list.
    1515    * @returns A list of the possible parents.
    1616    */
     
    2626    }
    2727
    28     /*
     28    /**
    2929    * Creates a new task with the given params.
    30     * @params The params to use when creating the new task.
     30    * @param params The params to use when creating the new task.
    3131    * @returns A map containing result.error=true (if any error) and result.taskInstance.
    3232    */
     
    6969    } // end create()
    7070
    71     /*
     71    /**
    7272    * Creates a subTask copying attributes from the parentTask unless otherwise specified.
     73    * The taskProcedure is only assigned to the sub task if given in params.
    7374    * @param parentTask The parent task to get attributes from, also set as the parent.
    7475    * @param params Overrides the parent task values if specified.
     
    9495        p.targetStartDate = params.targetStartDate ?: parentTask.targetStartDate
    9596        p.targetCompletionDate = params.targetCompletionDate ?: parentTask.targetCompletionDate
     97
     98        if(params.taskProcedure) p.taskProcedure = params.taskProcedure
    9699
    97100                    //Set the assignedPersons
     
    108111    } // end createSubTask()
    109112
    110     /*
     113    /**
    111114    * Creates a new task entry.
    112     * @params The params to use when creating the new entry.
     115    * @param params The params to use when creating the new entry.
    113116    * @returns A map containing result.error=true (if any error), result.entryInstance and result.taskId.
    114117    */
     
    180183    } // end create()
    181184
     185    /**
     186    * Updates an existing task.
     187    * @param params The params to update for task with id of params.id.
     188    * @returns A map containing result.error=true (if any error) and result.taskInstance.
     189    */
    182190    def update(params) {
    183191        Task.withTransaction { status ->
     
    223231    }  // end update()
    224232
     233    /**
     234    * Completes an existing task.
     235    * @param params The params for task with id of params.id.
     236    * @returns A map containing result.error=true (if any error) and result.taskInstance.
     237    */
    225238    def complete(params) {
    226239        Task.withTransaction { status ->
     
    241254
    242255                result.taskInstance.taskStatus = TaskStatus.get(3)
    243 
    244                 if(result.taskInstance.save()) {
    245 
    246                     result.taskInstance.taskRecurringSchedule?.enabled = false
    247 
     256                result.taskInstance.taskRecurringSchedule?.enabled = false
     257
     258                if(result.taskInstance.save()) {
    248259                    def taskModification = new TaskModification(person:personService.currentUser(),
    249260                                                            taskModificationType: TaskModificationType.get(4),
     
    270281    }  // end complete()
    271282
     283    /**
     284    * Reopens an existing task.
     285    * @param params The params for task with id of params.id.
     286    * @returns A map containing result.error=true (if any error) and result.taskInstance.
     287    */
    272288    def reopen(params) {
    273289        Task.withTransaction { status ->
     
    313329    }  // end reopen()
    314330
     331    /**
     332    * Move a task to the trash.
     333    * @param params The params for task with id of params.id.
     334    * @returns A map containing result.error=true (if any error) and result.taskInstance.
     335    */
    315336    def trash(params) {
    316337        Task.withTransaction { status ->
     
    331352
    332353                result.taskInstance.trash = true
    333 
    334                 if(result.taskInstance.save()) {
    335 
    336                     result.taskInstance.taskRecurringSchedule?.enabled = false
    337 
     354                result.taskInstance.taskRecurringSchedule?.enabled = false
     355
     356                if(result.taskInstance.save()) {
    338357                    def taskModification = new TaskModification(person:personService.currentUser(),
    339358                                                            taskModificationType: TaskModificationType.get(6),
     
    359378    }  // end trash()
    360379
     380    /**
     381    * Restore a task from the trash.
     382    * @param params The params for task with id of params.id.
     383    * @returns A map containing result.error=true (if any error) and result.taskInstance.
     384    */
    361385    def restore(params) {
    362386        Task.withTransaction { status ->
     
    402426    }  // end restore()
    403427
     428    /**
     429    * Approve a task.
     430    * @param params The params for task with id of params.id.
     431    * @returns A map containing result.error=true (if any error) and result.taskInstance.
     432    */
    404433    def approve(params) {
    405434        Task.withTransaction { status ->
     
    445474    }  // end approve()
    446475
     476    /**
     477    * Remove a previously given approval from a task.
     478    * @param params The params for task with id of params.id.
     479    * @returns A map containing result.error=true (if any error) and result.taskInstance.
     480    */
    447481    def renegeApproval(params) {
    448482        Task.withTransaction { status ->
Note: See TracChangeset for help on using the changeset viewer.