]> git.mxchange.org Git - juser-core.git/blob - src/org/mxchange/jusercore/model/user/LoginUser.java
initial import (from jshop-core)
[juser-core.git] / src / org / mxchange / jusercore / model / user / LoginUser.java
1 /*
2  * Copyright (C) 2015 Roland Haeder
3  *
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.
8  *
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.
13  *
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/>.
16  */
17 package org.mxchange.jusercore.model.user;
18
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;
36
37 /**
38  * A shop customer class.
39  * <p>
40  * @author Roland Haeder<roland@mxchange.org>
41  */
42 @Entity (name = "user")
43 @Table (name = "user")
44 public class LoginUser implements User {
45
46         /**
47          * Serial number
48          */
49         private static final long serialVersionUID = 4_328_454_581_751L;
50
51         /**
52          * Id number from "contacts" table
53          */
54         @JoinColumn (name = "contact_id", nullable = false, updatable = false, unique = true)
55         @OneToOne (targetEntity = UserContact.class, optional = false)
56         private Contact contact;
57
58         /**
59          * Confirmation key
60          */
61         @Column (name = "user_confirm_key", length = 50)
62         private String userConfirmKey;
63
64         /**
65          * "created" timestamp
66          */
67         @Basic (optional = false)
68         @Temporal (TemporalType.TIMESTAMP)
69         @Column (name = "user_created", nullable = false)
70         private Calendar userCreated;
71
72         /**
73          * User id
74          */
75         @Id
76         @Column (name = "user_id", nullable = false, length = 20, updatable = false)
77         @GeneratedValue (strategy = GenerationType.IDENTITY)
78         private Long userId;
79
80         /**
81          * "locked" timestamp
82          */
83         @Temporal (TemporalType.TIMESTAMP)
84         @Column (name = "user_locked")
85         private Calendar userLocked;
86
87         /**
88          * User name
89          */
90         @Column (name = "user_name", nullable = false, length = 20)
91         private String userName;
92
93         /**
94          * Password hash
95          */
96         @Column (name = "user_password_hash")
97         private String userPasswordHash;
98
99         /**
100          * Account status
101          */
102         @Basic (optional = false)
103         @Column (name = "user_account_status", nullable = false)
104         @Enumerated (EnumType.STRING)
105         private UserAccountStatus userAccountStatus;
106
107         /**
108          * Default constructor
109          */
110         public LoginUser () {
111         }
112
113         @Override
114         public void copyAll (final User user) {
115                 // Copy also contact data
116                 this.getContact().copyAll(user.getContact());
117
118                 // Copy other data
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());
125         }
126
127         @Override
128         public Contact getContact () {
129                 return this.contact;
130         }
131
132         @Override
133         public void setContact (final Contact contact) {
134                 this.contact = contact;
135         }
136
137         @Override
138         public String getUserConfirmKey () {
139                 return this.userConfirmKey;
140         }
141
142         @Override
143         public void setUserConfirmKey (final String customerConfirmKey) {
144                 this.userConfirmKey = customerConfirmKey;
145         }
146
147         @Override
148         public Calendar getUserCreated () {
149                 return this.userCreated;
150         }
151
152         @Override
153         public void setUserCreated (final Calendar userCreated) {
154                 this.userCreated = userCreated;
155         }
156
157         @Override
158         public Long getUserId () {
159                 return this.userId;
160         }
161
162         @Override
163         public void setUserId (final Long userId) {
164                 this.userId = userId;
165         }
166
167         @Override
168         public Calendar getUserLocked () {
169                 return this.userLocked;
170         }
171
172         @Override
173         public void setUserLocked (final Calendar userLocked) {
174                 this.userLocked = userLocked;
175         }
176
177         @Override
178         public String getUserName () {
179                 return this.userName;
180         }
181
182         @Override
183         public void setUserName (final String userName) {
184                 this.userName = userName;
185         }
186
187         @Override
188         public String getUserPasswordHash () {
189                 return this.userPasswordHash;
190         }
191
192         @Override
193         public void setUserPasswordHash (final String userPasswordHash) {
194                 this.userPasswordHash = userPasswordHash;
195         }
196
197         @Override
198         public UserAccountStatus getUserAccountStatus () {
199                 return this.userAccountStatus;
200         }
201
202         @Override
203         public void setUserAccountStatus (final UserAccountStatus userAccountStatus) {
204                 this.userAccountStatus = userAccountStatus;
205         }
206 }