*/
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()));
}
}
* @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);
}
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;
/**
*
* @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
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;
+ }
}
--- /dev/null
+/*
+ * 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);
+}
--- /dev/null
+/*
+ * 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;
+ }
+}