root / src / org / gss_project / gss / server / domain / Invitation.java @ 1206:292dec4eae08
History | View | Annotate | Download (3.9 kB)
1 |
/*
|
---|---|
2 |
* Copyright 2010 Electronic Business Systems Ltd.
|
3 |
*
|
4 |
* This file is part of GSS.
|
5 |
*
|
6 |
* GSS is free software: you can redistribute it and/or modify
|
7 |
* it under the terms of the GNU General Public License as published by
|
8 |
* the Free Software Foundation, either version 3 of the License, or
|
9 |
* (at your option) any later version.
|
10 |
*
|
11 |
* GSS is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with GSS. If not, see <http://www.gnu.org/licenses/>.
|
18 |
*/
|
19 |
package org.gss_project.gss.server.domain; |
20 |
|
21 |
import java.io.Serializable; |
22 |
|
23 |
import javax.persistence.Column; |
24 |
import javax.persistence.Entity; |
25 |
import javax.persistence.GeneratedValue; |
26 |
import javax.persistence.Id; |
27 |
import javax.persistence.JoinColumn; |
28 |
import javax.persistence.ManyToOne; |
29 |
import javax.persistence.Version; |
30 |
|
31 |
import org.hibernate.annotations.Cache; |
32 |
import org.hibernate.annotations.CacheConcurrencyStrategy; |
33 |
|
34 |
/**
|
35 |
* The class that holds information about a user invitation for the system.
|
36 |
*
|
37 |
* @author past
|
38 |
*/
|
39 |
@Entity
|
40 |
@Cache(usage=CacheConcurrencyStrategy.READ_WRITE)
|
41 |
public class Invitation implements Serializable { |
42 |
/**
|
43 |
* The persistence ID of the object.
|
44 |
*/
|
45 |
@Id
|
46 |
@GeneratedValue
|
47 |
private Long id; |
48 |
|
49 |
/**
|
50 |
* Version field for optimistic locking.
|
51 |
*/
|
52 |
@SuppressWarnings("unused") |
53 |
@Version
|
54 |
private int version; |
55 |
|
56 |
/**
|
57 |
* The invitation code.
|
58 |
*/
|
59 |
@Column(unique = true) |
60 |
private String code; |
61 |
|
62 |
/**
|
63 |
* The first name of the user.
|
64 |
*/
|
65 |
private String firstname; |
66 |
|
67 |
/**
|
68 |
* The last name of the user.
|
69 |
*/
|
70 |
private String lastname; |
71 |
|
72 |
/**
|
73 |
* The full name of the user.
|
74 |
*/
|
75 |
private String name; |
76 |
|
77 |
/**
|
78 |
* The e-mail address of the user.
|
79 |
*/
|
80 |
private String email; |
81 |
|
82 |
/**
|
83 |
* The user that used this invitation.
|
84 |
*/
|
85 |
@ManyToOne
|
86 |
@JoinColumn
|
87 |
private User user;
|
88 |
|
89 |
/**
|
90 |
* Retrieve the firstname.
|
91 |
*
|
92 |
* @return the firstname
|
93 |
*/
|
94 |
public String getFirstname() { |
95 |
return firstname;
|
96 |
} |
97 |
|
98 |
/**
|
99 |
* Modify the firstname.
|
100 |
*
|
101 |
* @param newFirstname the firstname to set
|
102 |
*/
|
103 |
public void setFirstname(final String newFirstname) { |
104 |
firstname = newFirstname; |
105 |
} |
106 |
|
107 |
/**
|
108 |
* Retrieve the lastname.
|
109 |
*
|
110 |
* @return the lastname
|
111 |
*/
|
112 |
public String getLastname() { |
113 |
return lastname;
|
114 |
} |
115 |
|
116 |
/**
|
117 |
* Modify the lastname.
|
118 |
*
|
119 |
* @param newLastname the lastname to set
|
120 |
*/
|
121 |
public void setLastname(final String newLastname) { |
122 |
lastname = newLastname; |
123 |
} |
124 |
|
125 |
/**
|
126 |
* Retrieve the name.
|
127 |
*
|
128 |
* @return the name
|
129 |
*/
|
130 |
public String getName() { |
131 |
return name != null ? name : firstname + " " + lastname; |
132 |
} |
133 |
|
134 |
/**
|
135 |
* Modify the name.
|
136 |
*
|
137 |
* @param newName the name to set
|
138 |
*/
|
139 |
public void setName(final String newName) { |
140 |
name = newName; |
141 |
} |
142 |
|
143 |
/**
|
144 |
* Retrieve the email.
|
145 |
*
|
146 |
* @return the email
|
147 |
*/
|
148 |
public String getEmail() { |
149 |
return email;
|
150 |
} |
151 |
|
152 |
/**
|
153 |
* Modify the email.
|
154 |
*
|
155 |
* @param newEmail the email to set
|
156 |
*/
|
157 |
public void setEmail(final String newEmail) { |
158 |
email = newEmail; |
159 |
} |
160 |
|
161 |
/**
|
162 |
* Retrieve the code.
|
163 |
*
|
164 |
* @return the code
|
165 |
*/
|
166 |
public String getCode() { |
167 |
return code;
|
168 |
} |
169 |
|
170 |
|
171 |
/**
|
172 |
* Modify the code.
|
173 |
*
|
174 |
* @param aCode the code to set
|
175 |
*/
|
176 |
public void setCode(String aCode) { |
177 |
code = aCode; |
178 |
} |
179 |
|
180 |
/**
|
181 |
* Retrieve the id.
|
182 |
*
|
183 |
* @return the id
|
184 |
*/
|
185 |
public Long getId() { |
186 |
return id;
|
187 |
} |
188 |
|
189 |
|
190 |
/**
|
191 |
* Retrieve the user.
|
192 |
*
|
193 |
* @return the user
|
194 |
*/
|
195 |
public User getUser() {
|
196 |
return user;
|
197 |
} |
198 |
|
199 |
|
200 |
/**
|
201 |
* Modify the user.
|
202 |
*
|
203 |
* @param aUser the user to set
|
204 |
*/
|
205 |
public void setUser(User aUser) { |
206 |
user = aUser; |
207 |
} |
208 |
|
209 |
@Override
|
210 |
public boolean equals(Object o) { |
211 |
if (this == o) return true; |
212 |
if (!(o instanceof Invitation)) return false; |
213 |
Invitation invite = (Invitation) o; |
214 |
return invite.getCode().equals(code) && invite.getName().equals(getName());
|
215 |
} |
216 |
|
217 |
@Override
|
218 |
public int hashCode() { |
219 |
return 37 * code.hashCode() + getName().hashCode(); |
220 |
} |
221 |
} |