Ignore:
Timestamp:
Mar 3, 2010, 3:50:21 PM (15 years ago)
Author:
gav
Message:

Handle InventoryItem reverse alternateItems.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/domain/InventoryItem.groovy

    r422 r425  
    5656
    5757    String toString() {"${this.name}"}
     58
     59    def afterInsert = {
     60        addReverseAlternateItems()
     61    }
     62
     63    // Add reverse alternateItem references.
     64    def addReverseAlternateItems() {
     65        this.alternateItems.each() {
     66            if( !it.alternateItems?.contains(this) )
     67                it.addToAlternateItems(this)
     68        }
     69    }
     70
     71    /**
     72   * Remove all reverse alternateItem references.
     73    * Update: reverse alternateItem handling must be done in the
     74    * service class since the before assignment alternateItems are required.
     75    */
     76    def removeReverseAlternateItems(alternateItems = this.alternateItems) {
     77        alternateItems.each() {
     78            it.removeFromAlternateItems(this)
     79        }
     80    }
     81
    5882}
Note: See TracChangeset for help on using the changeset viewer.