Changeset 793 for branches/features/taskProcedureRework/grails-app/services/TaskProcedureService.groovy
- Timestamp:
- Feb 7, 2011, 3:43:55 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/features/taskProcedureRework/grails-app/services/TaskProcedureService.groovy
r775 r793 49 49 result.taskProcedureInstance.maintenanceActions.removeAll(nullMaintenanceActions) 50 50 } 51 def nullDocumentReferences = result.taskProcedureInstance.documentReferences.findAll {!it} 52 if (nullDocumentReferences) { 53 result.taskProcedureInstance.documentReferences.removeAll(nullDocumentReferences) 54 } 51 55 52 56 // Save for restoration if validation fails. 53 57 def savedMaintenanceActions = new ArrayList(result.taskProcedureInstance.maintenanceActions) 58 def savedDocumentReferences = new ArrayList(result.taskProcedureInstance.documentReferences) 54 59 55 60 // Remove toBeDeleted before validation. 56 def toBeDeleted = result.taskProcedureInstance.maintenanceActions.findAll {it.toBeDeleted} 57 if (toBeDeleted) { 58 result.taskProcedureInstance.maintenanceActions.removeAll(toBeDeleted) 61 def ma_toBeDeleted = result.taskProcedureInstance.maintenanceActions.findAll {it.toBeDeleted} 62 if (ma_toBeDeleted) { 63 result.taskProcedureInstance.maintenanceActions.removeAll(ma_toBeDeleted) 64 } 65 def docRef_toBeDeleted = result.taskProcedureInstance.documentReferences.findAll {it.toBeDeleted} 66 if (docRef_toBeDeleted) { 67 result.taskProcedureInstance.documentReferences.removeAll(docRef_toBeDeleted) 59 68 } 60 69 … … 64 73 // The toBeDeleted items are hidden in the view. 65 74 result.taskProcedureInstance.maintenanceActions = savedMaintenanceActions 66 // Populate maintenanceAction errors for display. 75 result.taskProcedureInstance.documentReferences = savedDocumentReferences 76 // Populate collection errors for display. 67 77 result.taskProcedureInstance.maintenanceActions.each { it.validate() } 78 result.taskProcedureInstance.documentReferences.each { it.validate() } 68 79 return fail(code:"default.update.failure") 69 80 } … … 108 119 result.taskProcedureInstance.maintenanceActions.removeAll(nullMaintenanceActions) 109 120 } 121 def nullDocumentReferences = result.taskProcedureInstance.documentReferences.findAll {!it} 122 if (nullDocumentReferences) { 123 result.taskProcedureInstance.documentReferences.removeAll(nullDocumentReferences) 124 } 110 125 111 126 // Also sets: taskInstance.taskProcedure = taskProcedureInstance … … 113 128 114 129 if(result.taskProcedureInstance.hasErrors() || !result.taskProcedureInstance.save()) { 115 // Populate maintenanceAction errors for display.130 // Populate collection errors for display. 116 131 result.taskProcedureInstance.maintenanceActions.each { it.validate() } 132 result.taskProcedureInstance.documentReferences.each { it.validate() } 117 133 return fail(code:"default.create.failure") 118 134 }
Note: See TracChangeset
for help on using the changeset viewer.