Subversion Repositories general

Rev

Rev 12 | Rev 16 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
11 dev 1
package ak.kickup.core.model;
3 dev 2
 
3
import java.math.BigDecimal;
4
import java.util.Collection;
9 dev 5
import java.util.Collections;
3 dev 6
import java.util.ArrayList;
7
import java.util.Iterator;
8
import java.util.Date;
9
import java.util.Map;
10
import java.util.HashMap;
11 dev 11
import ak.kickup.util.ModelException;
12
import ak.kickup.util.ModelSecurityException;
3 dev 13
 
14
/**
15
 *
16
 * @hibernate.class table="events"
17
 */
18
public class Event
19
	extends GeneralModelObject
20
{
21
	private String     name;
22
	private String     place;
23
	private String     address;
24
	private String     transportDesc;
25
	private Date       start;
26
	private Date       stop;
27
	private Date       lastRegister;
28
	private Date       lastUnregister;
29
	private BigDecimal price;
30
	private String     moneyAccount;
31
	private Boolean    enabled;
32
	private String     comment;
9 dev 33
	private Collection acts;                          // Collection(EventAct)
34
    private Map        actsMap = new HashMap();       // Map(Long id -> EventAct)
35
	private Collection apartments;                    // Collection(EventApartment)
36
    private Map        apartmentsMap = new HashMap(); // Map(Long id -> EventApartment)
3 dev 37
 
38
	protected Event()
39
	{
40
	}
41
 
42
	protected void init()
43
	{
44
		acts = new ArrayList();
45
	}
46
 
47
	/**
48
	 *
49
	 * @hibernate.property
50
	 */
51
	public String getName()
52
	{
53
		return name;
54
	}
55
 
56
	public void setName(String name)
57
	{
58
		this.name = name;
59
	}
60
 
61
	/**
62
	 *
63
	 * @hibernate.property
64
	 */
65
	public String getPlace()
66
	{
67
		return place;
68
	}
69
 
70
	public void setPlace(String place)
71
	{
72
		this.place = place;
73
	}
74
 
75
	/**
76
	 *
77
	 * @hibernate.property
78
	 */
79
	public String getAddress()
80
	{
81
		return address;
82
	}
83
 
84
	public void setAddress(String address)
85
	{
86
		this.address = address;
87
	}
88
 
89
	/**
90
	 *
91
	 * @hibernate.property column="transport_desc"
92
	 */
93
	public String getTransportDesc()
94
	{
95
		return transportDesc;
96
	}
97
 
98
	public void setTransportDesc(String transportDesc)
99
	{
100
		this.transportDesc = transportDesc;
101
	}
102
 
103
	/**
104
	 *
105
	 * @hibernate.property
106
	 */
107
	public Date getStart()
108
	{
109
		return start;
110
	}
111
 
112
	public void setStart(Date start)
113
	{
114
		this.start = start;
115
	}
116
 
117
	/**
118
	 *
119
	 * @hibernate.property
120
	 */
121
	public Date getStop()
122
	{
123
		return stop;
124
	}
125
 
126
	public void setStop(Date stop)
127
	{
128
		this.stop = stop;
129
	}
130
 
131
	/**
132
	 *
133
	 * @hibernate.property column="last_register"
134
	 */
135
	public Date getLastRegister()
136
	{
137
		return lastRegister;
138
	}
139
 
140
	public void setLastRegister(Date lastRegister)
141
	{
142
		this.lastRegister = lastRegister;
143
	}
144
 
145
	/**
146
	 *
147
	 * @hibernate.property column="last_unregister"
148
	 */
149
	public Date getLastUnregister()
150
	{
151
		return lastUnregister;
152
	}
153
 
154
	public void setLastUnregister(Date lastUnregister)
155
	{
156
		this.lastUnregister = lastUnregister;
157
	}
158
 
159
	/**
160
	 *
161
	 * @hibernate.property
162
	 */
163
	public BigDecimal getPrice()
164
	{
165
		return price;
166
	}
167
 
168
	public void setPrice(BigDecimal price)
169
	{
170
		this.price = price;
171
	}
172
 
173
	/**
174
	 *
175
	 * @hibernate.property column="money_account"
176
	 */
177
	public String getMoneyAccount()
178
	{
179
		return moneyAccount;
180
	}
181
 
182
	public void setMoneyAccount(String moneyAccount)
183
	{
184
		this.moneyAccount = moneyAccount;
185
	}
186
 
187
	/**
188
	 *
189
	 * @hibernate.property
190
	 */
191
	public Boolean getEnabled()
192
	{
193
		return enabled;
194
	}
195
 
196
	public void setEnabled(Boolean enabled)
197
	{
198
		this.enabled = enabled;
199
	}
200
 
201
	/**
202
	 *
203
	 * @hibernate.property
204
	 */
205
	public String getComment()
206
	{
207
		return comment;
208
	}
209
 
210
	public void setComment(String comment)
211
	{
212
		this.comment = comment;
213
	}
214
 
215
 	/**
216
 	 * @return Collection(EventAct)
217
 	 *
218
 	 * @hibernate.bag inverse="true" cascade="all-delete-orphan" lazy="true"
9 dev 219
	 * @hibernate.collection-key column="event"
11 dev 220
     * @hibernate.collection-one-to-many class="ak.kickup.core.model.EventAct"
3 dev 221
     */
9 dev 222
	protected Collection getActs()
3 dev 223
	{
224
		return acts;
225
	}
226
 
9 dev 227
	public Collection getActCollection()
228
	{
229
		return Collections.unmodifiableCollection(acts);
230
	}
231
 
3 dev 232
	/**
233
	 * @param destinations Collection(EventAct)
234
	 */
9 dev 235
	protected void setActs(Collection acts)
3 dev 236
	{
237
		this.acts = acts;
238
 
239
		actsMap.clear();
9 dev 240
		if(acts != null) {
241
			for(Iterator i = acts.iterator(); i.hasNext(); ) {
242
				EventAct a = (EventAct)i.next();
243
				actsMap.put(a.getAct().getId(), a);
244
			}
3 dev 245
		}
246
	}
247
 
248
	public EventAct getAct(Long actId)
249
	{
250
		return (EventAct)actsMap.get(actId);
251
	}
9 dev 252
 
253
	public void addAct(EventAct act)
254
	{
255
		acts.add(act);
256
		actsMap.put(act.getAct().getId(), act);
257
	}
258
 
259
	public void removeAct(EventAct act)
260
	{
261
		acts.remove(act);
262
		actsMap.remove(act.getAct().getId());
263
	}
264
 
265
 	/**
266
 	 * @return Collection(EventApartment)
267
 	 *
268
 	 * @hibernate.bag inverse="true" cascade="all-delete-orphan" lazy="true"
269
	 * @hibernate.collection-key column="event"
11 dev 270
     * @hibernate.collection-one-to-many class="ak.kickup.core.model.EventApartment"
9 dev 271
     */
272
	protected Collection getApartments()
273
	{
274
		return apartments;
275
	}
276
 
277
	public Collection getApartmentCollection()
278
	{
279
		return Collections.unmodifiableCollection(apartments);
280
	}
281
 
282
	/**
283
	 * @param destinations Collection(EventApartment)
284
	 */
285
	protected void setApartments(Collection apartments)
286
	{
287
		this.apartments = apartments;
288
 
289
		apartmentsMap.clear();
290
		if(apartments != null) {
291
			for(Iterator i = apartments.iterator(); i.hasNext(); ) {
292
				EventApartment a = (EventApartment)i.next();
293
				apartmentsMap.put(a.getApartment().getId(), a);
294
			}
295
		}
296
	}
297
 
298
	public EventApartment getApartment(Long apartmentId)
299
	{
300
		return (EventApartment)apartmentsMap.get(apartmentId);
301
	}
302
 
303
	public void addApartment(EventApartment apartment)
304
	{
305
		apartments.add(apartment);
306
		apartmentsMap.put(apartment.getApartment().getId(), apartment);
307
	}
308
 
309
	public void removeApartment(EventApartment apartment)
310
	{
311
		apartments.remove(apartment);
312
		apartmentsMap.remove(apartment.getApartment().getId());
313
	}
3 dev 314
}