]> git.mxchange.org Git - jcustomer-core.git/blob - src/org/mxchange/jshopcore/model/customer/ShopCustomer.java
Added dummy compareTo() (unimplemented, will follow) and Comparable<SomeInterface...
[jcustomer-core.git] / src / org / mxchange / jshopcore / model / customer / ShopCustomer.java
1 /*
2  * Copyright (C) 2016 Roland Haeder
3  *
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.
8  *
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.
13  *
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/>.
16  */
17 package org.mxchange.jshopcore.model.customer;
18
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;
37
38 /**
39  * A shop customer class.
40  * <p>
41  * @author Roland Haeder<roland@mxchange.org>
42  */
43 @Entity (name = "customer")
44 @Table (name = "customer")
45 public class ShopCustomer implements Customer, Comparable<Customer> {
46
47         /**
48          * Serial number
49          */
50         private static final long serialVersionUID = 4_328_454_581_751L;
51
52         /**
53          * Id number from "contacts" table
54          */
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;
58
59         /**
60          * Account status
61          */
62         @Basic (optional = false)
63         @Column (name = "customer_account_status", nullable = false)
64         @Enumerated (EnumType.STRING)
65         private CustomerAccountStatus customerAccountStatus;
66
67         /**
68          * Confirmation key
69          */
70         @Column (name = "customer_confirm_key", length = 50)
71         private String customerConfirmKey;
72
73         /**
74          * "created" timestamp
75          */
76         @Basic (optional = false)
77         @Temporal (TemporalType.TIMESTAMP)
78         @Column (name = "customer_created", nullable = false)
79         private Calendar customerCreated;
80
81         /**
82          * Customer id
83          */
84         @Id
85         @Column (name = "customer_id", nullable = false, length = 20, updatable = false)
86         @GeneratedValue (strategy = GenerationType.IDENTITY)
87         private Long customerId;
88
89         /**
90          * "locked" timestamp
91          */
92         @Temporal (TemporalType.TIMESTAMP)
93         @Column (name = "customer_locked_timestamp")
94         private Calendar customerLocked;
95
96         /**
97          * Customer number, this is different to the database entry customerId.
98          */
99         @Column (name = "customer_number", nullable = false, length = 20)
100         private String customerNumber;
101
102         /**
103          * Password hash
104          */
105         @Column (name = "customer_password_hash")
106         private String customerPasswordHash;
107
108         /**
109          * Default constructor
110          */
111         public ShopCustomer () {
112         }
113
114         @Override
115         public int compareTo (Customer customer) {
116                 throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
117         }
118
119         @Override
120         public void copyAll (final Customer customer) {
121                 // Copy also contact data
122                 this.getContact().copyAll(customer.getContact());
123
124                 // Copy other data
125                 this.setCustomerConfirmKey(customer.getCustomerConfirmKey());
126                 this.setCustomerNumber(customer.getCustomerNumber());
127                 this.setCustomerPasswordHash(customer.getCustomerPasswordHash());
128                 this.setCustomerAccountStatus(customer.getCustomerAccountStatus());
129                 this.setCustomerCreated(customer.getCustomerCreated());
130                 this.setCustomerLocked(customer.getCustomerLocked());
131         }
132
133         @Override
134         public Contact getContact () {
135                 return this.contact;
136         }
137
138         @Override
139         public void setContact (final Contact contact) {
140                 this.contact = contact;
141         }
142
143         @Override
144         public CustomerAccountStatus getCustomerAccountStatus () {
145                 return this.customerAccountStatus;
146         }
147
148         @Override
149         public void setCustomerAccountStatus (final CustomerAccountStatus customerAccountStatus) {
150                 this.customerAccountStatus = customerAccountStatus;
151         }
152
153         @Override
154         public String getCustomerConfirmKey () {
155                 return this.customerConfirmKey;
156         }
157
158         @Override
159         public void setCustomerConfirmKey (final String customerConfirmKey) {
160                 this.customerConfirmKey = customerConfirmKey;
161         }
162
163         @Override
164         public Calendar getCustomerCreated () {
165                 return this.customerCreated;
166         }
167
168         @Override
169         public void setCustomerCreated (final Calendar customerCreated) {
170                 this.customerCreated = customerCreated;
171         }
172
173         @Override
174         public Long getCustomerId () {
175                 return this.customerId;
176         }
177
178         @Override
179         public void setCustomerId (final Long customerId) {
180                 this.customerId = customerId;
181         }
182
183         @Override
184         public Calendar getCustomerLocked () {
185                 return this.customerLocked;
186         }
187
188         @Override
189         public void setCustomerLocked (final Calendar customerLocked) {
190                 this.customerLocked = customerLocked;
191         }
192
193         @Override
194         public String getCustomerNumber () {
195                 return this.customerNumber;
196         }
197
198         @Override
199         public void setCustomerNumber (final String customerNumber) {
200                 this.customerNumber = customerNumber;
201         }
202
203         @Override
204         public String getCustomerPasswordHash () {
205                 return this.customerPasswordHash;
206         }
207
208         @Override
209         public void setCustomerPasswordHash (final String customerPasswordHash) {
210                 this.customerPasswordHash = customerPasswordHash;
211         }
212
213 }