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