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

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

Add contacts to Person, Supplier, Manufacturer and Site.

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