View Javadoc

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