*/
@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
@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
*/
@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>
}
@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;
}
}
*/
@Entity (name = "customer")
@Table (name = "customer")
-public class ShopCustomer implements Customer {
+public class ShopCustomer implements Customer, Comparable<Customer> {
/**
* Serial number
@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
*/
@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
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;
this.customerPasswordHash = customerPasswordHash;
}
- @Override
- public CustomerAccountStatus getCustomerAccountStatus () {
- return this.customerAccountStatus;
- }
-
- @Override
- public void setCustomerAccountStatus (final CustomerAccountStatus customerAccountStatus) {
- this.customerAccountStatus = customerAccountStatus;
- }
}
*/
@Entity (name = "orders")
@Table (name = "orders")
-public class ShopOrder implements Orderable {
+public class ShopOrder implements Orderable, Comparable<Orderable> {
/**
* Serial number
@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
*/
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
@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;
}
@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
*/
@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
}
@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
}
@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;
}
}