| 1 18 19 package cowsultants.itracker.ejb.beans.entity; 20 21 import java.text.*; 22 import java.util.*; 23 import java.sql.Timestamp ; 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 getDescription(); 35 public abstract void setDescription(String 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 getResolution(); 44 public abstract void setResolution(String 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 projectId) throws FinderException; 80 81 public Date ejbHomeLatestModificationDate(Integer projectId) { 82 Timestamp latestDate = null; 83 84 try { 85 Collection dates = ejbSelectLastModifiedDates(projectId); 86 for(Iterator iterator = dates.iterator(); iterator.hasNext(); ) { 87 Timestamp lastModDate = (Timestamp ) 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 (new Date().getTime())); 185 } 186 187 } 188 | Popular Tags |