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.feeder.dao.hibernate;
19  
20  import org.bejug.javacareers.feeder.dao.RssFeedDao;
21  import org.bejug.javacareers.feeder.model.RssFeed;
22  import org.springframework.dao.DataAccessException;
23  import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
24  
25  import java.util.List;
26  
27  /***
28   * Hibernate implementation of RssFeedDao
29   *
30   * @author Stephan (last modified by $Author: stephan_janssen $)
31   * @version $Revision: 1.3 $ - $Date: 2005/10/11 08:29:11 $
32   */
33  public class RssFeedDaoHibernateImpl
34          extends HibernateDaoSupport
35          implements RssFeedDao {
36  
37      /*** 
38       * {@inheritDoc}
39       */
40      public void storeRssFeed(RssFeed feed) throws DataAccessException {
41          getHibernateTemplate().saveOrUpdate(feed);
42      }
43  
44      /***
45       * {@inheritDoc}
46       */
47      public List getRssFeeds() throws DataAccessException {
48          return getHibernateTemplate().loadAll(RssFeed.class);
49      }
50  
51      /***
52       * Convenience method to delete RSS feed by matching all properties
53       * @throws DataAccessException if an error
54       * @param feed The feed to delete
55       */
56      public void deleteRssFeed(RssFeed feed) throws DataAccessException{
57           getHibernateTemplate().delete(feed);
58      }
59  
60      /***
61       * Delete RSS feeds by URL
62       * @throws DataAccessException if an error
63       * @param url String
64       */
65      public void deleteRssFeedByUrl(String url) throws DataAccessException{
66          List items = getHibernateTemplate().
67                  findByNamedQueryAndNamedParam("findFeedByUrl","url", url);
68    	    getHibernateTemplate().deleteAll(items);
69      }
70  
71      /***
72       * gets a RssFeed by id.
73       * @throws DataAccessException if an error
74       * @param id the id of the RssFeed
75       * @return the wanted RssFeed
76       */
77      public RssFeed getRssFeed(Integer id) throws DataAccessException{
78          return (RssFeed) getHibernateTemplate().load(RssFeed.class, id);
79      }
80  
81      /***
82       * Delete RSS feeds by URL
83       *
84       * @param id ID of feed to delete
85       */
86      public void deleteRssFeed(Integer id) {
87          RssFeed feed = (RssFeed) getHibernateTemplate().load(RssFeed.class, id);
88          getHibernateTemplate().delete(feed);
89      }
90  }
91  
92  /***
93   * $Log: RssFeedDaoHibernateImpl.java,v $
94   * Revision 1.3  2005/10/11 08:29:11  stephan_janssen
95   * Added copyright.
96   *
97   * Revision 1.2  2005/09/13 08:11:17  schauwvliege
98   * organize imports
99   *
100  * Revision 1.1  2005/08/26 07:58:29  ge0ffrey
101  * split up the sources in service, serviceimpl and webclient
102  *
103  * Revision 1.5  2005/08/10 09:04:47  bavo_jcs
104  * Optimized imports according to checkstyle
105  *
106  * Revision 1.4  2005/06/17 13:09:39  schauwvliege
107  * Renamed add to store
108  *
109  * Revision 1.3  2005/06/14 12:05:53  schauwvliege
110  * CheckStyle and fixing tests
111  *
112  * Revision 1.2  2005/06/09 08:18:42  bejug_cc
113  * Fix initial import
114  *
115  * Revision 1.5  2005/06/05 12:26:27  sja
116  * Corrected javadoc.
117  *
118  * Revision 1.4  2005/06/01 15:07:11  bbr
119  * RssFeed page
120  *
121  * Revision 1.3  2005/06/01 12:36:54  bbr
122  * RssFeedService
123  *
124  * Revision 1.2  2005/05/24 11:52:39  bbr
125  * Using spring sheduling
126  *
127  * Revision 1.1  2005/05/23 17:04:57  sja
128  * Moved to org.bejug.javacareers.feeder package.
129  *
130  * Revision 1.2  2005/05/23 15:33:12  bbr
131  * added weight to lucene
132  *
133  * Revision 1.1  2005/05/23 08:46:33  PSONG09
134  * added feeder source files to project
135  *
136  * Revision 1.4  2005/05/23 07:11:53  stephan_janssen
137  * Code cleanup.
138  *
139  * Revision 1.3  2005/05/12 13:03:31  stephan_janssen
140  * Introduced GET_RSSFEED_QUERY 'constant'.
141  *
142  * Revision 1.2  2005/05/12 13:02:40  stephan_janssen
143  * Introduced GET_RSSFEED_QUERY 'constant'.
144  *
145  * Revision 1.1  2005/05/11 11:53:25  bavo_jcs
146  * refactored
147  * - conform to conventions
148  * - some javadoc
149  * - Added FeederTask design
150  *
151  * Revision 1.3  2005/05/10 11:32:48  bavo_jcs
152  * integrated with services from JavaCareers Web
153  *
154  * Revision 1.2  2005/05/04 15:43:21  bavo_jcs
155  * Added mockups, changes to IoC mechanism
156  *
157  * Revision 1.1.1.1  2005/04/26 14:13:49  stephan_janssen
158  * Initial import
159  *
160  * Revision 1.1.1.1  2005/04/26 12:58:29  sja
161  * Initial Release
162  *
163  * Revision 1.1.1.1  2005/04/26 12:51:24  sja
164  * Initial Release
165  *
166  */