From: Roland Haeder Date: Sat, 20 Feb 2016 21:13:03 +0000 (+0100) Subject: Added dummy compareTo() (unimplemented, will follow) and Comparable where missing. Maybe e.g. for classes extending BaseItem this is a repeat, but it is okay, to repeat such code to have it more understandable. --- diff --git a/src/org/mxchange/jshopcore/model/basket/items/BasketItem.java b/src/org/mxchange/jshopcore/model/basket/items/BasketItem.java index 3dc05dc..fb5fd00 100644 --- a/src/org/mxchange/jshopcore/model/basket/items/BasketItem.java +++ b/src/org/mxchange/jshopcore/model/basket/items/BasketItem.java @@ -37,7 +37,7 @@ import org.mxchange.jshopcore.model.product.Product; */ @Entity (name = "basket_items") @Table (name = "basket_items") -public class BasketItem extends BaseItem implements AddableBasketItem { +public class BasketItem extends BaseItem implements AddableBasketItem, Comparable { /** * Serial number diff --git a/src/org/mxchange/jshopcore/model/category/ProductCategory.java b/src/org/mxchange/jshopcore/model/category/ProductCategory.java index f02fb93..721e638 100644 --- a/src/org/mxchange/jshopcore/model/category/ProductCategory.java +++ b/src/org/mxchange/jshopcore/model/category/ProductCategory.java @@ -50,13 +50,6 @@ public class ProductCategory implements Category, Comparable { @Column (name = "category_id", length = 20, nullable = false) private Long categoryId; - /** - * Parent category - */ - @JoinColumn (name = "parent_id") - @OneToOne (targetEntity = ProductCategory.class, cascade = CascadeType.MERGE) - private Category parentCategory; - /** * Title of category */ @@ -64,6 +57,13 @@ public class ProductCategory implements Category, Comparable { @Column (name = "category_title", length = 100, nullable = false, unique = true) private String categoryTitle; + /** + * Parent category + */ + @JoinColumn (name = "parent_id") + @OneToOne (targetEntity = ProductCategory.class, cascade = CascadeType.MERGE) + private Category parentCategory; + /** * Constructor which accepts all database fields *

@@ -122,22 +122,22 @@ public class ProductCategory implements Category, Comparable { } @Override - public Category getParentCategory () { - return this.parentCategory; + public String getCategoryTitle () { + return this.categoryTitle; } @Override - public void setParentCategory (final Category parentCategory) { - this.parentCategory = parentCategory; + public void setCategoryTitle (final String categoryTitle) { + this.categoryTitle = categoryTitle; } @Override - public String getCategoryTitle () { - return this.categoryTitle; + public Category getParentCategory () { + return this.parentCategory; } @Override - public void setCategoryTitle (final String categoryTitle) { - this.categoryTitle = categoryTitle; + public void setParentCategory (final Category parentCategory) { + this.parentCategory = parentCategory; } } diff --git a/src/org/mxchange/jshopcore/model/customer/ShopCustomer.java b/src/org/mxchange/jshopcore/model/customer/ShopCustomer.java index 00de0eb..02610b3 100644 --- a/src/org/mxchange/jshopcore/model/customer/ShopCustomer.java +++ b/src/org/mxchange/jshopcore/model/customer/ShopCustomer.java @@ -42,7 +42,7 @@ import org.mxchange.jshopcore.model.customer.status.CustomerAccountStatus; */ @Entity (name = "customer") @Table (name = "customer") -public class ShopCustomer implements Customer { +public class ShopCustomer implements Customer, Comparable { /** * Serial number @@ -56,6 +56,14 @@ public class ShopCustomer implements Customer { @OneToOne (targetEntity = UserContact.class, cascade = CascadeType.ALL, optional = false) private Contact contact; + /** + * Account status + */ + @Basic (optional = false) + @Column (name = "customer_account_status", nullable = false) + @Enumerated (EnumType.STRING) + private CustomerAccountStatus customerAccountStatus; + /** * Confirmation key */ @@ -97,20 +105,17 @@ public class ShopCustomer implements Customer { @Column (name = "customer_password_hash") private String customerPasswordHash; - /** - * Account status - */ - @Basic (optional = false) - @Column (name = "customer_account_status", nullable = false) - @Enumerated (EnumType.STRING) - private CustomerAccountStatus customerAccountStatus; - /** * Default constructor */ public ShopCustomer () { } + @Override + public int compareTo (Customer customer) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + @Override public void copyAll (final Customer customer) { // Copy also contact data @@ -135,6 +140,16 @@ public class ShopCustomer implements Customer { this.contact = contact; } + @Override + public CustomerAccountStatus getCustomerAccountStatus () { + return this.customerAccountStatus; + } + + @Override + public void setCustomerAccountStatus (final CustomerAccountStatus customerAccountStatus) { + this.customerAccountStatus = customerAccountStatus; + } + @Override public String getCustomerConfirmKey () { return this.customerConfirmKey; @@ -195,13 +210,4 @@ public class ShopCustomer implements Customer { this.customerPasswordHash = customerPasswordHash; } - @Override - public CustomerAccountStatus getCustomerAccountStatus () { - return this.customerAccountStatus; - } - - @Override - public void setCustomerAccountStatus (final CustomerAccountStatus customerAccountStatus) { - this.customerAccountStatus = customerAccountStatus; - } } diff --git a/src/org/mxchange/jshopcore/model/order/ShopOrder.java b/src/org/mxchange/jshopcore/model/order/ShopOrder.java index 4cb508b..11dce55 100644 --- a/src/org/mxchange/jshopcore/model/order/ShopOrder.java +++ b/src/org/mxchange/jshopcore/model/order/ShopOrder.java @@ -42,7 +42,7 @@ import org.mxchange.jshopcore.model.customer.ShopCustomer; */ @Entity (name = "orders") @Table (name = "orders") -public class ShopOrder implements Orderable { +public class ShopOrder implements Orderable, Comparable { /** * Serial number @@ -56,14 +56,6 @@ public class ShopOrder implements Orderable { @Column (name = "access_key", length = 100, nullable = false, unique = true) private String accessKey; - /** - * Created timestamp - */ - @Basic (optional = false) - @Temporal (TemporalType.TIMESTAMP) - @Column (name = "order_created", nullable = false) - private Calendar orderCreated; - /** * Customer instance */ @@ -72,10 +64,12 @@ public class ShopOrder implements Orderable { private Customer customer; /** - * Item list, don't save this + * Created timestamp */ - @Transient - private List orderedItems; + @Basic (optional = false) + @Temporal (TemporalType.TIMESTAMP) + @Column (name = "order_created", nullable = false) + private Calendar orderCreated; /** * Order orderId @@ -85,6 +79,17 @@ public class ShopOrder implements Orderable { @Column (name = "order_id", length = 20) private Long orderId; + /** + * Item list, don't save this + */ + @Transient + private List orderedItems; + + @Override + public int compareTo (Orderable order) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + @Override public String getAccessKey () { return this.accessKey; @@ -96,23 +101,23 @@ public class ShopOrder implements Orderable { } @Override - public Calendar getOrderCreated () { - return this.orderCreated; + public Customer getCustomer () { + return this.customer; } @Override - public void setOrderCreated (final Calendar orderCreated) { - this.orderCreated = orderCreated; + public void setCustomer (final Customer customer) { + this.customer = customer; } @Override - public Customer getCustomer () { - return this.customer; + public Calendar getOrderCreated () { + return this.orderCreated; } @Override - public void setCustomer (final Customer customer) { - this.customer = customer; + public void setOrderCreated (final Calendar orderCreated) { + this.orderCreated = orderCreated; } @Override diff --git a/src/org/mxchange/jshopcore/model/order/items/OrderItem.java b/src/org/mxchange/jshopcore/model/order/items/OrderItem.java index 6f8fa36..4ddb964 100644 --- a/src/org/mxchange/jshopcore/model/order/items/OrderItem.java +++ b/src/org/mxchange/jshopcore/model/order/items/OrderItem.java @@ -38,7 +38,7 @@ import org.mxchange.jshopcore.model.product.Product; */ @Entity (name = "ordered_item") @Table (name = "ordered_items") -public class OrderItem extends BaseItem implements AddableBasketItem { +public class OrderItem extends BaseItem implements AddableBasketItem, Comparable { /** * Serial number @@ -81,23 +81,23 @@ public class OrderItem extends BaseItem implements AddableBasketItem { } @Override - public Long getOrderedAmount () { - return this.amount; + public Long getItemId () { + return this.id; } @Override - public void setOrderedAmount (final Long amount) { - this.amount = amount; + public void setItemId (final Long id) { + this.id = id; } @Override - public Long getItemId () { - return this.id; + public Product getItemProduct () { + return this.product; } @Override - public void setItemId (final Long id) { - this.id = id; + public void setItemProduct (final Product product) { + this.product = product; } @Override @@ -111,12 +111,12 @@ public class OrderItem extends BaseItem implements AddableBasketItem { } @Override - public Product getItemProduct () { - return this.product; + public Long getOrderedAmount () { + return this.amount; } @Override - public void setItemProduct (final Product product) { - this.product = product; + public void setOrderedAmount (final Long amount) { + this.amount = amount; } }