Fixed flightPaths adding new flight path error
This commit is contained in:
Binary file not shown.
@@ -1153,21 +1153,22 @@ public class Dataset {
|
|||||||
String insertPathQuery = "INSERT INTO `" + this.name + "_Flight_Path` (`Path_ID`, `Source_Airport`, " +
|
String insertPathQuery = "INSERT INTO `" + this.name + "_Flight_Path` (`Path_ID`, `Source_Airport`, " +
|
||||||
"`Destination_Airport`) VALUES ("+pathID+", \""+sourceAirport+"\", \""+destAirport+"\" )";
|
"`Destination_Airport`) VALUES ("+pathID+", \""+sourceAirport+"\", \""+destAirport+"\" )";
|
||||||
stmt.execute(insertPathQuery);
|
stmt.execute(insertPathQuery);
|
||||||
} catch (Exception e){
|
|
||||||
System.err.println( e.getClass().getName() + ": " + e.getMessage() );
|
|
||||||
System.exit(0);
|
|
||||||
}
|
|
||||||
newPath.setID(pathID);
|
newPath.setID(pathID);
|
||||||
|
|
||||||
flightPathDictionary.put(pathID, newPath);
|
flightPathDictionary.put(pathID, newPath);
|
||||||
flightPaths.add(newPath);
|
flightPaths.add(newPath);
|
||||||
FlightPoint sourcePoint = new FlightPoint(sourceAirport, pathID);
|
FlightPoint sourcePoint = new FlightPoint(sourceAirport, pathID);
|
||||||
FlightPoint destinationPoint = new FlightPoint(destAirport, pathID);
|
FlightPoint destinationPoint = new FlightPoint(destAirport, pathID);
|
||||||
try{
|
|
||||||
addFlightPointToPath(sourcePoint);
|
addFlightPointToPath(sourcePoint);
|
||||||
addFlightPointToPath(destinationPoint);
|
addFlightPointToPath(destinationPoint);
|
||||||
|
updateFlightPath(newPath);
|
||||||
} catch (DataException e){
|
} catch (DataException e){
|
||||||
System.err.println( e.getClass().getName() + ": " + e.getMessage() );
|
System.err.println( e.getClass().getName() + ": " + e.getMessage() );
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
|
}catch (Exception e){
|
||||||
|
System.err.println( e.getClass().getName() + ": " + e.getMessage() );
|
||||||
|
System.exit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2047,13 +2048,10 @@ public class Dataset {
|
|||||||
Class.forName("org.sqlite.JDBC");
|
Class.forName("org.sqlite.JDBC");
|
||||||
c = DriverManager.getConnection("jdbc:sqlite:res/userdb.db");
|
c = DriverManager.getConnection("jdbc:sqlite:res/userdb.db");
|
||||||
stmt = c.createStatement();
|
stmt = c.createStatement();
|
||||||
String querySource = "UPDATE `"+this.name+"_Flight_Path` SET `Source_Airport` = \""+startPoint.getName().replace("\"", "\"\"")+"\" " +
|
String query= "UPDATE `"+this.name+"_Flight_Path` SET `Source_Airport` = \""+startPoint.getName().replace("\"", "\"\"")+"\", " +
|
||||||
|
"`Destination_Airport` = \""+endPoint.getName().replace("\"", "\"\"") + "\" " +
|
||||||
"WHERE `Path_ID` = "+startPoint.getIndex();
|
"WHERE `Path_ID` = "+startPoint.getIndex();
|
||||||
stmt.execute(querySource);
|
stmt.execute(query);
|
||||||
stmt = c.createStatement();
|
|
||||||
String queryDest = "UPDATE `"+this.name+"_Flight_Path` SET `Destination_Airport` = \""+endPoint.getName().replace("\"", "\"\"")+"\" " +
|
|
||||||
"WHERE `Path_ID` = "+endPoint.getIndex();
|
|
||||||
stmt.execute(queryDest);
|
|
||||||
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() );
|
||||||
@@ -2089,30 +2087,7 @@ public class Dataset {
|
|||||||
stmt.execute(updatePointOrderQuery);
|
stmt.execute(updatePointOrderQuery);
|
||||||
}
|
}
|
||||||
stmt.close();
|
stmt.close();
|
||||||
|
updateFlightPath(flightPath);
|
||||||
if (index == 0 || curIndex == 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 || curIndex == 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() );
|
||||||
|
|||||||
Reference in New Issue
Block a user