Changeset 243


Ignore:
Timestamp:
Dec 24, 2009, 10:22:35 AM (14 years ago)
Author:
gav
Message:

Implement copying of assigned groups and persons to auto generated sub tasks.
As per ticket #55.

Location:
trunk/grails-app
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/i18n/messages.properties

    r242 r243  
    4747task.failedToSave=Could not complete operation, task failed to save.
    4848task.modifications.failedToSave=Could not complete operation, as task modification record failed to save.
     49task.assignedGroups.failedToSave=Could not complete operation, as assignedGroup record failed to save.
     50task.assignedPersons.failedToSave=Could not complete operation, as assignedPerson record failed to save.
    4951tast.taskRecurringSchedule.alreadyExists=This task already has a recurring schedule.
    5052
  • trunk/grails-app/services/TaskRecurringScheduleService.groovy

    r219 r243  
    1717            if ( dateUtilService.tomorrow > it.nextGenerationDate) {
    1818                    def p = [:]
     19
     20                    // Build the required params.
    1921                    p.targetStartDate = it.nextTargetStartDate
    2022                    p.targetCompletionDate = it.nextTargetCompletionDate
    2123                    if(it.task.taskProcedure) p.taskProcedure = it.task.taskProcedure
     24                    if(it.task.assignedGroups) p.assignedGroups = new ArrayList(it.task.assignedGroups)
     25                    if(it.task.assignedPersons) p.assignedPersons = new ArrayList(it.task.assignedPersons)
     26
    2227                    def result = taskService.createSubTask(it.task, p)
    2328                    if( !result.error ) {
  • trunk/grails-app/services/TaskService.groovy

    r241 r243  
    5757                }
    5858
    59                 // If we get here all went well.
     59                //Add the assignedGroups, provided by a new ArrayList(task.assignedGroups)
     60                if(params.assignedGroups) {
     61                    def assignedGroupInstance
     62                    params.assignedGroups.each() {
     63                        assignedGroupInstance = new AssignedGroup(personGroup: it.personGroup,
     64                                                                                                        task: taskInstance,
     65                                                                                                        estimatedHour: it.estimatedHour,
     66                                                                                                        estimatedMinute: it.estimatedMinute)
     67
     68                        if(!assignedGroupInstance.save()) {
     69                            status.setRollbackOnly()
     70                            taskInstance.errors.rejectValue("assignedGroups", "task.assignedGroups.failedToSave")
     71                            result.error = true
     72                            return result
     73                        }
     74                    }
     75                }
     76
     77                //Add the assignedPersons, provided by a new ArrayList(task.assignedPersons)
     78                if(params.assignedPersons) {
     79                    def assignedPersonInstance
     80                    params.assignedPersons.each() {
     81                        assignedPersonInstance = new AssignedPerson(person: it.person,
     82                                                                                                            task: taskInstance,
     83                                                                                                            estimatedHour: it.estimatedHour,
     84                                                                                                            estimatedMinute: it.estimatedMinute)
     85
     86                        if(!assignedPersonInstance.save()) {
     87                            status.setRollbackOnly()
     88                            taskInstance.errors.rejectValue("assignedPersons", "task.assignedPersons.failedToSave")
     89                            result.error = true
     90                            return result
     91                        }
     92                    }
     93                }
     94
     95                // Success.
    6096                return result
    6197            }
     
    71107    * Creates a subTask copying attributes from the parentTask unless otherwise specified.
    72108    * The taskProcedure is only assigned to the sub task if given in params.
     109    * The assignedPersons and assignedGroups are only added to the sub task if given as new ArrayList's in params.
    73110    * @param parentTask The parent task to get attributes from, also set as the parent.
    74111    * @param params Overrides the parent task values if specified.
     
    96133
    97134        if(params.taskProcedure) p.taskProcedure = params.taskProcedure
    98 
    99                     //Set the assignedPersons
    100 //                     taskInstance.assignedPersons.each() {
    101 //
    102 //                     def assignedPerson = new AssignedPerson(person: it.person,
    103 //                                                                                             task: subTaskInstance,
    104 //                                                                                             estimatedHour: it.estimatedHour,
    105 //                                                                                             estimatedMinute: it.estimatedMinute).save()
    106 //                     }
     135        if(params.assignedGroups) p.assignedGroups = params.assignedGroups
     136        if(params.assignedPersons) p.assignedPersons = params.assignedPersons
    107137
    108138        result = create(p)
Note: See TracChangeset for help on using the changeset viewer.