|
|
|
@ -752,6 +752,7 @@ public class Dataset {
|
|
|
|
airportsByIATA.put(airport.getIATA_FFA(), airport);
|
|
|
|
airportsByIATA.put(airport.getIATA_FFA(), airport);
|
|
|
|
airportsByICAO.put(airport.getICAO(), airport);
|
|
|
|
airportsByICAO.put(airport.getICAO(), airport);
|
|
|
|
airport.setCountry(countryDictionary.get(airport.getCountryName()));
|
|
|
|
airport.setCountry(countryDictionary.get(airport.getCountryName()));
|
|
|
|
|
|
|
|
//airport.getCountry().setPosition(new Position(airport.getLatitude(), airport.getLongitude()));
|
|
|
|
//TODO Add City in country (This is extra work).
|
|
|
|
//TODO Add City in country (This is extra work).
|
|
|
|
airport.setCity(cityDictionary.get(airport.getCityName()));
|
|
|
|
airport.setCity(cityDictionary.get(airport.getCityName()));
|
|
|
|
airport.getCity().addAirport(airport);
|
|
|
|
airport.getCity().addAirport(airport);
|
|
|
|
@ -847,6 +848,7 @@ public class Dataset {
|
|
|
|
addAirport(airportToAdd);
|
|
|
|
addAirport(airportToAdd);
|
|
|
|
addCity(cityToAdd);
|
|
|
|
addCity(cityToAdd);
|
|
|
|
addCountry(countryToAdd);
|
|
|
|
addCountry(countryToAdd);
|
|
|
|
|
|
|
|
createDataLinks();
|
|
|
|
}catch (NumberFormatException e){
|
|
|
|
}catch (NumberFormatException e){
|
|
|
|
throw new DataException("Latitude, Longitude, Altitude and Timezone must be numbers");
|
|
|
|
throw new DataException("Latitude, Longitude, Altitude and Timezone must be numbers");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -859,6 +861,9 @@ public class Dataset {
|
|
|
|
if (airportToAdd.getICAO() != "" && airportToAdd.getICAO().length() != 4){
|
|
|
|
if (airportToAdd.getICAO() != "" && airportToAdd.getICAO().length() != 4){
|
|
|
|
throw new DataException("ICAO either empty or 4 letters");
|
|
|
|
throw new DataException("ICAO either empty or 4 letters");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (airportToAdd.getName() == ""){
|
|
|
|
|
|
|
|
throw new DataException("An Airport cannot have no name.");
|
|
|
|
|
|
|
|
}
|
|
|
|
for (String key : airportDictionary.keySet()){
|
|
|
|
for (String key : airportDictionary.keySet()){
|
|
|
|
airportDictionary.get(key).hasDuplicate(airportToAdd);
|
|
|
|
airportDictionary.get(key).hasDuplicate(airportToAdd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -876,6 +881,7 @@ public class Dataset {
|
|
|
|
"\""+airportToAdd.getCountryName()+"\", \""+airportToAdd.getIATA_FFA()+"\", \""+airportToAdd.getICAO()+"\", " +
|
|
|
|
"\""+airportToAdd.getCountryName()+"\", \""+airportToAdd.getIATA_FFA()+"\", \""+airportToAdd.getICAO()+"\", " +
|
|
|
|
""+airportToAdd.getLatitude()+", "+airportToAdd.getLongitude()+", "+airportToAdd.getAltitude()+");";
|
|
|
|
""+airportToAdd.getLatitude()+", "+airportToAdd.getLongitude()+", "+airportToAdd.getAltitude()+");";
|
|
|
|
stmt.execute(insertAirportQuery);
|
|
|
|
stmt.execute(insertAirportQuery);
|
|
|
|
|
|
|
|
stmt.close();
|
|
|
|
//get the airport id
|
|
|
|
//get the airport id
|
|
|
|
stmt = c.createStatement();
|
|
|
|
stmt = c.createStatement();
|
|
|
|
String airportIDQuery = "SELECT * FROM `sqlite_sequence` WHERE `name` = \""+this.name+"_Airport\" LIMIT 1;";
|
|
|
|
String airportIDQuery = "SELECT * FROM `sqlite_sequence` WHERE `name` = \""+this.name+"_Airport\" LIMIT 1;";
|
|
|
|
@ -887,6 +893,9 @@ public class Dataset {
|
|
|
|
airportToAdd.setID(airportID);
|
|
|
|
airportToAdd.setID(airportID);
|
|
|
|
airports.add(airportToAdd);
|
|
|
|
airports.add(airportToAdd);
|
|
|
|
airportDictionary.put(airportToAdd.getName(), airportToAdd);
|
|
|
|
airportDictionary.put(airportToAdd.getName(), airportToAdd);
|
|
|
|
|
|
|
|
airportIDRes.close();
|
|
|
|
|
|
|
|
stmt.close();
|
|
|
|
|
|
|
|
c.close();
|
|
|
|
} catch ( Exception e ) {
|
|
|
|
} catch ( Exception e ) {
|
|
|
|
System.err.println( e.getClass().getName() + ": " + e.getMessage() );
|
|
|
|
System.err.println( e.getClass().getName() + ": " + e.getMessage() );
|
|
|
|
System.exit(0);
|
|
|
|
System.exit(0);
|
|
|
|
@ -912,6 +921,7 @@ public class Dataset {
|
|
|
|
stmt.close();
|
|
|
|
stmt.close();
|
|
|
|
cityDictionary.put(city.getName(), city);
|
|
|
|
cityDictionary.put(city.getName(), city);
|
|
|
|
cities.add(city);
|
|
|
|
cities.add(city);
|
|
|
|
|
|
|
|
c.close();
|
|
|
|
} catch ( Exception e ) {
|
|
|
|
} catch ( Exception e ) {
|
|
|
|
System.err.println( e.getClass().getName() + ": " + e.getMessage() );
|
|
|
|
System.err.println( e.getClass().getName() + ": " + e.getMessage() );
|
|
|
|
System.exit(0);
|
|
|
|
System.exit(0);
|
|
|
|
@ -936,6 +946,7 @@ public class Dataset {
|
|
|
|
stmt.close();
|
|
|
|
stmt.close();
|
|
|
|
countryDictionary.put(country.getName(), country);
|
|
|
|
countryDictionary.put(country.getName(), country);
|
|
|
|
countries.add(country);
|
|
|
|
countries.add(country);
|
|
|
|
|
|
|
|
c.close();
|
|
|
|
} catch ( Exception e ) {
|
|
|
|
} catch ( Exception e ) {
|
|
|
|
System.err.println( e.getClass().getName() + ": " + e.getMessage() );
|
|
|
|
System.err.println( e.getClass().getName() + ": " + e.getMessage() );
|
|
|
|
System.exit(0);
|
|
|
|
System.exit(0);
|
|
|
|
|