]> git.mxchange.org Git - jshop-core.git/commitdiff
Added dummy compareTo() (unimplemented, will follow) and Comparable<SomeInterface...
authorRoland Haeder <roland@mxchange.org>
Sat, 20 Feb 2016 21:13:03 +0000 (22:13 +0100)
committerRoland Haeder <roland@mxchange.org>
Sat, 20 Feb 2016 21:13:03 +0000 (22:13 +0100)
src/org/mxchange/jshopcore/model/basket/items/BasketItem.java
src/org/mxchange/jshopcore/model/category/ProductCategory.java
src/org/mxchange/jshopcore/model/customer/ShopCustomer.java
src/org/mxchange/jshopcore/model/order/ShopOrder.java
src/org/mxchange/jshopcore/model/order/items/OrderItem.java

index 3dc05dc54c713453d951be1e327a06ade62fcb14..fb5fd00d2167ea226314998afd63d9fd86f34c26 100644 (file)
@@ -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<AddableBasketItem> {
 
        /**
         * Serial number
index f02fb937136937d3c425c39ec19fb55d8b22019b..721e638fef6e124c198b8e8a7bf4e723a71f451f 100644 (file)
@@ -50,13 +50,6 @@ public class ProductCategory implements Category, Comparable<Category> {
        @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<Category> {
        @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
         * <p>
@@ -122,22 +122,22 @@ public class ProductCategory implements Category, Comparable<Category> {
        }
 
        @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;
        }
 }
index 00de0eb38d6df51715304f7d35a45ffb60c8efe3..02610b346c9d69b847013c256571d55326910724 100644 (file)
@@ -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<Customer> {
 
        /**
         * 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;
-       }
 }
index 4cb508bc5b9ed7f2b131fe62d14c1a910a1a2793..11dce5557b08e2cd9dd7cfd83208148e3e4990ed 100644 (file)
@@ -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<Orderable> {
 
        /**
         * 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<AddableBasketItem> 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<AddableBasketItem> 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
index 6f8fa361cec5f40d67485645a539302cc4f06f9b..4ddb964c41e40e7c7cb27edbb8be90b7bcba59df 100644 (file)
@@ -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<AddableBasketItem> {
 
        /**
         * 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;
        }
 }