]> git.mxchange.org Git - jshop-core.git/blobdiff - src/org/mxchange/jshopcore/model/customer/ShopCustomer.java
added missing javadoc + updated jars
[jshop-core.git] / src / org / mxchange / jshopcore / model / customer / ShopCustomer.java
index 42811374a2be73cc0f4a8c40ae1861634f6915e1..606f633d4e2ff3d1e24e8042e79e0c5ab4af28f0 100644 (file)
@@ -20,6 +20,8 @@ import java.util.Calendar;
 import javax.persistence.Basic;
 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;
@@ -28,15 +30,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.jcore.model.contact.UserContact;
+import org.mxchange.jshopcore.model.customer.status.CustomerAccountStatus;
 
 /**
  * A shop customer class.
  *
  * @author Roland Haeder<roland@mxchange.org>
  */
-@Entity (name = "Customer")
+@Entity (name = "customer")
 @Table (name = "customer")
 public class ShopCustomer implements Customer {
 
@@ -45,19 +48,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", referencedColumnName = "customer_contact_id", name = "id", nullable = false, updatable = false, unique = true)
-       @OneToOne (optional = false, targetEntity = BaseContact.class, orphanRemoval = true)
+       @JoinColumn (name = "contact_id", nullable = false, updatable = false, unique = true)
+       @OneToOne (targetEntity = UserContact.class, optional = false)
        private Contact contact;
 
        /**
@@ -69,11 +64,19 @@ public class ShopCustomer implements Customer {
        /**
         * "created" timestamp
         */
-       @Basic(optional = false)
+       @Basic (optional = false)
        @Temporal (TemporalType.TIMESTAMP)
        @Column (name = "customer_created", nullable = false)
        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
         */
@@ -96,8 +99,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 +119,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());
        }
@@ -143,6 +154,16 @@ public class ShopCustomer implements Customer {
                this.customerCreated = customerCreated;
        }
 
+       @Override
+       public Long getCustomerId () {
+               return this.customerId;
+       }
+
+       @Override
+       public void setCustomerId (final Long customerId) {
+               this.customerId = customerId;
+       }
+
        @Override
        public Calendar getCustomerLocked () {
                return this.customerLocked;
@@ -174,22 +195,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;
        }
 }