Ignore:
Timestamp:
Dec 22, 2009, 5:38:37 PM (15 years ago)
Author:
gav
Message:

Convert assignedPersons to assignedGroups as per ticket #37.

Location:
trunk/grails-app/controllers
Files:
1 added
1 deleted
1 moved

Legend:

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

    r233 r240  
    11import org.codehaus.groovy.grails.plugins.springsecurity.Secured
    22
    3 class AssignedPersonDetailedController extends BaseController {
     3class AssignedGroupDetailedController extends BaseController {
    44
    55    def index = { redirect(action:list,params:params) }
     
    1010    def list = {
    1111        params.max = Math.min( params.max ? params.max.toInteger() : 10,  100)
    12         [ assignedPersonInstanceList: AssignedPerson.list( params ), assignedPersonInstanceTotal: AssignedPerson.count() ]
     12        [ assignedGroupInstanceList: AssignedGroup.list( params ), assignedGroupInstanceTotal: AssignedGroup.count() ]
    1313    }
    1414
    1515    def show = {
    16         def assignedPersonInstance = AssignedPerson.get( params.id )
     16        def assignedGroupInstance = AssignedGroup.get( params.id )
    1717
    18         if(!assignedPersonInstance) {
    19             flash.message = "AssignedPerson not found with id ${params.id}"
     18        if(!assignedGroupInstance) {
     19            flash.message = "AssignedGroup not found with id ${params.id}"
    2020            redirect(action:list)
    2121        }
    22         else { return [ assignedPersonInstance : assignedPersonInstance ] }
     22        else { return [ assignedGroupInstance : assignedGroupInstance ] }
    2323    }
    2424
    2525    def delete = {
    26         def assignedPersonInstance = AssignedPerson.get( params.id )
    27         if(assignedPersonInstance) {
     26        def assignedGroupInstance = AssignedGroup.get( params.id )
     27        if(assignedGroupInstance) {
    2828            try {
    29                 def taskId = assignedPersonInstance.task.id
    30                 assignedPersonInstance.delete()
    31                 flash.message = "AssignedPerson ${params.id} deleted"
     29                def taskId = assignedGroupInstance.task.id
     30                assignedGroupInstance.delete()
     31                flash.message = "AssignedGroup ${params.id} deleted"
    3232                redirect(controller:"taskDetailed", action:"show", id: taskId)
    3333            }
    3434            catch(org.springframework.dao.DataIntegrityViolationException e) {
    35                 flash.message = "AssignedPerson ${params.id} could not be deleted"
     35                flash.message = "AssignedGroup ${params.id} could not be deleted"
    3636                redirect(action:show,id:params.id)
    3737            }
    3838        }
    3939        else {
    40             flash.message = "AssignedPerson not found with id ${params.id}"
     40            flash.message = "AssignedGroup not found with id ${params.id}"
    4141            redirect(action:list)
    4242        }
     
    4444
    4545    def edit = {
    46         def assignedPersonInstance = AssignedPerson.get( params.id )
     46        def assignedGroupInstance = AssignedGroup.get( params.id )
    4747
    48         if(!assignedPersonInstance) {
    49             flash.message = "AssignedPerson not found with id ${params.id}"
     48        if(!assignedGroupInstance) {
     49            flash.message = "AssignedGroup not found with id ${params.id}"
    5050            redirect(action:list)
    5151        }
    5252        else {
    53             return [ assignedPersonInstance : assignedPersonInstance ]
     53            return [ assignedGroupInstance : assignedGroupInstance ]
    5454        }
    5555    }
    5656
    5757    def update = {
    58         def assignedPersonInstance = AssignedPerson.get( params.id )
    59         if(assignedPersonInstance) {
     58        def assignedGroupInstance = AssignedGroup.get( params.id )
     59        if(assignedGroupInstance) {
    6060            if(params.version) {
    6161                def version = params.version.toLong()
    62                 if(assignedPersonInstance.version > version) {
     62                if(assignedGroupInstance.version > version) {
    6363
    64                     assignedPersonInstance.errors.rejectValue("version", "assignedPerson.optimistic.locking.failure", "Another user has updated this AssignedPerson while you were editing.")
    65                     render(view:'edit',model:[assignedPersonInstance:assignedPersonInstance])
     64                    assignedGroupInstance.errors.rejectValue("version", "assignedGroup.optimistic.locking.failure", "Another user has updated this AssignedGroup while you were editing.")
     65                    render(view:'edit',model:[assignedGroupInstance:assignedGroupInstance])
    6666                    return
    6767                }
    6868            }
    69             assignedPersonInstance.properties = params
    70             if(!assignedPersonInstance.hasErrors() && assignedPersonInstance.save(flush: true)) {
    71                 flash.message = "AssignedPerson ${params.id} updated"
    72                 redirect(action:show,id:assignedPersonInstance.id)
     69            assignedGroupInstance.properties = params
     70            if(!assignedGroupInstance.hasErrors() && assignedGroupInstance.save(flush: true)) {
     71                flash.message = "AssignedGroup ${params.id} updated"
     72                redirect(action:show,id:assignedGroupInstance.id)
    7373            }
    7474            else {
    75                 render(view:'edit',model:[assignedPersonInstance:assignedPersonInstance])
     75                render(view:'edit',model:[assignedGroupInstance:assignedGroupInstance])
    7676            }
    7777        }
    7878        else {
    79             flash.message = "AssignedPerson not found with id ${params.id}"
     79            flash.message = "AssignedGroup not found with id ${params.id}"
    8080            redirect(action:edit,id:params.id)
    8181        }
     
    8484    def create = {
    8585        if(!params.task?.id) {
    86             flash.message = "Please select a task and then 'Add Assigned Person'"
    87             redirect(controller: "taskDetailed", action: search)
     86            flash.message = "Please select a task and then 'Add Assigned Group'"
     87            redirect(controller: "taskDetailed", action: "search")
    8888        }
    8989        else {
    90             def assignedPersonInstance = new AssignedPerson()
    91             assignedPersonInstance.properties = params
    92             return ['assignedPersonInstance':assignedPersonInstance]
     90            def assignedGroupInstance = new AssignedGroup()
     91            assignedGroupInstance.properties = params
     92            return ['assignedGroupInstance':assignedGroupInstance]
    9393        }
    9494    }
    9595
    9696    def save = {
    97         def assignedPersonInstance = new AssignedPerson(params)
     97        def assignedGroupInstance = new AssignedGroup(params)
    9898
    99         if(!assignedPersonInstance.hasErrors() && assignedPersonInstance.save(flush: true)) {
    100             flash.message = "AssignedPerson ${assignedPersonInstance.id} created"
     99        if(!assignedGroupInstance.hasErrors() && assignedGroupInstance.save(flush: true)) {
     100            flash.message = "AssignedGroup ${assignedGroupInstance.id} created"
    101101            redirect(controller:"taskDetailed", action:"show", id: params.task.id)
    102102        }
    103103        else {
    104             render(view:'create',model:[assignedPersonInstance:assignedPersonInstance])
     104            render(view:'create',model:[assignedGroupInstance:assignedGroupInstance])
    105105        }
    106106    }
Note: See TracChangeset for help on using the changeset viewer.