]> git.mxchange.org Git - jcustomer-core.git/blob - src/org/mxchange/jshopcore/model/order/ShopOrder.java
Continued:
[jcustomer-core.git] / src / org / mxchange / jshopcore / model / order / ShopOrder.java
1 /*
2  * Copyright (C) 2015 Roland Haeder
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17 package org.mxchange.jshopcore.model.order;
18
19 import java.util.Calendar;
20 import java.util.List;
21 import javax.persistence.Basic;
22 import javax.persistence.Column;
23 import javax.persistence.Entity;
24 import javax.persistence.GeneratedValue;
25 import javax.persistence.GenerationType;
26 import javax.persistence.Id;
27 import javax.persistence.JoinColumn;
28 import javax.persistence.OneToOne;
29 import javax.persistence.Table;
30 import javax.persistence.Temporal;
31 import javax.persistence.TemporalType;
32 import javax.persistence.Transient;
33 import org.mxchange.jshopcore.model.basket.AddableBasketItem;
34 import org.mxchange.jshopcore.model.customer.Customer;
35 import org.mxchange.jshopcore.model.customer.ShopCustomer;
36
37 /**
38  * An entity class for shop orders
39  *
40  * @author Roland Haeder
41  */
42 @Entity (name = "orders")
43 @Table (name = "orders")
44 public class ShopOrder implements Orderable {
45
46         /**
47          * Serial number
48          */
49         private static final long serialVersionUID = 19_728_938_459_834L;
50
51         /**
52          * Access key
53          */
54         @Basic (optional = false)
55         @Column (name = "access_key", length = 100, nullable = false, unique = true)
56         private String accessKey;
57
58         /**
59          * Created timestamp
60          */
61         @Basic (optional = false)
62         @Temporal (TemporalType.TIMESTAMP)
63         @Column (name = "order_created", nullable = false)
64         private Calendar orderCreated;
65
66         /**
67          * Customer instance
68          */
69         @JoinColumn (name = "customer_id", nullable = false, updatable = false)
70         @OneToOne (targetEntity = ShopCustomer.class, optional = false)
71         private Customer customer;
72
73         /**
74          * Item list, don't save this
75          */
76         @Transient
77         private List<AddableBasketItem> itemList;
78
79         /**
80          * Order orderId
81          */
82         @Id
83         @GeneratedValue (strategy = GenerationType.IDENTITY)
84         @Column (name = "order_id", length = 20)
85         private Long orderId;
86
87         @Override
88         public String getAccessKey () {
89                 return this.accessKey;
90         }
91
92         @Override
93         public void setAccessKey (final String accessKey) {
94                 this.accessKey = accessKey;
95         }
96
97         @Override
98         public Calendar getOrderCreated () {
99                 return this.orderCreated;
100         }
101
102         @Override
103         public void setOrderCreated (final Calendar orderCreated) {
104                 this.orderCreated = orderCreated;
105         }
106
107         @Override
108         public Customer getCustomer () {
109                 return this.customer;
110         }
111
112         @Override
113         public void setCustomer (final Customer customer) {
114                 this.customer = customer;
115         }
116
117         @Override
118         public Long getOrderId () {
119                 return this.orderId;
120         }
121
122         @Override
123         public void setOrderId (final Long orderId) {
124                 this.orderId = orderId;
125         }
126
127         @Override
128         public List<AddableBasketItem> getOrderedItems () {
129                 return itemList;
130         }
131
132         @Override
133         public void setOrderedItems (final List<AddableBasketItem> itemList) {
134                 this.itemList = itemList;
135         }
136 }