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

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

Install searchable plugin, configure and start inventory search.

File size: 1.4 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    static searchable = {
33        root false // only index as a component of InventoryItem.
34        only = ['name', 'description', 'comment']
35    }
36
37    //  This additional setter is used to convert the checkBoxList string or string array
38    //  of ids selected to the corresponding domain objects.
39    public void setAssetSubItemsFromCheckBoxList(ids) {
40        def idList = []
41        if(ids instanceof String) {
42                if(ids.isInteger())
43                    idList << ids.toInteger()
44        }
45        else {
46            ids.each() {
47                if(it.isInteger())
48                    idList << it.toInteger()
49            }
50        }
51        this.assetSubItems = idList.collect { AssetSubItem.get( it ) }
52    }
53
54}
55
Note: See TracBrowser for help on using the repository browser.