+++ /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.jcore.model.contact;
-
-/**
- * Customer contact class
- *
- * @author Roland Haeder
- */
-public class CustomerContact extends BaseContact {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 47_895_786_328_781L;
-}
import org.mxchange.jshopcore.model.basket.AddableBasketItem;
/**
- * An exception thrown when the given item is already added to the basketController.
+ * An exception thrown when the given item is already added to the
+ * basketController.
*
* @author Roland Haeder
*/
public class BasketItemAlreadyAddedException extends Exception {
+
/**
* Serial number
*/
* @param <T> Any item that is or extends the interface
* @param item An instance of a T item
*/
- public <T extends AddableBasketItem>BasketItemAlreadyAddedException (final T item) {
+ public <T extends AddableBasketItem> BasketItemAlreadyAddedException (final T item) {
// Create message and pass it along
super(MessageFormat.format("Item {0} has already been added. Did you miss to call isAdded()?", item));
}
* @author Roland Haeder
*/
public class CannotAddCategoryException extends Exception {
+
/**
* Serial number
*/
* @author Roland Haeder
*/
public class CannotAddProductException extends Exception {
+
/**
* Serial number
*/
/**
* An exception thrown when the given title is already used
- *
+ *
* @author Roland Haeder<roland@mxchange.org>
*/
public class CategoryTitleAlreadyUsedException extends Exception {
+
/**
* Serial number
*/
* @author Roland Haeder
*/
public class CustomerAlreadyRegisteredException extends Exception {
+
/**
* Serial number
*/
/**
* An exception thrown when the given title is already used
- *
+ *
* @author Roland Haeder<roland@mxchange.org>
*/
public class ProductTitleAlreadyUsedException extends Exception {
+
/**
* Serial number
*/
+++ /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.exceptions;
-
-import java.sql.SQLWarning;
-import java.text.MessageFormat;
-
-/**
- * This exception is thrown when a query could not be executed
- *
- * @author Roland Haeder
- * @deprecated No longer used
- */
-@Deprecated
-public class QueryNotExecutedException extends Exception {
- /**
- * Serial number
- */
- private static final long serialVersionUID = 97_548_375_847_581L;
-
- /**
- * Prepares exception with given sql warnings
- *
- * @param warnings SQL warnings
- */
- public QueryNotExecutedException (final SQLWarning warnings) {
- // Call super contructor
- super(MessageFormat.format("SQL statement did not execute: {0} with state: {1}", warnings.getMessage(), warnings.getSQLState()), warnings.getCause());
- }
-}
*/
public interface AddableBasketItem extends Serializable {
+ /**
+ * Check equality on item instance
+ *
+ * @param object Other object to check
+ */
+ @Override
+ public boolean equals (final Object object);
+
/**
* Getter for item amount
*
*
* @return the id
*/
- public Long getId ();
+ public Long getItemId ();
/**
* Setter for entry id (from database backend)
*
* @param id the id to set
*/
- public void setId (final Long id);
-
- /**
- * Getter for product id
- *
- * @return Product id
- */
- public Long getProductId ();
-
- /**
- * Setter for product id
- *
- * @param productId Product id
- */
- public void setProductId (final Long productId);
+ public void setItemId (final Long id);
/**
* Getter for item type
public void setProduct (final Product product);
/**
- * Determines whether the item has a Product instance set
- *
- * @return Whether a Product instance is set
- */
- public boolean isProductType ();
-
- /**
- * Check equality on item instance
- *
- * @param object Other object to check
+ * Hash-code calculattion
*/
@Override
- public boolean equals (final Object object);
+ public int hashCode ();
/**
- * Hash-code calculattion
+ * Determines whether the item has a Product instance set
+ *
+ * @return Whether a Product instance is set
*/
- @Override
- public int hashCode ();
+ public boolean isProductType ();
}
* @param <T> Any instance that implements AddableBasketItem
*/
public abstract class BaseBasket<T extends AddableBasketItem> implements Basket<T> {
+
/**
* Serial number
*/
}
@Override
- public boolean isEmpty () {
- // Deligate call to frontend
- return this.deque.isEmpty();
+ public void clear () {
+ // Deligate to deque
+ this.deque.clear();
}
@Override
}
@Override
- public void clear () {
- // Deligate to deque
- this.deque.clear();
+ public boolean isEmpty () {
+ // Deligate call to frontend
+ return this.deque.isEmpty();
}
}
/**
* Adds given item instance to this basket
- *
+ *
* @param item Item instance to add
- * @throws org.mxchange.jshopcore.exceptions.BasketItemAlreadyAddedException If the item instance has already been added
+ * @throws org.mxchange.jshopcore.exceptions.BasketItemAlreadyAddedException
+ * If the item instance has already been added
*/
public void addItem (final T item) throws BasketItemAlreadyAddedException;
*/
public void clear ();
- /**
- * Checks whether the given item has already been added by checking the
- * item's id.
- *
- * @param item Item instance to check
- * @return Whether the given item has been found
- */
- public boolean isAdded (final T item);
-
- /**
- * Checks if the basket is empty
- *
- * @return Whether the basket is empty
- */
- public boolean isEmpty ();
-
/**
* Some "getter" for all entries in this basket
*
/**
* Getter for last num rows
- *
+ *
* @return Last num rows
*/
public int getLastNumRows ();
+
+ /**
+ * Checks whether the given item has already been added by checking the
+ * item's id.
+ *
+ * @param item Item instance to check
+ * @return Whether the given item has been found
+ */
+ public boolean isAdded (final T item);
+
+ /**
+ * Checks if the basket is empty
+ *
+ * @return Whether the basket is empty
+ */
+ public boolean isEmpty ();
}
* @author Roland Haeder<roland@mxchange.org>
*/
public class ShopBasket extends BaseBasket<AddableBasketItem> implements Basket<AddableBasketItem> {
+
/**
* Serial number
*/
/*
- * Copyright (C) 2015 Roland Haeder
+ * Copyright (C) 2015 KLC
*
* 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
package org.mxchange.jshopcore.model.basket.items;
import java.util.Objects;
-import javax.persistence.Basic;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.Transient;
import org.mxchange.jshopcore.model.basket.AddableBasketItem;
import org.mxchange.jshopcore.model.product.Product;
*
* @author Roland Haeder<roland@mxchange.org>
*/
-@Entity(name = "item")
public abstract class BaseItem implements AddableBasketItem, Comparable<AddableBasketItem> {
/**
*/
private static final long serialVersionUID = 24_348_671_457_829_156L;
- /**
- * Entry id (from database backend)
- */
- @Id
- @GeneratedValue
- private Long id;
-
- /**
- * Item amount
- */
- @Basic(optional = false)
- private Long amount;
-
- /**
- * Product id
- */
- @Column(name = "product_id", length = 20)
- private Long productId;
-
- /**
- * Item type
- */
- @Basic(optional = false)
- @Column(name = "item_type", length = 20)
- private String itemType;
-
- /**
- * Product instance
- */
- @Transient
- private Product product;
-
@Override
public int compareTo (final AddableBasketItem item) {
// item should not be null
}
// Is the id the same?
- if (Objects.equals(this.getProductId(), item.getProductId())) {
+ if (Objects.equals(this.getProduct(), item.getProduct())) {
// Same id, means same item
return 0;
- } else if (this.getProductId() > item.getProductId()) {
+ } else if (this.getProduct().getId() > item.getProduct().getId()) {
// This id is larger than compared to
return -1;
}
return 1;
}
- @Override
- public Long getAmount () {
- return this.amount;
- }
-
- @Override
- public void setAmount (final Long amount) {
- this.amount = amount;
- }
-
- @Override
- public Long getId () {
- return this.id;
- }
-
- @Override
- public void setId (final Long id) {
- this.id = id;
- }
-
- @Override
- public Long getProductId () {
- return this.productId;
- }
-
- @Override
- public void setProductId (final Long productId) {
- this.productId = productId;
- }
-
- @Override
- public String getItemType () {
- return this.itemType;
- }
-
- @Override
- public void setItemType (final String itemType) {
- this.itemType = itemType;
- }
-
- @Override
- public Product getProduct () {
- return this.product;
- }
-
- @Override
- public void setProduct (final Product product) {
- this.product = product;
- }
-
@Override
public boolean equals (final Object object) {
// Is it same type?
AddableBasketItem item = (AddableBasketItem) object;
// Item id and type must be the same
- return ((Objects.equals(item.getProductId(), this.getProductId()))
+ return ((Objects.equals(item.getProduct().getId(), this.getProduct().getId()))
&& (Objects.equals(item.getItemType(), this.getItemType())));
}
@Override
public int hashCode () {
int hash = 5;
- hash = 29 * hash + Objects.hashCode(this.getProductId());
+ hash = 29 * hash + Objects.hashCode(this.getProduct().getId());
hash = 29 * hash + Objects.hashCode(this.getItemType());
return hash;
}
*/
package org.mxchange.jshopcore.model.basket.items;
+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 org.mxchange.jshopcore.model.basket.AddableBasketItem;
+import org.mxchange.jshopcore.model.product.GenericProduct;
import org.mxchange.jshopcore.model.product.Product;
/**
*
* @author Roland Haeder<roland@mxchange.org>
*/
+@Entity (name = "basket_items")
+@Table (name = "basket_items")
public class BasketItem extends BaseItem implements AddableBasketItem {
+
/**
* Serial number
*/
private static final long serialVersionUID = 52_749_158_492_581_578L;
+ /**
+ * Item amount
+ */
+ @Basic (optional = false)
+ @Column (name = "amount", nullable = false, length = 20)
+ private Long amount;
+
+ /**
+ * Entry itemId (from database backend)
+ */
+ @Id
+ @GeneratedValue (strategy = GenerationType.IDENTITY)
+ @Column (name = "item_id", nullable = false, updatable = false)
+ private Long itemId;
+
+ /**
+ * Item type
+ */
+ @Basic (optional = false)
+ @Column (name = "item_type", nullable = false, length = 20)
+ private String itemType;
+
+ /**
+ * Product instance
+ */
+ @JoinColumn (name = "product_id", updatable = false)
+ @OneToOne (targetEntity = GenericProduct.class)
+ private Product product;
+
/**
* Default constructor
*/
/**
* Constructor for an item from given Product instance
- *
+ *
* @param product Product instance
*/
public BasketItem (final Product product) {
}
// Copy all neccessary values
- this.setProductId(product.getId());
- this.setItemType("product"); //NOI18N
+ this.itemType = "product"; //NOI18N
// Copy instance
- this.setProduct(product);
+ this.product = product;
}
/**
* Constructor for an item from given Product instance and amount.
- *
+ *
* @param product Product instance
* @param amount Ordered amount
*/
}
// Set amount
- this.setAmount(amount);
+ this.amount = amount;
+ }
+
+ @Override
+ public Long getAmount () {
+ return this.amount;
+ }
+
+ @Override
+ public void setAmount (final Long amount) {
+ this.amount = amount;
+ }
+
+ @Override
+ public Long getItemId () {
+ return this.itemId;
+ }
+
+ @Override
+ public void setItemId (final Long itemId) {
+ this.itemId = itemId;
+ }
+
+ @Override
+ public String getItemType () {
+ return this.itemType;
+ }
+
+ @Override
+ public void setItemType (final String itemType) {
+ this.itemType = itemType;
+ }
+
+ @Override
+ public Product getProduct () {
+ return this.product;
+ }
+
+ @Override
+ public void setProduct (final Product product) {
+ this.product = product;
}
}
+++ /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.category;
-
-import java.util.Objects;
-import javax.persistence.Basic;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.Table;
-
-/**
- * A general product category class
- *
- * @author Roland Haeder<roland@mxchange.org>
- */
-@Entity(name = "category")
-@Table(name = "category")
-public abstract class BaseCategory implements Category, Comparable<Category> {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 38_472_937_685_901L;
-
- /**
- * Id number of category
- */
- @Id
- @GeneratedValue
- @Column
- private Long id;
-
- /**
- * Parent category id
- */
- @Column(name = "parent_id", length = 20)
- private Long parentId;
-
- /**
- * Title of category
- */
- @Basic(optional = false)
- @Column(length = 100, nullable = false, unique = true)
- private String title;
-
- /**
- * Constructor which accepts all database fields
- *
- * @param id Id number of database record
- * @param title Category title
- * @param parentId Parent id
- */
- protected BaseCategory (final Long id, final String title, final Long parentId) {
- // Set all here
- this.id = id;
- this.title = title;
- this.parentId = parentId;
- }
-
- /**
- * Default constructor
- */
- protected BaseCategory () {
- }
-
- /**
- * Compares two categories with each other
- *
- * @param category Category comparator
- * @return Comparison value
- */
- @Override
- public int compareTo (final Category category) {
- // category should not be null
- if (null == category) {
- throw new NullPointerException("category is null"); //NOI18N
- }
-
- // Is the id the same?
- if (Objects.equals(this.getId(), category.getId())) {
- // Same id, means same category
- return 0;
- } else if (this.getId() > category.getId()) {
- // This id is larger than compared to
- return -1;
- }
-
- // The other id is larger
- return 1;
- }
-
- @Override
- public void copyAll (final Category category) {
- // Copy all data
- this.setParentId(category.getParentId());
- this.setTitle(category.getTitle());
- }
-
- /**
- * Id number of category
- *
- * @return the id
- */
- @Override
- public Long getId () {
- return this.id;
- }
-
- /**
- * Id number of category
- *
- * @param id the id to set
- */
- @Override
- public void setId (final Long id) {
- this.id = id;
- }
-
- /**
- * Parent category id
- *
- * @return the parentId
- */
- @Override
- public Long getParentId () {
- return this.parentId;
- }
-
- /**
- * Parent category id
- *
- * @param parentId the parentId to set
- */
- @Override
- public void setParentId (final Long parentId) {
- this.parentId = parentId;
- }
-
- /**
- * Title of category
- *
- * @return the title
- */
- @Override
- public String getTitle () {
- return this.title;
- }
-
- /**
- * Title of category
- *
- * @param title the title to set
- */
- @Override
- public void setTitle (final String title) {
- this.title = title;
- }
-}
/**
* Id number of category
+ *
* @return the id
*/
- public Long getId ();
+ public Long getCategoryId ();
/**
* Id number of category
+ *
* @param id the id to set
*/
- public void setId (final Long id);
+ public void setCategoryId (final Long id);
/**
- * Parent category id
- * @return the parent
+ * Parent category
+ *
+ * @return the parent category
*/
- public Long getParentId ();
+ public Category getParentCategory ();
/**
- * Parent category id
- * @param parent the parent to set
+ * Parent category
+ *
+ * @param parentCategory the parent category to set
*/
- public void setParentId (final Long parent);
+ public void setParentCategory (final Category parentCategory);
/**
* Title of category
+ *
* @return the title
*/
public String getTitle ();
/**
* Title of category
+ *
* @param title the title to set
*/
public void setTitle (final String title);
*/
package org.mxchange.jshopcore.model.category;
+import java.util.Objects;
+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;
+
/**
* A product category
+ *
* @author Roland Haeder<roland@mxchange.org>
*/
-public class ProductCategory extends BaseCategory {
+@Entity (name = "category")
+@Table (name = "category")
+public class ProductCategory implements Category, Comparable<Category> {
+
/**
* Serial number
*/
private static final long serialVersionUID = 21_458_945_712_659L;
+ /**
+ * Id number of category
+ */
+ @Id
+ @GeneratedValue (strategy = GenerationType.IDENTITY)
+ @Column (name = "category_id", length = 20, nullable = false)
+ private Long categoryId;
+
+ /**
+ * Parent category categoryId
+ */
+ @JoinColumn (name = "parent_id")
+ @OneToOne (targetEntity = ProductCategory.class)
+ private Category parentCategory;
+
+ /**
+ * Title of category
+ */
+ @Basic (optional = false)
+ @Column (name = "title", length = 100, nullable = false, unique = true)
+ private String title;
+
/**
* Constructor which accepts all database fields
*
- * @param id Id number of database record
+ * @param categoryId Id number of database record
* @param title Category title
- * @param parent Parent id
+ * @param parentCategory Parent category
*/
- public ProductCategory (final Long id, final String title, final Long parent) {
- // Call parent constructor
- super(id, title, parent);
+ public ProductCategory (final Long categoryId, final String title, final Category parentCategory) {
+ // Set all here
+ this.categoryId = categoryId;
+ this.title = title;
+ this.parentCategory = parentCategory;
}
/**
*/
public ProductCategory () {
}
+
+ @Override
+ public int compareTo (final Category category) {
+ // category should not be null
+ if (null == category) {
+ throw new NullPointerException("category is null"); //NOI18N
+ }
+
+ // Is the categoryId the same?
+ if (Objects.equals(this.getCategoryId(), category.getCategoryId())) {
+ // Same categoryId, means same category
+ return 0;
+ } else if (this.getCategoryId() > category.getCategoryId()) {
+ // This categoryId is larger than compared to
+ return -1;
+ }
+
+ // The other categoryId is larger
+ return 1;
+ }
+
+ @Override
+ public void copyAll (final Category category) {
+ // Copy all data
+ this.setParentCategory(category.getParentCategory());
+ this.setTitle(category.getTitle());
+ }
+
+ @Override
+ public Long getCategoryId () {
+ return this.categoryId;
+ }
+
+ @Override
+ public void setCategoryId (final Long categoryId) {
+ this.categoryId = categoryId;
+ }
+
+ @Override
+ public Category getParentCategory () {
+ return this.parentCategory;
+ }
+
+ @Override
+ public void setParentCategory (final Category parentCategory) {
+ this.parentCategory = parentCategory;
+ }
+
+ @Override
+ public String getTitle () {
+ return this.title;
+ }
+
+ @Override
+ public void setTitle (final String title) {
+ this.title = title;
+ }
}
public void copyAll (final Customer customer);
/**
- * Setter for contact instance
+ * Getter for contact instance
*
- * @param contact Contact instance
+ * @return Contact id number
*/
- public void setContact (final Contact contact);
+ public Contact getContact ();
/**
- * Getter for contact instance
+ * Setter for contact instance
*
- * @return Contact id number
+ * @param contact Contact instance
*/
- public Contact getContact();
+ public void setContact (final Contact contact);
/**
* Getter for confirmation key
*/
public void setCustomerCreated (final Calendar customerCreated);
+ /**
+ * 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);
+
/**
* Getter for "locked" timestamp
*
public void setCustomerLocked (final Calendar customerLocked);
/**
- * Setter for customer number
+ * Getter for customer number
*
- * @param customerNumber Customer number
+ * @return Customer number
*/
- public void setCustomerNumber (final String customerNumber);
+ public String getCustomerNumber ();
/**
- * Getter for customer number
+ * Setter for customer number
*
- * @return Customer number
+ * @param customerNumber Customer number
*/
- public String getCustomerNumber ();
+ public void setCustomerNumber (final String customerNumber);
/**
* Getter for password hash
* @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);
}
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;
/**
* A shop customer class.
*
* @author Roland Haeder<roland@mxchange.org>
*/
-@Entity (name = "Customer")
+@Entity (name = "customer")
@Table (name = "customer")
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 (optional = false, targetEntity = UserContact.class)
private Contact contact;
/**
/**
* "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
*/
/**
* Account status
*/
+ @Basic (optional = false)
@Column (name = "customer_status", nullable = false)
private String customerStatus;
+ /**
+ * Default constructor
+ */
+ public ShopCustomer () {
+ }
+
@Override
public void copyAll (final Customer customer) {
// Copy also contact data
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;
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;
- }
}
public void setAccessKey (final String accessKey);
/**
- * Getter for order id
+ * Getter for created timestamp
*
- * @return Order id
+ * @return Created timestamp
*/
- public Long getId ();
+ public Calendar getCreated ();
/**
- * Setter for order id
+ * Setter for created timestamp
*
- * @param id Order id
+ * @param created Created timestamp
*/
- public void setId (final Long id);
+ public void setCreated (final Calendar created);
/**
* Getter for customer instance
public void setCustomer (final Customer customer);
/**
- * Getter for created timestamp
+ * Getter for order id
*
- * @return Created timestamp
+ * @return Order id
*/
- public Calendar getCreated ();
+ public Long getOrderId ();
/**
- * Setter for created timestamp
+ * Setter for order id
*
- * @param created Created timestamp
+ * @param id Order id
*/
- public void setCreated (final Calendar created);
+ public void setOrderId (final Long id);
/**
* Getter for list of ordered basket items
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
-import javax.persistence.OneToMany;
+import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
import org.mxchange.jshopcore.model.basket.AddableBasketItem;
import org.mxchange.jshopcore.model.customer.Customer;
+import org.mxchange.jshopcore.model.customer.ShopCustomer;
/**
* An entity class for shop orders
*
* @author Roland Haeder
*/
-@Entity (name = "Orders")
+@Entity (name = "orders")
@Table (name = "orders")
public class ShopOrder implements Orderable {
*/
private static final long serialVersionUID = 19_728_938_459_834L;
- /**
- * Order id
- */
- @Id
- @GeneratedValue (strategy = GenerationType.IDENTITY)
- private Long id;
-
- /**
- * Customer instance
- */
- @Basic (optional = false)
- @OneToMany
- @JoinColumn (table = "customer", referencedColumnName = "id", name = "customer_id", nullable = false, updatable = false)
- private Customer customer;
-
/**
* Access key
*/
*/
@Basic (optional = false)
@Temporal (TemporalType.TIMESTAMP)
- @Column (nullable = false)
+ @Column (name = "created", nullable = false)
private Calendar created;
+ /**
+ * Customer instance
+ */
+ @JoinColumn (name = "customer_id", nullable = false, updatable = false)
+ @OneToOne (targetEntity = ShopCustomer.class, optional = false)
+ private Customer customer;
+
/**
* Item list, don't save this
*/
@Transient
private List<AddableBasketItem> itemList;
+ /**
+ * Order orderId
+ */
+ @Id
+ @GeneratedValue (strategy = GenerationType.IDENTITY)
+ @Column (name = "order_id", length = 20)
+ private Long orderId;
+
@Override
public String getAccessKey () {
return this.accessKey;
}
@Override
- public Long getId () {
- return this.id;
+ public Long getOrderId () {
+ return this.orderId;
}
@Override
- public void setId (final Long id) {
- this.id = id;
+ public void setOrderId (final Long orderId) {
+ this.orderId = orderId;
}
@Override
*/
package org.mxchange.jshopcore.model.order.items;
+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 org.mxchange.jshopcore.model.basket.AddableBasketItem;
import org.mxchange.jshopcore.model.basket.items.BaseItem;
+import org.mxchange.jshopcore.model.product.GenericProduct;
+import org.mxchange.jshopcore.model.product.Product;
/**
* A general basket item
*
* @author Roland Haeder<roland@mxchange.org>
*/
-@Table(name = "ordered_items")
+@Entity (name = "ordered_item")
+@Table (name = "ordered_items")
public class OrderItem extends BaseItem implements AddableBasketItem {
+
/**
* Serial number
*/
private static final long serialVersionUID = 44_189_562_738_723_581L;
+ /**
+ * Item amount
+ */
+ @Basic (optional = false)
+ @Column (name = "amount", length = 20, nullable = false)
+ private Long amount;
+
+ /**
+ * Entry id (from database backend)
+ */
+ @Id
+ @GeneratedValue (strategy = GenerationType.IDENTITY)
+ @Column (name = "id", nullable = false, length = 20)
+ private Long id;
+
+ /**
+ * Item type
+ */
+ @Basic (optional = false)
+ @Column (name = "item_type", length = 20)
+ private String itemType;
+
+ /**
+ * Product instance
+ */
+ @JoinColumn (name = "product_id", updatable = false)
+ @OneToOne (targetEntity = GenericProduct.class)
+ private Product product;
+
/**
* Default constructor
*/
public OrderItem () {
}
+
+ @Override
+ public Long getAmount () {
+ return this.amount;
+ }
+
+ @Override
+ public void setAmount (final Long amount) {
+ this.amount = amount;
+ }
+
+ @Override
+ public Long getItemId () {
+ return this.id;
+ }
+
+ @Override
+ public void setItemId (final Long id) {
+ this.id = id;
+ }
+
+ @Override
+ public String getItemType () {
+ return this.itemType;
+ }
+
+ @Override
+ public void setItemType (final String itemType) {
+ this.itemType = itemType;
+ }
+
+ @Override
+ public Product getProduct () {
+ return this.product;
+ }
+
+ @Override
+ public void setProduct (final Product product) {
+ this.product = product;
+ }
}
+++ /dev/null
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-package org.mxchange.jshopcore.model.product;
-
-import java.util.Objects;
-import javax.persistence.Basic;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.Table;
-
-/**
- * A general product class
- *
- * @author Roland Haeder<roland@mxchange.org>
- */
-@Entity(name = "product")
-@Table (name = "products")
-public abstract class BaseProduct implements Product, Comparable<Product> {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 48_379_575_267_451L;
-
- /**
- * Availability of product
- */
- @Column
- private Boolean available;
-
- /**
- * Product category
- */
- @Basic(optional = false)
- @Column(name = "category_id", length = 20, nullable = false)
- private Long categoryId;
-
- /**
- * Id number of product
- */
- @Id
- @GeneratedValue
- @Column
- private Long id;
-
- /**
- * Price of product
- */
- @Basic(optional = false)
- @Column(nullable = false)
- private Float price;
-
- /**
- * Title of product
- */
- @Basic(optional = false)
- @Column(length = 100, nullable = false)
- private String title;
-
- @Override
- public int compareTo (final Product product) {
- // category should not be null
- if (null == product) {
- throw new NullPointerException("product is null"); //NOI18N
- }
-
- // Is the id the same?
- if (Objects.equals(this.getId(), product.getId())) {
- // Same id, means same category
- return 0;
- } else if (this.getId() > product.getId()) {
- // This id is larger than compared to
- return 1;
- }
-
- // The other id is larger
- return -1;
- }
-
- @Override
- public void copyAll (final Product product) {
- // Copy all
- this.setAvailable(product.getAvailable());
- this.setCategoryId(product.getCategoryId());
- this.setPrice(product.getPrice());
- this.setTitle(product.getTitle());
- }
-
- @Override
- public Boolean getAvailable () {
- return this.available;
- }
-
- @Override
- public void setAvailable (final Boolean available) {
- this.available = available;
- }
-
- @Override
- public Long getCategoryId () {
- return this.categoryId;
- }
-
- @Override
- public void setCategoryId (final Long categoryId) {
- this.categoryId = categoryId;
- }
-
- @Override
- public Long getId () {
- return this.id;
- }
-
- @Override
- public void setId (final Long id) {
- this.id = id;
- }
-
- @Override
- public Float getPrice () {
- return this.price;
- }
-
- @Override
- public void setPrice (final Float price) {
- this.price = price;
- }
-
- @Override
- public String getTitle () {
- return this.title;
- }
-
- @Override
- public void setTitle (final String title) {
- this.title = title;
- }
-}
*/
package org.mxchange.jshopcore.model.product;
+import java.util.Objects;
+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 org.mxchange.jshopcore.model.category.Category;
+
/**
* Generic product class
*
* @author Roland Haeder<roland@mxchange.org>
* TODO: Find a better name
*/
-public class GenericProduct extends BaseProduct implements Product {
+@Entity (name = "products")
+@Table (name = "products")
+public class GenericProduct implements Product, Comparable<Product> {
+
/**
* Serial number
*/
private static final long serialVersionUID = 54_578_571_769_283L;
+ /**
+ * Availability of product
+ */
+ @Column (name = "available", nullable = false)
+ private Boolean available;
+
+ /**
+ * Product category
+ */
+ @Basic (optional = false)
+ @Column (name = "category_id", length = 20, nullable = false)
+ private Category category;
+
+ /**
+ * Id number of product
+ */
+ @Id
+ @GeneratedValue (strategy = GenerationType.IDENTITY)
+ @Column(name = "product_id", length = 20, nullable = false, updatable = false)
+ private Long id;
+
+ /**
+ * Price of product
+ */
+ @Basic (optional = false)
+ @Column (name = "price", nullable = false)
+ private Float price;
+
+ /**
+ * Title of product
+ */
+ @Basic (optional = false)
+ @Column (name = "title", length = 100, nullable = false)
+ private String title;
+
/**
* Default constructor
*/
* @param id Id number of product
* @param title Name of product
* @param price Price
- * @param categoryId Category id
+ * @param category Category instance
* @param available Availability (selectable by customer)
*/
- public GenericProduct (final Long id, final String title, final Float price, final Long categoryId, final Boolean available) {
+ public GenericProduct (final Long id, final String title, final Float price, final Category category, final Boolean available) {
// Set all here
- this.setId(id);
- this.setTitle(title);
- this.setPrice(price);
- this.setCategoryId(categoryId);
- this.setAvailable(available);
+ this.id = id;
+ this.title = title;
+ this.price = price;
+ this.category = category;
+ this.available = available;
+ }
+
+ @Override
+ public int compareTo (final Product product) {
+ // category should not be null
+ if (null == product) {
+ throw new NullPointerException("product is null"); //NOI18N
+ }
+
+ // Is the id the same?
+ if (Objects.equals(this.getId(), product.getId())) {
+ // Same id, means same category
+ return 0;
+ } else if (this.getId() > product.getId()) {
+ // This id is larger than compared to
+ return 1;
+ }
+
+ // The other id is larger
+ return -1;
+ }
+
+ @Override
+ public void copyAll (final Product product) {
+ // Copy all
+ this.setAvailable(product.getAvailable());
+ this.setCategory(product.getCategory());
+ this.setPrice(product.getPrice());
+ this.setTitle(product.getTitle());
+ }
+
+ @Override
+ public Boolean getAvailable () {
+ return this.available;
+ }
+
+ @Override
+ public void setAvailable (final Boolean available) {
+ this.available = available;
+ }
+
+ @Override
+ public Category getCategory () {
+ return this.category;
+ }
+
+ @Override
+ public void setCategory (final Category category) {
+ this.category = category;
+ }
+
+ @Override
+ public Long getId () {
+ return this.id;
+ }
+
+ @Override
+ public void setId (final Long id) {
+ this.id = id;
+ }
+
+ @Override
+ public Float getPrice () {
+ return this.price;
+ }
+
+ @Override
+ public void setPrice (final Float price) {
+ this.price = price;
+ }
+
+ @Override
+ public String getTitle () {
+ return this.title;
+ }
+
+ @Override
+ public void setTitle (final String title) {
+ this.title = title;
}
}
package org.mxchange.jshopcore.model.product;
import java.io.Serializable;
+import org.mxchange.jshopcore.model.category.Category;
/**
* An interface for in database storable products
public void copyAll (final Product product);
/**
- * Getter for id number, suitable for form fields.
- *
- * @return Id number of product
+ * Getter for product availability
+ *
+ * @return Product availability
*/
- public Long getId ();
+ public Boolean getAvailable ();
/**
- * Id number of product
- * @param id the id number to set
+ * Setter for product availability
+ *
+ * @param available Product availability
*/
- public void setId (final Long id);
+ public void setAvailable (final Boolean available);
/**
- * Getter for title.
- *
- * @return Title of product
+ * Getter for product category id
+ *
+ * @return Product category id
*/
- public String getTitle ();
+ public Category getCategory ();
/**
- * Title of product
- * @param title the title to set
+ * Setter for product category
+ *
+ * @param category Product category
*/
- public void setTitle (final String title);
+ public void setCategory (final Category category);
/**
- * Getter for raw price.
- *
- * @return Single price of product
+ * Getter for id number, suitable for form fields.
+ *
+ * @return Id number of product
*/
- public Float getPrice ();
+ public Long getId ();
/**
- * Price of product
- * @param price the price to set
+ * Id number of product
+ *
+ * @param id the id number to set
*/
- public void setPrice (final Float price);
+ public void setId (final Long id);
/**
- * Getter for product category id
+ * Getter for raw price.
*
- * @return Product category id
+ * @return Single price of product
*/
- public Long getCategoryId ();
+ public Float getPrice ();
/**
- * Setter for product category
+ * Price of product
*
- * @param categoryId Product category
+ * @param price the price to set
*/
- public void setCategoryId (final Long categoryId);
+ public void setPrice (final Float price);
/**
- * Getter for product availability
+ * Getter for title.
*
- * @return Product availability
+ * @return Title of product
*/
- public Boolean getAvailable ();
+ public String getTitle ();
/**
- * Setter for product availability
+ * Title of product
*
- * @param available Product availability
+ * @param title the title to set
*/
- public void setAvailable (final Boolean available);
+ public void setTitle (final String title);
}
* @author Roland Haeder
*/
public class CheckoutWrapper implements WrapableCheckout {
+
/**
* Serial number
*/
/**
* Setter for customer instance
+ *
* @param customer Customer instance
*/
public void setCustomer (final Customer customer);
/**
* Getter for a List of AddableBasktem instances
+ *
* @return List with AddableBasketItem instances
*/
public List<AddableBasketItem> getList ();
/**
* Setter for a List of AddableBasktem instances
+ *
* @param list List with AddableBasketItem instances
*/
public void setList (final List<AddableBasketItem> list);