Ignore:
Timestamp:
Feb 12, 2010, 12:14:23 PM (15 years ago)
Author:
gav
Message:

Added some checks to prevent recurrsion loops in Asset tree.

Location:
trunk/grails-app/services
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/services/AssetService.groovy

    r350 r352  
    1212        def criteria = AssetSubItem.createCriteria()
    1313        def possibleAssetSubItems = criteria.list() {
    14             isNull("parentItem")
     14            and {
     15                eq('isActive', true)
     16                isNull("parentItem")
     17                }
    1518        }
    1619    }
  • trunk/grails-app/services/AssetSubItemService.groovy

    r350 r352  
    22
    33    boolean transactional = false
     4
     5    /**
     6    * Determines and returns sorted list of possible parent items.
     7    * @param assetSubItemInstance The instance to prepare the list for.
     8    * @returns A list of the possible parentItems.
     9    */
     10    def possibleParentItems(assetSubItemInstance) {
     11        def criteria = AssetSubItem.createCriteria()
     12        def possibleParentItems = criteria.list() {
     13            and {
     14                eq('isActive', true)
     15                ne('id', assetSubItemInstance.id)
     16                assetSubItemInstance.subItems.each() { notEqual('id', it.id) }
     17                }
     18        }
     19        possibleParentItems.sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) }
     20    }
    421
    522    def delete(params) {
Note: See TracChangeset for help on using the changeset viewer.