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.CascadeType;
22 import javax.persistence.Column;
23 import javax.persistence.Entity;
24 import javax.persistence.EnumType;
25 import javax.persistence.Enumerated;
26 import javax.persistence.GeneratedValue;
27 import javax.persistence.GenerationType;
28 import javax.persistence.Id;
29 import javax.persistence.JoinColumn;
30 import javax.persistence.OneToOne;
31 import javax.persistence.Table;
32 import javax.persistence.Temporal;
33 import javax.persistence.TemporalType;
34 import org.mxchange.jcontacts.contact.Contact;
35 import org.mxchange.jcontacts.contact.UserContact;
36 import org.mxchange.jshopcore.model.customer.status.CustomerAccountStatus;
39 * A shop customer class.
41 * @author Roland Haeder<roland@mxchange.org>
43 @Entity (name = "customer")
44 @Table (name = "customer")
45 public class ShopCustomer implements Customer {
50 private static final long serialVersionUID = 4_328_454_581_751L;
53 * Id number from "contacts" table
55 @JoinColumn (name = "contact_id", nullable = false, updatable = false, unique = true)
56 @OneToOne (targetEntity = UserContact.class, cascade = CascadeType.ALL, optional = false)
57 private Contact contact;
62 @Column (name = "customer_confirm_key", length = 50)
63 private String customerConfirmKey;
68 @Basic (optional = false)
69 @Temporal (TemporalType.TIMESTAMP)
70 @Column (name = "customer_created", nullable = false)
71 private Calendar customerCreated;
77 @Column (name = "customer_id", nullable = false, length = 20, updatable = false)
78 @GeneratedValue (strategy = GenerationType.IDENTITY)
79 private Long customerId;
84 @Temporal (TemporalType.TIMESTAMP)
85 @Column (name = "customer_locked_timestamp")
86 private Calendar customerLocked;
89 * Customer number, this is different to the database entry customerId.
91 @Column (name = "customer_number", nullable = false, length = 20)
92 private String customerNumber;
97 @Column (name = "customer_password_hash")
98 private String customerPasswordHash;
103 @Basic (optional = false)
104 @Column (name = "customer_account_status", nullable = false)
105 @Enumerated (EnumType.STRING)
106 private CustomerAccountStatus customerAccountStatus;
109 * Default constructor
111 public ShopCustomer () {
115 public void copyAll (final Customer customer) {
116 // Copy also contact data
117 this.getContact().copyAll(customer.getContact());
120 this.setCustomerConfirmKey(customer.getCustomerConfirmKey());
121 this.setCustomerNumber(customer.getCustomerNumber());
122 this.setCustomerPasswordHash(customer.getCustomerPasswordHash());
123 this.setCustomerAccountStatus(customer.getCustomerAccountStatus());
124 this.setCustomerCreated(customer.getCustomerCreated());
125 this.setCustomerLocked(customer.getCustomerLocked());
129 public Contact getContact () {
134 public void setContact (final Contact contact) {
135 this.contact = contact;
139 public String getCustomerConfirmKey () {
140 return this.customerConfirmKey;
144 public void setCustomerConfirmKey (final String customerConfirmKey) {
145 this.customerConfirmKey = customerConfirmKey;
149 public Calendar getCustomerCreated () {
150 return this.customerCreated;
154 public void setCustomerCreated (final Calendar customerCreated) {
155 this.customerCreated = customerCreated;
159 public Long getCustomerId () {
160 return this.customerId;
164 public void setCustomerId (final Long customerId) {
165 this.customerId = customerId;
169 public Calendar getCustomerLocked () {
170 return this.customerLocked;
174 public void setCustomerLocked (final Calendar customerLocked) {
175 this.customerLocked = customerLocked;
179 public String getCustomerNumber () {
180 return this.customerNumber;
184 public void setCustomerNumber (final String customerNumber) {
185 this.customerNumber = customerNumber;
189 public String getCustomerPasswordHash () {
190 return this.customerPasswordHash;
194 public void setCustomerPasswordHash (final String customerPasswordHash) {
195 this.customerPasswordHash = customerPasswordHash;
199 public CustomerAccountStatus getCustomerAccountStatus () {
200 return this.customerAccountStatus;
204 public void setCustomerAccountStatus (final CustomerAccountStatus customerAccountStatus) {
205 this.customerAccountStatus = customerAccountStatus;