COnnected maps to airlines, Airports and ROutes

This commit is contained in:
YaFedImYaEatIm
2016-09-17 20:06:19 +12:00
parent 44ed68ee7a
commit 5363cf8b4e
12 changed files with 114 additions and 7 deletions
@@ -50,6 +50,7 @@ public class App extends Application
InputStream in = getClass().getClassLoader().getResourceAsStream("menu.fxml");
mainContainer = (VBox) loader.load(in);
Scene scene = new Scene(mainContainer, 800, 600);
primaryStage.setResizable(false);
primaryStage.setScene(scene);
primaryStage.sizeToScene();
MenuController menuController = (MenuController) loader.getController();
@@ -135,6 +136,7 @@ public class App extends Application
System.out.println("Missing Session Class");
System.exit(1);
} catch (Exception e) {
session = new Session();
e.printStackTrace();
}
}
@@ -752,6 +752,7 @@ public class Dataset {
airportsByIATA.put(airport.getIATA_FFA(), airport);
airportsByICAO.put(airport.getICAO(), airport);
airport.setCountry(countryDictionary.get(airport.getCountryName()));
//airport.getCountry().setPosition(new Position(airport.getLatitude(), airport.getLongitude()));
//TODO Add City in country (This is extra work).
airport.setCity(cityDictionary.get(airport.getCityName()));
airport.getCity().addAirport(airport);
@@ -846,6 +847,7 @@ public class Dataset {
addAirport(airportToAdd);
addCity(cityToAdd);
addCountry(countryToAdd);
createDataLinks();
}catch (NumberFormatException e){
throw new DataException("Latitude, Longitude, Altitude and Timezone must be numbers");
}
@@ -858,6 +860,9 @@ public class Dataset {
if (airportToAdd.getICAO() != "" && airportToAdd.getICAO().length() != 4){
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()){
airportDictionary.get(key).hasDuplicate(airportToAdd);
}
@@ -875,6 +880,7 @@ public class Dataset {
"\""+airportToAdd.getCountryName()+"\", \""+airportToAdd.getIATA_FFA()+"\", \""+airportToAdd.getICAO()+"\", " +
""+airportToAdd.getLatitude()+", "+airportToAdd.getLongitude()+", "+airportToAdd.getAltitude()+");";
stmt.execute(insertAirportQuery);
stmt.close();
//get the airport id
stmt = c.createStatement();
String airportIDQuery = "SELECT * FROM `sqlite_sequence` WHERE `name` = \""+this.name+"_Airport\" LIMIT 1;";
@@ -886,6 +892,9 @@ public class Dataset {
airportToAdd.setID(airportID);
airports.add(airportToAdd);
airportDictionary.put(airportToAdd.getName(), airportToAdd);
airportIDRes.close();
stmt.close();
c.close();
} catch ( Exception e ) {
System.err.println( e.getClass().getName() + ": " + e.getMessage() );
System.exit(0);
@@ -910,6 +919,7 @@ public class Dataset {
stmt.close();
cityDictionary.put(city.getName(), city);
cities.add(city);
c.close();
} catch ( Exception e ) {
System.err.println( e.getClass().getName() + ": " + e.getMessage() );
System.exit(0);
@@ -934,6 +944,7 @@ public class Dataset {
stmt.close();
countryDictionary.put(country.getName(), country);
countries.add(country);
c.close();
} catch ( Exception e ) {
System.err.println( e.getClass().getName() + ": " + e.getMessage() );
System.exit(0);
@@ -7,7 +7,7 @@ public enum SceneCode {
INITIAL(""), AIRLINE_SUMMARY("airline_summary.fxml"), AIRLINE_RAW_DATA("airline_raw_data.fxml"),
AIRPORT_SUMMARY("airport_summary.fxml"), AIRPORT_RAW_DATA("airport_raw_data.fxml"),
ROUTE_SUMMARY("routes_summary.fxml"), ROUTE_RAW_DATA("route_raw_data.fxml"), FLIGHT_SUMMARY("flight_data_summary.fxml"),
FLIGHT_RAW_DATA("flight_raw_data.fxml"), AIRPORT_ANALYSER("airport_analyser.fxml"), ROUTE_ANALYSER("route_analyser.fxml");;
FLIGHT_RAW_DATA("flight_raw_data.fxml"), AIRPORT_ANALYSER("airport_analyser.fxml"), ROUTE_ANALYSER("route_analyser.fxml");
private String filePath;