From e3ec2da66bc09d08c0ad866c8476d8d00feee647 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Tue, 22 Sep 2015 16:06:15 +0200 Subject: [PATCH] =?utf8?q?JPA=20started=20Signed-off-by:Roland=20H=C3=A4de?= =?utf8?q?r=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- lib/jcore.jar | Bin 29624 -> 31130 bytes lib/jcoreee.jar | Bin 21332 -> 19254 bytes .../CustomerAlreadyRegisteredException.java | 2 +- .../jshopcore/model/customer/Customer.java | 14 +++ .../model/customer/ShopCustomer.java | 58 ++++++++-- .../jshopcore/model/order/Orderable.java | 70 ++++++++++++ .../jshopcore/model/order/ShopOrder.java | 102 ++++++++++++++++++ 7 files changed, 238 insertions(+), 8 deletions(-) create mode 100644 src/org/mxchange/jshopcore/model/order/Orderable.java create mode 100644 src/org/mxchange/jshopcore/model/order/ShopOrder.java diff --git a/lib/jcore.jar b/lib/jcore.jar index 12190beef63bed67f80a91b64eeee71aede608fc..ead5916a21197864b7915b3c83d96c971ff478c8 100644 GIT binary patch delta 7318 zcmb7J33yc16+U-nk~f)|>>Ei4NgyG~1PNPKmXMHuVMzi6Fajo%}B4T_L8!vb>s}}rv zRwnpyRz>_KL%HZy8R`W8nPH0H2MyB%KWmsp{6Mv_Gg<r1=e^k(aTBiN?XqQ%d8G zkq1m-WMN*LArV*2S$@?D=Wzx=|MmQyf;@g%elGuROuQ}C0!B!ZAX$PGUOuH*n!o9# zk2miAjPHn=%~$4cjE(^dgBd*0kjy*!tYTe8K~6S0i zKznrN$*Z^TJi)&%IIUo-RL`2LWNvuf@$2{=P_&Br;2lf^oRf6CyUamA=w7(H8qH*8EIwqnq^3D1kJO_aO zCt)B9(CWhzz6Uljfs{R`-r+9#h~;Qk-rf6E0MnuIZfnaB7aBXhfk>a4`)QU8VI7pFEX8#-ahY z&)F+4b$XqhF1gn2_V^q=r^oHZ=!@waOZ()0uhZ+3-Cc6&ERSoT*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{WffCe-`W`#bYVI>kl7lp0eJad)R8G?0Flgy*7&4yN~zY2FX0Sqj;jY$!n1Pf}c8|NaO};Nga@V>>`T zZ@s!?pG&@6^1H4?$nyO1m~~zB+6mcxRv6e`-1sbJCj^e&a&p+6q20xB%SQ;0KbTaQ YEbT6hx#gh;Xx;(*et@9gT%x-_0VrPSu>b%7 diff --git a/src/org/mxchange/jshopcore/exceptions/CustomerAlreadyRegisteredException.java b/src/org/mxchange/jshopcore/exceptions/CustomerAlreadyRegisteredException.java index ae77abe..eb93d49 100644 --- a/src/org/mxchange/jshopcore/exceptions/CustomerAlreadyRegisteredException.java +++ b/src/org/mxchange/jshopcore/exceptions/CustomerAlreadyRegisteredException.java @@ -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())); } } diff --git a/src/org/mxchange/jshopcore/model/customer/Customer.java b/src/org/mxchange/jshopcore/model/customer/Customer.java index 792d639..d3a1620 100644 --- a/src/org/mxchange/jshopcore/model/customer/Customer.java +++ b/src/org/mxchange/jshopcore/model/customer/Customer.java @@ -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); } diff --git a/src/org/mxchange/jshopcore/model/customer/ShopCustomer.java b/src/org/mxchange/jshopcore/model/customer/ShopCustomer.java index 509c06c..9b8331b 100644 --- a/src/org/mxchange/jshopcore/model/customer/ShopCustomer.java +++ b/src/org/mxchange/jshopcore/model/customer/ShopCustomer.java @@ -17,6 +17,17 @@ 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 */ +@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 index 0000000..93f75ff --- /dev/null +++ b/src/org/mxchange/jshopcore/model/order/Orderable.java @@ -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 . + */ +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 index 0000000..65361ee --- /dev/null +++ b/src/org/mxchange/jshopcore/model/order/ShopOrder.java @@ -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 . + */ +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; + } +} -- 2.39.5