]> git.mxchange.org Git - jshop-core.git/blobdiff - src/org/mxchange/jshopcore/model/customer/ShopCustomer.java
Dont't miss _timestamp prefix + updated jar(s)
[jshop-core.git] / src / org / mxchange / jshopcore / model / customer / ShopCustomer.java
index 954988a8fb41d1bf368a01f1bc93676336103a10..5d72ed056f662786324030edd1d9beb5ce216421 100644 (file)
  */
 package org.mxchange.jshopcore.model.customer;
 
+import java.util.Calendar;
 import javax.persistence.Basic;
+import javax.persistence.CascadeType;
 import javax.persistence.Column;
 import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
 import javax.persistence.GeneratedValue;
 import javax.persistence.GenerationType;
 import javax.persistence.Id;
@@ -27,15 +31,16 @@ import javax.persistence.OneToOne;
 import javax.persistence.Table;
 import javax.persistence.Temporal;
 import javax.persistence.TemporalType;
-import org.mxchange.jcore.model.contact.BaseContact;
-import org.mxchange.jcore.model.contact.Contact;
+import org.mxchange.jcontacts.contact.Contact;
+import org.mxchange.jcontacts.contact.UserContact;
+import org.mxchange.jshopcore.model.customer.status.CustomerAccountStatus;
 
 /**
  * A shop customer class.
- *
+ * <p>
  * @author Roland Haeder<roland@mxchange.org>
  */
-@Entity (name = "Customer")
+@Entity (name = "customer")
 @Table (name = "customer")
 public class ShopCustomer implements Customer {
 
@@ -44,20 +49,11 @@ public class ShopCustomer implements Customer {
         */
        private static final long serialVersionUID = 4_328_454_581_751L;
 
-       /**
-        * Customer id
-        */
-       @Id
-       @Column (name = "id", nullable = false, length = 20)
-       @GeneratedValue(strategy = GenerationType.IDENTITY)
-       private Long customerId;
-
        /**
         * Id number from "contacts" table
         */
-       @JoinColumn (table = "contacts", unique = true)
-       @OneToOne (optional = false, targetEntity = BaseContact.class, orphanRemoval = true)
-       @Column (name = "customer_contact_id", nullable = false, length = 20)
+       @JoinColumn (name = "contact_id", nullable = false, updatable = false, unique = true)
+       @OneToOne (targetEntity = UserContact.class, cascade = CascadeType.ALL, optional = false)
        private Contact contact;
 
        /**
@@ -69,17 +65,25 @@ public class ShopCustomer implements Customer {
        /**
         * "created" timestamp
         */
-       @Basic(optional = false)
+       @Basic (optional = false)
        @Temporal (TemporalType.TIMESTAMP)
        @Column (name = "customer_created", nullable = false)
-       private String customerCreated;
+       private Calendar customerCreated;
+
+       /**
+        * Customer id
+        */
+       @Id
+       @Column (name = "customer_id", nullable = false, length = 20, updatable = false)
+       @GeneratedValue (strategy = GenerationType.IDENTITY)
+       private Long customerId;
 
        /**
         * "locked" timestamp
         */
        @Temporal (TemporalType.TIMESTAMP)
-       @Column (name = "customer_locked")
-       private String customerLocked;
+       @Column (name = "customer_locked_timestamp")
+       private Calendar customerLocked;
 
        /**
         * Customer number, this is different to the database entry customerId.
@@ -96,8 +100,16 @@ public class ShopCustomer implements Customer {
        /**
         * Account status
         */
-       @Column (name = "customer_status", nullable = false)
-       private String customerStatus;
+       @Basic (optional = false)
+       @Column (name = "customer_account_status", nullable = false)
+       @Enumerated (EnumType.STRING)
+       private CustomerAccountStatus customerAccountStatus;
+
+       /**
+        * Default constructor
+        */
+       public ShopCustomer () {
+       }
 
        @Override
        public void copyAll (final Customer customer) {
@@ -108,7 +120,7 @@ public class ShopCustomer implements Customer {
                this.setCustomerConfirmKey(customer.getCustomerConfirmKey());
                this.setCustomerNumber(customer.getCustomerNumber());
                this.setCustomerPasswordHash(customer.getCustomerPasswordHash());
-               this.setCustomerStatus(customer.getCustomerStatus());
+               this.setCustomerAccountStatus(customer.getCustomerAccountStatus());
                this.setCustomerCreated(customer.getCustomerCreated());
                this.setCustomerLocked(customer.getCustomerLocked());
        }
@@ -134,22 +146,32 @@ public class ShopCustomer implements Customer {
        }
 
        @Override
-       public String getCustomerCreated () {
+       public Calendar getCustomerCreated () {
                return this.customerCreated;
        }
 
        @Override
-       public void setCustomerCreated (final String customerCreated) {
+       public void setCustomerCreated (final Calendar customerCreated) {
                this.customerCreated = customerCreated;
        }
 
        @Override
-       public String getCustomerLocked () {
+       public Long getCustomerId () {
+               return this.customerId;
+       }
+
+       @Override
+       public void setCustomerId (final Long customerId) {
+               this.customerId = customerId;
+       }
+
+       @Override
+       public Calendar getCustomerLocked () {
                return this.customerLocked;
        }
 
        @Override
-       public void setCustomerLocked (final String customerLocked) {
+       public void setCustomerLocked (final Calendar customerLocked) {
                this.customerLocked = customerLocked;
        }
 
@@ -174,22 +196,12 @@ public class ShopCustomer implements Customer {
        }
 
        @Override
-       public String getCustomerStatus () {
-               return this.customerStatus;
-       }
-
-       @Override
-       public void setCustomerStatus (final String customerStatus) {
-               this.customerStatus = customerStatus;
+       public CustomerAccountStatus getCustomerAccountStatus () {
+               return this.customerAccountStatus;
        }
 
        @Override
-       public Long getCustomerId () {
-               return this.customerId;
-       }
-
-       @Override
-       public void setCustomerId (final Long customerId) {
-               this.customerId = customerId;
+       public void setCustomerAccountStatus (final CustomerAccountStatus customerAccountStatus) {
+               this.customerAccountStatus = customerAccountStatus;
        }
 }