From 83ccf04d85cf5ee6cd0607747a36017ecb201d27 Mon Sep 17 00:00:00 2001 From: Liam Beckett Date: Tue, 13 Sep 2016 13:23:44 +1200 Subject: [PATCH 1/4] Implemented the GUI to open for the Flight Data Summary page however was unable to get it to open in the same stage so it opens in a new window. This is something to address later. --- .../seng202/group9/GUI/MenuController.java | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/main/java/seng202/group9/GUI/MenuController.java b/src/main/java/seng202/group9/GUI/MenuController.java index 2d8037e..320ff5e 100644 --- a/src/main/java/seng202/group9/GUI/MenuController.java +++ b/src/main/java/seng202/group9/GUI/MenuController.java @@ -5,10 +5,16 @@ import java.util.ResourceBundle; import javax.swing.JOptionPane; +import javafx.fxml.FXML; import javafx.fxml.Initializable; +import javafx.scene.Scene; +import javafx.scene.layout.BorderPane; + +import javafx.stage.Stage; +import seng202.group9.Controller.App; public class MenuController implements Initializable{ - + public void importAirports(){ JOptionPane.showMessageDialog(null, "This is not Implemented yet"); } @@ -25,6 +31,23 @@ public class MenuController implements Initializable{ JOptionPane.showMessageDialog(null, "This is not Implemented yet"); } + @FXML + public void viewFlightSummary() { + + Stage stage = new Stage(); + BorderPane root = new BorderPane(); //root panel + Scene scene = new Scene(root); + //create the Flight summary page + FlightDataSummary flightSummPage = new FlightDataSummary(); + root.setTop(flightSummPage.getFlightSummary()); + stage.setScene(scene); + stage.show(); + //seng202.group9.Controller.App.primaryStage.setScene(scene); + //System.out.println("GOT HERE"); + //seng202.group9.Controller.App.primaryStage.show(); + } + + public void initialize(URL arg0, ResourceBundle arg1) { // TODO Auto-generated method stub From b7674fc8ea69969d7adf5f6c724f15ab1bcec990 Mon Sep 17 00:00:00 2001 From: Liam Beckett Date: Tue, 13 Sep 2016 13:46:25 +1200 Subject: [PATCH 2/4] Added in the Raw Flight Data page which now appears as a new window something again we will need to fix, have updated the menu.fxml document to include the tags for the two menu buttons for flight. Have realized that I will have to rework the GUI so that it scales better. --- .../java/seng202/group9/GUI/MenuController.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/java/seng202/group9/GUI/MenuController.java b/src/main/java/seng202/group9/GUI/MenuController.java index 320ff5e..b5e1e8a 100644 --- a/src/main/java/seng202/group9/GUI/MenuController.java +++ b/src/main/java/seng202/group9/GUI/MenuController.java @@ -31,7 +31,6 @@ public class MenuController implements Initializable{ JOptionPane.showMessageDialog(null, "This is not Implemented yet"); } - @FXML public void viewFlightSummary() { Stage stage = new Stage(); @@ -43,7 +42,20 @@ public class MenuController implements Initializable{ stage.setScene(scene); stage.show(); //seng202.group9.Controller.App.primaryStage.setScene(scene); - //System.out.println("GOT HERE"); + //seng202.group9.Controller.App.primaryStage.show(); + } + + public void viewFlightRawData() { + + Stage stage = new Stage(); + BorderPane root = new BorderPane(); //root panel + Scene scene = new Scene(root); + //create the Flight summary page + FlightRawData flightRawDataPage = new FlightRawData(); + root.setTop(flightRawDataPage.getFlightRawData()); + stage.setScene(scene); + stage.show(); + //seng202.group9.Controller.App.primaryStage.setScene(scene); //seng202.group9.Controller.App.primaryStage.show(); } From a46609b0b259eae22bfe444879cd32de343912cb Mon Sep 17 00:00:00 2001 From: Liam Beckett Date: Tue, 13 Sep 2016 16:24:43 +1200 Subject: [PATCH 3/4] Begun work on the flight data parser, committing changes and merging in order to add another feature. --- .../seng202/group9/Controller/Dataset.java | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/src/main/java/seng202/group9/Controller/Dataset.java b/src/main/java/seng202/group9/Controller/Dataset.java index 9847b2b..3e93c9b 100644 --- a/src/main/java/seng202/group9/Controller/Dataset.java +++ b/src/main/java/seng202/group9/Controller/Dataset.java @@ -629,9 +629,90 @@ public class Dataset { createDataLinks(); return message; } + + /** + * Imports Airline files to dataset + * @param filePath + * @return Success Message + * @throws DataException + */ + + /* + public String importFlight(String filePath) throws DataException { + FlightPathParser parser = new FlightPathParser(filePath); + //remember this still has to append the duplicate message to it. + //routes are identified in the diction by routeAirline + routeSourceAirport + routeArrvAirport + routeCodeShare + routeStops + routeEquip; + String message = parser.parse(); + ArrayList flightsToImport = parser.getResult(); + //check for dup + int numOfDuplicates = 0; + int nextID = -1; + //query database. + Connection c = null; + Statement stmt = null; + try { + Class.forName("org.sqlite.JDBC"); + c = DriverManager.getConnection("jdbc:sqlite:res/userdb.db"); + stmt = c.createStatement(); + String queryName = this.name.replace("'", "''").replace("\"", "\"\""); + String IDQuery = "SELECT * FROM `sqlite_sequence` WHERE `name` = '"+queryName+"_Routes' LIMIT 1;"; + ResultSet IDResult = stmt.executeQuery(IDQuery); + while(IDResult.next()){ + nextID = Integer.parseInt(IDResult.getString("seq")) + 1;//for some reason sqlite3 stores incremental values as a string... + } + stmt.close(); + stmt = c.createStatement(); + String insertFlightQuery = "INSERT INTO `" + this.name + "_Routes` (`Airline`, `Source_Airport`, `Destination_Airport`," + + " `Codeshare`, `Stops`, `Equipment`) VALUES "; + int numOfRoutes = 0; + for (int i = 0; i < flightsToImport.size(); i ++){ + String routeIdentifier = flightsToImport.get(i).getType() + flightsToImport.get(i).getID() + + flightsToImport.get(i).getAltitude() + flightsToImport.get(i).getLatitude() + + flightsToImport.get(i).getLongitude(); + //if (routeDictionary.containsKey(routeIdentifier)){ + // numOfDuplicates ++; + //}else{ + //route variables + String flightType = flightsToImport.get(i).getType().replace("\"", "\"\""); + String flightID = flightsToImport.get(i).getID().replace("\"", "\"\""); + double flightAltitude = flightsToImport.get(i).getAltitude(); + double flightLatitude = flightsToImport.get(i).getLatitude(); + double flightLongitude = flightsToImport.get(i).getLongitude(); + //insert import into database + if (numOfRoutes > 0){ + insertFlightQuery += ","; + } + insertFlightQuery += "(\""+flightType+"\", \"" + flightID + "\", \"" + flightAltitude + "\", " + + "\"" + flightLatitude + "\", " + flightLongitude + "\")"; + flightsToImport.get(i).setID(nextID); + //add data to dataset array. + //this is placed after incase the database messes up + flights.add(flightsToImport.get(i)); + routeDictionary.put(routeIdentifier, flightsToImport.get(i)); + nextID++; + numOfRoutes++; + //} + } + if (numOfRoutes > 0){ + stmt.execute(insertRouteQuery); + stmt.close(); + } + } catch ( Exception e ) { + System.err.println( e.getClass().getName() + ": " + e.getMessage() ); + System.exit(0); + } + message += "\nDuplicates ommitted: "+numOfDuplicates; + createDataLinks(); + return message; + } + /* + + + */ /** * This function updates the connections between airports citys countries etc. */ + public void createDataLinks(){ } From 3e5b793cb2e62f0ff386b1c2370fcb10f8840f8e Mon Sep 17 00:00:00 2001 From: Liam Beckett Date: Tue, 13 Sep 2016 16:39:22 +1200 Subject: [PATCH 4/4] Trying to fix the merge conflict --- src/main/java/seng202/group9/Controller/Dataset.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/seng202/group9/Controller/Dataset.java b/src/main/java/seng202/group9/Controller/Dataset.java index 3e93c9b..19c4056 100644 --- a/src/main/java/seng202/group9/Controller/Dataset.java +++ b/src/main/java/seng202/group9/Controller/Dataset.java @@ -707,7 +707,7 @@ public class Dataset { } /* - + */ /** * This function updates the connections between airports citys countries etc.