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 org.itracker.model;
20
21 import org.apache.commons.lang.builder.ToStringBuilder;
22
23 /**
24 * An issue activity.
25 * <p/>
26 * <p>
27 * An IssueActivity can only belong to 1 Issue (composition).
28 * </p>
29 * <p/>
30 * <p>
31 * The natural key of an IssueActivity is issue + user + type + createDate.
32 * </p>
33 *
34 * @author ready
35 */
36 public class IssueActivity extends AbstractEntity {
37
38 /**
39 *
40 */
41 private static final long serialVersionUID = 1L;
42
43 /**
44 * Issue to which this activity is related.
45 */
46 private Issue issue;
47
48 /**
49 * The User who generated this activity.
50 */
51 private User user;
52
53 /**
54 * Optional activity description.
55 */
56 private String description = "";
57
58 /**
59 * Whether a notification has been sent for this activity.
60 */
61 private boolean notificationSent = false;
62
63 private IssueActivityType activityType = IssueActivityType.ISSUE_CREATED;
64
65 /**
66 * Default constructor (required by Hibernate).
67 * <p/>
68 * <p>
69 * PENDING: should be <code>private</code> so that it can only be used by
70 * Hibernate, to ensure that <code>issue</code>, <code>user</code> and
71 * <code>type</code>, which form an instance's identity, are always
72 * initialized.
73 * </p>
74 */
75 public IssueActivity() {
76
77 }
78
79 /**
80 * Creates a new instance with a <code>notificationSent</code> flag set to
81 * <tt>false</tt> and a creation and last modified time stamp set to the
82 * current time.
83 */
84 public IssueActivity(Issue issue, User user, IssueActivityType type) {
85 setIssue(issue);
86 setUser(user);
87 setActivityType(type);
88 }
89
90 public Issue getIssue() {
91 return issue;
92 }
93
94 public void setIssue(Issue issue) {
95 if (issue == null) {
96 throw new IllegalArgumentException("null issue");
97 }
98 this.issue = issue;
99 }
100
101 public User getUser() {
102 return user;
103 }
104
105 public void setUser(User user) {
106 if (user == null) {
107 throw new IllegalArgumentException("null user");
108 }
109 this.user = user;
110 }
111
112 public void setActivityType(IssueActivityType type) {
113
114 // this.type = type.code;
115 this.activityType = type;
116 }
117
118 public IssueActivityType getActivityType() {
119 return this.activityType;
120 }
121
122 public String getDescription() {
123 return description;
124 }
125
126 public void setDescription(String description) {
127 this.description = description;
128 }
129
130 public boolean getNotificationSent() {
131 return notificationSent;
132 }
133
134 public void setNotificationSent(boolean sent) {
135 this.notificationSent = sent;
136 }
137
138 public String toString() {
139 return new ToStringBuilder(this).append("id", getId())
140 .append("issue", getIssue()).append("user", getUser()).append("type",
141 getActivityType()).append("createDate", getCreateDate())
142 .toString();
143
144 }
145
146 }