Made Delete update the Flight Path Information

main
YaFedImYaEatIm 9 years ago
parent 986e22bf1e
commit fdce7e2f2f

Binary file not shown.

@ -1609,32 +1609,6 @@ public class Dataset {
} }
stmt.close(); stmt.close();
int index = flightPath.getFlightPoints().indexOf(flightPoint);
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(); c.close();
} catch ( Exception e ) { } catch ( Exception e ) {
System.err.println( e.getClass().getName() + ": " + e.getMessage() ); System.err.println( e.getClass().getName() + ": " + e.getMessage() );
@ -1643,6 +1617,7 @@ public class Dataset {
flightPath.getFlightPoints().remove(flightPoint); flightPath.getFlightPoints().remove(flightPoint);
flightPointDictionary.remove(flightPoint); flightPointDictionary.remove(flightPoint);
updateFlightPointInfo(flightPath); updateFlightPointInfo(flightPath);
updateFlightPath(flightPath);
} }
/** /**
@ -2050,38 +2025,32 @@ 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() );
} }
FlightPath flightPath = flightPathDictionary.get(flightPoint.getIndex()); updateFlightPath(flightPathDictionary.get(flightPoint.getIndex()));
int indexOf = flightPath.getFlightPoints().indexOf(flightPoint); createDataLinks();
}
if (indexOf == 0){ private void updateFlightPath(FlightPath flightPath){
try { Connection c = null;
Class.forName("org.sqlite.JDBC"); Statement stmt = null;
c = DriverManager.getConnection("jdbc:sqlite:res/userdb.db"); FlightPoint startPoint = flightPath.getFlightPoints().get(0);
stmt = c.createStatement(); FlightPoint endPoint = flightPath.getFlightPoints().get(flightPath.getFlightPoints().size() - 1);
String query = "UPDATE `"+this.name+"_Flight_Path` SET `Source_Airport` = \""+flightPoint.getName().replace("\"", "\"\"")+"\" " + try {
"WHERE `Path_ID` = "+flightPoint.getIndex(); Class.forName("org.sqlite.JDBC");
stmt.execute(query); c = DriverManager.getConnection("jdbc:sqlite:res/userdb.db");
c.close(); stmt = c.createStatement();
} catch ( Exception e ) { String querySource = "UPDATE `"+this.name+"_Flight_Path` SET `Source_Airport` = \""+startPoint.getName().replace("\"", "\"\"")+"\" " +
System.err.println( e.getClass().getName() + ": " + e.getMessage() ); "WHERE `Path_ID` = "+startPoint.getIndex();
} stmt.execute(querySource);
flightPath.setDepartureAirport(flightPoint.getName()); stmt = c.createStatement();
} else if (indexOf == flightPath.getFlightPoints().size() - 1) { String queryDest = "UPDATE `"+this.name+"_Flight_Path` SET `Destination_Airport` = \""+endPoint.getName().replace("\"", "\"\"")+"\" " +
try { "WHERE `Path_ID` = "+endPoint.getIndex();
Class.forName("org.sqlite.JDBC"); stmt.execute(queryDest);
c = DriverManager.getConnection("jdbc:sqlite:res/userdb.db"); c.close();
stmt = c.createStatement(); } catch ( Exception e ) {
String query = "UPDATE `"+this.name+"_Flight_Path` SET `Destination_Airport` = \""+flightPoint.getName().replace("\"", "\"\"")+"\" " + System.err.println( e.getClass().getName() + ": " + e.getMessage() );
"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());
} }
flightPath.setArrivalAirport(endPoint.getName());
createDataLinks(); flightPath.setDepartureAirport(startPoint.getName());
} }
/** /**

Loading…
Cancel
Save