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

Last change on this file since 495 was 456, checked in by gav, 15 years ago

Set batchSize:1000 on asset tree domain classes.

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