[274] | 1 | import org.codehaus.groovy.grails.plugins.springsecurity.Secured |
---|
| 2 | |
---|
| 3 | class AssetSubItemExtendedAttributeDetailedController extends BaseController { |
---|
| 4 | |
---|
[293] | 5 | def index = { redirect(controller: "assetDetailed", action: "search", params:params) } |
---|
| 6 | |
---|
[274] | 7 | // the delete, save and update actions only accept POST requests |
---|
| 8 | static allowedMethods = [delete:'POST', save:'POST', update:'POST'] |
---|
| 9 | |
---|
| 10 | def show = { |
---|
| 11 | def assetSubItemExtendedAttributeInstance = AssetSubItemExtendedAttribute.get( params.id ) |
---|
| 12 | |
---|
| 13 | if(!assetSubItemExtendedAttributeInstance) { |
---|
| 14 | flash.message = "AssetSubItemExtendedAttribute not found with id ${params.id}" |
---|
[293] | 15 | redirect(controller: "assetDetailed", action: "search") |
---|
[274] | 16 | } |
---|
| 17 | else { return [ assetSubItemExtendedAttributeInstance : assetSubItemExtendedAttributeInstance ] } |
---|
| 18 | } |
---|
| 19 | |
---|
| 20 | def delete = { |
---|
| 21 | def assetSubItemExtendedAttributeInstance = AssetSubItemExtendedAttribute.get( params.id ) |
---|
| 22 | if(assetSubItemExtendedAttributeInstance) { |
---|
| 23 | try { |
---|
| 24 | assetSubItemExtendedAttributeInstance.delete(flush:true) |
---|
| 25 | flash.message = "AssetSubItemExtendedAttribute ${params.id} deleted" |
---|
[293] | 26 | redirect(controller: "assetDetailed", action: "search") |
---|
[274] | 27 | } |
---|
| 28 | catch(org.springframework.dao.DataIntegrityViolationException e) { |
---|
| 29 | flash.message = "AssetSubItemExtendedAttribute ${params.id} could not be deleted" |
---|
| 30 | redirect(action:show,id:params.id) |
---|
| 31 | } |
---|
| 32 | } |
---|
| 33 | else { |
---|
| 34 | flash.message = "AssetSubItemExtendedAttribute not found with id ${params.id}" |
---|
[293] | 35 | redirect(controller: "assetDetailed", action: "search") |
---|
[274] | 36 | } |
---|
| 37 | } |
---|
| 38 | |
---|
| 39 | def edit = { |
---|
| 40 | def assetSubItemExtendedAttributeInstance = AssetSubItemExtendedAttribute.get( params.id ) |
---|
| 41 | |
---|
| 42 | if(!assetSubItemExtendedAttributeInstance) { |
---|
| 43 | flash.message = "AssetSubItemExtendedAttribute not found with id ${params.id}" |
---|
[293] | 44 | redirect(controller: "assetDetailed", action: "search") |
---|
[274] | 45 | } |
---|
| 46 | else { |
---|
| 47 | return [ assetSubItemExtendedAttributeInstance : assetSubItemExtendedAttributeInstance ] |
---|
| 48 | } |
---|
| 49 | } |
---|
| 50 | |
---|
| 51 | def update = { |
---|
| 52 | def assetSubItemExtendedAttributeInstance = AssetSubItemExtendedAttribute.get( params.id ) |
---|
| 53 | if(assetSubItemExtendedAttributeInstance) { |
---|
| 54 | if(params.version) { |
---|
| 55 | def version = params.version.toLong() |
---|
| 56 | if(assetSubItemExtendedAttributeInstance.version > version) { |
---|
| 57 | |
---|
| 58 | assetSubItemExtendedAttributeInstance.errors.rejectValue("version", "assetSubItemExtendedAttribute.optimistic.locking.failure", "Another user has updated this AssetSubItemExtendedAttribute while you were editing.") |
---|
| 59 | render(view:'edit',model:[assetSubItemExtendedAttributeInstance:assetSubItemExtendedAttributeInstance]) |
---|
| 60 | return |
---|
| 61 | } |
---|
| 62 | } |
---|
| 63 | assetSubItemExtendedAttributeInstance.properties = params |
---|
| 64 | if(!assetSubItemExtendedAttributeInstance.hasErrors() && assetSubItemExtendedAttributeInstance.save(flush: true)) { |
---|
| 65 | flash.message = "AssetSubItemExtendedAttribute ${params.id} updated" |
---|
| 66 | redirect(action:show,id:assetSubItemExtendedAttributeInstance.id) |
---|
| 67 | } |
---|
| 68 | else { |
---|
| 69 | render(view:'edit',model:[assetSubItemExtendedAttributeInstance:assetSubItemExtendedAttributeInstance]) |
---|
| 70 | } |
---|
| 71 | } |
---|
| 72 | else { |
---|
| 73 | flash.message = "AssetSubItemExtendedAttribute not found with id ${params.id}" |
---|
[293] | 74 | redirect(controller: "assetDetailed", action: "search") |
---|
[274] | 75 | } |
---|
| 76 | } |
---|
| 77 | |
---|
| 78 | def create = { |
---|
| 79 | def assetSubItemExtendedAttributeInstance = new AssetSubItemExtendedAttribute() |
---|
| 80 | assetSubItemExtendedAttributeInstance.properties = params |
---|
| 81 | return ['assetSubItemExtendedAttributeInstance':assetSubItemExtendedAttributeInstance] |
---|
| 82 | } |
---|
| 83 | |
---|
| 84 | def save = { |
---|
| 85 | def assetSubItemExtendedAttributeInstance = new AssetSubItemExtendedAttribute(params) |
---|
| 86 | if(!assetSubItemExtendedAttributeInstance.hasErrors() && assetSubItemExtendedAttributeInstance.save(flush: true)) { |
---|
| 87 | flash.message = "AssetSubItemExtendedAttribute ${assetSubItemExtendedAttributeInstance.id} created" |
---|
| 88 | redirect(action:show,id:assetSubItemExtendedAttributeInstance.id) |
---|
| 89 | } |
---|
| 90 | else { |
---|
| 91 | render(view:'create',model:[assetSubItemExtendedAttributeInstance:assetSubItemExtendedAttributeInstance]) |
---|
| 92 | } |
---|
| 93 | } |
---|
| 94 | } |
---|