1 package org.wcb.model.manager.impl;
2
3 import org.wcb.exception.ManagerException;
4 import org.wcb.exception.InfrastructureException;
5 import org.wcb.model.dao.IAircraftDAO;
6 import org.wcb.model.vo.hibernate.AircraftBO;
7 import org.wcb.model.manager.IAircraftManager;
8
9 import java.util.List;
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 public class AircraftManager extends BaseManager implements IAircraftManager {
32
33 private IAircraftDAO iDAO;
34
35
36
37
38
39
40 public void setDao(IAircraftDAO oDAO) {
41 this.iDAO = oDAO;
42 }
43
44
45
46
47
48
49 public IAircraftDAO getDao() {
50 return this.iDAO;
51 }
52
53
54
55
56
57
58 public List<AircraftBO> findAll() throws ManagerException {
59 try
60 {
61 return iDAO.findAll();
62 }
63 catch (InfrastructureException ie) {
64 throw new ManagerException("Could not find any aircraft");
65 }
66 }
67
68
69
70
71
72
73
74 public AircraftBO findByRegistry(String registration) throws ManagerException {
75 AircraftBO returnValue = new AircraftBO();
76 try
77 {
78 returnValue = iDAO.findAircraft(registration);
79 if (returnValue == null)
80 {
81 throw new ManagerException("Failed to find registration entry: " + registration);
82 }
83 }
84 catch (InfrastructureException ie)
85 {
86 throw new ManagerException("Failed to find registration entry due to InfrastructureException " + registration, ie);
87 }
88 catch (IndexOutOfBoundsException ioobe) {
89 throw new ManagerException("Failed to find registration entry in database");
90 }
91 return returnValue;
92 }
93
94
95
96
97
98
99
100 public void saveOrUpdateAircraft(AircraftBO craft) throws ManagerException {
101 try
102 {
103 iDAO.saveOrUpdateObject(craft);
104 }
105 catch (Exception ie) {
106 throw new ManagerException("Failed to save aircraft entry due to InfrastructureException ", ie);
107 }
108 }
109
110
111
112
113
114
115 public void deleteAircraftEntry(AircraftBO craft) throws ManagerException {
116 try
117 {
118 iDAO.deleteAircraft(craft);
119 }
120 catch (InfrastructureException ie) {
121 throw new ManagerException("Failed to delete aircraft entry due to InfrastructureException ", ie);
122 }
123 }
124 }