Trialing some push pull stuff

main
Sunguin Peng 9 years ago
commit d485176967

Binary file not shown.

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

@ -261,7 +261,7 @@ public class FlightRDController extends Controller {
/** /**
* Will link to the flight analyser when implemented. * Will link to the flight analyser when implemented.
*/ */
private void flightAnalyser(){ public void flightAnalyser(){
JOptionPane.showMessageDialog(null, "This is not Implemented yet"); JOptionPane.showMessageDialog(null, "This is not Implemented yet");
} }

Loading…
Cancel
Save