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

Last change on this file since 381 was 343, checked in by gav, 15 years ago

Improvements to CustomTagLib checkBoxList, sorting, dynamic displayFields and a small fix to the domain class set method.

File size: 1.2 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
24    String toString() {
25        "${this.name}"
26    }
[286]27
[343]28    //  This additional setter is used to convert the checkBoxList string or string array
[286]29    //  of ids selected to the corresponding domain objects.
30    public void setAssetSubItemsFromCheckBoxList(ids) {
31        def idList = []
[343]32        if(ids instanceof String) {
33                if(ids.isInteger())
34                    idList << ids.toInteger()
[286]35        }
[343]36        else {
37            ids.each() {
38                if(it.isInteger())
39                    idList << it.toInteger()
40            }
41        }
[286]42        this.assetSubItems = idList.collect { AssetSubItem.get( it ) }
43    }
44
[116]45}
46
Note: See TracBrowser for help on using the repository browser.