]> git.mxchange.org Git - jcustomer-core.git/commitdiff
JPA started
authorRoland Haeder <roland@mxchange.org>
Tue, 22 Sep 2015 14:06:15 +0000 (16:06 +0200)
committerRoland Haeder <roland@mxchange.org>
Tue, 22 Sep 2015 14:06:15 +0000 (16:06 +0200)
Signed-off-by:Roland Häder <roland@mxchange.org>

lib/jcore.jar
lib/jcoreee.jar
src/org/mxchange/jshopcore/exceptions/CustomerAlreadyRegisteredException.java
src/org/mxchange/jshopcore/model/customer/Customer.java
src/org/mxchange/jshopcore/model/customer/ShopCustomer.java
src/org/mxchange/jshopcore/model/order/Orderable.java [new file with mode: 0644]
src/org/mxchange/jshopcore/model/order/ShopOrder.java [new file with mode: 0644]

index 12190beef63bed67f80a91b64eeee71aede608fc..ead5916a21197864b7915b3c83d96c971ff478c8 100644 (file)
Binary files a/lib/jcore.jar and b/lib/jcore.jar differ
index e0c8236ae42db2dfedabf0bad7bbb814ce166491..93d401de39c53a2d93aaa31e42cad7b2ccac7bb9 100644 (file)
Binary files a/lib/jcoreee.jar and b/lib/jcoreee.jar differ
index ae77abe531200d91cbd548e3a6c2005faf8d457d..eb93d4912c7f386fd018bc9b892b68f1e23b9304 100644 (file)
@@ -37,6 +37,6 @@ public class CustomerAlreadyRegisteredException extends Exception {
         */
        public CustomerAlreadyRegisteredException (final Customer customer) {
                // Call super contructor
-               super(MessageFormat.format("Customer {0} already registered with number {1} at record id {2}. Maybe forgot to call isRegistered(customer) ?", customer, customer.getCustomerNumber(), customer.getId()));
+               super(MessageFormat.format("Customer {0} already registered with number {1} at record id {2}. Maybe forgot to call isRegistered(customer) ?", customer, customer.getCustomerNumber(), customer.getCustomerId()));
        }
 }
index 792d639e37f24be2d0b21d409cf5428bcab95a51..d3a16206aabd496ea5f76e903f7763cfadf02028 100644 (file)
@@ -123,4 +123,18 @@ public interface Customer extends Contact {
         * @param customerStatus Account status
         */
        public void setCustomerStatus (final String customerStatus);
+
+       /**
+        * Getter for customer id number
+        *
+        * @return Customer id number
+        */
+       public Long getCustomerId ();
+
+       /**
+        * Settte for customer id number
+        *
+        * @param customerId Customer id number
+        */
+       public void setCustomerId (final Long customerId);
 }
index 509c06cc1ee5d285ff39c15cd89eaa7988355816..9b8331bfd563bfc623b2cc9c9057d9c1424612e4 100644 (file)
 package org.mxchange.jshopcore.model.customer;
 
 import java.sql.Timestamp;
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.OneToOne;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
 import org.mxchange.jcore.model.contact.BaseContact;
 
 /**
@@ -24,45 +35,68 @@ import org.mxchange.jcore.model.contact.BaseContact;
  *
  * @author Roland Haeder<roland@mxchange.org>
  */
