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

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

Add address feature.

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    String email
29    boolean emailShow = true
[58]30
[154]31    /** description */
32    String description = ''
[58]33
[154]34    /** plain password to create a MD5 password */
35    String pass
[58]36
[154]37    static constraints = {
38        loginName(blank: false, unique: true, minSize:4) //minSize:7
39        firstName(blank: false)
[58]40        lastName(blank: false)
41        employeeID(blank: true, nullable:true)
[73]42        description()
[164]43        department(nullable:true)
[73]44        email()
45        emailShow()
46        isActive()
47        //Enforcing minSize on password does not work since "" gets encoded to a string.
[154]48        password(blank: false)
[73]49        //So we need to use pass for validation then encode it for above.
[147]50        pass(blank: false, minSize:4) //minSize:7
[139]51        sessionTimeout(min:60, max:43200)
[73]52
[154]53    }
[58]54
55    //Overriding the default toString method
56    String toString() {"${this.firstName} ${this.lastName}"}
[294]57
[343]58    //  This additional setter is used to convert the checkBoxList string or string array
[294]59    //  of ids selected to the corresponding domain objects.
60    public void setPersonGroupsFromCheckBoxList(ids) {
61        def idList = []
[343]62        if(ids instanceof String) {
63                if(ids.isInteger())
64                    idList << ids.toInteger()
[294]65        }
[343]66        else {
67            ids.each() {
68                if(it.isInteger())
69                    idList << it.toInteger()
70            }
71        }
[294]72        this.personGroups = idList.collect { PersonGroup.get( it ) }
73    }
74
75} // end class
Note: See TracBrowser for help on using the repository browser.