source: trunk/grails-app/domain/Asset.groovy @ 562

Last change on this file since 562 was 562, checked in by gav, 14 years ago

Install searchable plugin, configure and start inventory search.

File size: 1.4 KB
RevLine 
[116]1class Asset {
[122]2
[268]3    Section section
[122]4
[116]5    String name
6    String description = ""
[329]7    String comment = ""
[116]8    boolean isActive = true
9
[268]10    static hasMany = [assetSubItems: AssetSubItem,
11                                    maintenanceActions: MaintenanceAction,
[131]12                                    assetExtendedAttributes: AssetExtendedAttribute]
[121]13
[268]14    static belongsTo = [Section]
[121]15
[124]16    static constraints = {
[268]17        name(maxSize:50, unique:true, blank:false)
[329]18        description(maxSize:75)
19        comment(maxSize:500)
[268]20        isActive()
21        section()
[124]22    }
[116]23
[456]24    static mapping = {
25        assetSubItems(batchSize:1000)
26    }
27
[116]28    String toString() {
29        "${this.name}"
30    }
[286]31
[562]32    static searchable = {
33        root false // only index as a component of InventoryItem.
34        only = ['name', 'description', 'comment']
35    }
36
[343]37    //  This additional setter is used to convert the checkBoxList string or string array
[286]38    //  of ids selected to the corresponding domain objects.
39    public void setAssetSubItemsFromCheckBoxList(ids) {
40        def idList = []
[343]41        if(ids instanceof String) {
42                if(ids.isInteger())
43                    idList << ids.toInteger()
[286]44        }
[343]45        else {
46            ids.each() {
47                if(it.isInteger())
48                    idList << it.toInteger()
49            }
50        }
[286]51        this.assetSubItems = idList.collect { AssetSubItem.get( it ) }
52    }
53
[116]54}
55
Note: See TracBrowser for help on using the repository browser.