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