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
12   * details.
13   *
14   * You should have received a copy of the GNU General Public License along with
15   * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
16   * Place, Suite 330, Boston, MA 02111-1307 USA.
17   *
18   */
19  package org.bejug.javacareers.jobs.dao.hibernate;
20  
21  import java.util.Iterator;
22  
23  import org.bejug.javacareers.jobs.dao.ItemDao;
24  import org.bejug.javacareers.jobs.model.Interview;
25  import org.bejug.javacareers.jobs.model.Item;
26  import org.bejug.javacareers.jobs.model.QAndA;
27  import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
28  
29  /***
30   * implementation for the item-dao.
31   * TODO: make all the Item-stuff more generic.
32   * @author Bart Meyers (Last modified by $Author: shally $)
33   * @version $Revision: 1.8 $ - $Date: 2005/12/20 15:36:46 $
34   */ 
35  public class ItemDaoHibernateImpl 
36  	extends HibernateDaoSupport 
37  		implements ItemDao {
38  
39  	/***
40  	 * {@inheritDoc}
41  	 */
42  	public Item getItem(Integer id) {
43  		return (Item) getHibernateTemplate().get(Item.class, id);
44  	}
45  
46  	/***
47  	 * {@inheritDoc}
48  	 */
49  	public void deleteItem(Item item) {
50  		getHibernateTemplate().delete(item);
51  	}
52  
53  	/***
54  	 * {@inheritDoc}
55  	 */
56  	public void deleteItem(Integer id) {
57  		getHibernateTemplate().delete(getHibernateTemplate().get(Item.class, id));
58  	}
59  	
60  	/***
61  	 * {@inheritDoc}
62  	 */
63  	public void storeItem(Item item) {
64          if (item instanceof Interview) {
65              Interview interview = (Interview) item;
66              for(Iterator iter = interview.getQandas().iterator(); iter.hasNext(); ){
67                  ((QAndA)iter.next()).setModificationDate(interview.getModificationDate());
68              }
69          }
70          
71  		getHibernateTemplate().saveOrUpdate(item);
72  	}
73  }
74  /***
75   * $Log: ItemDaoHibernateImpl.java,v $
76   * Revision 1.8  2005/12/20 15:36:46  shally
77   * CheckStyle and PMD changes.
78   *
79   * Revision 1.7  2005/09/13 08:11:17  schauwvliege
80   * organize imports
81   *
82   * Revision 1.6  2005/09/09 10:54:04  bavo_jcs
83   * Added CommercialEducationOffer
84   *
85   * Revision 1.5  2005/09/08 13:52:03  bavo_jcs
86   * Added PostInterview
87   *
88   * Revision 1.4  2005/09/06 15:37:51  schauwvliege
89   * typo
90   *
91   * Revision 1.3  2005/09/06 14:52:06  schauwvliege
92   * added add item
93   *
94   * Revision 1.2  2005/09/06 13:21:44  schauwvliege
95   * Intro if interview
96   *
97   * Revision 1.1  2005/08/26 07:58:30  ge0ffrey
98   * split up the sources in service, serviceimpl and webclient
99   *
100  * Revision 1.3  2005/08/25 08:43:13  bme_jcs
101  * updated header
102  *
103  * Revision 1.2  2005/08/25 08:42:34  bme_jcs
104  * updated header
105  *
106  * Revision 1.1  2005/08/24 08:04:38  bme_jcs
107  * first release
108  *
109  */