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 = "user")
43 @Table (name = "user")
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 contact;
61 @Column (name = "user_confirm_key", length = 50)
62 private String userConfirmKey;
67 @Basic (optional = false)
68 @Temporal (TemporalType.TIMESTAMP)
69 @Column (name = "user_created", nullable = false)
70 private Calendar userCreated;
76 @Column (name = "user_id", nullable = false, length = 20, updatable = false)
77 @GeneratedValue (strategy = GenerationType.IDENTITY)
83 @Temporal (TemporalType.TIMESTAMP)
84 @Column (name = "user_locked")
85 private Calendar userLocked;
90 @Column (name = "user_name", nullable = false, length = 20)
91 private String userName;
96 @Column (name = "user_password_hash")
97 private String userPasswordHash;
102 @Basic (optional = false)
103 @Column (name = "user_account_status", nullable = false)
104 @Enumerated (EnumType.STRING)
105 private UserAccountStatus userAccountStatus;
108 * Default constructor
110 public LoginUser () {
114 public void copyAll (final User user) {
115 // Copy also contact data
116 this.getContact().copyAll(user.getContact());
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 getContact () {
133 public void setContact (final Contact contact) {
134 this.contact = contact;
138 public String getUserConfirmKey () {
139 return this.userConfirmKey;
143 public void setUserConfirmKey (final String customerConfirmKey) {
144 this.userConfirmKey = customerConfirmKey;
148 public Calendar getUserCreated () {
149 return this.userCreated;
153 public void setUserCreated (final Calendar userCreated) {
154 this.userCreated = userCreated;
158 public Long getUserId () {
163 public void setUserId (final Long userId) {
164 this.userId = userId;
168 public Calendar getUserLocked () {
169 return this.userLocked;
173 public void setUserLocked (final Calendar userLocked) {
174 this.userLocked = userLocked;
178 public String getUserName () {
179 return this.userName;
183 public void setUserName (final String userName) {
184 this.userName = userName;
188 public String getUserPasswordHash () {
189 return this.userPasswordHash;
193 public void setUserPasswordHash (final String userPasswordHash) {
194 this.userPasswordHash = userPasswordHash;
198 public UserAccountStatus getUserAccountStatus () {
199 return this.userAccountStatus;
203 public void setUserAccountStatus (final UserAccountStatus userAccountStatus) {
204 this.userAccountStatus = userAccountStatus;