KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > cowsultants > itracker > ejb > beans > entity > IssueBean


1 /*
2  * This software was designed and created by Jason Carroll.
3  * Copyright (c) 2002, 2003, 2004 Jason Carroll.
4  * The author can be reached at jcarroll@cowsultants.com
5  * ITracker website: http://www.cowsultants.com
6  * ITracker forums: http://www.cowsultants.com/phpBB/index.php
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it only under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  */

18
19 package cowsultants.itracker.ejb.beans.entity;
20
21 import java.text.*;
22 import java.util.*;
23 import java.sql.Timestamp JavaDoc;
24 import javax.ejb.*;
25
26 import javax.naming.*;
27 import javax.rmi.*;
28
29 import cowsultants.itracker.ejb.client.util.*;
30 import cowsultants.itracker.ejb.client.models.*;
31
32 public abstract class IssueBean extends GenericBean {
33
34     public abstract String JavaDoc getDescription();
35     public abstract void setDescription(String JavaDoc value);
36
37     public abstract int getSeverity();
38     public abstract void setSeverity(int value);
39
40     public abstract int getStatus();
41     public abstract void setStatus(int value);
42
43     public abstract String JavaDoc getResolution();
44     public abstract void setResolution(String JavaDoc value);
45
46     public abstract ProjectLocal getProject();
47     public abstract void setProject(ProjectLocal value);
48
49     public abstract UserLocal getCreator();
50     public abstract void setCreator(UserLocal value);
51
52     public abstract UserLocal getOwner();
53     public abstract void setOwner(UserLocal value);
54
55     public abstract VersionLocal getTargetVersion();
56     public abstract void setTargetVersion(VersionLocal value);
57
58     public abstract Collection getComponents();
59     public abstract void setComponents(Collection components);
60
61     public abstract Collection getVersions();
62     public abstract void setVersions(Collection versions);
63
64     public abstract Collection getNotifications();
65     public abstract void setNotifications(Collection notifications);
66
67     public abstract Collection getActivities();
68     public abstract void setActivities(Collection activities);
69
70     public abstract Collection getAttachments();
71     public abstract void setAttachments(Collection attachments);
72
73     public abstract Collection getFields();
74     public abstract void setFields(Collection attachments);
75
76     public abstract Collection getHistory();
77     public abstract void setHistory(Collection notifications);
78
79     public abstract Collection ejbSelectLastModifiedDates(Integer JavaDoc projectId) throws FinderException;
80
81     public Date ejbHomeLatestModificationDate(Integer JavaDoc projectId) {
82         Timestamp JavaDoc latestDate = null;
83
84         try {
85             Collection dates = ejbSelectLastModifiedDates(projectId);
86             for(Iterator iterator = dates.iterator(); iterator.hasNext(); ) {
87                 Timestamp JavaDoc lastModDate = (Timestamp JavaDoc) iterator.next();
88                 if(latestDate == null) {
89                     latestDate = lastModDate;
90                 }
91                 if(lastModDate.after(latestDate)) {
92                     latestDate = lastModDate;
93                 }
94             }
95         } catch(FinderException fe) {
96             Logger.logWarn("FinderException while getting lastModified dates.", fe);
97         }
98         return (Date) latestDate;
99     }
100
101
102     public IssueModel getModel() {
103         IssueModel model = new IssueModel();
104         model.setId(this.getId());
105         model.setDescription(this.getDescription());
106         model.setSeverity(this.getSeverity());
107         model.setStatus(this.getStatus());
108         model.setResolution(this.getResolution());
109         model.setLastModifiedDate(this.getLastModifiedDate());
110         model.setCreateDate(this.getCreateDate());
111
112         if(this.getProject() != null) {
113             model.setProject(this.getProject().getModel());
114         }
115
116         if(this.getTargetVersion() != null) {
117             model.setTargetVersion(this.getTargetVersion().getModel());
118         }
119
120         if(this.getCreator() != null) {
121             model.setCreator(this.getCreator().getModel());
122         }
123
124         if(this.getOwner() != null) {
125             model.setOwner(this.getOwner().getModel());
126         }
127
128         Collection attachments = this.getAttachments();
129         IssueAttachmentModel[] attachmentsArray = new IssueAttachmentModel[attachments.size()];
130         int i = 0;
131         for(Iterator iterator = attachments.iterator(); iterator.hasNext(); i++) {
132             attachmentsArray[i] = ((IssueAttachmentLocal) iterator.next()).getModel();
133         }
134         model.setAttachments(attachmentsArray);
135
136         Collection history = this.getHistory();
137         IssueHistoryModel[] historyArray = new IssueHistoryModel[history.size()];
138         i = 0;
139         for(Iterator iterator = history.iterator(); iterator.hasNext(); i++) {
140             historyArray[i] = ((IssueHistoryLocal) iterator.next()).getModel();
141         }
142         model.setHistory(historyArray);
143
144         Collection fields = this.getFields();
145         IssueFieldModel[] fieldsArray = new IssueFieldModel[fields.size()];
146         i = 0;
147         for(Iterator iterator = fields.iterator(); iterator.hasNext(); i++) {
148             fieldsArray[i] = ((IssueFieldLocal) iterator.next()).getModel();
149         }
150         model.setFields(fieldsArray);
151
152         Collection notifications = this.getNotifications();
153         NotificationModel[] notificationsArray = new NotificationModel[notifications.size()];
154         i = 0;
155         for(Iterator iterator = notifications.iterator(); iterator.hasNext(); i++) {
156             notificationsArray[i] = ((NotificationLocal) iterator.next()).getModel();
157         }
158         model.setNotifications(notificationsArray);
159
160         Collection components = this.getComponents();
161         ComponentModel[] componentsArray = new ComponentModel[components.size()];
162         i = 0;
163         for(Iterator iterator = components.iterator(); iterator.hasNext(); i++) {
164             componentsArray[i] = ((ComponentLocal) iterator.next()).getModel();
165         }
166         model.setComponents(componentsArray);
167
168         Collection versions = this.getVersions();
169         VersionModel[] versionsArray = new VersionModel[versions.size()];
170         i = 0;
171         for(Iterator iterator = versions.iterator(); iterator.hasNext(); i++) {
172             versionsArray[i] = ((VersionLocal) iterator.next()).getModel();
173         }
174         model.setVersions(versionsArray);
175
176         return model;
177     }
178
179     public void setModel(IssueModel model) {
180         this.setDescription(model.getDescription());
181         this.setSeverity(model.getSeverity());
182         this.setStatus(model.getStatus());
183         this.setResolution(model.getResolution());
184         this.setLastModifiedDate(new Timestamp JavaDoc(new Date().getTime()));
185     }
186
187 }
188
Popular Tags