1   package org.wcb.model.dao.impl;
2   
3   import org.wcb.exception.DAOException;
4   import org.wcb.exception.InfrastructureException;
5   import org.wcb.model.vo.hibernate.AircraftBO;
6   import org.wcb.model.dao.IAircraftDAO;
7   
8   import java.util.List;
9   
10  /**
11   * <small>
12   * Copyright (c)  2006  wbogaardt.
13   * Permission is granted to copy, distribute and/or modify this document
14   * under the terms of the GNU Free Documentation License, Version 1.2
15   * or any later version published by the Free Software Foundation;
16   * with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
17   * Texts.  A copy of the license is included in the section entitled "GNU
18   * Free Documentation License".
19   * <p/>
20   * $File:  $ <br>
21   * $Change:  $ submitted by $Author: wbogaardt $ at $DateTime: Mar 24, 2006 10:09:00 AM $ <br>
22   * </small>
23   *
24   * @author wbogaardt
25   * @version 1
26   *          Date: Mar 24, 2006
27   *          Time: 10:09:00 AM
28   */
29  
30  public class AircraftDAO extends AbstractHibernateDAO implements IAircraftDAO {
31  
32      public AircraftBO findAircraft(String registration) throws InfrastructureException {
33      	try {
34      		return (AircraftBO) super.getObjectsBy(AircraftBO.class, "registrationNumber", registration).get(0);
35      	} catch (DAOException daoe) {
36      		throw new InfrastructureException(daoe);
37      	} catch (IndexOutOfBoundsException ioobe) {
38              throw new InfrastructureException("No entry found");
39          }
40      }
41  
42      public List<AircraftBO> findAll() throws InfrastructureException {
43      	try {
44      		return super.getObjects(AircraftBO.class);
45      	} catch (DAOException daoe) {
46      		throw new InfrastructureException(daoe);
47      	}
48      }
49  
50      public void deleteAircraft(AircraftBO oCraft) throws InfrastructureException {
51          getHibernateTemplate().delete(oCraft);
52      }
53  }