1 /***
2 *
3 */
4 package org.bejug.javacareers.jobs.model;
5
6 import java.util.Date;
7 import java.util.Set;
8 import java.util.HashSet;
9
10 import org.apache.commons.lang.builder.CompareToBuilder;
11 import org.apache.commons.lang.builder.EqualsBuilder;
12 import org.apache.commons.lang.builder.HashCodeBuilder;
13 import org.apache.commons.lang.builder.ToStringBuilder;
14 import org.apache.commons.lang.StringUtils;
15
16 /***
17 *
18 * @author Sven Schauwvliege (Last modified by $Author: shally $)
19 * @version $Revision: 1.8 $ - $Date: 2005/12/20 15:36:45 $
20 */
21
22
23 public class Item extends AbstractPersistableObject {
24
25 /***
26 * The title String.
27 */
28 private String title;
29
30 /***
31 * the comments to the offer.
32 */
33 private Set comments = null;
34
35 /***
36 * The publicationDate Date.
37 */
38 private Date publicationDate;
39
40 /***
41 * The user User.
42 */
43 protected User user;
44
45 /***
46 * The adminApproved boolean.
47 */
48 protected boolean adminApproved = false;
49 /***
50 * description of the offer.
51 */
52 protected String description = null;
53 private static final int MAX_DESC_LENGTH = 100;
54
55 /***
56 * @return Returns the publicationDate.
57 */
58 public Date getPublicationDate() {
59 return publicationDate;
60 }
61 /***
62 * @param publicationDate The publicationDate to set.
63 */
64 public void setPublicationDate(Date publicationDate) {
65 this.publicationDate = publicationDate;
66 }
67 /***
68 * @return Returns the title.
69 */
70 public String getTitle() {
71 return title;
72 }
73 /***
74 * @param title The title to set.
75 */
76 public void setTitle(String title) {
77 this.title = title;
78 }
79
80 /***
81 * {@inheritDoc}
82 */
83 public int compareTo(Object o) {
84 Item item = (Item) o;
85 return new CompareToBuilder()
86 .appendSuper(super.compareTo(o))
87 .append(this.title, item.getTitle())
88 .append(this.publicationDate, item.getPublicationDate())
89 .toComparison();
90 }
91
92 /***
93 * {@inheritDoc}
94 */
95 public boolean equals(Object o) {
96 if (!(o instanceof Item)) {
97 return false;
98 }
99 if (this == o) {
100 return true;
101 }
102 Item item = (Item) o;
103 return new EqualsBuilder()
104 .appendSuper(super.equals(o))
105 .append(this.title, item.getTitle())
106 .append(this.publicationDate, item.getPublicationDate())
107 .isEquals();
108 }
109
110
111 /***
112 * {@inheritDoc}
113 */
114 public int hashCode() {
115 return new HashCodeBuilder(719, 71)
116 .append(this.title)
117 .append(this.publicationDate)
118 .toHashCode();
119 }
120
121
122 /***
123 * {@inheritDoc}
124 */
125 public String toString() {
126 return new ToStringBuilder(this)
127 .appendSuper(super.toString())
128 .append("title", this.title)
129 .append("publicationDate", this.publicationDate)
130 .toString();
131 }
132 /***
133 * @return Returns the user.
134 */
135 public User getUser() {
136 return user;
137 }
138 /***
139 * @param user The user to set.
140 */
141 public void setUser(User user) {
142 this.user = user;
143 }
144 /***
145 * @return Returns the adminApproved.
146 */
147 public boolean isAdminApproved() {
148 return adminApproved;
149 }
150 /***
151 * @param adminApproved The adminApproved to set.
152 */
153 public void setAdminApproved(boolean adminApproved) {
154 this.adminApproved = adminApproved;
155 }
156
157 /***
158 * adds a comment
159 * @param comment the comment to add
160 */
161 public void addComment(Comment comment) {
162 if (comments == null) {
163 comments = new HashSet();
164 }
165 this.comments.add(comment);
166 comment.setOffer(this);
167 }
168
169
170 /***
171 * @return Returns the comments.
172 */
173 public Set getComments() {
174 return comments;
175 }
176
177 /***
178 * @param comments The comments to set.
179 */
180 public void setComments(Set comments) {
181 this.comments = comments;
182 }
183
184 /***
185 *
186 * @return AbbreviatedDescription
187 */
188 public String getAbbreviatedDescription() {
189 String abbreviate = StringUtils.abbreviate(description, MAX_DESC_LENGTH);
190 return abbreviate;
191
192 }
193
194 /***
195 *
196 * @return description String
197 */
198 public String getDescription() {
199 return description;
200 }
201
202 /***
203 * @param description String
204 */
205 public void setDescription(String description) {
206 this.description = description;
207 }
208
209 /***
210 * Convenience method returning the nr of comments related to this offer
211 * @return nrOfComments
212 */
213 public int getNrOfComments(){
214 return getComments().size();
215 }
216 }
217 /***
218 * $Log: Item.java,v $
219 * Revision 1.8 2005/12/20 15:36:45 shally
220 * CheckStyle and PMD changes.
221 *
222 * Revision 1.7 2005/09/30 12:26:14 bavo_jcs
223 * Include comments in table
224 *
225 * Revision 1.6 2005/09/29 14:52:58 bavo_jcs
226 * Layout and minor bugfixes
227 *
228 * Revision 1.5 2005/09/19 16:14:59 schauwvliege
229 * Introduction of Approve items
230 *
231 * Revision 1.4 2005/09/19 15:53:30 bavo_jcs
232 * Refactored comments to use Items
233 *
234 * Revision 1.3 2005/09/06 08:38:07 schauwvliege
235 * JAVACAREERS-319 Moved user to Item
236 *
237 * Revision 1.2 2005/08/31 12:15:09 bme_jcs
238 * refactoring and introduction of apache builders
239 *
240 * Revision 1.1 2005/08/26 07:58:26 ge0ffrey
241 * split up the sources in service, serviceimpl and webclient
242 *
243 * Revision 1.2 2005/08/24 16:29:58 schauwvliege
244 * introduction of mixed list of all items
245 *
246 * Revision 1.1 2005/08/22 13:39:13 schauwvliege
247 * Introduction of Item
248 *
249 **/