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.jshopcore.model.customer;
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.jcore.model.contact.Contact;
34 import org.mxchange.jcore.model.contact.UserContact;
35 import org.mxchange.jshopcore.model.customer.status.CustomerAccountStatus;
38 * A shop customer class.
40 * @author Roland Haeder<roland@mxchange.org>
42 @Entity (name = "customer")
43 @Table (name = "customer")
44 public class ShopCustomer implements Customer {
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 (optional = false, targetEntity = UserContact.class)
56 private Contact contact;
61 @Column (name = "customer_confirm_key", length = 50)
62 private String customerConfirmKey;
67 @Basic (optional = false)
68 @Temporal (TemporalType.TIMESTAMP)
69 @Column (name = "customer_created", nullable = false)
70 private Calendar customerCreated;
76 @Column (name = "customer_id", nullable = false, length = 20, updatable = false)
77 @GeneratedValue (strategy = GenerationType.IDENTITY)
78 private Long customerId;
83 @Temporal (TemporalType.TIMESTAMP)
84 @Column (name = "customer_locked")
85 private Calendar customerLocked;
88 * Customer number, this is different to the database entry customerId.
90 @Column (name = "customer_number", nullable = false, length = 20)
91 private String customerNumber;
96 @Column (name = "customer_password_hash")
97 private String customerPasswordHash;
102 @Basic (optional = false)
103 @Column (name = "customer_account_status", nullable = false)
104 @Enumerated(EnumType.STRING)
105 private CustomerAccountStatus customerAccountStatus;
108 * Default constructor
110 public ShopCustomer () {
114 public void copyAll (final Customer customer) {
115 // Copy also contact data
116 this.getContact().copyAll(customer.getContact());
119 this.setCustomerConfirmKey(customer.getCustomerConfirmKey());
120 this.setCustomerNumber(customer.getCustomerNumber());
121 this.setCustomerPasswordHash(customer.getCustomerPasswordHash());
122 this.setCustomerAccountStatus(customer.getCustomerAccountStatus());
123 this.setCustomerCreated(customer.getCustomerCreated());
124 this.setCustomerLocked(customer.getCustomerLocked());
128 public Contact getContact () {
133 public void setContact (final Contact contact) {
134 this.contact = contact;
138 public String getCustomerConfirmKey () {
139 return this.customerConfirmKey;
143 public void setCustomerConfirmKey (final String customerConfirmKey) {
144 this.customerConfirmKey = customerConfirmKey;
148 public Calendar getCustomerCreated () {
149 return this.customerCreated;
153 public void setCustomerCreated (final Calendar customerCreated) {
154 this.customerCreated = customerCreated;
158 public Long getCustomerId () {
159 return this.customerId;
163 public void setCustomerId (final Long customerId) {
164 this.customerId = customerId;
168 public Calendar getCustomerLocked () {
169 return this.customerLocked;
173 public void setCustomerLocked (final Calendar customerLocked) {
174 this.customerLocked = customerLocked;
178 public String getCustomerNumber () {
179 return this.customerNumber;
183 public void setCustomerNumber (final String customerNumber) {
184 this.customerNumber = customerNumber;
188 public String getCustomerPasswordHash () {
189 return this.customerPasswordHash;
193 public void setCustomerPasswordHash (final String customerPasswordHash) {
194 this.customerPasswordHash = customerPasswordHash;
198 public CustomerAccountStatus getCustomerAccountStatus () {
199 return this.customerAccountStatus;
203 public void setCustomerAccountStatus (final CustomerAccountStatus customerAccountStatus) {
204 this.customerAccountStatus = customerAccountStatus;