1   package org.wcb.model.manager.impl;
2   
3   import org.wcb.model.dao.IAircraftTypeDAO;
4   import org.wcb.model.vo.hibernate.AircraftTypeBO;
5   import org.wcb.model.manager.IAircraftTypeManager;
6   import org.wcb.exception.ManagerException;
7   import org.wcb.exception.InfrastructureException;
8   
9   import java.util.List;
10  
11  /**
12   * <small>
13   * Copyright (c)  2006  wbogaardt.
14   * Permission is granted to copy, distribute and/or modify this document
15   * under the terms of the GNU Free Documentation License, Version 1.2
16   * or any later version published by the Free Software Foundation;
17   * with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
18   * Texts.  A copy of the license is included in the section entitled "GNU
19   * Free Documentation License".
20   * <p/>
21   * $File:  $ <br>
22   * $Change:  $ submitted by $Author: wbogaardt $ at $DateTime: Mar 27, 2006 9:56:58 AM $ <br>
23   * </small>
24   *
25   * @author wbogaardt
26   * @version 1
27   *          Date: Mar 27, 2006
28   *          Time: 9:56:58 AM
29   */
30  
31  public class AircraftTypeManager extends BaseManager implements IAircraftTypeManager {
32  
33       private IAircraftTypeDAO iDAO;
34  
35      /**
36       * This is injected by Spring framework normally.
37       *
38       * @param oDAO AircraftTypeDAO object injected by spring.
39       */
40      public void setDao(IAircraftTypeDAO oDAO) {
41          this.iDAO = oDAO;
42      }
43  
44      /**
45       * This is a bean enabled manager so we can get
46       * a reference to the DAO object this way.
47       * @return The interface to the AircraftTypeDAO.
48       */
49      public IAircraftTypeDAO getDao() {
50          return this.iDAO;
51      }
52  
53      public AircraftTypeBO getAircraftTypeById(Integer id) throws ManagerException {
54          try
55          {
56              return iDAO.findAircraftType(id);
57          }
58          catch (InfrastructureException ie)
59          {
60              throw new ManagerException("AircraftBO type problem trying to find it for " + id, ie);
61          }
62      }
63  
64      public List<AircraftTypeBO> getAllAircraftTypes() throws ManagerException {
65          List<AircraftTypeBO> returnValue = null;
66          try
67          {
68              returnValue = iDAO.findAll();
69              if (returnValue == null)
70              {
71                  throw new ManagerException("Failed to find AircraftBO types entries: ");
72              }
73          }
74          catch (InfrastructureException ie)
75          {
76              throw new ManagerException("Failed to find aircraft types entries due to InfrastructureException", ie);
77          }
78          return returnValue;
79      }
80  
81      public void saveAircraftType(AircraftTypeBO aircraft) throws ManagerException {
82          try
83          {
84              iDAO.saveOrUpdateObject(aircraft);
85          }
86          catch (Exception ie)
87          {
88              throw new ManagerException("Unable to save aircraft type ", ie);
89          }
90      }
91  }