]> git.mxchange.org Git - jproduct-core.git/blob - src/org/mxchange/jshopcore/model/order/items/OrderItem.java
Updated copyright year
[jproduct-core.git] / src / org / mxchange / jshopcore / model / order / items / OrderItem.java
1 /*
2  * Copyright (C) 2016 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.items;
18
19 import javax.persistence.Basic;
20 import javax.persistence.CascadeType;
21 import javax.persistence.Column;
22 import javax.persistence.Entity;
23 import javax.persistence.GeneratedValue;
24 import javax.persistence.GenerationType;
25 import javax.persistence.Id;
26 import javax.persistence.JoinColumn;
27 import javax.persistence.OneToOne;
28 import javax.persistence.Table;
29 import org.mxchange.jshopcore.model.basket.AddableBasketItem;
30 import org.mxchange.jshopcore.model.basket.items.BaseItem;
31 import org.mxchange.jshopcore.model.product.GenericProduct;
32 import org.mxchange.jshopcore.model.product.Product;
33
34 /**
35  * A general basket item
36  * <p>
37  * @author Roland Haeder<roland@mxchange.org>
38  */
39 @Entity (name = "ordered_item")
40 @Table (name = "ordered_items")
41 public class OrderItem extends BaseItem implements AddableBasketItem {
42
43         /**
44          * Serial number
45          */
46         private static final long serialVersionUID = 44_189_562_738_723_581L;
47
48         /**
49          * Item amount
50          */
51         @Basic (optional = false)
52         @Column (name = "amount", length = 20, nullable = false)
53         private Long amount;
54
55         /**
56          * Entry id (from database backend)
57          */
58         @Id
59         @GeneratedValue (strategy = GenerationType.IDENTITY)
60         @Column (name = "id", nullable = false, length = 20)
61         private Long id;
62
63         /**
64          * Item type
65          */
66         @Basic (optional = false)
67         @Column (name = "item_type", length = 20)
68         private String itemType;
69
70         /**
71          * Product instance
72          */
73         @JoinColumn (name = "product_id", updatable = false)
74         @OneToOne (targetEntity = GenericProduct.class, cascade = CascadeType.MERGE)
75         private Product product;
76
77         /**
78          * Default constructor
79          */
80         public OrderItem () {
81         }
82
83         @Override
84         public Long getOrderedAmount () {
85                 return this.amount;
86         }
87
88         @Override
89         public void setOrderedAmount (final Long amount) {
90                 this.amount = amount;
91         }
92
93         @Override
94         public Long getItemId () {
95                 return this.id;
96         }
97
98         @Override
99         public void setItemId (final Long id) {
100                 this.id = id;
101         }
102
103         @Override
104         public String getItemType () {
105                 return this.itemType;
106         }
107
108         @Override
109         public void setItemType (final String itemType) {
110                 this.itemType = itemType;
111         }
112
113         @Override
114         public Product getItemProduct () {
115                 return this.product;
116         }
117
118         @Override
119         public void setItemProduct (final Product product) {
120                 this.product = product;
121         }
122 }