OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 151 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
17 ilm 1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
7
 * only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
8
 * copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
9
 * language governing permissions and limitations under the License.
10
 *
11
 * When distributing the software, include this License Header Notice in each file.
12
 */
13
 
14
 package org.openconcerto.sql.users;
15
 
142 ilm 16
import org.openconcerto.sql.model.SQLRowAccessor;
17 ilm 17
 
174 ilm 18
import java.awt.Color;
19
 
142 ilm 20
import net.jcip.annotations.Immutable;
21
 
22
@Immutable
23
public final class User {
17 ilm 24
    private final int id;
142 ilm 25
    private final String name, firstName, nickName;
144 ilm 26
    private final Boolean active;
174 ilm 27
    private final Color color;
17 ilm 28
 
142 ilm 29
    public User(final SQLRowAccessor r) {
30
        this.id = r.getID();
31
        this.name = r.getString("NOM").trim();
32
        this.firstName = r.getString("PRENOM").trim();
33
        this.nickName = r.getString("SURNOM").trim();
151 ilm 34
        if (r.contains("DISABLED")) {
142 ilm 35
            this.active = !r.getBoolean("DISABLED");
36
        } else {
37
            this.active = null;
38
        }
174 ilm 39
        if (r.contains("COLOR")) {
40
            this.color = new Color(r.getInt("COLOR"));
41
        } else {
42
            this.color = null;
43
        }
17 ilm 44
    }
45
 
46
    public String getName() {
47
        return this.name;
48
    }
49
 
50
    public int getId() {
51
        return this.id;
52
    }
53
 
54
    @Override
55
    public String toString() {
56
        return this.getFullName() + " /" + getId();
57
    }
58
 
63 ilm 59
    public String getFirstName() {
60
        return this.firstName;
17 ilm 61
    }
62
 
63
    public String getNickName() {
64
        return this.nickName;
65
    }
66
 
67
    public String getFullName() {
63 ilm 68
        return getFirstName() + " " + getName();
17 ilm 69
    }
70
 
132 ilm 71
    public boolean isActive() {
142 ilm 72
        return this.active;
132 ilm 73
    }
174 ilm 74
 
75
    public Color getColor() {
76
        return this.color;
77
    }
17 ilm 78
}