]> SALOME platform Git repositories - tools/siman.git/blob - Workspace/Siman-Common/src/org/splat/service/dto/UserDTO.java
Salome HOME
Modifications done to respect PMD rules. Versioning a document is fixed. Validation...
[tools/siman.git] / Workspace / Siman-Common / src / org / splat / service / dto / UserDTO.java
1 package org.splat.service.dto;
2
3 import java.security.Principal;
4
5 import org.splat.kernel.Name;
6
7 /**
8  * User DTO.
9  *
10  * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
11  */
12 public class UserDTO implements Principal, Name {
13
14         private String _password; // Property without getter function
15         private String _username; // Unique in the user directory
16         private String _firstName;
17         private String _name;
18         private String _displayName; // Optional
19         private RoleDTO _role = new RoleDTO(); // Roles as list (as stored into the database)
20         private String _mailAddress;
21         private String _organizationName;
22
23         /**
24          * Persistent id of the type.
25          */
26         private long _index;
27
28         // ==============================================================================================================================
29         // Public member functions
30         // ==============================================================================================================================
31
32         @Override
33         public boolean equals(final Object item) {
34                 boolean res = (item != null);
35                 if (res) {
36                         if (item instanceof String) {
37                                 res = this._username.equals(item); // Usernames are unique
38                         } else if (item instanceof UserDTO) {
39                                 UserDTO given = (UserDTO) item;
40                                 res = given._username.equals(this._username); // Usernames are unique
41                         }
42                 }
43                 return res;
44         }
45
46         public String getDisplayName() {
47                 String res = _displayName;
48                 if (res == null) {
49                         res = _name + " " + _firstName;
50                 }
51                 return res;
52         }
53
54         public String getFirstName() {
55                 return _firstName;
56         }
57
58         public void setFirstName(final String name) {
59                 _firstName = name;
60         }
61
62         public String getMailAddress() {
63                 return _mailAddress;
64         }
65
66         public void setMailAddress(final String addr) {
67                 _mailAddress = addr;
68         }
69
70         public String getName() {
71                 return _name;
72         }
73         
74         public void setName(final String name) {
75                 _name = name;
76         }
77
78         public String getOrganizationName() {
79                 return _organizationName;
80         }
81
82         public void setOrganizationName(final String name) {
83                 _organizationName = name;
84         }
85
86         public String getRoleNames() {
87                 return _role.getName();
88         }
89
90         public RoleDTO[] getRoles() {
91                 return _role.toArray();
92         }
93
94         public String getUsername() {
95                 return _username;
96         }
97
98         @Override
99         public String toString() {
100                 return _name + " " + _firstName;
101         }
102
103         /**
104          * Get the rid.
105          * 
106          * @return the rid
107          */
108         public long getIndex() {
109                 return _index;
110         }
111
112         /**
113          * Set the rid.
114          * 
115          * @param rid
116          *            the rid to set
117          */
118         public void setIndex(final long rid) {
119                 this._index = rid;
120         }
121
122         /**
123          * Get the password.
124          * @return the password
125          */
126         public String getPassword() {
127                 return _password;
128         }
129
130         /**
131          * Set the password.
132          * @param password the password to set
133          */
134         public void setPassword(final String password) {
135                 this._password = password;
136         }
137
138         /**
139          * Set the username.
140          * @param username the username to set
141          */
142         public void setUsername(final String username) {
143                 this._username = username;
144         }
145
146         /**
147          * Get the role.
148          * @return the role
149          */
150         public RoleDTO getRole() {
151                 return _role;
152         }
153
154         /**
155          * Set the role.
156          * @param role the role to set
157          */
158         public void setRole(final RoleDTO role) {
159                 this._role = role;
160         }
161
162         /**
163          * Set the displayName.
164          * @param displayName the displayName to set
165          */
166         public void setDisplayName(final String displayName) {
167                 _displayName = displayName;
168         }
169 }