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.sql.Timestamp;
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.BaseContact;
32 import org.mxchange.jcore.model.contact.Contact;
35 * A shop customer class.
37 * @author Roland Haeder<roland@mxchange.org>
39 @Entity (name = "Customer")
40 @Table (name = "customer")
41 public class ShopCustomer implements Customer {
46 private static final long serialVersionUID = 4_328_454_581_751L;
52 @Column (name = "id", nullable = false, length = 20)
53 @GeneratedValue(strategy = GenerationType.IDENTITY)
54 private Long customerId;
57 * Id number from "contacts" table
59 @JoinColumn (table = "contacts", unique = true)
60 @OneToOne (optional = false, targetEntity = BaseContact.class, orphanRemoval = true)
61 @Column (name = "customer_contact_id", nullable = false, length = 20)
62 private Contact contact;
67 @Column (name = "customer_confirm_key", length = 50)
68 private String customerConfirmKey;
73 @Basic(optional = false)
74 @Temporal (TemporalType.TIMESTAMP)
75 @Column (name = "customer_created", nullable = false)
76 private Timestamp customerCreated;
81 @Temporal (TemporalType.TIMESTAMP)
82 @Column (name = "customer_locked")
83 private Timestamp 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 @Column (name = "customer_status", nullable = false)
101 private String customerStatus;
104 public void copyAll (final Customer customer) {
105 // Copy also contact data
106 this.getContact().copyAll(customer.getContact());
109 this.setCustomerConfirmKey(customer.getCustomerConfirmKey());
110 this.setCustomerNumber(customer.getCustomerNumber());
111 this.setCustomerPasswordHash(customer.getCustomerPasswordHash());
112 this.setCustomerStatus(customer.getCustomerStatus());
113 this.setCustomerCreated(customer.getCustomerCreated());
114 this.setCustomerLocked(customer.getCustomerLocked());
118 public Contact getContact () {
123 public void setContact (final Contact contact) {
124 this.contact = contact;
128 public String getCustomerConfirmKey () {
129 return this.customerConfirmKey;
133 public void setCustomerConfirmKey (final String customerConfirmKey) {
134 this.customerConfirmKey = customerConfirmKey;
138 public Timestamp getCustomerCreated () {
139 return this.customerCreated;
143 public void setCustomerCreated (final Timestamp customerCreated) {
144 this.customerCreated = customerCreated;
148 public Timestamp getCustomerLocked () {
149 return this.customerLocked;
153 public void setCustomerLocked (final Timestamp customerLocked) {
154 this.customerLocked = customerLocked;
158 public String getCustomerNumber () {
159 return this.customerNumber;
163 public void setCustomerNumber (final String customerNumber) {
164 this.customerNumber = customerNumber;
168 public String getCustomerPasswordHash () {
169 return this.customerPasswordHash;
173 public void setCustomerPasswordHash (final String customerPasswordHash) {
174 this.customerPasswordHash = customerPasswordHash;
178 public String getCustomerStatus () {
179 return this.customerStatus;
183 public void setCustomerStatus (final String customerStatus) {
184 this.customerStatus = customerStatus;
188 public Long getCustomerId () {
189 return this.customerId;
193 public void setCustomerId (final Long customerId) {
194 this.customerId = customerId;