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

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

Remove email and emailShow from Person in preparation for ContactDetails.

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                        addresses: Address]
9
10    static belongsTo = [Authority]
11
12    Department department
13
14    String loginName
15    String firstName
16    String lastName
17    String employeeID
18
19    /* Set after login by 'welcome' action, default to 12 hours, aka "sess.setMaxInactiveInterval(seconds) */
20    Integer sessionTimeout = 43200
21
22    /** MD5 Password */
23    String password
24
25    /** enabled */
26    boolean isActive = true
27
28    /** description */
29    String description = ''
30
31    /** plain password to create a MD5 password */
32    String pass
33
34    static constraints = {
35        loginName(blank: false, unique: true, minSize:4) //minSize:7
36        firstName(blank: false)
37        lastName(blank: false)
38        employeeID(blank: true, nullable:true)
39        description()
40        department(nullable:true)
41        isActive()
42        //Enforcing minSize on password does not work since "" gets encoded to a string.
43        password(blank: false)
44        //So we need to use pass for validation then encode it for above.
45        pass(blank: false, minSize:4) //minSize:7
46        sessionTimeout(min:60, max:43200)
47
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.