Changeset 347 for trunk/grails-app
- Timestamp:
- Feb 10, 2010, 3:52:30 AM (15 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/AssetSubItemDetailedController.groovy
r342 r347 92 92 93 93 def delete = { 94 def assetSubItemInstance = AssetSubItem.get( params.id)95 if(assetSubItemInstance) { 96 try{97 assetSubItemInstance.delete(flush:true)98 flash.message = "AssetSubItem ${params.id} deleted"99 redirect(action: "search")100 101 catch(org.springframework.dao.DataIntegrityViolationException e) { 102 flash.errorMessage = "AssetSubItem ${params.id} could not be deleted"103 redirect(action:show,id:params.id) 104 }105 }106 else {107 flash.message = "AssetSubItem not found with id ${params.id}"108 redirect(action: "search") 109 }94 def result = assetSubItemService.delete(params) 95 96 if(!result.error) { 97 flash.message = g.message(code: "default.delete.success", args: ["AssetSubItem", params.id]) 98 redirect(action: search) 99 return 100 } 101 102 flash.errorMessage = g.message(code: result.error.code, args: result.error.args) 103 104 if(result.error.code == "default.not.found") { 105 redirect(action: search) 106 return 107 } 108 109 redirect(action:show, id: params.id) 110 110 } 111 111 -
trunk/grails-app/i18n/messages.properties
r323 r347 12 12 13 13 assetSubItem.asset.not.found=Could not complete operation as an asset was supplied but not found. 14 assetSubItem.assets.associated=Could not complete operation as assets are still associated with this sub item. 15 assetSubItem.maintenanceActions.associated=Could not complete operation as maintenance actions are still associated with this sub item. 14 16 15 17 sub.task.create.confirm=Immediately create and save a new sub task? -
trunk/grails-app/services/AssetSubItemService.groovy
r290 r347 2 2 3 3 boolean transactional = false 4 5 def delete(params) { 6 def result = [:] 7 def fail = { Map m -> 8 result.error = [ code: m.code, args: ["AssetSubItem", params.id] ] 9 return result 10 } 11 12 result.assetSubItemInstance = AssetSubItem.get(params.id) 13 14 if(!result.assetSubItemInstance) 15 return fail(code:"default.not.found") 16 17 if(result.assetSubItemInstance.assets) 18 return fail(code:"assetSubItem.assets.associated") 19 20 if(result.assetSubItemInstance.maintenanceActions) 21 return fail(code:"assetSubItem.maintenanceActions.associated") 22 23 try { 24 result.assetSubItemInstance.delete(flush:true) 25 return result //Success. 26 } 27 catch(org.springframework.dao.DataIntegrityViolationException e) { 28 return fail(code:"default.delete.failure") 29 } 30 31 } 4 32 5 33 def create(params) {
Note: See TracChangeset
for help on using the changeset viewer.