Ignore:
Timestamp:
Feb 16, 2011, 8:10:39 PM (14 years ago)
Author:
gav
Message:

Domain change, first draft of TaskProcedureRevisions.

Location:
trunk/grails-app/controllers
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/controllers/TaskDetailedController.groovy

    r747 r809  
    434434            def assignedPersonList = taskInstance.assignedPersons.sort { p1, p2 -> p1.person.firstName.compareToIgnoreCase(p2.person.firstName) }
    435435
    436             def taskProcedureInstance = TaskProcedure.get(taskInstance.taskProcedure?.id)
     436            def taskProcedureRevision = TaskProcedureRevision.get(taskInstance.taskProcedureRevision?.id)
    437437            def taskProcedureExits = new Boolean("true")
    438             if(!taskProcedureInstance) {
     438            if(!taskProcedureRevision) {
    439439                taskProcedureExits = false
    440440            }
    441 
    442             def maParams = [:]
    443             maParams.max = 100
    444             maParams.order = "asc"
    445             maParams.sort = "procedureStepNumber"
    446             def maintenanceActionList = MaintenanceAction.findAllByTaskProcedure(taskProcedureInstance, maParams)
    447441
    448442            def taskRecurringScheduleInstance = TaskRecurringSchedule.get(taskInstance.taskRecurringSchedule?.id)
     
    456450                            entryCauseList: entryCauseList,
    457451                            entryWorkDoneList: entryWorkDoneList,
    458                             taskProcedureInstance: taskProcedureInstance,
     452                            taskProcedureRevision: taskProcedureRevision,
    459453                            taskProcedureExits: taskProcedureExits,
    460454                            showTab: showTab,
     
    462456                            subTaskInstanceTotal: subTaskInstanceTotal,
    463457                            subTaskInstanceMax: params.max,
    464                             maintenanceActionList: maintenanceActionList,
    465458                            taskRecurringScheduleInstance: taskRecurringScheduleInstance,
    466459                            taskRecurringScheduleExits: taskRecurringScheduleExits,
  • trunk/grails-app/controllers/TaskProcedureDetailedController.groovy

    r798 r809  
    4343        if(!taskProcedureInstance) {
    4444            flash.errorMessage = "TaskProcedure not found with id ${params.id}"
    45             redirect(controller:'taskDetailed', action:'search')
     45            redirect(action:'list')
    4646            return
    4747        }
    4848
    49         redirect(controller:'taskDetailed',
    50                         action:'show',
    51                         id:taskProcedureInstance.linkedTask?.id,
    52                         params:[showTab:"showProcedureTab"])
    53     }
     49        def taskProcedureRevision
     50        if(params.revision?.toInteger())
     51             taskProcedureRevision = taskProcedureInstance.getRevision( params.revision )
     52        else
     53             taskProcedureRevision = taskProcedureInstance.latestRevision
    5454
    55     def delete = {
    56         def taskProcedureInstance = TaskProcedure.get( params.id )
    57         if(taskProcedureInstance) {
    58             def taskInstance = taskProcedureInstance.linkedTask
    59             try {
    60                 taskProcedureInstance.tasks.each {
    61                     it.taskProcedure = null
    62                 }
    63                 taskProcedureInstance.delete(flush:true)
    64                 flash.message = "TaskProcedure ${params.id} deleted"
    65                 redirect(controller:'taskDetailed',
    66                                 action:'show',
    67                                 id:taskInstance.id,
    68                                 params:[showTab:"showProcedureTab"])
    69             }
    70             catch(org.springframework.dao.DataIntegrityViolationException e) {
    71                 flash.errorMessage = "TaskProcedure ${params.id} could not be deleted"
    72                 redirect(controller:'taskDetailed',
    73                                 action:'show',
    74                                 id:taskInstance.id,
    75                                 params:[showTab:"showProcedureTab"])
    76             }
     55        if(!taskProcedureRevision) {
     56            flash.errorMessage = "TaskProcedure ${params.id} revision ${params.revision} not found"
     57            redirect(action:'list')
     58            return
    7759        }
    78         else {
    79             flash.errorMessage = "TaskProcedure not found with id ${params.id}"
    80             redirect(action:list)
    81         }
     60
     61        return [taskProcedureRevision: taskProcedureRevision]
     62
    8263    }
    8364
     
    8566
    8667        // In the case of an actionSubmit button, rewrite action name from 'index'.
    87         if(params._action_Edit)
     68        //if(params._action_Edit)
    8869            params.action='edit'
    8970
     
    10687        if(!result.error) {
    10788            flash.message = g.message(code: "default.update.success", args: ["TaskProcedure", params.id])
    108             redirect(controller:'taskDetailed',
    109                             action:'show',
    110                             id:result.taskProcedureInstance.linkedTask.id,
    111                             params:[showTab:"showProcedureTab"])
     89            redirect(action:'show', id:result.taskProcedureInstance.id)
    11290            return
    11391        }
     
    12199        if(result.error.code == "default.optimistic.locking.failure") {
    122100            flash.errorMessage = g.message(code: result.error.code, args: result.error.args)
    123             redirect(controller:'taskDetailed',
    124                             action:'show',
    125                             id:result.taskProcedureInstance.linkedTask.id,
    126                             params:[showTab:"showProcedureTab"])
     101            redirect(action:'show', id:result.taskProcedureInstance.id)
    127102            return
    128103        }
     
    144119
    145120        // Task already has a taskProcedure.
    146         if(params.linkedTask.taskProcedure) {
     121        if(params.linkedTask.taskProcedureRevision) {
    147122            flash.errorMessage = g.message(code: 'default.optimistic.locking.failure')
    148123            redirect(controller:'taskDetailed',
     
    183158        if(!result.error) {
    184159            flash.message = g.message(code: "default.create.success", args: ["TaskProcedure", result.taskProcedureInstance.id])
    185             redirect(controller:'taskDetailed',
    186                             action:'show',
    187                             id:result.taskProcedureInstance.linkedTask.id,
    188                             params:[showTab:"showProcedureTab"])
     160            redirect(action:'show', id:result.taskProcedureInstance.id)
    189161            return
    190162        }
    191163
     164        // Task already has a taskProcedure.
    192165        if(result.error.code == "default.optimistic.locking.failure") {
    193166            flash.errorMessage = g.message(code: result.error.code, args: result.error.args)
    194167            redirect(controller:'taskDetailed',
    195168                            action:'show',
    196                             id:result.taskProcedureInstance.linkedTask.id,
     169                            id:params.linkedTask.id,
    197170                            params:[showTab:"showProcedureTab"])
    198171            return
Note: See TracChangeset for help on using the changeset viewer.