+@Entity (name = "Customer")
+@Table (name = "customer")
 public class ShopCustomer extends BaseContact implements Customer {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 4_328_454_581_751L;
+
        /**
-        * Id number from "contact" table
+        * 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)
        private long contactId;
 
        /**
         * Confirmation key
         */
+       @Column (name = "customer_confirm_key", length = 50)
        private String customerConfirmKey;
 
        /**
         * "created" timestamp
         */
+       @Basic(optional = false)
+       @Temporal (TemporalType.TIMESTAMP)
+       @Column (name = "customer_created", nullable = false)
        private Timestamp customerCreated;
 
        /**
         * "locked" timestamp
         */
+       @Temporal (TemporalType.TIMESTAMP)
+       @Column (name = "customer_locked")
        private Timestamp customerLocked;
 
        /**
-        * Customer number, this is different to the database entry id.
+        * Customer number, this is different to the database entry customerId.
         */
+       @Column (name = "customer_number", nullable = false, length = 20)
        private String customerNumber;
 
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 4_328_454_581_751L;
-
        /**
         * Password hash
         */
+       @Column (name = "customer_password_hash")
        private String customerPasswordHash;
 
        /**
         * Account status
         */
+       @Column (name = "customer_status", nullable = false)
        private String customerStatus;
 
        @Override
@@ -134,4 +168,14 @@ public class ShopCustomer extends BaseContact implements Customer {
        public void setCustomerStatus (final String customerStatus) {
                this.customerStatus = customerStatus;
        }
+
+       @Override
+       public Long getCustomerId () {
+               return this.customerId;
+       }
+
+       @Override
+       public void setCustomerId (final Long customerId) {
+               this.customerId = customerId;
+       }
 }
diff --git a/src/org/mxchange/jshopcore/model/order/Orderable.java b/src/org/mxchange/jshopcore/model/order/Orderable.java
new file mode 100644 (file)
index 0000000..93f75ff
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2015 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jshopcore.model.order;
+
+import java.io.Serializable;
+import java.sql.Timestamp;
+
+/**
+ * An interface for customer orders
+ *
+ * @author Roland Haeder
+ */
+public interface Orderable extends Serializable {
+
+       /**
+        * Getter for order id
+        *
+        * @return Order id
+        */
+       public Long getId ();
+
+       /**
+        * Setter for order id
+        *
+        * @param id Order id
+        */
+       public void setId (final Long id);
+
+       /**
+        * Getter for customer id
+        *
+        * @return Customer id
+        */
+       public Long getCustomerId ();
+
+       /**
+        * Setter for customer id
+        *
+        * @param customerId Customer id
+        */
+       public void setCustomerId (final Long customerId);
+
+       /**
+        * Getter for created timestamp
+        *
+        * @return Created timestamp
+        */
+       public Timestamp getCreated ();
+
+       /**
+        * Setter for created timestamp
+        *
+        * @param created Created timestamp
+        */
+       public void setCreated (final Timestamp created);
+}
diff --git a/src/org/mxchange/jshopcore/model/order/ShopOrder.java b/src/org/mxchange/jshopcore/model/order/ShopOrder.java
new file mode 100644 (file)
index 0000000..65361ee
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2015 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jshopcore.model.order;
+
+import java.sql.Timestamp;
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+/**
+ * An entity class for shop orders
+ *
+ * @author Roland Haeder
+ */
+@Entity (name = "Orders")
+@Table (name = "orders")
+public class ShopOrder implements Orderable {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 19_728_938_459_834L;
+
+       /**
+        * Order id
+        */
+       @Id
+       @GeneratedValue (strategy = GenerationType.IDENTITY)
+       private Long id;
+
+       /**
+        * Customer id
+        */
+       @Basic (optional = false)
+       @Column (name = "customer_id", length = 20, nullable = false)
+       private Long customerId;
+
+       /**
+        * Access key
+        */
+       @Basic (optional = false)
+       @Column (name = "access_key", length = 100, nullable = false, unique = true)
+       private String accessKey;
+
+       /**
+        * Created timestamp
+        */
+       @Basic (optional = false)
+       @Temporal (TemporalType.TIMESTAMP)
+       @Column (nullable = false)
+       private Timestamp created;
+
+       @Override
+       public Timestamp getCreated () {
+               return this.created;
+       }
+
+       @Override
+       public void setCreated (final Timestamp created) {
+               this.created = created;
+       }
+
+       @Override
+       public Long getCustomerId () {
+               return this.customerId;
+       }
+
+       @Override
+       public void setCustomerId (final Long customerId) {
+               this.customerId = customerId;
+       }
+
+       @Override
+       public Long getId () {
+               return this.id;
+       }
+
+       @Override
+       public void setId (final Long id) {
+               this.id = id;
+       }
+}