View Javadoc

1   /***
2   Copyright (C) 2005 The Java Community
3   
4   This program is free software; you can redistribute it and/or modify  it under
5   the terms of the GNU General Public License as published by  the Free Software
6   Foundation; either version 2 of the License, or  (at your option) any later
7   version.
8   
9   This program is distributed in the hope that it will be useful,  but WITHOUT
10  ANY WARRANTY; without even the implied warranty of  MERCHANTABILITY or FITNESS
11  FOR A PARTICULAR PURPOSE. See the  GNU General Public License for more details.
12  
13  You should have received a copy of the GNU General Public License  along with
14  this program; if not, write to the Free Software  Foundation, Inc., 59 Temple
15  Place, Suite 330, Boston, MA 02111-1307 USA.
16  
17   */
18  package org.bejug.javacareers.jobs.model;
19  
20  import java.util.ArrayList;
21  import java.util.List;
22  import java.util.Set;
23  
24  import org.apache.commons.lang.builder.CompareToBuilder;
25  import org.apache.commons.lang.builder.EqualsBuilder;
26  import org.apache.commons.lang.builder.HashCodeBuilder;
27  import org.apache.commons.lang.builder.ToStringBuilder;
28  
29  /***
30   * A general Offer.
31   *
32   * @author bme (last modified by $Author: shally $
33   * @version $Revision: 1.10 $ - $Date: 2005/12/20 15:36:45 $
34   */
35  public class Offer extends Item {
36  
37  	
38  	/***
39       * flag to see if job is manual inserted or by feeder.
40       */
41      private boolean rssFeed = false;
42  
43  
44      /***
45       * the status of the offer.
46      */
47      private int status = -1;
48  
49  
50      /***
51       * comma-separeted list of the locations where this offer is situated.
52       */
53      private String location = null;
54  
55      /***
56       * the url of the offer.
57       */
58      private String url = null;
59  
60      /***
61       * the source name of the offer(for the feeder).
62       */
63      private String sourceName = null;
64  
65      /***
66       * the sourceUrl of the offer(for the feeder).
67       */
68      private String sourceUrl = null;
69  
70      /***
71       * the sourceUrl of the offer(for the feeder).
72       */
73      private String feedUrl = null;
74      /***
75       * the subscribers to this offer.
76       */
77      private Set subscribers = null;
78  
79      /***
80       * the profiles this offer applies to.
81       */
82      private Set profiles = null;
83  
84      /***
85       * the offertypes this offer applies to.
86       */
87      private Set offerTypes = null;
88  
89      /***
90       * @return Returns the source name.
91       */
92      public String getSourceName() {
93          return sourceName;
94      }
95  
96      /***
97       * @param sourceName the source to set.
98       */
99      public void setSourceName(String sourceName) {
100         this.sourceName = sourceName;
101     }
102 
103     /***
104      * @return Returs the url of the source.
105      */
106     public String getSourceUrl() {
107         return sourceUrl;
108     }
109 
110     /***
111      * @param sourceUrl the url to set
112      */
113     public void setSourceUrl(String sourceUrl) {
114         this.sourceUrl = sourceUrl;
115     }
116 
117     /***
118      * @return location String
119      */
120     public String getLocation() {
121         return location;
122     }
123 
124     /***
125      * @param location String
126      */
127     public void setLocation(String location) {
128         this.location = location;
129     }
130 
131   
132 
133     /***
134      *
135      * @return status
136      */
137     public int getStatus() {
138         return status;
139     }
140 
141     /***
142      * @param status int
143      */
144     public void setStatus(int status) {
145         this.status = status;
146     }
147 
148    
149     /***
150      *
151      * @return url String
152      */
153     public String getUrl() {
154         return url;
155     }
156 
157     /***
158      * Todo: Add XDoclet tags
159      * @param url String
160      */
161     public void setUrl(String url) {
162         this.url = url;
163     }
164 
165     /***
166      * @return Returns the subscriptions.
167      */
168     public Set getSubscribers() {
169         return subscribers;
170     }
171 
172     /***
173      * @param subscribers The subscribers to set.
174      */
175     public void setSubscribers(Set subscribers) {
176         this.subscribers = subscribers;
177     }
178 
179 
180     /***
181      * @return Returns the rssFeed.
182      */
183     public boolean isRssFeed() {
184         return rssFeed;
185     }
186 
187     /***
188      * @param rssFeed The rssFeed to set.
189      */
190     public void setRssFeed(boolean rssFeed) {
191         this.rssFeed = rssFeed;
192     }
193 
194      /***
195      * @return Returns the profiles.
196      */
197     public Set getProfiles() {
198         return profiles;
199     }
200 
201     /***
202      * @param profiles The profiles to set.
203      */
204     public void setProfiles(Set profiles) {
205         this.profiles = profiles;
206     }
207 
208     /***
209      * @return Returns the offerTypes.
210      */
211     public Set getOfferTypes() {
212         return offerTypes;
213     }
214 
215     /***
216      * @param offerTypes The offerTypes to set.
217      */
218     public void setOfferTypes(Set offerTypes) {
219         this.offerTypes = offerTypes;
220     }
221 
222     /***
223      * @return feed Url
224      */
225     public String getFeedUrl() {
226         return feedUrl;
227     }
228 
229     /***
230      * @param feedUrl String
231      */
232     public void setFeedUrl(String feedUrl) {
233         this.feedUrl = feedUrl;
234     }
235 
236 
237 
238     
239     /***
240 	 * {@inheritDoc}
241 	 */
242 	public int compareTo(Object o) {
243 	     Offer offer = (Offer) o;
244 	     return new CompareToBuilder()
245 	       .appendSuper(super.compareTo(o))
246 	       .append(this.user, offer.getUser())
247 	       //.append(this.comments, offer.getComments())
248 	       .append(this.description, offer.getDescription())
249 	       .append(this.status, offer.getStatus())
250 	       .append(this.location, offer.getLocation())
251 	       .append(this.url, offer.getUrl())
252 	       .append(this.sourceName, offer.getSourceName())
253 	       .append(this.sourceUrl, offer.getSourceUrl())
254 	       .append(this.feedUrl, offer.getFeedUrl())
255 	       .append(this.subscribers, offer.getSubscribers())
256 	       .append(this.profiles, offer.getProfiles())
257 	       .append(this.offerTypes, offer.getOfferTypes())
258 	       .toComparison();
259 	}
260 	
261 	/***
262      * {@inheritDoc}
263      */
264     public boolean equals(Object o) {
265     	if (!(o instanceof Offer)) {
266     	     return false;
267     	   }
268     	   if (this == o) {
269     	     return true;
270     	   }
271     	   Offer offer = (Offer) o;
272     	   boolean ok = new EqualsBuilder()
273     	   		.appendSuper(super.equals(o))
274     	   	//	.append(this.user, offer.getUser())
275 
276     	   		.append(this.description, offer.getDescription())
277     	   		.append(this.status, offer.getStatus())
278     	   		.append(this.location, offer.getLocation())
279     	   		.append(this.url, offer.getUrl())
280     	   		.append(this.sourceName, offer.getSourceName())
281     	   		.append(this.sourceUrl, offer.getSourceUrl())
282     	   		.append(this.feedUrl, offer.getFeedUrl())
283     	   		.append(this.subscribers, offer.getSubscribers())
284     	   		.append(this.profiles, offer.getProfiles())
285     	   		.append(this.offerTypes, offer.getOfferTypes())
286     	        .isEquals();
287     	   return ok ;
288     }
289     
290     
291     /***
292      * {@inheritDoc}
293      */
294     public int hashCode() {
295         return new HashCodeBuilder(719, 71)
296         	.append(this.user)
297         	//.append(this.comments)
298         	.append(this.description)
299         	.append(this.status)
300         	.append(this.location)
301         	.append(this.url)
302         	.append(this.sourceName)
303         	.append(this.sourceUrl)
304         	.append(this.feedUrl)
305         	.append(this.subscribers)
306         	.append(this.profiles)
307         	.append(this.offerTypes)
308         	.toHashCode();
309     }
310     
311     
312     /***
313      * {@inheritDoc}
314      */
315     public String toString() {
316     	return new ToStringBuilder(this)
317     		.appendSuper(super.toString())
318     		.append("user", this.user)
319     		//.append("comments", this.comments)
320     		.append("description", this.description)
321     		.append("status", this.status)
322     		.append("location", this.location)
323     		.append("url", this.url)
324     		.append("sourceName", this.sourceName)
325     		.append("sourceUrl", this.sourceUrl)
326     		.append("feedUrl", this.feedUrl)
327     		.append("subsribers", this.subscribers)
328     		.append("profiles", this.profiles)
329     		.append("offerTypes", this.offerTypes)
330     		.toString();
331     }
332 
333     /***
334      * 
335      * @return list of Profiles
336      */
337     public List getProfilesAsList() {
338         List profileList = new ArrayList();
339         profileList.addAll(profiles);
340         return profileList;
341     }
342 
343 
344 }
345 /***
346  * $Log: Offer.java,v $
347  * Revision 1.10  2005/12/20 15:36:45  shally
348  * CheckStyle and PMD changes.
349  *
350  * Revision 1.9  2005/12/08 14:53:44  shally
351  * Opkuis voor checkstyle.
352  *
353  * Revision 1.8  2005/09/30 12:26:14  bavo_jcs
354  * Include comments in table
355  *
356  * Revision 1.7  2005/09/29 14:52:58  bavo_jcs
357  * Layout and minor bugfixes
358  *
359  * Revision 1.6  2005/09/19 15:53:31  bavo_jcs
360  * Refactored comments to use Items
361  *
362  * Revision 1.5  2005/09/15 12:47:53  bavo_jcs
363  * SearchCriteria doesnt want abstract objects
364  *
365  * Revision 1.4  2005/09/06 08:38:07  schauwvliege
366  * JAVACAREERS-319 Moved user to Item
367  *
368  * Revision 1.3  2005/09/05 16:24:38  schauwvliege
369  * JAVACAREERS-317
370  * commented User in equals
371  *
372  * Revision 1.2  2005/08/31 12:15:09  bme_jcs
373  * refactoring and introduction of apache builders
374  *
375  * Revision 1.1  2005/08/26 07:58:26  ge0ffrey
376  * split up the sources in service, serviceimpl and webclient
377  *
378  * Revision 1.12  2005/08/23 09:32:04  bme_jcs
379  * introduction of ItemService-classes
380  *
381  * Revision 1.11  2005/08/22 13:42:24  schauwvliege
382  * Introduction of Item
383  *
384  * Revision 1.10  2005/08/22 13:39:13  schauwvliege
385  * Introduction of Item
386  *
387  * Revision 1.9  2005/08/10 09:04:49  bavo_jcs
388  * Optimized imports according to checkstyle
389  *
390  * Revision 1.8  2005/08/09 12:59:55  bavo_jcs
391  * Optimized imports
392  *
393  * Revision 1.7  2005/08/05 14:21:27  bavo_jcs
394  * Feeder smart delete fix
395  *
396  * Revision 1.6  2005/08/03 08:17:28  psong09
397  * added comments count column to jobOfferTable
398  *
399  * Revision 1.5  2005/06/30 10:21:55  bme_jcs
400  * bugfix to be able to insert more than 1 comment on a job
401  *
402  * Revision 1.4  2005/06/14 12:05:53  schauwvliege
403  * CheckStyle and fixing tests
404  *
405  * Revision 1.3  2005/06/13 13:05:09  bavo_jcs
406  * delete by URL fix
407  *
408  * Revision 1.2  2005/06/09 08:18:52  bejug_cc
409  * Fix initial import
410  *
411  * Revision 1.16  2005/06/05 12:25:21  sja
412  * Added sourceUrl and sourceName.
413  *
414  * Revision 1.15  2005/05/17 11:59:56  ssc
415  * Refactored User and Publisher class to User Class added cvAdded Boolean, added Address to user, Fixed test to work with this setup
416  *
417  * Revision 1.14  2005/05/13 14:55:49  ssc
418  * fixed error relationship when adding offer to user/comment
419  *
420  * Revision 1.13  2005/05/10 14:28:42  ssc
421  * added rssFeed
422  *
423  * Revision 1.12  2005/05/10 13:55:12  bme
424  * added profiles and offertypes
425  *
426  * Revision 1.11  2005/05/09 13:42:10  ssc
427  * checkstyle
428  *
429  * Revision 1.10  2005/05/07 15:44:39  ssc
430  * added child commend and tests
431  *
432  * Revision 1.9  2005/05/04 11:42:57  ssc
433  * added commit mappings
434  *
435  * Revision 1.8  2005/05/04 08:56:48  ssc
436  * Changed List to Set
437  *
438  * Revision 1.7  2005/05/02 13:34:14  ssc
439  * Added  subscribers
440  *
441  * Revision 1.6  2005/04/29 12:20:37  bme
442  * updated for feeder
443  *
444  * Revision 1.4  2005/04/28 10:50:19  PSONG09
445  * Update DAO's and testing
446  *
447  * Revision 1.3  2005/04/25 12:04:49  ssc
448  * *** empty log message ***
449  *
450  * Revision 1.2  2005/04/25 08:05:09  bme
451  * Changed startDate to publicationDate
452  *
453  * Revision 1.1  2005/04/19 11:51:22  PSONG09
454  * First release
455  *
456  * Revision 1.3  2005/04/15 22:18:45  sja
457  * Made Offer abstract
458  *
459  * Revision 1.2  2005/04/15 14:39:49  sja
460  * updated wrong package name.
461  *
462  * Revision 1.1  2005/04/15 14:19:45  sja
463  * Updated first release
464  *
465  */