1 package org.wcb.model.bd;
2
3 import org.wcb.model.service.ILogbookService;
4 import org.wcb.model.vo.hibernate.AircraftBO;
5 import org.wcb.model.vo.hibernate.AircraftTypeBO;
6 import org.wcb.exception.ServiceException;
7
8 import java.util.List;
9 import java.util.ArrayList;
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 public class AircraftDelegate {
32
33 private ILogbookService logbookService;
34
35 public ILogbookService getLogbookService() {
36 return logbookService;
37 }
38
39 public void setLogbookService(ILogbookService logbookService) {
40 this.logbookService = logbookService;
41 }
42
43 public List<AircraftBO> getAllAircraft() {
44 try
45 {
46 return getLogbookService().findAllAircraft();
47 }
48 catch (ServiceException se)
49 {
50 se.printStackTrace();
51 }
52 return null;
53 }
54
55 public boolean saveAircraftType(AircraftTypeBO type) {
56 try
57 {
58 getLogbookService().saveAircraftType(type);
59 return true;
60 }
61 catch (ServiceException se)
62 {
63 se.printStackTrace();
64 }
65 return false;
66 }
67
68
69
70
71
72 public List<AircraftTypeBO> getAircraftTypes() {
73 try {
74 return getLogbookService().findAllAircraftType();
75 }
76 catch (ServiceException se)
77 {
78 ArrayList<AircraftTypeBO> list = new ArrayList<AircraftTypeBO>();
79 list.add(new AircraftTypeBO("Cessna", "150M", "C-150M", 0));
80 return list;
81 }
82 }
83
84
85
86
87
88
89 public AircraftTypeBO getAircraftType(Integer id) {
90 try
91 {
92 return getLogbookService().getAircraftTypeById(id);
93 }
94 catch (ServiceException se)
95 {
96 se.printStackTrace();
97 }
98 return new AircraftTypeBO("Cessna","150M","C-150M",0);
99 }
100
101
102
103
104
105
106
107 public boolean saveAircraft(AircraftBO craft) {
108 try
109 {
110 getLogbookService().saveAircraft(craft);
111 }
112 catch (ServiceException se) {
113 return false;
114 }
115 return true;
116 }
117
118
119
120
121
122
123
124 public boolean deleteAircraft(AircraftBO craft) {
125 try
126 {
127 getLogbookService().deleteAircraft(craft);
128 }
129 catch (ServiceException se) {
130 return false;
131 }
132 return true;
133 }
134 }