+++ /dev/null
-/*
- * Copyright (C) 2016 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.customer;
-
-import java.util.Calendar;
-import java.util.Objects;
-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;
-import javax.persistence.JoinColumn;
-import javax.persistence.OneToOne;
-import javax.persistence.Table;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
-import org.mxchange.jcontacts.contact.Contact;
-import org.mxchange.jcontacts.contact.UserContact;
-import org.mxchange.jcustomercore.model.customer.Customer;
-import org.mxchange.jcustomercore.model.customer.status.CustomerAccountStatus;
-
-/**
- * A shop customer class.
- * <p>
- * @author Roland Haeder<roland@mxchange.org>
- */
-@Entity (name = "customer")
-@Table (name = "customer")
-@SuppressWarnings ("PersistenceUnitPresent")
-public class ShopCustomer implements Customer {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 4_328_454_581_751L;
-
- /**
- * Account status
- */
- @Basic (optional = false)
- @Column (name = "customer_account_status", nullable = false)
- @Enumerated (EnumType.STRING)
- private CustomerAccountStatus customerAccountStatus;
-
- /**
- * Confirmation key
- */
- @Column (name = "customer_confirm_key", length = 50)
- private String customerConfirmKey;
-
- /**
- * Id number from "contacts" table
- */
- @JoinColumn (name = "contact_id", nullable = false, updatable = false, unique = true)
- @OneToOne (targetEntity = UserContact.class, cascade = CascadeType.ALL, optional = false)
- private Contact customerContact;
-
- /**
- * "created" timestamp
- */
- @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
- */
- @Temporal (TemporalType.TIMESTAMP)
- @Column (name = "customer_locked_timestamp")
- private Calendar customerLocked;
-
- /**
- * Customer number, this is different to the database entry customerId.
- */
- @Column (name = "customer_number", nullable = false, length = 20)
- private String customerNumber;
-
- /**
- * Password hash
- */
- @Column (name = "customer_password_hash")
- private String customerPasswordHash;
-
- /**
- * Default constructor
- */
- public ShopCustomer () {
- }
-
- @Override
- public void copyAll (final Customer customer) {
- // Copy also customerContact data
- this.getCustomerContact().copyAll(customer.getCustomerContact());
-
- // Copy other data
- this.setCustomerConfirmKey(customer.getCustomerConfirmKey());
- this.setCustomerNumber(customer.getCustomerNumber());
- this.setCustomerPasswordHash(customer.getCustomerPasswordHash());
- this.setCustomerAccountStatus(customer.getCustomerAccountStatus());
- this.setCustomerCreated(customer.getCustomerCreated());
- this.setCustomerLocked(customer.getCustomerLocked());
- }
-
- @Override
- public boolean equals (final Object object) {
- if (this == object) {
- return true;
- } else if (null == object) {
- return false;
- } else if (this.getClass() != object.getClass()) {
- return false;
- }
-
- final Customer other = (Customer) object;
-
- if (!Objects.equals(this.getCustomerNumber(), other.getCustomerNumber())) {
- return false;
- } else if (!Objects.equals(this.getCustomerContact(), other.getCustomerContact())) {
- return false;
- }
-
- return Objects.equals(this.getCustomerContact(), other.getCustomerContact());
- }
-
- @Override
- public int hashCode () {
- int hash = 3;
- hash = 17 * hash + Objects.hashCode(this.getCustomerContact());
- hash = 17 * hash + Objects.hashCode(this.getCustomerId());
- hash = 17 * hash + Objects.hashCode(this.getCustomerNumber());
- return hash;
- }
-
- @Override
- public CustomerAccountStatus getCustomerAccountStatus () {
- return this.customerAccountStatus;
- }
-
- @Override
- public void setCustomerAccountStatus (final CustomerAccountStatus customerAccountStatus) {
- this.customerAccountStatus = customerAccountStatus;
- }
-
- @Override
- public String getCustomerConfirmKey () {
- return this.customerConfirmKey;
- }
-
- @Override
- public void setCustomerConfirmKey (final String customerConfirmKey) {
- this.customerConfirmKey = customerConfirmKey;
- }
-
- @Override
- public Contact getCustomerContact () {
- return this.customerContact;
- }
-
- @Override
- public void setCustomerContact (final Contact customerContact) {
- this.customerContact = customerContact;
- }
-
- @Override
- public Calendar getCustomerCreated () {
- return this.customerCreated;
- }
-
- @Override
- public void setCustomerCreated (final Calendar customerCreated) {
- 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;
- }
-
- @Override
- public void setCustomerLocked (final Calendar customerLocked) {
- this.customerLocked = customerLocked;
- }
-
- @Override
- public String getCustomerNumber () {
- return this.customerNumber;
- }
-
- @Override
- public void setCustomerNumber (final String customerNumber) {
- this.customerNumber = customerNumber;
- }
-
- @Override
- public String getCustomerPasswordHash () {
- return this.customerPasswordHash;
- }
-
- @Override
- public void setCustomerPasswordHash (final String customerPasswordHash) {
- this.customerPasswordHash = customerPasswordHash;
- }
-
-}