Changeset 350 for trunk/grails-app/services
- Timestamp:
- Feb 10, 2010, 5:09:22 AM (15 years ago)
- Location:
- trunk/grails-app/services
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/services/AssetService.groovy
r329 r350 2 2 3 3 boolean transactional = false 4 5 def assetSubItemService 4 6 5 7 /** … … 13 15 } 14 16 } 17 18 def delete(params) { 19 Asset.withTransaction { status -> 20 def result = [:] 21 22 def fail = { Map m -> 23 status.setRollbackOnly() 24 if(result.assetInstance && m.field) 25 result.assetInstance.errors.rejectValue(m.field, m.code) 26 result.error = [ code: m.code, args: ["Asset", params.id] ] 27 return result 28 } 29 30 result.assetInstance = Asset.get(params.id) 31 32 if(!result.assetInstance) 33 return fail(code:"default.not.found") 34 35 if(result.assetInstance.maintenanceActions) 36 return fail(code:"maintenanceActions.still.associated") 37 38 // Remove orphan assetSubItems. 39 def assetSubItems = new ArrayList(result.assetInstance.assetSubItems) // avoid ConcurrentModificationException. 40 def r 41 for(assetSubItem in assetSubItems) { 42 result.assetInstance.removeFromAssetSubItems(assetSubItem) 43 if(!assetSubItem.assets && !assetSubItem.parentItem) { 44 r = assetSubItemService.delete(id: assetSubItem.id) 45 if(r.error) { 46 fail(code:"asset.subItems.delete.failure") 47 break 48 } 49 } 50 } 51 52 if(result.error) 53 return result 54 55 try { 56 result.assetInstance.delete(flush:true) 57 return result //Success. 58 } 59 catch(org.springframework.dao.DataIntegrityViolationException e) { 60 return fail(code:"default.delete.failure") 61 } 62 63 } // end withTransaction 64 } // end delete() 15 65 16 66 def create(params) { … … 164 214 return result 165 215 166 } // end withTransaction216 } // end withTransaction 167 217 } // end saveCopySrvce 168 218 -
trunk/grails-app/services/AssetSubItemService.groovy
r347 r350 19 19 20 20 if(result.assetSubItemInstance.maintenanceActions) 21 return fail(code:" assetSubItem.maintenanceActions.associated")21 return fail(code:"maintenanceActions.still.associated") 22 22 23 23 try {
Note: See TracChangeset
for help on using the changeset viewer.