- Timestamp:
- Jan 14, 2010, 10:51:03 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/AssetSubItemController.groovy
r267 r268 1 1 import org.codehaus.groovy.grails.plugins.springsecurity.Secured 2 2 3 class Asset TypeController extends BaseAppAdminController {3 class AssetSubItemController extends BaseAppAdminController { 4 4 5 5 def index = { redirect(action:list,params:params) } … … 10 10 def list = { 11 11 params.max = Math.min( params.max ? params.max.toInteger() : 10, 100) 12 [ asset TypeInstanceList: AssetType.list( params ), assetTypeInstanceTotal: AssetType.count() ]12 [ assetSubItemInstanceList: AssetSubItem.list( params ), assetSubItemInstanceTotal: AssetSubItem.count() ] 13 13 } 14 14 15 15 def show = { 16 def asset TypeInstance = AssetType.get( params.id )16 def assetSubItemInstance = AssetSubItem.get( params.id ) 17 17 18 if(!asset TypeInstance) {19 flash.message = "Asset Typenot found with id ${params.id}"18 if(!assetSubItemInstance) { 19 flash.message = "AssetSubItem not found with id ${params.id}" 20 20 redirect(action:list) 21 21 } 22 else { return [ asset TypeInstance : assetTypeInstance ] }22 else { return [ assetSubItemInstance : assetSubItemInstance ] } 23 23 } 24 24 25 25 def delete = { 26 def asset TypeInstance = AssetType.get( params.id )27 if(asset TypeInstance) {26 def assetSubItemInstance = AssetSubItem.get( params.id ) 27 if(assetSubItemInstance) { 28 28 try { 29 asset TypeInstance.delete(flush:true)30 flash.message = "Asset Type${params.id} deleted"29 assetSubItemInstance.delete(flush:true) 30 flash.message = "AssetSubItem ${params.id} deleted" 31 31 redirect(action:list) 32 32 } 33 33 catch(org.springframework.dao.DataIntegrityViolationException e) { 34 flash.message = "Asset Type${params.id} could not be deleted"34 flash.message = "AssetSubItem ${params.id} could not be deleted" 35 35 redirect(action:show,id:params.id) 36 36 } 37 37 } 38 38 else { 39 flash.message = "Asset Typenot found with id ${params.id}"39 flash.message = "AssetSubItem not found with id ${params.id}" 40 40 redirect(action:list) 41 41 } … … 43 43 44 44 def edit = { 45 def asset TypeInstance = AssetType.get( params.id )45 def assetSubItemInstance = AssetSubItem.get( params.id ) 46 46 47 if(!asset TypeInstance) {48 flash.message = "Asset Typenot found with id ${params.id}"47 if(!assetSubItemInstance) { 48 flash.message = "AssetSubItem not found with id ${params.id}" 49 49 redirect(action:list) 50 50 } 51 51 else { 52 return [ asset TypeInstance : assetTypeInstance ]52 return [ assetSubItemInstance : assetSubItemInstance ] 53 53 } 54 54 } 55 55 56 56 def update = { 57 def asset TypeInstance = AssetType.get( params.id )58 if(asset TypeInstance) {57 def assetSubItemInstance = AssetSubItem.get( params.id ) 58 if(assetSubItemInstance) { 59 59 if(params.version) { 60 60 def version = params.version.toLong() 61 if(asset TypeInstance.version > version) {61 if(assetSubItemInstance.version > version) { 62 62 63 asset TypeInstance.errors.rejectValue("version", "assetType.optimistic.locking.failure", "Another user has updated this AssetTypewhile you were editing.")64 render(view:'edit',model:[asset TypeInstance: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]) 65 65 return 66 66 } 67 67 } 68 asset TypeInstance.properties = params69 if(!asset TypeInstance.hasErrors() && assetTypeInstance.save(flush: true)) {70 flash.message = "Asset Type${params.id} updated"71 redirect(action:show,id:asset TypeInstance.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) 72 72 } 73 73 else { 74 render(view:'edit',model:[asset TypeInstance:assetTypeInstance])74 render(view:'edit',model:[assetSubItemInstance:assetSubItemInstance]) 75 75 } 76 76 } 77 77 else { 78 flash.message = "Asset Typenot found with id ${params.id}"78 flash.message = "AssetSubItem not found with id ${params.id}" 79 79 redirect(action:list) 80 80 } … … 82 82 83 83 def create = { 84 def asset TypeInstance = new AssetType()85 asset TypeInstance.properties = params86 return ['asset TypeInstance':assetTypeInstance]84 def assetSubItemInstance = new AssetSubItem() 85 assetSubItemInstance.properties = params 86 return ['assetSubItemInstance':assetSubItemInstance] 87 87 } 88 88 89 89 def save = { 90 def asset TypeInstance = new AssetType(params)91 if(!asset TypeInstance.hasErrors() && assetTypeInstance.save(flush: true)) {92 flash.message = "Asset Type ${assetTypeInstance.id} created"93 redirect(action:show,id:asset TypeInstance.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) 94 94 } 95 95 else { 96 render(view:'create',model:[asset TypeInstance:assetTypeInstance])96 render(view:'create',model:[assetSubItemInstance:assetSubItemInstance]) 97 97 } 98 98 }
Note: See TracChangeset
for help on using the changeset viewer.