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.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;
36 * A shop customer class.
38 * @author Roland Haeder<roland@mxchange.org>
40 @Entity (name = "customer")
41 @Table (name = "customer")
42 public class ShopCustomer implements Customer {
47 private static final long serialVersionUID = 4_328_454_581_751L;
50 * Id number from "contacts" table
52 @JoinColumn (name = "contact_id", nullable = false, updatable = false, unique = true)
53 @OneToOne (optional = false, targetEntity = UserContact.class)
54 private Contact contact;
59 @Column (name = "customer_confirm_key", length = 50)
60 private String customerConfirmKey;
65 @Basic (optional = false)
66 @Temporal (TemporalType.TIMESTAMP)
67 @Column (name = "customer_created", nullable = false)
68 private Calendar customerCreated;
74 @Column (name = "customer_id", nullable = false, length = 20, updatable = false)
75 @GeneratedValue (strategy = GenerationType.IDENTITY)
76 private Long customerId;
81 @Temporal (TemporalType.TIMESTAMP)
82 @Column (name = "customer_locked")
83 private Calendar customerLocked;
86 * Customer number, this is different to the database entry customerId.
88 @Column (name = "customer_number", nullable = false, length = 20)
89 private String customerNumber;
94 @Column (name = "customer_password_hash")
95 private String customerPasswordHash;
100 @Basic (optional = false)
101 @Column (name = "customer_account_status", nullable = false)
102 private CustomerAccountStatus customerAccountStatus;
105 * Default constructor
107 public ShopCustomer () {
111 public void copyAll (final Customer customer) {
112 // Copy also contact data
113 this.getContact().copyAll(customer.getContact());
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());
125 public Contact getContact () {
130 public void setContact (final Contact contact) {
131 this.contact = contact;
135 public String getCustomerConfirmKey () {
136 return this.customerConfirmKey;
140 public void setCustomerConfirmKey (final String customerConfirmKey) {
141 this.customerConfirmKey = customerConfirmKey;
145 public Calendar getCustomerCreated () {
146 return this.customerCreated;
150 public void setCustomerCreated (final Calendar customerCreated) {
151 this.customerCreated = customerCreated;
155 public Long getCustomerId () {
156 return this.customerId;
160 public void setCustomerId (final Long customerId) {
161 this.customerId = customerId;
165 public Calendar getCustomerLocked () {
166 return this.customerLocked;
170 public void setCustomerLocked (final Calendar customerLocked) {
171 this.customerLocked = customerLocked;
175 public String getCustomerNumber () {
176 return this.customerNumber;
180 public void setCustomerNumber (final String customerNumber) {
181 this.customerNumber = customerNumber;
185 public String getCustomerPasswordHash () {
186 return this.customerPasswordHash;
190 public void setCustomerPasswordHash (final String customerPasswordHash) {
191 this.customerPasswordHash = customerPasswordHash;
195 public CustomerAccountStatus getCustomerAccountStatus () {
196 return this.customerAccountStatus;
200 public void setCustomerAccountStatus (final CustomerAccountStatus customerAccountStatus) {
201 this.customerAccountStatus = customerAccountStatus;