1 19 20 package za.org.coefficient.modules.issueTracker; 21 22 import za.org.coefficient.authentication.CoefficientUser; 23 import za.org.coefficient.authentication.Role; 24 import za.org.coefficient.core.Project; 25 26 import java.util.ArrayList ; 27 import java.util.Date ; 28 import java.util.Iterator ; 29 import java.util.List ; 30 31 import net.sf.hibernate.Validatable; 32 import net.sf.hibernate.ValidationFailure; 33 34 38 public class DiscussionData implements Validatable, java.io.Serializable { 39 41 private CoefficientUser user; 42 private Date postDate; 43 private DiscussionData parent; 44 private List children = new ArrayList (); 45 private Long id; 46 private Project project; 47 private Role maxReadRole; 48 private Role maxWriteRole; 49 private String comments; 50 private String subject; 51 private String type; 52 private int replies; 53 54 56 public DiscussionData () { 57 postDate = new Date (System.currentTimeMillis()); 58 } 59 60 public void setAllMaxReadRoles(Role maxReadRole) { 61 this.maxReadRole = maxReadRole; 62 63 for (Iterator it = children.iterator(); it.hasNext();) { 65 DiscussionData child = (DiscussionData) it.next(); 66 child.setMaxReadRole(maxReadRole); 67 } 68 } 69 70 public void setAllMaxWriteRoles(Role maxWriteRole) { 71 this.maxWriteRole = maxWriteRole; 72 73 for (Iterator it = children.iterator(); it.hasNext();) { 75 DiscussionData child = (DiscussionData) it.next(); 76 child.setMaxWriteRole(maxWriteRole); 77 } 78 } 79 80 public void setChildren(List argList) { 81 this.children = argList; 82 } 83 84 98 public List getChildren() { 99 return this.children; 100 } 101 102 public int getChildrenCount() { 103 int count = children.size(); 104 for (Iterator it = children.iterator(); it.hasNext();) { 105 DiscussionData child = (DiscussionData) it.next(); 106 count += child.getChildrenCount(); 107 } 108 109 return count; 110 } 111 112 public void setComments(String argComments) { 113 this.comments = argComments; 114 } 115 116 124 public String getComments() { 125 return this.comments; 126 } 127 128 public void setId(Long argId) { 129 this.id = argId; 130 } 131 132 140 public Long getId() { 141 return this.id; 142 } 143 144 public void setMaxReadRole(Role maxReadRole) { 145 this.maxReadRole = maxReadRole; 146 } 147 148 153 public Role getMaxReadRole() { 154 return maxReadRole; 155 } 156 157 public void setMaxWriteRole(Role maxWriteRole) { 158 this.maxWriteRole = maxWriteRole; 159 } 160 161 166 public Role getMaxWriteRole() { 167 return maxWriteRole; 168 } 169 170 public void setParent(DiscussionData data) { 171 this.parent = data; 172 } 173 174 180 public DiscussionData getParent() { 181 return this.parent; 182 } 183 184 public void setPostDate(Date argPostDate) { 185 this.postDate = argPostDate; 186 } 187 188 195 public Date getPostDate() { 196 return this.postDate; 197 } 198 199 public void setProject(Project argProject) { 200 this.project = argProject; 201 } 202 203 209 public Project getProject() { 210 return this.project; 211 } 212 213 public void setReplies(int argReplies) { 214 this.replies = argReplies; 215 } 216 217 224 public int getReplies() { 225 return this.replies; 226 } 227 228 public void setSubject(String argSubject) { 229 this.subject = argSubject; 230 } 231 232 240 public String getSubject() { 241 return this.subject; 242 } 243 244 249 public void setType(String type) { 250 this.type = type; 251 } 252 253 261 public String getType() { 262 return this.type; 263 } 264 265 public void setUser(CoefficientUser argUser) { 266 this.user = argUser; 267 } 268 269 275 public CoefficientUser getUser() { 276 return this.user; 277 } 278 279 public void addChild(DiscussionData child) { 280 this.children.add(child); 281 } 282 283 public boolean equals(Object other) { 284 DiscussionData o = (DiscussionData) other; 285 286 return (o != null) && (this != null) 287 && (((o.id == null) && (this.id == null)) || o.id.equals(this.id)); 288 } 289 290 public void removeChild(DiscussionData child) { 291 int idx = this.children.indexOf(child); 292 if (idx != -1) { 293 this.children.remove(idx); 294 } 295 } 296 297 public void validate() throws ValidationFailure { 298 if (subject.length() > 1024) { 299 throw new ValidationFailure("Subject can not be greater than 1024 characters"); 300 } 301 } 302 } 303 | Popular Tags |