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.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", referencedColumnName = "customer_contact_id", name = "id", nullable = false, updatable = false, unique = true)
60 @OneToOne (optional = false, targetEntity = BaseContact.class, orphanRemoval = true)
61 private Contact contact;
66 @Column (name = "customer_confirm_key", length = 50)
67 private String customerConfirmKey;
72 @Basic(optional = false)
73 @Temporal (TemporalType.TIMESTAMP)
74 @Column (name = "customer_created", nullable = false)
75 private Calendar customerCreated;
80 @Temporal (TemporalType.TIMESTAMP)
81 @Column (name = "customer_locked")
82 private Calendar customerLocked;
85 * Customer number, this is different to the database entry customerId.
87 @Column (name = "customer_number", nullable = false, length = 20)
88 private String customerNumber;
93 @Column (name = "customer_password_hash")
94 private String customerPasswordHash;
99 @Column (name = "customer_status", nullable = false)
100 private String customerStatus;
103 public void copyAll (final Customer customer) {
104 // Copy also contact data
105 this.getContact().copyAll(customer.getContact());
108 this.setCustomerConfirmKey(customer.getCustomerConfirmKey());
109 this.setCustomerNumber(customer.getCustomerNumber());
110 this.setCustomerPasswordHash(customer.getCustomerPasswordHash());
111 this.setCustomerStatus(customer.getCustomerStatus());
112 this.setCustomerCreated(customer.getCustomerCreated());
113 this.setCustomerLocked(customer.getCustomerLocked());
117 public Contact getContact () {
122 public void setContact (final Contact contact) {
123 this.contact = contact;
127 public String getCustomerConfirmKey () {
128 return this.customerConfirmKey;
132 public void setCustomerConfirmKey (final String customerConfirmKey) {
133 this.customerConfirmKey = customerConfirmKey;
137 public Calendar getCustomerCreated () {
138 return this.customerCreated;
142 public void setCustomerCreated (final Calendar customerCreated) {
143 this.customerCreated = customerCreated;
147 public Calendar getCustomerLocked () {
148 return this.customerLocked;
152 public void setCustomerLocked (final Calendar customerLocked) {
153 this.customerLocked = customerLocked;
157 public String getCustomerNumber () {
158 return this.customerNumber;
162 public void setCustomerNumber (final String customerNumber) {
163 this.customerNumber = customerNumber;
167 public String getCustomerPasswordHash () {
168 return this.customerPasswordHash;
172 public void setCustomerPasswordHash (final String customerPasswordHash) {
173 this.customerPasswordHash = customerPasswordHash;
177 public String getCustomerStatus () {
178 return this.customerStatus;
182 public void setCustomerStatus (final String customerStatus) {
183 this.customerStatus = customerStatus;
187 public Long getCustomerId () {
188 return this.customerId;
192 public void setCustomerId (final Long customerId) {
193 this.customerId = customerId;