KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > jtrac > domain > AbstractItem


1 /*
2  * Copyright 2002-2005 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package info.jtrac.domain;
18
19 import java.io.Serializable JavaDoc;
20 import java.util.Date JavaDoc;
21
22 import static info.jtrac.domain.Field.Name.*;
23 import info.jtrac.util.DateUtils;
24 import java.util.LinkedHashSet JavaDoc;
25 import java.util.Set JavaDoc;
26 import org.springmodules.lucene.index.core.DocumentCreator;
27
28 /**
29  * Abstract class that serves as base for both Item and History
30  * this contains the fields that are common to both and persisted
31  */

32 public abstract class AbstractItem implements Serializable JavaDoc, DocumentCreator {
33
34     private long id;
35     private int version;
36     private Item parent; // slightly different meaning for Item and History
37
private String JavaDoc summary;
38     private String JavaDoc detail;
39     private User loggedBy;
40     private User assignedTo;
41     private Date JavaDoc timeStamp;
42     private Double JavaDoc plannedEffort;
43     //===========================
44
private Integer JavaDoc status;
45     private Integer JavaDoc severity;
46     private Integer JavaDoc priority;
47     private Integer JavaDoc cusInt01;
48     private Integer JavaDoc cusInt02;
49     private Integer JavaDoc cusInt03;
50     private Integer JavaDoc cusInt04;
51     private Integer JavaDoc cusInt05;
52     private Integer JavaDoc cusInt06;
53     private Integer JavaDoc cusInt07;
54     private Integer JavaDoc cusInt08;
55     private Integer JavaDoc cusInt09;
56     private Integer JavaDoc cusInt10;
57     private Double JavaDoc cusDbl01;
58     private Double JavaDoc cusDbl02;
59     private Double JavaDoc cusDbl03;
60     private String JavaDoc cusStr01;
61     private String JavaDoc cusStr02;
62     private String JavaDoc cusStr03;
63     private String JavaDoc cusStr04;
64     private String JavaDoc cusStr05;
65     private Date JavaDoc cusTim01;
66     private Date JavaDoc cusTim02;
67     private Date JavaDoc cusTim03;
68     
69     // probably belong to Item not AbstractItem, but convenient for item_view_form binding
70
private Set JavaDoc<ItemUser> itemUsers;
71     private Set JavaDoc<ItemItem> relatedItems;
72     private Set JavaDoc<ItemItem> relatingItems;
73     private Set JavaDoc<ItemTag> itemTags;
74     
75     // mvc form binding convenience not really domain, TODO refactor
76
private boolean sendNotifications = true;
77     
78     // we could have used reflection or a Map but doing this way for performance
79
public Object JavaDoc getValue(Field.Name fieldName) {
80         switch(fieldName) {
81             case SEVERITY: return severity;
82             case PRIORITY: return priority;
83             case CUS_INT_01: return cusInt01;
84             case CUS_INT_02: return cusInt02;
85             case CUS_INT_03: return cusInt03;
86             case CUS_INT_04: return cusInt04;
87             case CUS_INT_05: return cusInt05;
88             case CUS_INT_06: return cusInt06;
89             case CUS_INT_07: return cusInt07;
90             case CUS_INT_08: return cusInt08;
91             case CUS_INT_09: return cusInt09;
92             case CUS_INT_10: return cusInt10;
93             case CUS_DBL_01: return cusDbl01;
94             case CUS_DBL_02: return cusDbl02;
95             case CUS_DBL_03: return cusDbl03;
96             case CUS_STR_01: return cusStr01;
97             case CUS_STR_02: return cusStr02;
98             case CUS_STR_03: return cusStr03;
99             case CUS_STR_04: return cusStr04;
100             case CUS_STR_05: return cusStr05;
101             case CUS_TIM_01: return cusTim01;
102             case CUS_TIM_02: return cusTim02;
103             case CUS_TIM_03: return cusTim03;
104         }
105         // should never reach here
106
return null;
107     }
108     
109     // we could have used reflection or a Map but doing this way for performance
110
public void setValue(Field.Name fieldName, Object JavaDoc value) {
111         switch(fieldName) {
112             case SEVERITY: severity = (Integer JavaDoc) value; break;
113             case PRIORITY: priority = (Integer JavaDoc) value; break;
114             case CUS_INT_01: cusInt01 = (Integer JavaDoc) value; break;
115             case CUS_INT_02: cusInt02 = (Integer JavaDoc) value; break;
116             case CUS_INT_03: cusInt03 = (Integer JavaDoc) value; break;
117             case CUS_INT_04: cusInt04 = (Integer JavaDoc) value; break;
118             case CUS_INT_05: cusInt05 = (Integer JavaDoc) value; break;
119             case CUS_INT_06: cusInt06 = (Integer JavaDoc) value; break;
120             case CUS_INT_07: cusInt07 = (Integer JavaDoc) value; break;
121             case CUS_INT_08: cusInt08 = (Integer JavaDoc) value; break;
122             case CUS_INT_09: cusInt09 = (Integer JavaDoc) value; break;
123             case CUS_INT_10: cusInt10 = (Integer JavaDoc) value; break;
124             case CUS_DBL_01: cusDbl01 = (Double JavaDoc) value; break;
125             case CUS_DBL_02: cusDbl02 = (Double JavaDoc) value; break;
126             case CUS_DBL_03: cusDbl03 = (Double JavaDoc) value; break;
127             case CUS_STR_01: cusStr01 = (String JavaDoc) value; break;
128             case CUS_STR_02: cusStr02 = (String JavaDoc) value; break;
129             case CUS_STR_03: cusStr03 = (String JavaDoc) value; break;
130             case CUS_STR_04: cusStr04 = (String JavaDoc) value; break;
131             case CUS_STR_05: cusStr05 = (String JavaDoc) value; break;
132             case CUS_TIM_01: cusTim01 = (Date JavaDoc) value ; break;
133             case CUS_TIM_02: cusTim02 = (Date JavaDoc) value; break;
134             case CUS_TIM_03: cusTim03 = (Date JavaDoc) value;
135         }
136     }
137     
138     // must override, History behaves differently from Item
139
public abstract Space getSpace();
140     public abstract String JavaDoc getRefId();
141     
142     public String JavaDoc getCustomValue(Field.Name fieldName) {
143         // using accessor for space, getSpace() is overridden in subclass History
144
if (fieldName.getType() <= 3) {
145             return getSpace().getMetadata().getCustomValue(fieldName, (Integer JavaDoc) getValue(fieldName));
146         } else {
147             Object JavaDoc o = getValue(fieldName);
148             if (o == null) {
149                 return "";
150             }
151             if (o instanceof Date JavaDoc) {
152                 return DateUtils.format((Date JavaDoc) o);
153             }
154             return o.toString();
155         }
156     }
157
158     public String JavaDoc getStatusValue() {
159         // using accessor for space, getSpace() is overridden in subclass History
160
return getSpace().getMetadata().getStatusValue(status);
161     }
162     
163     //===================================================
164

165     public Integer JavaDoc getStatus() {
166         return status;
167     }
168
169     public Integer JavaDoc getSeverity() {
170         return severity;
171     }
172
173     public Integer JavaDoc getPriority() {
174         return priority;
175     }
176
177     public Integer JavaDoc getCusInt01() {
178         return cusInt01;
179     }
180
181     public Integer JavaDoc getCusInt02() {
182         return cusInt02;
183     }
184
185     public Integer JavaDoc getCusInt03() {
186         return cusInt03;
187     }
188
189     public Integer JavaDoc getCusInt04() {
190         return cusInt04;
191     }
192
193     public Integer JavaDoc getCusInt05() {
194         return cusInt05;
195     }
196
197     public Integer JavaDoc getCusInt06() {
198         return cusInt06;
199     }
200
201     public Integer JavaDoc getCusInt07() {
202         return cusInt07;
203     }
204
205     public Integer JavaDoc getCusInt08() {
206         return cusInt08;
207     }
208
209     public Integer JavaDoc getCusInt09() {
210         return cusInt09;
211     }
212
213     public Integer JavaDoc getCusInt10() {
214         return cusInt10;
215     }
216
217     public Double JavaDoc getCusDbl01() {
218         return cusDbl01;
219     }
220
221     public Double JavaDoc getCusDbl02() {
222         return cusDbl02;
223     }
224
225     public Double JavaDoc getCusDbl03() {
226         return cusDbl03;
227     }
228
229     public String JavaDoc getCusStr01() {
230         return cusStr01;
231     }
232
233     public String JavaDoc getCusStr02() {
234         return cusStr02;
235     }
236
237     public String JavaDoc getCusStr03() {
238         return cusStr03;
239     }
240
241     public String JavaDoc getCusStr04() {
242         return cusStr04;
243     }
244
245     public String JavaDoc getCusStr05() {
246         return cusStr05;
247     }
248
249     public Date JavaDoc getCusTim01() {
250         return cusTim01;
251     }
252
253     public Date JavaDoc getCusTim02() {
254         return cusTim02;
255     }
256
257     public Date JavaDoc getCusTim03() {
258         return cusTim03;
259     }
260
261     //===============================================================
262

263     public void setStatus(Integer JavaDoc status) {
264         this.status = status;
265     }
266
267     public void setSeverity(Integer JavaDoc severity) {
268         this.severity = severity;
269     }
270
271     public void setPriority(Integer JavaDoc priority) {
272         this.priority = priority;
273     }
274
275     public void setCusInt01(Integer JavaDoc cusInt01) {
276         this.cusInt01 = cusInt01;
277     }
278
279     public void setCusInt02(Integer JavaDoc cusInt02) {
280         this.cusInt02 = cusInt02;
281     }
282
283     public void setCusInt03(Integer JavaDoc cusInt03) {
284         this.cusInt03 = cusInt03;
285     }
286
287     public void setCusInt04(Integer JavaDoc cusInt04) {
288         this.cusInt04 = cusInt04;
289     }
290
291     public void setCusInt05(Integer JavaDoc cusInt05) {
292         this.cusInt05 = cusInt05;
293     }
294
295     public void setCusInt06(Integer JavaDoc cusInt06) {
296         this.cusInt06 = cusInt06;
297     }
298
299     public void setCusInt07(Integer JavaDoc cusInt07) {
300         this.cusInt07 = cusInt07;
301     }
302
303     public void setCusInt08(Integer JavaDoc cusInt08) {
304         this.cusInt08 = cusInt08;
305     }
306
307     public void setCusInt09(Integer JavaDoc cusInt09) {
308         this.cusInt09 = cusInt09;
309     }
310
311     public void setCusInt10(Integer JavaDoc cusInt10) {
312         this.cusInt10 = cusInt10;
313     }
314
315     public void setCusDbl01(Double JavaDoc cusDbl01) {
316         this.cusDbl01 = cusDbl01;
317     }
318
319     public void setCusDbl02(Double JavaDoc cusDbl02) {
320         this.cusDbl02 = cusDbl02;
321     }
322
323     public void setCusDbl03(Double JavaDoc cusDbl03) {
324         this.cusDbl03 = cusDbl03;
325     }
326
327     public void setCusStr01(String JavaDoc cusStr01) {
328         this.cusStr01 = cusStr01;
329     }
330
331     public void setCusStr02(String JavaDoc cusStr02) {
332         this.cusStr02 = cusStr02;
333     }
334
335     public void setCusStr03(String JavaDoc cusStr03) {
336         this.cusStr03 = cusStr03;
337     }
338
339     public void setCusStr04(String JavaDoc cusStr04) {
340         this.cusStr04 = cusStr04;
341     }
342
343     public void setCusStr05(String JavaDoc cusStr05) {
344         this.cusStr05 = cusStr05;
345     }
346
347     public void setCusTim01(Date JavaDoc cusTim01) {
348         this.cusTim01 = cusTim01;
349     }
350
351     public void setCusTim02(Date JavaDoc cusTim02) {
352         this.cusTim02 = cusTim02;
353     }
354
355     public void setCusTim03(Date JavaDoc cusTim03) {
356         this.cusTim03 = cusTim03;
357     }
358
359     //=======================================================================
360

361     public long getId() {
362         return id;
363     }
364
365     public void setId(long id) {
366         this.id = id;
367     }
368     
369     public int getVersion() {
370         return version;
371     }
372
373     public void setVersion(int version) {
374         this.version = version;
375     }
376
377     public Item getParent() {
378         return parent;
379     }
380
381     public void setParent(Item parent) {
382         this.parent = parent;
383     }
384
385     public String JavaDoc getSummary() {
386         return summary;
387     }
388
389     public void setSummary(String JavaDoc summary) {
390         this.summary = summary;
391     }
392
393     public String JavaDoc getDetail() {
394         return detail;
395     }
396
397     public void setDetail(String JavaDoc detail) {
398         this.detail = detail;
399     }
400
401     public User getLoggedBy() {
402         return loggedBy;
403     }
404
405     public void setLoggedBy(User loggedBy) {
406         this.loggedBy = loggedBy;
407     }
408
409     public User getAssignedTo() {
410         return assignedTo;
411     }
412
413     public void setAssignedTo(User assignedTo) {
414         this.assignedTo = assignedTo;
415     }
416
417     public Date JavaDoc getTimeStamp() {
418         return timeStamp;
419     }
420
421     public void setTimeStamp(Date JavaDoc timeStamp) {
422         this.timeStamp = timeStamp;
423     }
424
425     public Double JavaDoc getPlannedEffort() {
426         return plannedEffort;
427     }
428
429     public void setPlannedEffort(Double JavaDoc plannedEffort) {
430         this.plannedEffort = plannedEffort;
431     }
432     
433     public boolean isSendNotifications() {
434         return sendNotifications;
435     }
436
437     public void setSendNotifications(boolean sendNotifications) {
438         this.sendNotifications = sendNotifications;
439     }
440     
441     public Set JavaDoc<ItemUser> getItemUsers() {
442         return itemUsers;
443     }
444
445     public void setItemUsers(Set JavaDoc<ItemUser> itemUsers) {
446         this.itemUsers = itemUsers;
447     }
448     
449     public Set JavaDoc<ItemItem> getRelatedItems() {
450         return relatedItems;
451     }
452
453     public void setRelatedItems(Set JavaDoc<ItemItem> relatedItems) {
454         this.relatedItems = relatedItems;
455     }
456     
457     public Set JavaDoc<ItemItem> getRelatingItems() {
458         return relatingItems;
459     }
460
461     public void setRelatingItems(Set JavaDoc<ItemItem> relatingItems) {
462         this.relatingItems = relatingItems;
463     }
464     
465     public Set JavaDoc<ItemTag> getItemTags() {
466         return itemTags;
467     }
468
469     public void setItemTags(Set JavaDoc<ItemTag> itemTags) {
470         this.itemTags = itemTags;
471     }
472     
473     @Override JavaDoc
474     public String JavaDoc toString() {
475         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
476         sb.append("id [").append(id);
477         sb.append("]; parent [").append(parent == null ? "" : parent.getId());
478         sb.append("]; summary [").append(summary);
479         sb.append("]; detail [").append(detail);
480         sb.append("]; loggedBy [").append(loggedBy);
481         sb.append("]; status [").append(status);
482         sb.append("]; assignedTo [").append(assignedTo);
483         sb.append("]; timeStamp [").append(timeStamp);
484         sb.append("]; severity [").append(severity);
485         sb.append("]; priority [").append(priority);
486         sb.append("]; cusInt01 [").append(cusInt01);
487         sb.append("]; cusInt02 [").append(cusInt02);
488         sb.append("]; cusInt03 [").append(cusInt03);
489         sb.append("]; cusInt04 [").append(cusInt04);
490         sb.append("]; cusInt05 [").append(cusInt05);
491         sb.append("]; cusInt06 [").append(cusInt06);
492         sb.append("]; cusInt07 [").append(cusInt07);
493         sb.append("]; cusInt08 [").append(cusInt08);
494         sb.append("]; cusInt09 [").append(cusInt09);
495         sb.append("]; cusInt10 [").append(cusInt10);
496         sb.append("]; cusDbl01 [").append(cusDbl01);
497         sb.append("]; cusDbl02 [").append(cusDbl02);
498         sb.append("]; cusDbl03 [").append(cusDbl03);
499         sb.append("]; cusStr01 [").append(cusStr01);
500         sb.append("]; cusStr02 [").append(cusStr02);
501         sb.append("]; cusStr03 [").append(cusStr03);
502         sb.append("]; cusStr04 [").append(cusStr04);
503         sb.append("]; cusStr05 [").append(cusStr05);
504         sb.append("]; cusTim01 [").append(cusTim01);
505         sb.append("]; cusTim02 [").append(cusTim02);
506         sb.append("]; cusTim03 [").append(cusTim03);
507         sb.append("]");
508         return sb.toString();
509     }
510
511 }
512
Popular Tags