2 * Copyright 2010 Electronic Business Systems Ltd.
4 * This file is part of GSS.
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.
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.
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/>.
19 package gr.ebs.gss.server.domain;
21 import java.io.Serializable;
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;
31 import org.hibernate.annotations.Cache;
32 import org.hibernate.annotations.CacheConcurrencyStrategy;
35 * The class that holds information about a user invitation for the system.
40 @Cache(usage=CacheConcurrencyStrategy.READ_WRITE)
41 public class Invitation implements Serializable {
43 * The persistence ID of the object.
50 * Version field for optimistic locking.
52 @SuppressWarnings("unused")
57 * The invitation code.
59 @Column(unique = true)
63 * The first name of the user.
65 private String firstname;
68 * The last name of the user.
70 private String lastname;
73 * The full name of the user.
78 * The e-mail address of the user.
83 * The user that used this invitation.
90 * Retrieve the firstname.
92 * @return the firstname
94 public String getFirstname() {
99 * Modify the firstname.
101 * @param newFirstname the firstname to set
103 public void setFirstname(final String newFirstname) {
104 firstname = newFirstname;
108 * Retrieve the lastname.
110 * @return the lastname
112 public String getLastname() {
117 * Modify the lastname.
119 * @param newLastname the lastname to set
121 public void setLastname(final String newLastname) {
122 lastname = newLastname;
130 public String getName() {
131 return name != null ? name : firstname + " " + lastname;
137 * @param newName the name to set
139 public void setName(final String newName) {
144 * Retrieve the email.
148 public String getEmail() {
155 * @param newEmail the email to set
157 public void setEmail(final String newEmail) {
166 public String getCode() {
174 * @param aCode the code to set
176 public void setCode(String aCode) {
185 public Long getId() {
195 public User getUser() {
203 * @param aUser the user to set
205 public void setUser(User aUser) {
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());
218 public int hashCode() {
219 return 37 * code.hashCode() + getName().hashCode();