Ignore:
Timestamp:
Jan 14, 2010, 10:51:03 PM (15 years ago)
Author:
gav
Message:

Refactor classes for asset tree refinement.
Regenerate views and controllers to suite.

File:
1 edited

Legend:

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

    r267 r268  
    11import org.codehaus.groovy.grails.plugins.springsecurity.Secured
    22
    3 class AssetTypeController extends BaseAppAdminController {
     3class AssetSubItemController extends BaseAppAdminController {
    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         [ assetTypeInstanceList: AssetType.list( params ), assetTypeInstanceTotal: AssetType.count() ]
     12        [ assetSubItemInstanceList: AssetSubItem.list( params ), assetSubItemInstanceTotal: AssetSubItem.count() ]
    1313    }
    1414
    1515    def show = {
    16         def assetTypeInstance = AssetType.get( params.id )
     16        def assetSubItemInstance = AssetSubItem.get( params.id )
    1717
    18         if(!assetTypeInstance) {
    19             flash.message = "AssetType not found with id ${params.id}"
     18        if(!assetSubItemInstance) {
     19            flash.message = "AssetSubItem not found with id ${params.id}"
    2020            redirect(action:list)
    2121        }
    22         else { return [ assetTypeInstance : assetTypeInstance ] }
     22        else { return [ assetSubItemInstance : assetSubItemInstance ] }
    2323    }
    2424
    2525    def delete = {
    26         def assetTypeInstance = AssetType.get( params.id )
    27         if(assetTypeInstance) {
     26        def assetSubItemInstance = AssetSubItem.get( params.id )
     27        if(assetSubItemInstance) {
    2828            try {
    29                 assetTypeInstance.delete(flush:true)
    30                 flash.message = "AssetType ${params.id} deleted"
     29                assetSubItemInstance.delete(flush:true)
     30                flash.message = "AssetSubItem ${params.id} deleted"
    3131                redirect(action:list)
    3232            }
    3333            catch(org.springframework.dao.DataIntegrityViolationException e) {
    34                 flash.message = "AssetType ${params.id} could not be deleted"
     34                flash.message = "AssetSubItem ${params.id} could not be deleted"
    3535                redirect(action:show,id:params.id)
    3636            }
    3737        }
    3838        else {
    39             flash.message = "AssetType not found with id ${params.id}"
     39            flash.message = "AssetSubItem not found with id ${params.id}"
    4040            redirect(action:list)
    4141        }
     
    4343
    4444    def edit = {
    45         def assetTypeInstance = AssetType.get( params.id )
     45        def assetSubItemInstance = AssetSubItem.get( params.id )
    4646
    47         if(!assetTypeInstance) {
    48             flash.message = "AssetType not found with id ${params.id}"
     47        if(!assetSubItemInstance) {
     48            flash.message = "AssetSubItem not found with id ${params.id}"
    4949            redirect(action:list)
    5050        }
    5151        else {
    52             return [ assetTypeInstance : assetTypeInstance ]
     52            return [ assetSubItemInstance : assetSubItemInstance ]
    5353        }
    5454    }
    5555
    5656    def update = {
    57         def assetTypeInstance = AssetType.get( params.id )
    58         if(assetTypeInstance) {
     57        def assetSubItemInstance = AssetSubItem.get( params.id )
     58        if(assetSubItemInstance) {
    5959            if(params.version) {
    6060                def version = params.version.toLong()
    61                 if(assetTypeInstance.version > version) {
     61                if(assetSubItemInstance.version > version) {
    6262                   
    63                     assetTypeInstance.errors.rejectValue("version", "assetType.optimistic.locking.failure", "Another user has updated this AssetType while you were editing.")
    64                     render(view:'edit',model:[assetTypeInstance:assetTypeInstance])
     63                    assetSubItemInstance.errors.rejectValue("version", "assetSubItem.optimistic.locking.failure", "Another user has updated this AssetSubItem while you were editing.")
     64                    render(view:'edit',model:[assetSubItemInstance:assetSubItemInstance])
    6565                    return
    6666                }
    6767            }
    68             assetTypeInstance.properties = params
    69             if(!assetTypeInstance.hasErrors() && assetTypeInstance.save(flush: true)) {
    70                 flash.message = "AssetType ${params.id} updated"
    71                 redirect(action:show,id:assetTypeInstance.id)
     68            assetSubItemInstance.properties = params
     69            if(!assetSubItemInstance.hasErrors() && assetSubItemInstance.save(flush: true)) {
     70                flash.message = "AssetSubItem ${params.id} updated"
     71                redirect(action:show,id:assetSubItemInstance.id)
    7272            }
    7373            else {
    74                 render(view:'edit',model:[assetTypeInstance:assetTypeInstance])
     74                render(view:'edit',model:[assetSubItemInstance:assetSubItemInstance])
    7575            }
    7676        }
    7777        else {
    78             flash.message = "AssetType not found with id ${params.id}"
     78            flash.message = "AssetSubItem not found with id ${params.id}"
    7979            redirect(action:list)
    8080        }
     
    8282
    8383    def create = {
    84         def assetTypeInstance = new AssetType()
    85         assetTypeInstance.properties = params
    86         return ['assetTypeInstance':assetTypeInstance]
     84        def assetSubItemInstance = new AssetSubItem()
     85        assetSubItemInstance.properties = params
     86        return ['assetSubItemInstance':assetSubItemInstance]
    8787    }
    8888
    8989    def save = {
    90         def assetTypeInstance = new AssetType(params)
    91         if(!assetTypeInstance.hasErrors() && assetTypeInstance.save(flush: true)) {
    92             flash.message = "AssetType ${assetTypeInstance.id} created"
    93             redirect(action:show,id:assetTypeInstance.id)
     90        def assetSubItemInstance = new AssetSubItem(params)
     91        if(!assetSubItemInstance.hasErrors() && assetSubItemInstance.save(flush: true)) {
     92            flash.message = "AssetSubItem ${assetSubItemInstance.id} created"
     93            redirect(action:show,id:assetSubItemInstance.id)
    9494        }
    9595        else {
    96             render(view:'create',model:[assetTypeInstance:assetTypeInstance])
     96            render(view:'create',model:[assetSubItemInstance:assetSubItemInstance])
    9797        }
    9898    }
Note: See TracChangeset for help on using the changeset viewer.