Ignore:
Timestamp:
Feb 7, 2011, 3:43:55 PM (14 years ago)
Author:
gav
Message:

Domain change, add DocumentReference.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/features/taskProcedureRework/grails-app/services/TaskProcedureService.groovy

    r775 r793  
    4949                result.taskProcedureInstance.maintenanceActions.removeAll(nullMaintenanceActions)
    5050            }
     51            def nullDocumentReferences = result.taskProcedureInstance.documentReferences.findAll {!it}
     52            if (nullDocumentReferences) {
     53                result.taskProcedureInstance.documentReferences.removeAll(nullDocumentReferences)
     54            }
    5155
    5256            // Save for restoration if validation fails.
    5357            def savedMaintenanceActions = new ArrayList(result.taskProcedureInstance.maintenanceActions)
     58            def savedDocumentReferences = new ArrayList(result.taskProcedureInstance.documentReferences)
    5459
    5560            // 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)
    5968            }
    6069
     
    6473                // The toBeDeleted items are hidden in the view.
    6574                result.taskProcedureInstance.maintenanceActions = savedMaintenanceActions
    66                 // Populate maintenanceAction errors for display.
     75                result.taskProcedureInstance.documentReferences = savedDocumentReferences
     76                // Populate collection errors for display.
    6777                result.taskProcedureInstance.maintenanceActions.each { it.validate() }
     78                result.taskProcedureInstance.documentReferences.each { it.validate() }
    6879                return fail(code:"default.update.failure")
    6980            }
     
    108119                result.taskProcedureInstance.maintenanceActions.removeAll(nullMaintenanceActions)
    109120            }
     121            def nullDocumentReferences = result.taskProcedureInstance.documentReferences.findAll {!it}
     122            if (nullDocumentReferences) {
     123                result.taskProcedureInstance.documentReferences.removeAll(nullDocumentReferences)
     124            }
    110125
    111126            // Also sets: taskInstance.taskProcedure = taskProcedureInstance
     
    113128
    114129            if(result.taskProcedureInstance.hasErrors() || !result.taskProcedureInstance.save()) {
    115                 // Populate maintenanceAction errors for display.
     130                // Populate collection errors for display.
    116131                result.taskProcedureInstance.maintenanceActions.each { it.validate() }
     132                result.taskProcedureInstance.documentReferences.each { it.validate() }
    117133                return fail(code:"default.create.failure")
    118134            }
Note: See TracChangeset for help on using the changeset viewer.