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

Last change on this file since 299 was 286, checked in by gav, 15 years ago

Add CustomTagLib with checkBoxList.

File size: 963 bytes
RevLine 
[116]1class Asset {
[122]2
[268]3    Section section
[122]4
[116]5    String name
6    String description = ""
7    boolean isActive = true
8
[268]9    static hasMany = [assetSubItems: AssetSubItem,
10                                    maintenanceActions: MaintenanceAction,
[131]11                                    assetExtendedAttributes: AssetExtendedAttribute]
[121]12
[268]13    static belongsTo = [Section]
[121]14
[124]15    static constraints = {
[268]16        name(maxSize:50, unique:true, blank:false)
17        description(maxSize:100)
18        isActive()
19        section()
[124]20    }
[116]21
22    String toString() {
23        "${this.name}"
24    }
[286]25
26    //  This additional setter is used to convert the checkBoxList string
27    //  of ids selected to the corresponding domain objects.
28    public void setAssetSubItemsFromCheckBoxList(ids) {
29        def idList = []
30        ids.each() {
31            if(it.isInteger())
32                idList << it.toInteger()
33        }
34        this.assetSubItems = idList.collect { AssetSubItem.get( it ) }
35    }
36
[116]37}
38
Note: See TracBrowser for help on using the repository browser.