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
Line 
1class Asset {
2
3    Section section
4
5    String name
6    String description = ""
7    boolean isActive = true
8
9    static hasMany = [assetSubItems: AssetSubItem,
10                                    maintenanceActions: MaintenanceAction,
11                                    assetExtendedAttributes: AssetExtendedAttribute]
12
13    static belongsTo = [Section]
14
15    static constraints = {
16        name(maxSize:50, unique:true, blank:false)
17        description(maxSize:100)
18        isActive()
19        section()
20    }
21
22    String toString() {
23        "${this.name}"
24    }
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
37}
38
Note: See TracBrowser for help on using the repository browser.