1   package org.wcb.model.vo.hibernate;
2   
3   import java.io.Serializable;
4   import org.apache.commons.lang.builder.ToStringBuilder;
5   
6   import javax.persistence.*;
7   
8   
9   /**
10   *
11   * This object stores airports in the database and is the core of the logbook application.
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 30, 2006 10:35:19 AM $ <br>
23   * </small>
24   *
25   * @author wbogaardt
26   * @version 1
27   *          Date: Mar 30, 2006
28   *          Time: 10:35:19 AM
29   */
30  @Entity
31  @Table(name ="airport")
32  public class AirportBO implements Serializable {
33  
34      /** identifier field */
35      private Integer id;
36  
37      /** persistent field */
38      private String icao;
39  
40      /** persistent field */
41      private String faa;
42  
43      /** persistent field */
44      private String iata;
45  
46      /** nullable persistent field */
47      private String name;
48  
49      /** nullable persistent field */
50      private String municipal;
51  
52      /** nullable persistent field */
53      private String state;
54  
55      /** nullable persistent field */
56      private String country;
57  
58      /** nullable persistent field */
59      private String latitude;
60  
61      /** nullable persistent field */
62      private String longitude;
63  
64      /** nullable persistent field */
65      private String altitude;
66  
67      /** full constructor */
68      public AirportBO(String icao, String faa, String iata, String name, String municipal, String state, String country, String latitude, String longitude, String altitude) {
69          this.icao = icao;
70          this.faa = faa;
71          this.iata = iata;
72          this.name = name;
73          this.municipal = municipal;
74          this.state = state;
75          this.country = country;
76          this.latitude = latitude;
77          this.longitude = longitude;
78          this.altitude = altitude;
79      }
80  
81      /** default constructor */
82      public AirportBO() {
83      }
84  
85      /** minimal constructor */
86      public AirportBO(String icao, String faa, String iata) {
87          this.icao = icao;
88          this.faa = faa;
89          this.iata = iata;
90      }
91  
92      /**
93       * Primary key.
94       * @return primary key
95       */
96      @Id
97      @GeneratedValue(strategy= GenerationType.AUTO)
98      public Integer getId() {
99          return this.id;
100     }
101 
102     public void setId(Integer id) {
103         this.id = id;
104     }
105 
106     /**
107      * ICAO code for airport.
108      * @return icao code
109      */
110     @Column(name = "icao", nullable=false, length=4)
111     public String getIcao() {
112         return this.icao;
113     }
114 
115     public void setIcao(String icao) {
116         this.icao = icao;
117     }
118 
119     /**
120      * FAA code similar to ICAO code.
121      * @return faa code
122      */
123     @Column(name = "faa", nullable=false, length=4)
124     public String getFaa() {
125         return this.faa;
126     }
127 
128     public void setFaa(String faa) {
129         this.faa = faa;
130     }
131 
132     /**
133      * International airport code.
134      * @return similary to ICAO code.
135      */
136     @Column(name = "iata", nullable=false, length=4)
137     public String getIata() {
138         return this.iata;
139     }
140 
141     public void setIata(String iata) {
142         this.iata = iata;
143     }
144 
145     /**
146      * Name of the airport sometimes the
147      * same name as the municipality.
148      * @return name of airport.
149      */
150     @Column(name = "name", length=50)
151     public String getName() {
152         return this.name;
153     }
154 
155     public void setName(String name) {
156         this.name = name;
157     }
158 
159     /**
160      * Municipality location of the airport.
161      * @return city
162      */
163     @Column(name = "municipal", length=50)
164     public String getMunicipal() {
165         return this.municipal;
166     }
167 
168     public void setMunicipal(String municipal) {
169         this.municipal = municipal;
170     }
171 
172     /**
173      * State location of the airport.
174      * @return state location
175      */
176     @Column(name = "state", length=50)
177     public String getState() {
178         return this.state;
179     }
180 
181     public void setState(String state) {
182         this.state = state;
183     }
184 
185     /**
186      * Country location of the airport.
187      * @return Country location.
188      */
189     @Column(name = "country", length=50)
190     public String getCountry() {
191         return this.country;
192     }
193 
194     public void setCountry(String country) {
195         this.country = country;
196     }
197 
198     /**
199      * Latitude of the airport. This code is entered as
200      * 34-12-02.9000N format
201      * @return string format of latitude
202      */
203     @Column(name = "latitude", length=30)
204     public String getLatitude() {
205         return this.latitude;
206     }
207 
208     public void setLatitude(String latitude) {
209         this.latitude = latitude;
210     }
211 
212     /**
213      * Longitude of the airport. this code is entered as
214      * 119-12-26.0000W format
215      * @return string format of longitude
216      */
217     @Column(name = "longitude", length=30)
218     public String getLongitude() {
219         return this.longitude;
220     }
221 
222     public void setLongitude(String longitude) {
223         this.longitude = longitude;
224     }
225 
226     /**
227      * Altitude of the airport.
228      * @return altitude msl of airport
229      */
230     @Column(name = "altitude", length=7)
231     public String getAltitude() {
232         return this.altitude;
233     }
234 
235     public void setAltitude(String altitude) {
236         this.altitude = altitude;
237     }
238 
239     public String toString() {
240         return new ToStringBuilder(this)
241             .append("id", getId())
242             .toString();
243     }
244 
245     public boolean equals(Object o) {
246         if (this == o) return true;
247         if (o == null || getClass() != o.getClass()) return false;
248 
249         AirportBO airportBO = (AirportBO) o;
250 
251         if (altitude != null ? !altitude.equals(airportBO.altitude) : airportBO.altitude != null) return false;
252         if (country != null ? !country.equals(airportBO.country) : airportBO.country != null) return false;
253         if (faa != null ? !faa.equals(airportBO.faa) : airportBO.faa != null) return false;
254         if (iata != null ? !iata.equals(airportBO.iata) : airportBO.iata != null) return false;
255         if (!icao.equals(airportBO.icao)) return false;
256         if (!id.equals(airportBO.id)) return false;
257         if (latitude != null ? !latitude.equals(airportBO.latitude) : airportBO.latitude != null) return false;
258         if (longitude != null ? !longitude.equals(airportBO.longitude) : airportBO.longitude != null) return false;
259         if (municipal != null ? !municipal.equals(airportBO.municipal) : airportBO.municipal != null) return false;
260         if (name != null ? !name.equals(airportBO.name) : airportBO.name != null) return false;
261         if (state != null ? !state.equals(airportBO.state) : airportBO.state != null) return false;
262 
263         return true;
264     }
265 
266     public int hashCode() {
267         int result;
268         result = id.hashCode();
269         result = 31 * result + icao.hashCode();
270         result = 31 * result + (faa != null ? faa.hashCode() : 0);
271         result = 31 * result + (iata != null ? iata.hashCode() : 0);
272         result = 31 * result + (name != null ? name.hashCode() : 0);
273         result = 31 * result + (municipal != null ? municipal.hashCode() : 0);
274         result = 31 * result + (state != null ? state.hashCode() : 0);
275         result = 31 * result + (country != null ? country.hashCode() : 0);
276         result = 31 * result + (latitude != null ? latitude.hashCode() : 0);
277         result = 31 * result + (longitude != null ? longitude.hashCode() : 0);
278         result = 31 * result + (altitude != null ? altitude.hashCode() : 0);
279         return result;
280     }
281 }