1   package org.wcb.model.vo.hibernate;
2   
3   import java.io.Serializable;
4   import java.util.Date;
5   import org.apache.commons.lang.builder.ToStringBuilder;
6   
7   import javax.persistence.*;
8   
9   
10  /**
11   *
12   * This object stores logbook entries in the database and is the core of the logbook application.
13   * <small>
14   * Copyright (c)  2006  wbogaardt.
15   * Permission is granted to copy, distribute and/or modify this document
16   * under the terms of the GNU Free Documentation License, Version 1.2
17   * or any later version published by the Free Software Foundation;
18   * with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
19   * Texts.  A copy of the license is included in the section entitled "GNU
20   * Free Documentation License".
21   * <p/>
22   * $File:  $ <br>
23   * $Change:  $ submitted by $Author: wbogaardt $ at $DateTime: Mar 30, 2006 10:35:19 AM $ <br>
24   * </small>
25   *
26   * @author wbogaardt
27   * @version 1
28   *          Date: Mar 30, 2006
29   *          Time: 10:35:19 AM
30   */
31  @Entity
32  @Table(name ="logbook")
33  public class Logbook implements Serializable {
34  
35      /** identifier field */
36      private Integer id;
37  
38      /** nullable persistent field */
39      private Date entryDate;
40  
41      /** nullable persistent field */
42      private String registration;
43  
44      /** nullable persistent field */
45      private String faaFrom;
46  
47      /** nullable persistent field */
48      private String faaVia;
49  
50      /** nullable persistent field */
51      private String faaTo;
52  
53      /** nullable persistent field */
54      private Double flightDuration;
55  
56      /** nullable persistent field */
57      private Double pic;
58  
59      /** nullable persistent field */
60      private Double sic;
61  
62      /** nullable persistent field */
63      private Double crossCountry;
64  
65      /** nullable persistent field */
66      private Double flightInstructing;
67  
68      /** nullable persistent field */
69      private Double safetyPilot;
70  
71      /** nullable persistent field */
72      private Double dualReceived;
73  
74      /** nullable persistent field */
75      private Double solo;
76  
77      /** nullable persistent field */
78      private Integer dayTakeoffs;
79  
80      /** nullable persistent field */
81      private Integer dayLandings;
82  
83      /** nullable persistent field */
84      private Integer nightTakeoffs;
85  
86      /** nullable persistent field */
87      private Integer nightLandings;
88  
89      /** nullable persistent field */
90      private Integer instrumentApproaches;
91  
92      /** nullable persistent field */
93      private Double conditionNight;
94  
95      /** nullable persistent field */
96      private Double conditionActualImc;
97  
98      /** nullable persistent field */
99      private Double conditionSimulatedImc;
100 
101     /** nullable persistent field */
102     private Double conditionFlightSim;
103 
104     /** full constructor */
105     public Logbook(Date entryDate, String registration, String faaFrom, String faaVia, String faaTo, Double flightDuration, Double pic, Double sic, Double crossCountry, Double flightInstructing, Double safetyPilot, Double dualReceived, Double solo, Integer dayTakeoffs, Integer dayLandings, Integer nightTakeoffs, Integer nightLandings, Integer instrumentApproaches, Double conditionNight, Double conditionActualImc, Double conditionSimulatedImc, Double conditionFlightSim) {
106         this.entryDate = entryDate;
107         this.registration = registration;
108         this.faaFrom = faaFrom;
109         this.faaVia = faaVia;
110         this.faaTo = faaTo;
111         this.flightDuration = flightDuration;
112         this.pic = pic;
113         this.sic = sic;
114         this.crossCountry = crossCountry;
115         this.flightInstructing = flightInstructing;
116         this.safetyPilot = safetyPilot;
117         this.dualReceived = dualReceived;
118         this.solo = solo;
119         this.dayTakeoffs = dayTakeoffs;
120         this.dayLandings = dayLandings;
121         this.nightTakeoffs = nightTakeoffs;
122         this.nightLandings = nightLandings;
123         this.instrumentApproaches = instrumentApproaches;
124         this.conditionNight = conditionNight;
125         this.conditionActualImc = conditionActualImc;
126         this.conditionSimulatedImc = conditionSimulatedImc;
127         this.conditionFlightSim = conditionFlightSim;
128     }
129 
130     /** default constructor */
131     public Logbook() {
132     }
133 
134     /**
135      * The id primary key of the database table.
136      * @return primary key
137      */
138     @Id
139     @GeneratedValue(strategy= GenerationType.AUTO)
140     public Integer getId() {
141         return this.id;
142     }
143 
144     public void setId(Integer id) {
145         this.id = id;
146     }
147 
148     /**
149      * Entry date of log
150      * @return log date
151      */
152     @Column(name = "entry_date", length=10)
153     public Date getEntryDate() {
154         return this.entryDate;
155     }
156 
157     public void setEntryDate(Date entryDate) {
158         this.entryDate = entryDate;
159     }
160 
161     /**
162      * aircraft registration number
163      * @return aircraft registration
164      */
165     @Column(name = "registration", length=7)
166     public String getRegistration() {
167         return this.registration;
168     }
169 
170     public void setRegistration(String registration) {
171         this.registration = registration;
172     }
173 
174     /**
175      * starting airport of flight
176      * @return starting airport faa code
177      */
178     @Column(name = "faa_from", length=4)
179     public String getFaaFrom() {
180         return this.faaFrom;
181     }
182 
183     public void setFaaFrom(String faaFrom) {
184         this.faaFrom = faaFrom;
185     }
186 
187     /**
188      * Via field is used to store general routing information.
189      * @return open routing information string
190      */
191     @Column(name = "faa_via", length=40)
192     public String getFaaVia() {
193         return this.faaVia;
194     }
195 
196     public void setFaaVia(String faaVia) {
197         this.faaVia = faaVia;
198     }
199 
200     /**
201      * Destination airport.
202      * @return faa code
203      */
204     @Column(name = "faa_to", length=4)
205     public String getFaaTo() {
206         return this.faaTo;
207     }
208 
209     public void setFaaTo(String faaTo) {
210         this.faaTo = faaTo;
211     }
212 
213     /**
214      * Duration in flight time
215      * @return duration
216      */
217     @Column(name = "flight_duration", length=22)
218     public Double getFlightDuration() {
219         return this.flightDuration;
220     }
221 
222     public void setFlightDuration(Double flightDuration) {
223         this.flightDuration = flightDuration;
224     }
225 
226     /**
227      * Total time pic for this flight.
228      * @return total time
229      */
230     @Column(name = "pic", length=22)
231     public Double getPic() {
232         return this.pic;
233     }
234 
235     public void setPic(Double pic) {
236         this.pic = pic;
237     }
238 
239    /**
240      * Total time second in command for this flight.
241      * @return total time
242      */
243     @Column(name = "sic", length=22)
244     public Double getSic() {
245         return this.sic;
246     }
247 
248     public void setSic(Double sic) {
249         this.sic = sic;
250     }
251 
252     /**
253      * Total time flying over 50nm for this flight.
254      * @return total time
255      */
256     @Column(name = "cross_country", length=22)
257     public Double getCrossCountry() {
258         return this.crossCountry;
259     }
260 
261     public void setCrossCountry(Double crossCountry) {
262         this.crossCountry = crossCountry;
263     }
264 
265     /**
266      * Total time flight instructing for this flight.
267      * @return total time
268      */
269     @Column(name = "flight_instructing", length=22)
270     public Double getFlightInstructing() {
271         return this.flightInstructing;
272     }
273 
274     public void setFlightInstructing(Double flightInstructing) {
275         this.flightInstructing = flightInstructing;
276     }
277 
278     /**
279      * Total time flying as safety pilot for this flight.
280      * @return total time
281      */
282     @Column(name = "safety_pilot", length=22)
283     public Double getSafetyPilot() {
284         return this.safetyPilot;
285     }
286 
287     public void setSafetyPilot(Double safetyPilot) {
288         this.safetyPilot = safetyPilot;
289     }
290 
291     /**
292      * Total time received from flight instructor.
293      * @return total time.
294      */
295     @Column(name = "dual_received", length=22)
296     public Double getDualReceived() {
297         return this.dualReceived;
298     }
299 
300     public void setDualReceived(Double dualReceived) {
301         this.dualReceived = dualReceived;
302     }
303 
304     /**
305      * Total time flown solo.
306      * @return total hours.
307      */
308     @Column(name = "solo", length=22)
309     public Double getSolo() {
310         return this.solo;
311     }
312 
313     public void setSolo(Double solo) {
314         this.solo = solo;
315     }
316 
317     /**
318      * Number of takeoffs during the day.
319      * @return day count
320      */
321     @Column(name = "day_takeoffs", length=11)
322     public Integer getDayTakeoffs() {
323         return this.dayTakeoffs;
324     }
325 
326     public void setDayTakeoffs(Integer dayTakeoffs) {
327         this.dayTakeoffs = dayTakeoffs;
328     }
329 
330     /**
331      * Number of landings during the day.
332      * @return count.
333      */
334     @Column(name = "day_landings", length=11)
335     public Integer getDayLandings() {
336         return this.dayLandings;
337     }
338 
339     public void setDayLandings(Integer dayLandings) {
340         this.dayLandings = dayLandings;
341     }
342 
343     /**
344      * Number of takeoffs at night.
345      * @return count takeoffs
346      */
347     @Column(name = "night_takeoffs", length=11)
348     public Integer getNightTakeoffs() {
349         return this.nightTakeoffs;
350     }
351 
352     public void setNightTakeoffs(Integer nightTakeoffs) {
353         this.nightTakeoffs = nightTakeoffs;
354     }
355 
356     /**
357      * Number of landings at night.
358      * @return total night landing
359      */
360     @Column(name = "night_landings", length=11)
361     public Integer getNightLandings() {
362         return this.nightLandings;
363     }
364 
365     public void setNightLandings(Integer nightLandings) {
366         this.nightLandings = nightLandings;
367     }
368 
369     /**
370      * Number of instrument approaches
371      * @return number of approaches
372      */
373     @Column(name = "instrument_approaches", length=11)
374     public Integer getInstrumentApproaches() {
375         return this.instrumentApproaches;
376     }
377 
378     public void setInstrumentApproaches(Integer instrumentApproaches) {
379         this.instrumentApproaches = instrumentApproaches;
380     }
381 
382     /**
383      * Flight condition flown at night.
384      * @return total time
385      */
386     @Column(name = "condition_night", length=22)
387     public Double getConditionNight() {
388         return this.conditionNight;
389     }
390 
391     public void setConditionNight(Double conditionNight) {
392         this.conditionNight = conditionNight;
393     }
394 
395     /**
396      * Conditions under actual imc.
397      * @return total time.
398      */
399     @Column(name = "condition_actual_imc", length=22)
400     public Double getConditionActualImc() {
401         return this.conditionActualImc;
402     }
403 
404     public void setConditionActualImc(Double conditionActualImc) {
405         this.conditionActualImc = conditionActualImc;
406     }
407 
408     /**
409      * Time flown under simulated instruments.
410      * @return total time
411      */
412     @Column(name = "condition_simulated_imc", length=22)
413     public Double getConditionSimulatedImc() {
414         return this.conditionSimulatedImc;
415     }
416 
417     public void setConditionSimulatedImc(Double conditionSimulatedImc) {
418         this.conditionSimulatedImc = conditionSimulatedImc;
419     }
420 
421     /**
422      * Time flying simulator
423      * @return time flown
424      */
425     @Column(name = "condition_flight_sim", length=22)
426     public Double getConditionFlightSim() {
427         return this.conditionFlightSim;
428     }
429 
430     public void setConditionFlightSim(Double conditionFlightSim) {
431         this.conditionFlightSim = conditionFlightSim;
432     }
433 
434     public String toString() {
435         return new ToStringBuilder(this)
436             .append("id", getId())
437             .toString();
438     }
439     
440     public boolean equals(Object o) {
441         if (this == o) return true;
442         if (o == null || getClass() != o.getClass()) return false;
443 
444         Logbook logbook = (Logbook) o;
445 
446         if (conditionActualImc != null ? !conditionActualImc.equals(logbook.conditionActualImc) : logbook.conditionActualImc != null)
447             return false;
448         if (conditionFlightSim != null ? !conditionFlightSim.equals(logbook.conditionFlightSim) : logbook.conditionFlightSim != null)
449             return false;
450         if (conditionNight != null ? !conditionNight.equals(logbook.conditionNight) : logbook.conditionNight != null)
451             return false;
452         if (conditionSimulatedImc != null ? !conditionSimulatedImc.equals(logbook.conditionSimulatedImc) : logbook.conditionSimulatedImc != null)
453             return false;
454         if (crossCountry != null ? !crossCountry.equals(logbook.crossCountry) : logbook.crossCountry != null)
455             return false;
456         if (dayLandings != null ? !dayLandings.equals(logbook.dayLandings) : logbook.dayLandings != null) return false;
457         if (dayTakeoffs != null ? !dayTakeoffs.equals(logbook.dayTakeoffs) : logbook.dayTakeoffs != null) return false;
458         if (dualReceived != null ? !dualReceived.equals(logbook.dualReceived) : logbook.dualReceived != null)
459             return false;
460         if (!entryDate.equals(logbook.entryDate)) return false;
461         if (faaFrom != null ? !faaFrom.equals(logbook.faaFrom) : logbook.faaFrom != null) return false;
462         if (faaTo != null ? !faaTo.equals(logbook.faaTo) : logbook.faaTo != null) return false;
463         if (faaVia != null ? !faaVia.equals(logbook.faaVia) : logbook.faaVia != null) return false;
464         if (flightDuration != null ? !flightDuration.equals(logbook.flightDuration) : logbook.flightDuration != null)
465             return false;
466         if (flightInstructing != null ? !flightInstructing.equals(logbook.flightInstructing) : logbook.flightInstructing != null)
467             return false;
468         if (!id.equals(logbook.id)) return false;
469         if (instrumentApproaches != null ? !instrumentApproaches.equals(logbook.instrumentApproaches) : logbook.instrumentApproaches != null)
470             return false;
471         if (nightLandings != null ? !nightLandings.equals(logbook.nightLandings) : logbook.nightLandings != null)
472             return false;
473         if (nightTakeoffs != null ? !nightTakeoffs.equals(logbook.nightTakeoffs) : logbook.nightTakeoffs != null)
474             return false;
475         if (pic != null ? !pic.equals(logbook.pic) : logbook.pic != null) return false;
476         if (registration != null ? !registration.equals(logbook.registration) : logbook.registration != null)
477             return false;
478         if (safetyPilot != null ? !safetyPilot.equals(logbook.safetyPilot) : logbook.safetyPilot != null) return false;
479         if (sic != null ? !sic.equals(logbook.sic) : logbook.sic != null) return false;
480         if (solo != null ? !solo.equals(logbook.solo) : logbook.solo != null) return false;
481 
482         return true;
483     }
484 
485     public int hashCode() {
486         int result;
487         result = id.hashCode();
488         result = 31 * result + entryDate.hashCode();
489         result = 31 * result + (registration != null ? registration.hashCode() : 0);
490         result = 31 * result + (faaFrom != null ? faaFrom.hashCode() : 0);
491         result = 31 * result + (faaVia != null ? faaVia.hashCode() : 0);
492         result = 31 * result + (faaTo != null ? faaTo.hashCode() : 0);
493         result = 31 * result + (flightDuration != null ? flightDuration.hashCode() : 0);
494         result = 31 * result + (pic != null ? pic.hashCode() : 0);
495         result = 31 * result + (sic != null ? sic.hashCode() : 0);
496         result = 31 * result + (crossCountry != null ? crossCountry.hashCode() : 0);
497         result = 31 * result + (flightInstructing != null ? flightInstructing.hashCode() : 0);
498         result = 31 * result + (safetyPilot != null ? safetyPilot.hashCode() : 0);
499         result = 31 * result + (dualReceived != null ? dualReceived.hashCode() : 0);
500         result = 31 * result + (solo != null ? solo.hashCode() : 0);
501         result = 31 * result + (dayTakeoffs != null ? dayTakeoffs.hashCode() : 0);
502         result = 31 * result + (dayLandings != null ? dayLandings.hashCode() : 0);
503         result = 31 * result + (nightTakeoffs != null ? nightTakeoffs.hashCode() : 0);
504         result = 31 * result + (nightLandings != null ? nightLandings.hashCode() : 0);
505         result = 31 * result + (instrumentApproaches != null ? instrumentApproaches.hashCode() : 0);
506         result = 31 * result + (conditionNight != null ? conditionNight.hashCode() : 0);
507         result = 31 * result + (conditionActualImc != null ? conditionActualImc.hashCode() : 0);
508         result = 31 * result + (conditionSimulatedImc != null ? conditionSimulatedImc.hashCode() : 0);
509         result = 31 * result + (conditionFlightSim != null ? conditionFlightSim.hashCode() : 0);
510         return result;
511     }
512 }