Ignore:
Timestamp:
Feb 4, 2011, 2:11:45 AM (14 years ago)
Author:
gav
Message:

TaskProcedure? improvements, filter assemblies, pre populate a maintenanceAction for each assembly at creation.

File:
1 edited

Legend:

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

    r689 r776  
    2222                }
    2323        }
     24    }
     25
     26    /**
     27    * Determines and returns a list of assemblies for an asset.
     28    * This is purely a 'load from database' type method since a new hibernateSession is used.
     29    * @params Asset to get the subItems for.
     30    * @returns A list of the assemblies.
     31    */
     32    def getAssemblies(Asset asset) {
     33        def assemblies = []
     34        // Database efficiency:
     35        // The asset is configured to batch fetch assetSubItems which
     36        // in turn are configured to batch fetch subItems.
     37        Asset.withNewSession {
     38            Asset.get(asset.id).assetSubItems.each {
     39                assemblies.addAll(it.subItems)
     40            }
     41        }
     42        assemblies.sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) }
     43        return assemblies
    2444    }
    2545
Note: See TracChangeset for help on using the changeset viewer.