]> git.mxchange.org Git - jcustomer-core.git/blob - src/org/mxchange/jshopcore/model/customer/ShopCustomer.java
3ea4c9c9c000a052458c53907f257b3b7c3d6c13
[jcustomer-core.git] / src / org / mxchange / jshopcore / model / customer / ShopCustomer.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.jshopcore.model.customer;
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.GeneratedValue;
24 import javax.persistence.GenerationType;
25 import javax.persistence.Id;
26 import javax.persistence.JoinColumn;
27 import javax.persistence.OneToOne;
28 import javax.persistence.Table;
29 import javax.persistence.Temporal;
30 import javax.persistence.TemporalType;
31 import org.mxchange.jcore.model.contact.Contact;
32 import org.mxchange.jcore.model.contact.UserContact;
33 import org.mxchange.jshopcore.model.customer.status.CustomerAccountStatus;
34
35 /**
36  * A shop customer class.
37  *
38  * @author Roland Haeder<roland@mxchange.org>
39  */
40 @Entity (name = "customer")
41 @Table (name = "customer")
42 public class ShopCustomer implements Customer {
43
44         /**
45          * Serial number
46          */
47         private static final long serialVersionUID = 4_328_454_581_751L;
48
49         /**
50          * Id number from "contacts" table
51          */
52         @JoinColumn (name = "contact_id", nullable = false, updatable = false, unique = true)
53         @OneToOne (optional = false, targetEntity = UserContact.class)
54         private Contact contact;
55
56         /**
57          * Confirmation key
58          */
59         @Column (name = "customer_confirm_key", length = 50)
60         private String customerConfirmKey;
61
62         /**
63          * "created" timestamp
64          */
65         @Basic (optional = false)
66         @Temporal (TemporalType.TIMESTAMP)
67         @Column (name = "customer_created", nullable = false)
68         private Calendar customerCreated;
69
70         /**
71          * Customer id
72          */
73         @Id
74         @Column (name = "customer_id", nullable = false, length = 20, updatable = false)
75         @GeneratedValue (strategy = GenerationType.IDENTITY)
76         private Long customerId;
77
78         /**
79          * "locked" timestamp
80          */
81         @Temporal (TemporalType.TIMESTAMP)
82         @Column (name = "customer_locked")
83         private Calendar customerLocked;
84
85         /**
86          * Customer number, this is different to the database entry customerId.
87          */
88         @Column (name = "customer_number", nullable = false, length = 20)
89         private String customerNumber;
90
91         /**
92          * Password hash
93          */
94         @Column (name = "customer_password_hash")
95         private String customerPasswordHash;
96
97         /**
98          * Account status
99          */
100         @Basic (optional = false)
101         @Column (name = "customer_account_status", nullable = false)
102         private CustomerAccountStatus customerAccountStatus;
103
104         /**
105          * Default constructor
106          */
107         public ShopCustomer () {
108         }
109
110         @Override
111         public void copyAll (final Customer customer) {
112                 // Copy also contact data
113                 this.getContact().copyAll(customer.getContact());
114
115                 // Copy other data
116                 this.setCustomerConfirmKey(customer.getCustomerConfirmKey());
117                 this.setCustomerNumber(customer.getCustomerNumber());
118                 this.setCustomerPasswordHash(customer.getCustomerPasswordHash());
119                 this.setCustomerAccountStatus(customer.getCustomerAccountStatus());
120                 this.setCustomerCreated(customer.getCustomerCreated());
121                 this.setCustomerLocked(customer.getCustomerLocked());
122         }
123
124         @Override
125         public Contact getContact () {
126                 return this.contact;
127         }
128
129         @Override
130         public void setContact (final Contact contact) {
131                 this.contact = contact;
132         }
133
134         @Override
135         public String getCustomerConfirmKey () {
136                 return this.customerConfirmKey;
137         }
138
139         @Override
140         public void setCustomerConfirmKey (final String customerConfirmKey) {
141                 this.customerConfirmKey = customerConfirmKey;
142         }
143
144         @Override
145         public Calendar getCustomerCreated () {
146                 return this.customerCreated;
147         }
148
149         @Override
150         public void setCustomerCreated (final Calendar customerCreated) {
151                 this.customerCreated = customerCreated;
152         }
153
154         @Override
155         public Long getCustomerId () {
156                 return this.customerId;
157         }
158
159         @Override
160         public void setCustomerId (final Long customerId) {
161                 this.customerId = customerId;
162         }
163
164         @Override
165         public Calendar getCustomerLocked () {
166                 return this.customerLocked;
167         }
168
169         @Override
170         public void setCustomerLocked (final Calendar customerLocked) {
171                 this.customerLocked = customerLocked;
172         }
173
174         @Override
175         public String getCustomerNumber () {
176                 return this.customerNumber;
177         }
178
179         @Override
180         public void setCustomerNumber (final String customerNumber) {
181                 this.customerNumber = customerNumber;
182         }
183
184         @Override
185         public String getCustomerPasswordHash () {
186                 return this.customerPasswordHash;
187         }
188
189         @Override
190         public void setCustomerPasswordHash (final String customerPasswordHash) {
191                 this.customerPasswordHash = customerPasswordHash;
192         }
193
194         @Override
195         public CustomerAccountStatus getCustomerAccountStatus () {
196                 return this.customerAccountStatus;
197         }
198
199         @Override
200         public void setCustomerAccountStatus (final CustomerAccountStatus customerAccountStatus) {
201                 this.customerAccountStatus = customerAccountStatus;
202         }
203 }