source: trunk/grails-app/domain/Person.groovy @ 622

Last change on this file since 622 was 402, checked in by gav, 15 years ago

Add contacts to Person, Supplier, Manufacturer and Site.

File size: 2.1 KB
Line 
1class Person {
2    static transients = ['pass']
3    static hasMany = [authorities: Authority,
4                        personGroups: PersonGroup,
5                        taskModifications: TaskModification,
6                        entries: Entry,
7                        tasks: Task,
8                        contacts: Contact,
9                        addresses: Address]
10
11    static belongsTo = [Authority]
12
13    Department department
14
15    String loginName
16    String firstName
17    String lastName
18    String employeeID = ''
19
20    /* Set after login by 'welcome' action, default to 12 hours, aka "sess.setMaxInactiveInterval(seconds) */
21    Integer sessionTimeout = 43200
22
23    /** MD5 Password */
24    String password
25
26    /** enabled */
27    boolean isActive = true
28
29    /** description */
30    String description = ''
31
32    /** plain password to create a MD5 password */
33    String pass
34
35    static constraints = {
36        loginName(blank: false, unique: true, minSize:4) //minSize:7
37        firstName(blank: false)
38        lastName(blank: false)
39        employeeID()
40        description()
41        department(nullable:true)
42        isActive()
43        //Enforcing minSize on password does not work since "" gets encoded to a string.
44        password(blank: false)
45        //So we need to use pass for validation then encode it for above.
46        pass(blank: false, minSize:4) //minSize:7
47        sessionTimeout(min:60, max:43200)
48    }
49
50    //Overriding the default toString method
51    String toString() {"${this.firstName} ${this.lastName}"}
52
53    //  This additional setter is used to convert the checkBoxList string or string array
54    //  of ids selected to the corresponding domain objects.
55    public void setPersonGroupsFromCheckBoxList(ids) {
56        def idList = []
57        if(ids instanceof String) {
58                if(ids.isInteger())
59                    idList << ids.toInteger()
60        }
61        else {
62            ids.each() {
63                if(it.isInteger())
64                    idList << it.toInteger()
65            }
66        }
67        this.personGroups = idList.collect { PersonGroup.get( it ) }
68    }
69
70} // end class
Note: See TracBrowser for help on using the repository browser.