|
|
|
|
@ -23,13 +23,13 @@ public class Dataset {
|
|
|
|
|
private ArrayList<FlightPath> flightPaths;
|
|
|
|
|
private ArrayList<Country> countries;
|
|
|
|
|
private ArrayList<City> cities;
|
|
|
|
|
private LinkedHashMap<String, Airline> airlineDictionary;
|
|
|
|
|
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;
|
|
|
|
|
private LinkedHashMap<String, Airline> airlineDictionary;//key name
|
|
|
|
|
private LinkedHashMap<String, Airport> airportDictionary;//key name
|
|
|
|
|
private LinkedHashMap<String, Route> routeDictionary;//key routeAirline + routeSourceAirport + routeArrvAirport + routeCodeShare + routeStops + routeEquip
|
|
|
|
|
private LinkedHashMap<Integer, FlightPath> flightPathDictionary;//key path id
|
|
|
|
|
private LinkedHashMap<String, Country> countryDictionary;//key name
|
|
|
|
|
private LinkedHashMap<String, City> cityDictionary;//key city name
|
|
|
|
|
private LinkedHashMap<Integer, FlightPoint> flightPointDictionary;//key point id
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
@ -1545,7 +1545,12 @@ public class Dataset {
|
|
|
|
|
public void deleteFlightPath(FlightPath flightPath){
|
|
|
|
|
//delete all flight points with the id
|
|
|
|
|
while(flightPath.getFlightPoints().size() > 0){
|
|
|
|
|
deleteFlightPoint(flightPath.getFlightPoints().get(0), flightPath);
|
|
|
|
|
try {
|
|
|
|
|
flightPointDictionary.remove(flightPath.getFlightPoints().get(0).getID());
|
|
|
|
|
flightPath.getFlightPoints().remove(0);
|
|
|
|
|
} catch (DataException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//drop the entries
|
|
|
|
|
Connection c = null;
|
|
|
|
|
@ -1595,17 +1600,50 @@ public class Dataset {
|
|
|
|
|
String deleteQuery = "DELETE FROM `"+this.name+"_Flight_Points` WHERE `Point_ID` = " + flightPoint.getID() + ";";
|
|
|
|
|
stmt = c.createStatement();
|
|
|
|
|
stmt.execute(deleteQuery);
|
|
|
|
|
|
|
|
|
|
stmt = c.createStatement();
|
|
|
|
|
String updatePointOrderQuery = "";
|
|
|
|
|
for (int i = 0; i < flightPath.getFlightPoints().size(); i ++){
|
|
|
|
|
updatePointOrderQuery = "UPDATE `"+this.name+"_Flight_Points` SET `Order` = "+i+" WHERE `Point_ID` = "+flightPath.getFlightPoints().get(i).getID()+";";
|
|
|
|
|
stmt.execute(updatePointOrderQuery);
|
|
|
|
|
}
|
|
|
|
|
stmt.close();
|
|
|
|
|
|
|
|
|
|
int index = flightPath.getFlightPoints().indexOf(flightPoint);
|
|
|
|
|
System.out.println(index);
|
|
|
|
|
|
|
|
|
|
if (index == 0){
|
|
|
|
|
try {
|
|
|
|
|
stmt = c.createStatement();
|
|
|
|
|
String query = "UPDATE `"+this.name+"_Flight_Path` SET `Source_Airport` = \""+flightPoint.getName().replace("\"", "\"\"")+"\" " +
|
|
|
|
|
"WHERE `Path_ID` = "+flightPoint.getIndex();
|
|
|
|
|
stmt.execute(query);
|
|
|
|
|
c.close();
|
|
|
|
|
} catch ( Exception e ) {
|
|
|
|
|
System.err.println( e.getClass().getName() + ": " + e.getMessage() );
|
|
|
|
|
}
|
|
|
|
|
flightPath.setDepartureAirport(flightPoint.getName());
|
|
|
|
|
}else if (index == flightPath.getFlightPoints().size() - 1){
|
|
|
|
|
try {
|
|
|
|
|
stmt = c.createStatement();
|
|
|
|
|
String query = "UPDATE `"+this.name+"_Flight_Path` SET `Destination_Airport` = \""+flightPoint.getName().replace("\"", "\"\"")+"\" " +
|
|
|
|
|
"WHERE `Path_ID` = "+flightPoint.getIndex();
|
|
|
|
|
stmt.execute(query);
|
|
|
|
|
c.close();
|
|
|
|
|
} catch ( Exception e ) {
|
|
|
|
|
System.err.println( e.getClass().getName() + ": " + e.getMessage() );
|
|
|
|
|
}
|
|
|
|
|
flightPath.setArrivalAirport(flightPoint.getName());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
c.close();
|
|
|
|
|
} catch ( Exception e ) {
|
|
|
|
|
System.err.println( e.getClass().getName() + ": " + e.getMessage() );
|
|
|
|
|
System.exit(0);
|
|
|
|
|
}
|
|
|
|
|
flightPath.getFlightPoints().remove(flightPoint);
|
|
|
|
|
try {
|
|
|
|
|
flightPointDictionary.remove(flightPoint.getID());
|
|
|
|
|
} catch (DataException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
flightPointDictionary.remove(flightPoint);
|
|
|
|
|
updateFlightPointInfo(flightPath);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -1752,6 +1790,7 @@ public class Dataset {
|
|
|
|
|
public void editAirline(Airline airline, String name, String alias, String IATA, String ICAO, String callsign, String country, String active ) throws DataException {
|
|
|
|
|
//check the data errors
|
|
|
|
|
EntryParser parser = new EntryParser();
|
|
|
|
|
airlineDictionary.remove(airline);
|
|
|
|
|
parser.parseAirline(name, alias, IATA,ICAO, callsign, country, active);
|
|
|
|
|
airline.setName(name);
|
|
|
|
|
airline.setAlias(alias);
|
|
|
|
|
@ -1775,6 +1814,7 @@ public class Dataset {
|
|
|
|
|
} catch ( Exception e ) {
|
|
|
|
|
System.err.println( e.getClass().getName() + ": " + e.getMessage() );
|
|
|
|
|
}
|
|
|
|
|
airlineDictionary.put(airline.getName(), airline);
|
|
|
|
|
createDataLinks();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -1816,6 +1856,7 @@ public class Dataset {
|
|
|
|
|
*/
|
|
|
|
|
public void editAirport(Airport airport, String name, String city, String country, String IATA_FFA, String ICAO, String lat, String lng, String alt, String timezone, String DST, String olson) throws DataException {
|
|
|
|
|
EntryParser parser = new EntryParser();
|
|
|
|
|
airportDictionary.remove(airport.getName());
|
|
|
|
|
Airport newAirport = parser.parseAirport(name, city, country, IATA_FFA, ICAO, lat, lng, alt, timezone, DST, olson);
|
|
|
|
|
airport.setName(name);
|
|
|
|
|
airport.setCityName(city);
|
|
|
|
|
@ -1897,6 +1938,7 @@ public class Dataset {
|
|
|
|
|
} catch ( Exception e ) {
|
|
|
|
|
System.err.println( e.getClass().getName() + ": " + e.getMessage() );
|
|
|
|
|
}
|
|
|
|
|
airportDictionary.put(airport.getName(), airport);
|
|
|
|
|
createDataLinks();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -1928,6 +1970,8 @@ public class Dataset {
|
|
|
|
|
*/
|
|
|
|
|
public void editRoute(Route route, String airline, String source, String dest, String code, String stops, String equip) throws DataException {
|
|
|
|
|
EntryParser entryParser = new EntryParser();
|
|
|
|
|
//routeAirline + routeSourceAirport + routeArrvAirport + routeCodeShare + routeStops + routeEquip
|
|
|
|
|
routeDictionary.remove(route.getAirlineName()+route.getDepartureAirport()+route.getArrivalAirport()+route.getCode()+route.getStops() + route.getEquipment());
|
|
|
|
|
Route newRoute = entryParser.parseRoute(airline, source, dest, code, stops, equip);
|
|
|
|
|
route.setAirlineName(newRoute.getAirlineName());
|
|
|
|
|
route.setDepartureAirport(newRoute.getDepartureAirport());
|
|
|
|
|
@ -1951,6 +1995,8 @@ public class Dataset {
|
|
|
|
|
} catch ( Exception e ) {
|
|
|
|
|
System.err.println( e.getClass().getName() + ": " + e.getMessage() );
|
|
|
|
|
}
|
|
|
|
|
//routeAirline + routeSourceAirport + routeArrvAirport + routeCodeShare + routeStops + routeEquip
|
|
|
|
|
routeDictionary.put(route.getAirlineName()+route.getDepartureAirport()+route.getArrivalAirport()+route.getCode()+route.getStops() + route.getEquipment(), route);
|
|
|
|
|
createDataLinks();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|