|
|
|
|
@ -27,11 +27,11 @@ public class Dataset {
|
|
|
|
|
private LinkedHashMap<String, Airport> airportDictionary;
|
|
|
|
|
private LinkedHashMap<String, Route> routeDictionary;
|
|
|
|
|
private LinkedHashMap<Integer, FlightPath> flightPathDictionary;
|
|
|
|
|
private LinkedHashMap<Integer, FlightPoint> flightPointDictionary;
|
|
|
|
|
private LinkedHashMap<String, Country> countryDictionary;
|
|
|
|
|
private LinkedHashMap<String, City> cityDictionary;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @param name Name of the database
|
|
|
|
|
* @param action either Dataset.getExisting or Dataset.createNew
|
|
|
|
|
* @throws DataException Throws an exception if there is some error ie databases with the same name
|
|
|
|
|
@ -45,11 +45,16 @@ public class Dataset {
|
|
|
|
|
this.cities = new ArrayList<City>();
|
|
|
|
|
this.countries = new ArrayList<Country>();
|
|
|
|
|
this.airlineDictionary = new LinkedHashMap<String, Airline>();
|
|
|
|
|
this.airportDictionary = new LinkedHashMap<String, Airport>();;
|
|
|
|
|
this.routeDictionary = new LinkedHashMap<String, Route>();;
|
|
|
|
|
this.countryDictionary = new LinkedHashMap<String, Country>();;
|
|
|
|
|
this.cityDictionary = new LinkedHashMap<String, City>();;
|
|
|
|
|
this.airportDictionary = new LinkedHashMap<String, Airport>();
|
|
|
|
|
;
|
|
|
|
|
this.routeDictionary = new LinkedHashMap<String, Route>();
|
|
|
|
|
;
|
|
|
|
|
this.countryDictionary = new LinkedHashMap<String, Country>();
|
|
|
|
|
;
|
|
|
|
|
this.cityDictionary = new LinkedHashMap<String, City>();
|
|
|
|
|
;
|
|
|
|
|
this.flightPathDictionary = new LinkedHashMap<Integer, FlightPath>();
|
|
|
|
|
this.flightPointDictionary = new LinkedHashMap<Integer, FlightPoint>();
|
|
|
|
|
if (action == getExisting) {
|
|
|
|
|
updateDataset();
|
|
|
|
|
//after this make connections. ie filling in the country.cities airports.routes etc
|
|
|
|
|
@ -60,6 +65,7 @@ public class Dataset {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Updates Dataset Arrays from Database.
|
|
|
|
|
*
|
|
|
|
|
* @throws DataException
|
|
|
|
|
*/
|
|
|
|
|
public void updateDataset() throws DataException {
|
|
|
|
|
@ -204,9 +210,11 @@ public class Dataset {
|
|
|
|
|
double flightPtTotDist = rs.getDouble("Tot_Dist");
|
|
|
|
|
double flightPtLatitude = rs.getDouble("Latitude");
|
|
|
|
|
double flightPtLongitude = rs.getDouble("Longitude");
|
|
|
|
|
flightPaths.get(i).addFlightPoint(new FlightPoint(flightPtName, flightPtID, flightPtInd
|
|
|
|
|
FlightPoint flightPoint = new FlightPoint(flightPtName, flightPtID, flightPtInd
|
|
|
|
|
, flightPtType, flightPtVia, flightPtheading, flightPtAltitude, flightPtLegDistance, flightPtTotDist,
|
|
|
|
|
flightPtLatitude, flightPtLongitude));
|
|
|
|
|
flightPtLatitude, flightPtLongitude);
|
|
|
|
|
flightPaths.get(i).addFlightPoint(flightPoint);
|
|
|
|
|
flightPointDictionary.put(flightPtID, flightPoint);
|
|
|
|
|
}
|
|
|
|
|
rs.close();
|
|
|
|
|
stmt.close();
|
|
|
|
|
@ -245,6 +253,7 @@ public class Dataset {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Creates new Dataset with empty data tables etc
|
|
|
|
|
*
|
|
|
|
|
* @throws DataException
|
|
|
|
|
*/
|
|
|
|
|
public void createTables() throws DataException {
|
|
|
|
|
@ -359,6 +368,7 @@ public class Dataset {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Imports Airline files to the dataset
|
|
|
|
|
*
|
|
|
|
|
* @param filePath
|
|
|
|
|
* @return Success Message
|
|
|
|
|
* @throws DataException
|
|
|
|
|
@ -371,7 +381,7 @@ public class Dataset {
|
|
|
|
|
ArrayList<Airline> airlinesToImport = parser.getResult();
|
|
|
|
|
//check for dup
|
|
|
|
|
int numOfDuplicates = 0;
|
|
|
|
|
int nextID = -1;
|
|
|
|
|
int nextID = 1;
|
|
|
|
|
//query database.
|
|
|
|
|
Connection c = null;
|
|
|
|
|
Statement stmt = null;
|
|
|
|
|
@ -428,8 +438,10 @@ public class Dataset {
|
|
|
|
|
createDataLinks();
|
|
|
|
|
return message;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Imports Airport files to the dataset
|
|
|
|
|
*
|
|
|
|
|
* @param filePath
|
|
|
|
|
* @return Success Message
|
|
|
|
|
* @throws DataException
|
|
|
|
|
@ -444,7 +456,7 @@ public class Dataset {
|
|
|
|
|
ArrayList<Country> countriesToImport = parser.getCountryResult();
|
|
|
|
|
//check for dup
|
|
|
|
|
int numOfDuplicates = 0;
|
|
|
|
|
int nextID = -1;
|
|
|
|
|
int nextID = 1;
|
|
|
|
|
//query database.
|
|
|
|
|
Connection c = null;
|
|
|
|
|
Statement stmt = null;
|
|
|
|
|
@ -459,7 +471,6 @@ public class Dataset {
|
|
|
|
|
while (IDResult.next()) {
|
|
|
|
|
nextID = Integer.parseInt(IDResult.getString("seq")) + 1;//for some reason sqlite3 stores incremental values as a string...
|
|
|
|
|
}
|
|
|
|
|
System.out.println(nextID);
|
|
|
|
|
stmt.close();
|
|
|
|
|
stmt = c.createStatement();
|
|
|
|
|
String insertAirportQuery = "INSERT INTO `" + this.name + "_Airport` (`Name`, `City`, `Country`, `IATA/FFA`," +
|
|
|
|
|
@ -564,6 +575,7 @@ public class Dataset {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Imports Route files to dataset
|
|
|
|
|
*
|
|
|
|
|
* @param filePath
|
|
|
|
|
* @return Success Message
|
|
|
|
|
* @throws DataException
|
|
|
|
|
@ -576,7 +588,7 @@ public class Dataset {
|
|
|
|
|
ArrayList<Route> routesToImport = parser.getResult();
|
|
|
|
|
//check for dup
|
|
|
|
|
int numOfDuplicates = 0;
|
|
|
|
|
int nextID = -1;
|
|
|
|
|
int nextID = 1;
|
|
|
|
|
//query database.
|
|
|
|
|
Connection c = null;
|
|
|
|
|
Statement stmt = null;
|
|
|
|
|
@ -639,6 +651,7 @@ public class Dataset {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Imports Flight files to dataset
|
|
|
|
|
*
|
|
|
|
|
* @param filePath
|
|
|
|
|
* @return Success Message
|
|
|
|
|
* @throws DataException
|
|
|
|
|
@ -651,7 +664,7 @@ public class Dataset {
|
|
|
|
|
ArrayList<FlightPoint> flightPointsToImport = parser.getResult();
|
|
|
|
|
//check for dup
|
|
|
|
|
int numOfDuplicates = 0;
|
|
|
|
|
int nextID = -1;
|
|
|
|
|
int nextID = 1;
|
|
|
|
|
//query database.
|
|
|
|
|
Connection c = null;
|
|
|
|
|
Statement stmt = null;
|
|
|
|
|
@ -667,7 +680,7 @@ public class Dataset {
|
|
|
|
|
}
|
|
|
|
|
stmt.close();
|
|
|
|
|
stmt = c.createStatement();
|
|
|
|
|
//ADDED
|
|
|
|
|
|
|
|
|
|
String firstPt = flightPointsToImport.get(0).getName();
|
|
|
|
|
String lastPt = flightPointsToImport.get(flightPointsToImport.size() - 1).getName();
|
|
|
|
|
FlightPath flightPathToAdd = new FlightPath(firstPt, lastPt);
|
|
|
|
|
@ -677,7 +690,7 @@ public class Dataset {
|
|
|
|
|
stmt.execute(insertFlightPathQuery);
|
|
|
|
|
stmt.close();
|
|
|
|
|
stmt = c.createStatement();
|
|
|
|
|
int flightPathId = 0;
|
|
|
|
|
int flightPathId = 1;
|
|
|
|
|
String getLastestIndex = "SELECT * FROM `sqlite_sequence` WHERE `name` = \"" + this.name.replace("\"", "\"\"") +
|
|
|
|
|
"_Flight_Path\" LIMIT 1;";
|
|
|
|
|
ResultSet lastestIdResult = stmt.executeQuery(getLastestIndex);
|
|
|
|
|
@ -688,7 +701,7 @@ public class Dataset {
|
|
|
|
|
lastestIdResult.close();
|
|
|
|
|
stmt = c.createStatement();
|
|
|
|
|
flightPathToAdd.setID(flightPathId);
|
|
|
|
|
//ADDED
|
|
|
|
|
|
|
|
|
|
String insertFlightPointQuery = "INSERT INTO `" + this.name + "_Flight_Points` (`Index_ID`, `Name`, `Type`," +
|
|
|
|
|
" `Altitude`, `Latitude`, `Longitude`) VALUES ";
|
|
|
|
|
int numOfFlights = 0;
|
|
|
|
|
@ -713,7 +726,7 @@ public class Dataset {
|
|
|
|
|
//add data to dataset array.
|
|
|
|
|
//this is placed after incase the database messes up
|
|
|
|
|
flightPathToAdd.addFlightPoint(flightPointsToImport.get(i));
|
|
|
|
|
//routeDictionary.put(routeIdentifier, flightsToImport.get(i));
|
|
|
|
|
flightPointDictionary.put(flightPointsToImport.get(i).getID(), flightPointsToImport.get(i));
|
|
|
|
|
nextID++;
|
|
|
|
|
numOfFlights++;
|
|
|
|
|
//}
|
|
|
|
|
@ -750,7 +763,6 @@ public class Dataset {
|
|
|
|
|
//create Airline country link
|
|
|
|
|
for (Airline airline : airlines) {
|
|
|
|
|
airlineByIATA.put(airline.getIATA(), airline);
|
|
|
|
|
//System.out.println(airline.getAlias());
|
|
|
|
|
airline.setRoutes(new ArrayList<Route>());
|
|
|
|
|
airline.setCountry(countryDictionary.get(airline.getCountryName()));
|
|
|
|
|
Country country = countryDictionary.get(airline.getCountryName());
|
|
|
|
|
@ -762,7 +774,6 @@ public class Dataset {
|
|
|
|
|
HashMap<String, Airport> airportsByIATA = new HashMap<String, Airport>(); //this is used later for connecting the routes
|
|
|
|
|
HashMap<String, Airport> airportsByICAO = new HashMap<String, Airport>(); //this is used later for connecting the routes
|
|
|
|
|
for (Airport airport : airports) {
|
|
|
|
|
//System.out.println(airport.getIATA_FFA());
|
|
|
|
|
airportsByIATA.put(airport.getIATA_FFA(), airport);
|
|
|
|
|
airportsByICAO.put(airport.getICAO(), airport);
|
|
|
|
|
airport.setCountry(countryDictionary.get(airport.getCountryName()));
|
|
|
|
|
@ -796,6 +807,7 @@ public class Dataset {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Addes Single Airline to Program and Database.
|
|
|
|
|
*
|
|
|
|
|
* @param name
|
|
|
|
|
* @param alias
|
|
|
|
|
* @param IATA
|
|
|
|
|
@ -821,6 +833,7 @@ public class Dataset {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Adds a Single Airline from the Program to the Database
|
|
|
|
|
*
|
|
|
|
|
* @param airlineToAdd
|
|
|
|
|
* @throws DataException
|
|
|
|
|
*/
|
|
|
|
|
@ -873,6 +886,7 @@ public class Dataset {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Adds a single Airport from the Program to the Database
|
|
|
|
|
*
|
|
|
|
|
* @param name
|
|
|
|
|
* @param city
|
|
|
|
|
* @param country
|
|
|
|
|
@ -914,6 +928,7 @@ public class Dataset {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gets the name of the dataset.
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public String getName() {
|
|
|
|
|
@ -922,6 +937,7 @@ public class Dataset {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Adds an Airport to the database and dataset.
|
|
|
|
|
*
|
|
|
|
|
* @param airportToAdd
|
|
|
|
|
* @throws DataException
|
|
|
|
|
*/
|
|
|
|
|
@ -976,6 +992,7 @@ public class Dataset {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Adds a city to the dataset and database
|
|
|
|
|
*
|
|
|
|
|
* @param city
|
|
|
|
|
*/
|
|
|
|
|
private void addCity(City city) {
|
|
|
|
|
@ -1006,6 +1023,7 @@ public class Dataset {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Adds a Country to the dataset and database
|
|
|
|
|
*
|
|
|
|
|
* @param country
|
|
|
|
|
*/
|
|
|
|
|
private void addCountry(Country country) {
|
|
|
|
|
@ -1035,6 +1053,7 @@ public class Dataset {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Adds one single route to the program.
|
|
|
|
|
*
|
|
|
|
|
* @param airline
|
|
|
|
|
* @param sourceAirport
|
|
|
|
|
* @param destAirport
|
|
|
|
|
@ -1059,6 +1078,7 @@ public class Dataset {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Adds a single route the dataset and database.
|
|
|
|
|
*
|
|
|
|
|
* @param routeToAdd
|
|
|
|
|
* @throws DataException
|
|
|
|
|
*/
|
|
|
|
|
@ -1119,6 +1139,7 @@ public class Dataset {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Adds a path to the database and to the path dictionary
|
|
|
|
|
*
|
|
|
|
|
* @param sourceAirport
|
|
|
|
|
* @param destAirport
|
|
|
|
|
*/
|
|
|
|
|
@ -1163,6 +1184,7 @@ public class Dataset {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Adds a flight point to a given path woth the given id
|
|
|
|
|
*
|
|
|
|
|
* @param id
|
|
|
|
|
* @param name
|
|
|
|
|
* @param type
|
|
|
|
|
@ -1237,8 +1259,6 @@ public class Dataset {
|
|
|
|
|
", \"" + via + "\")";
|
|
|
|
|
stmt.execute(insertFlightPointQuery);
|
|
|
|
|
stmt.close();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
System.err.println(e.getClass().getName() + ": " + e.getMessage());
|
|
|
|
|
System.exit(0);
|
|
|
|
|
@ -1246,20 +1266,22 @@ public class Dataset {
|
|
|
|
|
|
|
|
|
|
FlightPoint pointToAdd = new FlightPoint(name, pointID + 1, id, type, via, headingVal, altitudeVal, legDistVal,
|
|
|
|
|
totalDistVal, latitudeVal, longitudeVal);
|
|
|
|
|
flightPointDictionary.put(pointID + 1, pointToAdd);
|
|
|
|
|
flightPathDictionary.get(Integer.valueOf(id)).addFlightPoint(pointToAdd, index);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***
|
|
|
|
|
* Adds a single flight Point to an Existing FLight Path.
|
|
|
|
|
* Adds a single flight Point to an Existing Flight Path.
|
|
|
|
|
* @param point
|
|
|
|
|
* @param index
|
|
|
|
|
* @throws DataException
|
|
|
|
|
*/
|
|
|
|
|
public void addFlightPointToPath(FlightPoint point, int index) throws DataException {
|
|
|
|
|
addFlightPointToPath(point.getIndex(), point.getName(), point.getType(), point.getVia(), String.valueOf(point.getAltitude()),
|
|
|
|
|
String.valueOf( point.getLatitude()),String.valueOf(point.getLongitude()),
|
|
|
|
|
String.valueOf(point.getHeading()), String.valueOf(point.getLegDistance()), String.valueOf(point.getTotalDistance()), index);
|
|
|
|
|
String.valueOf(point.getLatitude()), String.valueOf(point.getLongitude()), String.valueOf(point.getHeading()),
|
|
|
|
|
String.valueOf(point.getLegDistance()), String.valueOf(point.getTotalDistance()), index);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***
|
|
|
|
|
* Adds a single flight Point to an Existing FLight Path appended on the end of the list.
|
|
|
|
|
* @param point
|
|
|
|
|
@ -1267,12 +1289,13 @@ public class Dataset {
|
|
|
|
|
*/
|
|
|
|
|
public void addFlightPointToPath(FlightPoint point) throws DataException {
|
|
|
|
|
addFlightPointToPath(point.getIndex(), point.getName(), point.getType(), point.getVia(), String.valueOf(point.getAltitude()),
|
|
|
|
|
String.valueOf( point.getLatitude()),String.valueOf(point.getLongitude()),
|
|
|
|
|
String.valueOf(point.getHeading()), String.valueOf(point.getLegDistance()), String.valueOf(point.getTotalDistance()), -1);
|
|
|
|
|
String.valueOf(point.getLatitude()), String.valueOf(point.getLongitude()), String.valueOf(point.getHeading()),
|
|
|
|
|
String.valueOf(point.getLegDistance()), String.valueOf(point.getTotalDistance()), -1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Adds a single flight Point to an Existing FLight Path appended on the end of the list.
|
|
|
|
|
*
|
|
|
|
|
* @param id
|
|
|
|
|
* @param name
|
|
|
|
|
* @param type
|
|
|
|
|
@ -1290,6 +1313,7 @@ public class Dataset {
|
|
|
|
|
String heading, String legDist, String totDist) throws DataException {
|
|
|
|
|
addFlightPointToPath(id, name, type, via, altitude, latitude, longitude, heading, legDist, totDist, -1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This is called in conjunction to the App deleteDataset DO NOT CALL UNLESS THROUGH APP.DELETEDATASET
|
|
|
|
|
*/
|
|
|
|
|
@ -1320,6 +1344,7 @@ public class Dataset {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* deletes an airline from the dataset.
|
|
|
|
|
*
|
|
|
|
|
* @param airline
|
|
|
|
|
*/
|
|
|
|
|
public void deleteAirline(Airline airline) {
|
|
|
|
|
@ -1329,14 +1354,10 @@ public class Dataset {
|
|
|
|
|
try {
|
|
|
|
|
Class.forName("org.sqlite.JDBC");
|
|
|
|
|
c = DriverManager.getConnection("jdbc:sqlite:res/userdb.db");
|
|
|
|
|
//System.out.println(airline.getID());
|
|
|
|
|
String deleteQuery = "DELETE FROM `" + this.name + "_Airline` WHERE `Airline_ID` = " + airline.getID() + ";";
|
|
|
|
|
stmt = c.createStatement();
|
|
|
|
|
//System.out.println("Airline deleted");
|
|
|
|
|
stmt.execute(deleteQuery);
|
|
|
|
|
//System.out.println("Airline deleted");
|
|
|
|
|
stmt.close();
|
|
|
|
|
//System.out.println("Airline deleted");
|
|
|
|
|
stmt = c.createStatement();
|
|
|
|
|
//check if number of countries that contain airlines > 0 else delete the country
|
|
|
|
|
String countCountry = "SELECT COUNT(*) FROM `" + this.name + "_Airline` JOIN `" + this.name + "_Country` ON" +
|
|
|
|
|
@ -1380,6 +1401,7 @@ public class Dataset {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Deletes an AIrline from the dataset and database based on it index
|
|
|
|
|
*
|
|
|
|
|
* @param index
|
|
|
|
|
*/
|
|
|
|
|
public void deleteAirline(int index) {
|
|
|
|
|
@ -1388,6 +1410,7 @@ public class Dataset {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* deletes an airport from the dataset.
|
|
|
|
|
*
|
|
|
|
|
* @param airport
|
|
|
|
|
*/
|
|
|
|
|
public void deleteAirport(Airport airport) {
|
|
|
|
|
@ -1463,13 +1486,16 @@ public class Dataset {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Deletes an Airport from the dataset and database based on it index.
|
|
|
|
|
*
|
|
|
|
|
* @param index
|
|
|
|
|
*/
|
|
|
|
|
public void deleteAirport(int index) {
|
|
|
|
|
deleteAirport(airports.get(index));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* deletes an route from the dataset.
|
|
|
|
|
*
|
|
|
|
|
* @param route
|
|
|
|
|
*/
|
|
|
|
|
public void deleteRoute(Route route) {
|
|
|
|
|
@ -1496,13 +1522,16 @@ public class Dataset {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Deletes a Route from the dataset and database based on its index
|
|
|
|
|
*
|
|
|
|
|
* @param index
|
|
|
|
|
*/
|
|
|
|
|
public void deleteRoute(int index) {
|
|
|
|
|
deleteRoute(routes.get(index));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* deletes an airline from the dataset.
|
|
|
|
|
*
|
|
|
|
|
* @param flightPath
|
|
|
|
|
*/
|
|
|
|
|
public void deleteFlightPath(FlightPath flightPath) {
|
|
|
|
|
@ -1538,6 +1567,7 @@ public class Dataset {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Deletes a flight path from the database based on its index.
|
|
|
|
|
*
|
|
|
|
|
* @param index
|
|
|
|
|
*/
|
|
|
|
|
public void deleteFlightPath(int index) {
|
|
|
|
|
@ -1546,6 +1576,7 @@ public class Dataset {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* deletes an airline from the dataset.
|
|
|
|
|
*
|
|
|
|
|
* @param flightPoint
|
|
|
|
|
*/
|
|
|
|
|
public void deleteFlightPoint(FlightPoint flightPoint, FlightPath flightPath) {
|
|
|
|
|
@ -1564,10 +1595,16 @@ public class Dataset {
|
|
|
|
|
System.exit(0);
|
|
|
|
|
}
|
|
|
|
|
flightPath.getFlightPoints().remove(flightPoint);
|
|
|
|
|
try {
|
|
|
|
|
flightPointDictionary.remove(flightPoint.getID());
|
|
|
|
|
} catch (DataException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* deletes a single flight point from a given path.
|
|
|
|
|
*
|
|
|
|
|
* @param pathIndex
|
|
|
|
|
* @param pointIndex
|
|
|
|
|
*/
|
|
|
|
|
@ -1577,6 +1614,7 @@ public class Dataset {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* returns the airlines that are part of this dataset.
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public ArrayList<Airline> getAirlines() {
|
|
|
|
|
@ -1585,6 +1623,7 @@ public class Dataset {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* returns the airports that are associated with this dataset.
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public ArrayList<Airport> getAirports() {
|
|
|
|
|
@ -1593,6 +1632,7 @@ public class Dataset {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* returns the routes that are associated with this dataset.
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public ArrayList<Route> getRoutes() {
|
|
|
|
|
@ -1601,6 +1641,7 @@ public class Dataset {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* returns the flight paths that are associated with this dataset.
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public ArrayList<FlightPath> getFlightPaths() {
|
|
|
|
|
@ -1609,6 +1650,7 @@ public class Dataset {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* returns the countries that are associated with this dataset.
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public ArrayList<Country> getCountries() {
|
|
|
|
|
@ -1617,6 +1659,7 @@ public class Dataset {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* returns the cities that are associate wit hthis dataset.
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public ArrayList<City> getCities() {
|
|
|
|
|
@ -1625,6 +1668,7 @@ public class Dataset {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* returns a dictionary with the airlines that are associated with this datatset.
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public LinkedHashMap<String, Airline> getAirlineDictionary() {
|
|
|
|
|
@ -1633,6 +1677,7 @@ public class Dataset {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* returns a dictionary with the airports that are associated with this dataset.
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public LinkedHashMap<String, Airport> getAirportDictionary() {
|
|
|
|
|
@ -1641,6 +1686,7 @@ public class Dataset {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* returns a route dictionary with the routes that are associated wit hthis dataset.
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public LinkedHashMap<String, Route> getRouteDictionary() {
|
|
|
|
|
@ -1649,14 +1695,25 @@ public class Dataset {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* returns a flightpath dictionary with the flights that are associated with this dataset.
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public LinkedHashMap<Integer, FlightPath> getFlightPathDictionary() {
|
|
|
|
|
return flightPathDictionary;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* returns a flightpoint dictionary with the flights that are associated with this dataset.
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public LinkedHashMap<Integer, FlightPoint> getFlightPointDictionary() {
|
|
|
|
|
return flightPointDictionary;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* returns a Country Dictionary with the COuntries that are associated with this dataset.
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public LinkedHashMap<String, Country> getCountryDictionary() {
|
|
|
|
|
@ -1665,6 +1722,7 @@ public class Dataset {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* returns a City Dictionary with the Cities that are associated with this datatset.
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public LinkedHashMap<String, City> getCityDictionary() {
|
|
|
|
|
@ -1673,6 +1731,7 @@ public class Dataset {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Edits Airline and commits them to the database.
|
|
|
|
|
*
|
|
|
|
|
* @param index
|
|
|
|
|
* @param name
|
|
|
|
|
* @param alias
|
|
|
|
|
@ -1686,8 +1745,10 @@ public class Dataset {
|
|
|
|
|
public void editAirline(int index, String name, String alias, String IATA, String ICAO, String callsign, String country, String active) throws DataException {
|
|
|
|
|
editAirline(airlines.get(index), name, alias, IATA, ICAO, callsign, country, active);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Edits Airline and commits them to the database.
|
|
|
|
|
*
|
|
|
|
|
* @param airline
|
|
|
|
|
* @param name
|
|
|
|
|
* @param alias
|
|
|
|
|
@ -1729,6 +1790,7 @@ public class Dataset {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Edits the Airport in the dataset then commits it to the database.
|
|
|
|
|
*
|
|
|
|
|
* @param index
|
|
|
|
|
* @param name
|
|
|
|
|
* @param city
|
|
|
|
|
@ -1749,6 +1811,7 @@ public class Dataset {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Edits the Airport in the dataset then commits it to the database.
|
|
|
|
|
*
|
|
|
|
|
* @param airport
|
|
|
|
|
* @param name
|
|
|
|
|
* @param city
|
|
|
|
|
@ -1800,6 +1863,7 @@ public class Dataset {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Edits the ROutes in the dataset and commits it to the database.
|
|
|
|
|
*
|
|
|
|
|
* @param index
|
|
|
|
|
* @param airline
|
|
|
|
|
* @param source
|
|
|
|
|
@ -1815,6 +1879,7 @@ public class Dataset {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Edits the ROutes in the dataset and then commits it to the database.
|
|
|
|
|
*
|
|
|
|
|
* @param route
|
|
|
|
|
* @param airline
|
|
|
|
|
* @param source
|
|
|
|
|
@ -1854,6 +1919,7 @@ public class Dataset {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Edits a flight Point in the dataset then commits it to the database.
|
|
|
|
|
*
|
|
|
|
|
* @param flightPath
|
|
|
|
|
* @param index
|
|
|
|
|
* @param name
|
|
|
|
|
@ -1863,13 +1929,13 @@ public class Dataset {
|
|
|
|
|
* @param longitude
|
|
|
|
|
* @throws DataException
|
|
|
|
|
*/
|
|
|
|
|
public void editFlightPath(FlightPath flightPath, int index, String name, String type, String altitude, String latitude,
|
|
|
|
|
String longitude) throws DataException{
|
|
|
|
|
editFlightPoint(flightPath.getFlightPoints().get(index), name, type, altitude, latitude, longitude);
|
|
|
|
|
public void editFlight(FlightPath flightPath, int index, String name, String type, String altitude, String latitude, String longitude) throws DataException {
|
|
|
|
|
editFlight(flightPath.getFlightPoints().get(index), name, type, altitude, latitude, longitude);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Edits a flight Point in the dataset then commits it to the database.
|
|
|
|
|
*
|
|
|
|
|
* @param flightPoint
|
|
|
|
|
* @param name
|
|
|
|
|
* @param type
|
|
|
|
|
@ -1878,8 +1944,7 @@ public class Dataset {
|
|
|
|
|
* @param longitude
|
|
|
|
|
* @throws DataException
|
|
|
|
|
*/
|
|
|
|
|
public void editFlightPoint(FlightPoint flightPoint, String name, String type, String altitude, String latitude,
|
|
|
|
|
String longitude) throws DataException{
|
|
|
|
|
public void editFlight(FlightPoint flightPoint, String name, String type, String altitude, String latitude, String longitude) throws DataException {
|
|
|
|
|
EntryParser entryParser = new EntryParser();
|
|
|
|
|
FlightPoint flightPoint1 = entryParser.parsePoint(name, type, altitude, latitude, longitude);
|
|
|
|
|
flightPoint.setName(flightPoint1.getName());
|
|
|
|
|
@ -1905,8 +1970,7 @@ public class Dataset {
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
System.err.println(e.getClass().getName() + ": " + e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FlightPath flightPath = flightPathDictionary.get(flightPoint.getIndexID());
|
|
|
|
|
FlightPath flightPath = flightPathDictionary.get(flightPoint.getIndex());
|
|
|
|
|
int indexOf = flightPath.getFlightPoints().indexOf(flightPoint);
|
|
|
|
|
|
|
|
|
|
if (indexOf == 0) {
|
|
|
|
|
@ -1919,6 +1983,7 @@ public class Dataset {
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
System.err.println(e.getClass().getName() + ": " + e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
flightPath.setDepartureAirport(flightPoint.getName());
|
|
|
|
|
} else if (indexOf == flightPath.getFlightPoints().size() - 1) {
|
|
|
|
|
try {
|
|
|
|
|
stmt = c.createStatement();
|
|
|
|
|
@ -1929,8 +1994,36 @@ public class Dataset {
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
System.err.println(e.getClass().getName() + ": " + e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
flightPath.setArrivalAirport(flightPoint.getName());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateFlightPointInfo(flightPath);
|
|
|
|
|
createDataLinks();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Updates the Leg Distance, Total Distance and Bearing(Heading) of the Flight points in the flight path.
|
|
|
|
|
* @param flightPath
|
|
|
|
|
*/
|
|
|
|
|
public void updateFlightPointInfo(FlightPath flightPath){
|
|
|
|
|
flightPath.updateFlightPointInfo();
|
|
|
|
|
Connection c = null;
|
|
|
|
|
Statement stmt;
|
|
|
|
|
try {
|
|
|
|
|
c = DriverManager.getConnection("jdbc:sqlite:res/userdb.db");
|
|
|
|
|
//move all the points after this forward
|
|
|
|
|
for (FlightPoint flightPoint: flightPath.getFlightPoints()){
|
|
|
|
|
stmt = c.createStatement();
|
|
|
|
|
String updatePointQuery = "UPDATE `"+this.name+"_Flight_Points` SET `Heading` = "+flightPoint.getHeading()+", " +
|
|
|
|
|
"`Tot_Dist` = "+flightPoint.getTotalDistance()+", `Leg_Dist` = "+flightPoint.getLegDistance()+" WHERE `POINT_ID` = " +
|
|
|
|
|
"" + flightPoint.getID();
|
|
|
|
|
stmt.execute(updatePointQuery);
|
|
|
|
|
stmt.close();
|
|
|
|
|
}
|
|
|
|
|
c.close();
|
|
|
|
|
} catch ( Exception e ) {
|
|
|
|
|
System.err.println( e.getClass().getName() + ": " + e.getMessage() );
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
System.exit(0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|