]> git.mxchange.org Git - jproduct-core.git/blob - src/org/mxchange/jshopcore/model/order/ShopOrder.java
66b75e0c9dec1d063a8452b7cf2624fbcb6c4918
[jproduct-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.CascadeType;
23 import javax.persistence.Column;
24 import javax.persistence.Entity;
25 import javax.persistence.GeneratedValue;
26 import javax.persistence.GenerationType;
27 import javax.persistence.Id;
28 import javax.persistence.JoinColumn;
29 import javax.persistence.OneToOne;
30 import javax.persistence.Table;
31 import javax.persistence.Temporal;
32 import javax.persistence.TemporalType;
33 import javax.persistence.Transient;
34 import org.mxchange.jshopcore.model.basket.AddableBasketItem;
35 import org.mxchange.jshopcore.model.customer.Customer;
36 import org.mxchange.jshopcore.model.customer.ShopCustomer;
37
38 /**
39  * An entity class for shop orders
40  * <p>
41  * @author Roland Haeder
42  */
43 @Entity (name = "orders")
44 @Table (name = "orders")
45 public class ShopOrder implements Orderable {
46
47         /**
48          * Serial number
49          */
50         private static final long serialVersionUID = 19_728_938_459_834L;
51
52         /**
53          * Access key
54          */
55         @Basic (optional = false)
56         @Column (name = "access_key", length = 100, nullable = false, unique = true)
57         private String accessKey;
58
59         /**
60          * Created timestamp
61          */
62         @Basic (optional = false)
63         @Temporal (TemporalType.TIMESTAMP)
64         @Column (name = "order_created", nullable = false)
65         private Calendar orderCreated;
66
67         /**
68          * Customer instance
69          */
70         @JoinColumn (name = "customer_id", nullable = false, updatable = false)
71         @OneToOne (targetEntity = ShopCustomer.class, cascade = CascadeType.MERGE, optional = false)
72         private Customer customer;
73
74         /**
75          * Item list, don't save this
76          */
77         @Transient
78         private List<AddableBasketItem> orderedItems;
79
80         /**
81          * Order orderId
82          */
83         @Id
84         @GeneratedValue (strategy = GenerationType.IDENTITY)
85         @Column (name = "order_id", length = 20)
86         private Long orderId;
87
88         @Override
89         public String getAccessKey () {
90                 return this.accessKey;
91         }
92
93         @Override
94         public void setAccessKey (final String accessKey) {
95                 this.accessKey = accessKey;
96         }
97
98         @Override
99         public Calendar getOrderCreated () {
100                 return this.orderCreated;
101         }
102
103         @Override
104         public void setOrderCreated (final Calendar orderCreated) {
105                 this.orderCreated = orderCreated;
106         }
107
108         @Override
109         public Customer getCustomer () {
110                 return this.customer;
111         }
112
113         @Override
114         public void setCustomer (final Customer customer) {
115                 this.customer = customer;
116         }
117
118         @Override
119         public Long getOrderId () {
120                 return this.orderId;
121         }
122
123         @Override
124         public void setOrderId (final Long orderId) {
125                 this.orderId = orderId;
126         }
127
128         @Override
129         public List<AddableBasketItem> getOrderedItems () {
130                 return this.orderedItems;
131         }
132
133         @Override
134         public void setOrderedItems (final List<AddableBasketItem> orderedItems) {
135                 this.orderedItems = orderedItems;
136         }
137 }