Reader.java
5.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package fi.insomnia.bortal.model;
import static javax.persistence.CascadeType.DETACH;
import static javax.persistence.CascadeType.MERGE;
import static javax.persistence.CascadeType.PERSIST;
import static javax.persistence.CascadeType.REFRESH;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import org.eclipse.persistence.annotations.OptimisticLocking;
import org.eclipse.persistence.annotations.OptimisticLockingType;
import fi.insomnia.bortal.model.salespoint.SalesEntity;
/**
*
*/
@Entity
@Table(name = "readers", uniqueConstraints = { @UniqueConstraint(columnNames = { "reader_ident", "event_id" }) })
@OptimisticLocking(type = OptimisticLockingType.CHANGED_COLUMNS)
public class Reader extends GenericEntity {
public Reader(LanEvent ev, String ident) {
this(ev);
this.identification = ident;
}
public Reader() {
super();
}
public Reader(LanEvent ev) {
super();
this.setEvent(ev);
}
@Column(nullable = false, name = "type")
@Enumerated(EnumType.STRING)
private ReaderType type = ReaderType.RFID;
public static final String EVENT_ID_COLUMN = "event_id";
@ManyToOne()
@JoinColumn(name = EVENT_ID_COLUMN, nullable = false)
private LanEvent event;
@Column(nullable = false)
private Integer gamepoints = 0;
@Column(nullable = false)
private Integer maxEvents = 0;
@OneToOne(mappedBy = "reader")
private SalesEntity salesEntity;
@ManyToOne
@JoinColumn(name = "automatic_product_id")
private Product automaticProduct;
@Column(precision = 25, scale = 4, name = "automatic_product_count")
private BigDecimal automaticProductCount;
private static final long serialVersionUID = 616803985117256035L;
@Column(name = "reader_ident")
private String identification;
@Lob
@Column(name = "reader_description")
private String description;
@JoinColumn(name = "location_id", referencedColumnName = "id")
@ManyToOne
private Location location;
@ManyToOne
@JoinColumn(name = "map_id", referencedColumnName = "id")
private EventMap eventMap;
@Column(name = "map_x")
private Integer mapX;
@Column(name = "map_y")
private Integer mapY;
@OneToMany(mappedBy = "reader", cascade = { PERSIST, MERGE, REFRESH, DETACH })
private List<ReaderEvent> events = new ArrayList<ReaderEvent>();
public String getIdentification() {
return identification;
}
public void setIdentification(String readerId) {
this.identification = readerId;
}
public String getDescription() {
return description;
}
public void setDescription(String readerDescription) {
this.description = readerDescription;
}
public Location getLocation() {
return location;
}
public void setLocation(Location locationsId) {
this.location = locationsId;
}
/**
* @return the mapX
*/
public Integer getMapX() {
return mapX;
}
/**
* @param mapX
* the mapX to set
*/
public void setMapX(Integer mapX) {
this.mapX = mapX;
}
/**
* @return the mapY
*/
public Integer getMapY() {
return mapY;
}
/**
* @param mapY
* the mapY to set
*/
public void setMapY(Integer mapY) {
this.mapY = mapY;
}
/**
* @return the eventMap
*/
public EventMap getEventMap() {
return eventMap;
}
/**
* @param eventMap
* the eventMap to set
*/
public void setEventMap(EventMap eventMap) {
this.eventMap = eventMap;
}
public void setGamepoints(Integer gamepoints) {
this.gamepoints = gamepoints;
}
public Integer getGamepoints() {
return gamepoints;
}
public void setMaxEvents(Integer maxEvents) {
this.maxEvents = maxEvents;
}
public Integer getMaxEvents() {
return maxEvents;
}
public void setEvents(List<ReaderEvent> events) {
this.events = events;
}
public List<ReaderEvent> getEvents() {
return events;
}
public LanEvent getEvent() {
return event;
}
public void setEvent(LanEvent event) {
this.event = event;
}
public SalesEntity getSalesEntity() {
return salesEntity;
}
public void setSalesEntity(SalesEntity salesEntity) {
this.salesEntity = salesEntity;
}
public boolean isAutoproduct() {
return (automaticProduct != null && automaticProductCount != null);
}
public ReaderType getType() {
return type;
}
public void setType(ReaderType type) {
this.type = type;
}
public Product getAutomaticProduct() {
return automaticProduct;
}
public void setAutomaticProduct(Product automaticProduct) {
this.automaticProduct = automaticProduct;
}
public BigDecimal getAutomaticProductCount() {
return automaticProductCount;
}
public void setAutomaticProductCount(BigDecimal automaticProductCount) {
this.automaticProductCount = automaticProductCount;
}
}