2 * Copyright (C) 2015 Roland Haeder
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 package org.mxchange.jusercore.model.user;
19 import java.util.Calendar;
20 import javax.persistence.Basic;
21 import javax.persistence.Column;
22 import javax.persistence.Entity;
23 import javax.persistence.EnumType;
24 import javax.persistence.Enumerated;
25 import javax.persistence.GeneratedValue;
26 import javax.persistence.GenerationType;
27 import javax.persistence.Id;
28 import javax.persistence.JoinColumn;
29 import javax.persistence.OneToOne;
30 import javax.persistence.Table;
31 import javax.persistence.Temporal;
32 import javax.persistence.TemporalType;
33 import org.mxchange.jcontacts.contact.Contact;
34 import org.mxchange.jcontacts.contact.UserContact;
35 import org.mxchange.jusercore.model.user.status.UserAccountStatus;
38 * A shop customer class.
40 * @author Roland Haeder<roland@mxchange.org>
42 @Entity (name = "users")
43 @Table (name = "users")
44 public class LoginUser implements User {
49 private static final long serialVersionUID = 4_328_454_581_751L;
52 * Id number from "contacts" table
54 @JoinColumn (name = "contact_id", nullable = false, updatable = false, unique = true)
55 @OneToOne (targetEntity = UserContact.class, optional = false)
56 private Contact userContact;
61 @Basic (optional = false)
62 @Column (name = "user_account_status", nullable = false)
63 @Enumerated (value = EnumType.STRING)
64 private UserAccountStatus userAccountStatus;
69 @Column (name = "user_confirm_key", length = 50)
70 private String userConfirmKey;
75 @Basic (optional = false)
76 @Temporal (TemporalType.TIMESTAMP)
77 @Column (name = "user_created", nullable = false)
78 private Calendar userCreated;
84 @Column (name = "user_id", nullable = false, length = 20, updatable = false)
85 @GeneratedValue (strategy = GenerationType.IDENTITY)
91 @Temporal (TemporalType.TIMESTAMP)
92 @Column (name = "user_locked")
93 private Calendar userLocked;
98 @Column (name = "user_name", nullable = false, length = 20)
99 private String userName;
104 @Column (name = "user_password_hash")
105 private String userPasswordHash;
108 * Default constructor
110 public LoginUser () {
114 public void copyAll (final User user) {
115 // Copy also contact data
116 this.getUserContact().copyAll(user.getUserContact());
119 this.setUserConfirmKey(user.getUserConfirmKey());
120 this.setUserName(user.getUserName());
121 this.setUserPasswordHash(user.getUserPasswordHash());
122 this.setUserAccountStatus(user.getUserAccountStatus());
123 this.setUserCreated(user.getUserCreated());
124 this.setUserLocked(user.getUserLocked());
128 public Contact getUserContact () {
129 return this.userContact;
133 public void setUserContact (final Contact userContact) {
134 this.userContact = userContact;
138 public UserAccountStatus getUserAccountStatus () {
139 return this.userAccountStatus;
143 public void setUserAccountStatus (final UserAccountStatus userAccountStatus) {
144 this.userAccountStatus = userAccountStatus;
148 public String getUserConfirmKey () {
149 return this.userConfirmKey;
153 public void setUserConfirmKey (final String customerConfirmKey) {
154 this.userConfirmKey = customerConfirmKey;
158 public Calendar getUserCreated () {
159 return this.userCreated;
163 public void setUserCreated (final Calendar userCreated) {
164 this.userCreated = userCreated;
168 public Long getUserId () {
173 public void setUserId (final Long userId) {
174 this.userId = userId;
178 public Calendar getUserLocked () {
179 return this.userLocked;
183 public void setUserLocked (final Calendar userLocked) {
184 this.userLocked = userLocked;
188 public String getUserName () {
189 return this.userName;
193 public void setUserName (final String userName) {
194 this.userName = userName;
198 public String getUserPasswordHash () {
199 return this.userPasswordHash;
203 public void setUserPasswordHash (final String userPasswordHash) {
204 this.userPasswordHash = userPasswordHash;