Merge branch 'unitTests'

This commit is contained in:
YaFedImYaEatIm
2016-09-19 06:11:41 +12:00
32 changed files with 35762 additions and 162 deletions
@@ -12,6 +12,10 @@ public class AirlineFilter extends Filter{
private ArrayList<Airline> baseArray;
private ArrayList<Airline> filteredList;
/**
* Constructor of the class sets the base array that will be used for filtering
* @param baseList
*/
public AirlineFilter(ArrayList<Airline> baseList){
filteredList = new ArrayList<Airline>();
baseArray = new ArrayList<Airline>();
@@ -21,6 +25,10 @@ public class AirlineFilter extends Filter{
}
}
/**
* filters the list base by name case insensitive.
* @param name
*/
public void filterName(String name){
String regexCode = "(?i).*"+name+".*";
int index = 0;
@@ -33,6 +41,10 @@ public class AirlineFilter extends Filter{
}
}
/**
* filters list based on alias case insensitive.
* @param alias
*/
public void filterAlias(String alias){
String regexCode = "(?i).*"+alias+".*";
int index = 0;
@@ -45,6 +57,10 @@ public class AirlineFilter extends Filter{
}
}
/**
* Filters the list based on IATA code Case Insensitive.
* @param IATA
*/
public void filterIATA(String IATA){
String regexCode = "(?i).*"+IATA+".*";
int index = 0;
@@ -57,6 +73,10 @@ public class AirlineFilter extends Filter{
}
}
/**
* Filters the list based on ICAO code Case Insensitive.
* @param ICAO
*/
public void filterICAO(String ICAO){
String regexCode = "(?i).*"+ICAO+".*";
int index = 0;
@@ -69,6 +89,10 @@ public class AirlineFilter extends Filter{
}
}
/**
* FIlters the list based on Callsign case Insensitive.
* @param callsign
*/
public void filterCallsign(String callsign){
String regexCode = "(?i).*"+callsign+".*";
int index = 0;
@@ -81,6 +105,10 @@ public class AirlineFilter extends Filter{
}
}
/**
* Filters the list based on the country case insensitive.
* @param country
*/
public void filterCountry(String country){
String regexCode = "(?i).*"+country+".*";
int index = 0;
@@ -93,6 +121,10 @@ public class AirlineFilter extends Filter{
}
}
/**
* Filters the list by activity.
* @param active
*/
public void filterActive(String active){
String regexCode = "(?i).*"+active+".*";
int index = 0;
@@ -105,6 +137,9 @@ public class AirlineFilter extends Filter{
}
}
/**
* resets the filtered list back to the original list.
*/
public void reset() {
filteredList = new ArrayList<Airline>();
for (Airline airline: filteredList){
@@ -112,10 +147,18 @@ public class AirlineFilter extends Filter{
}
}
/**
* gets the filtered list.
* @return
*/
public ArrayList getFilteredData() {
return filteredList;
}
/**
* sets a new base list of the filter.
* @param arrayList
*/
public void setBaseList(ArrayList<Airline> arrayList) {
baseArray = new ArrayList<Airline>();
for (Airline airline: arrayList){
@@ -123,6 +166,9 @@ public class AirlineFilter extends Filter{
}
}
/**
* prints the filter to the console.
*/
public void printFilter(){
for (Airline airline: filteredList){
System.out.println(airline);
@@ -25,9 +25,9 @@ public class App extends Application
private ArrayList<Dataset> datasets = new ArrayList<Dataset>();
private Dataset currentDataset = null;
private Stage primaryStage = null;
private VBox mainContainer;
private Session session;
private MenuController menuController;
private VBox mainContainer = null;
private Session session = null;
private MenuController menuController = null;
public static void main( String[] args )
{
@@ -65,60 +65,11 @@ public class App extends Application
//testing out dataset
try {
currentDataset = new Dataset("test's", Dataset.getExisting);
datasets.add(currentDataset);
}catch (DataException e){
e.printStackTrace();
}
/*
AirlineFilter filter = new AirlineFilter(currentDataset.getAirlines());
filter.filterName("NZ");
filter.filterAlias("flight");
filter.printFilter();
//testout single route adding
try {
currentDataset.addRoute("D2", "MAC", "WIN", "Y", "0", "NOW");
}catch (DataException e){
e.printStackTrace();
}
//testout single airport adding
try {
currentDataset.addAirport("Windows 10", "PC", "Windows", "WIN", "WIND", "0.0", "0.0", "0.0", "0.0", "U", "PC/Windows");
}catch (DataException e){
e.printStackTrace();
}
//testout single airline adding
try {
currentDataset.addAirline("Dota2", "Valve", "D2", "DOT", "Defence of the Ancients", "Steam", "Y");
}catch (DataException e){
e.printStackTrace();
}
//testing out airport parser
try {
System.out.println(currentDataset.importAirport("res/Samples/Airports.txt"));
} catch (DataException e) {
e.printStackTrace();
}
//testing out airline parser
try{
System.out.println(currentDataset.importAirline("res/Samples/Airlines.txt"));
} catch (DataException e){
e.printStackTrace();
}
//testing out route parser
try {
System.out.println(currentDataset.importRoute("res/Samples/Routes.txt"));
} catch (DataException e) {
e.printStackTrace();
}
//testing out flight parser
try {
System.out.println(currentDataset.importFlight("res/Samples/NZCH-WSSS.csv"));
} catch (DataException e) {
e.printStackTrace();
}*/
//after all loading then load the previous session
try{
FileInputStream fileIn = new FileInputStream("res/session.ser");
@@ -189,8 +140,25 @@ public class App extends Application
return currentDataset;
}
public void createDataset(String datasetName) throws DataException{
Dataset newDataset = new Dataset(datasetName, Dataset.createNew);
datasets.add(newDataset);
currentDataset = newDataset;
}
public ArrayList<Dataset> getDatasets() {
return datasets;
}
public void deleteDataset(Dataset dataset){
dataset.deleteDataset();
datasets.remove(dataset);
if (dataset == currentDataset){
if (datasets.size() > 0){
currentDataset = datasets.get(0);
}else{
currentDataset = null;
}
}
}
}
@@ -709,6 +709,7 @@ public class Dataset {
insertFlightPointQuery += "(" + flightPathId +", \""+ flightName +"\", \"" + flightType + "\", "+ flightAltitude + ", " +
"" + flightLatitude + ", " + flightLongitude + ")";
flightPointsToImport.get(i).setID(nextID);
flightPointsToImport.get(i).setIndexID(flightPathId);
//add data to dataset array.
//this is placed after incase the database messes up
flightPathToAdd.addFlightPoint(flightPointsToImport.get(i));
@@ -739,11 +740,23 @@ public class Dataset {
public void createDataLinks(){
//this may be seperated into more sepearate function in the future for time optimisation
HashMap<String, Airline> airlineByIATA= new HashMap<String, Airline>();
for (Country country: countries){
country.setAirlines(new ArrayList<Airline>());
country.setCities(new ArrayList<City>());
}
for (City city: cities){
city.setAirports(new ArrayList<Airport>());
}
//create Airline country link
for (Airline airline: airlines){
airlineByIATA.put(airline.getIATA(), airline);
//System.out.println(airline.getAlias());
airline.setRoutes(new ArrayList<Route>());
airline.setCountry(countryDictionary.get(airline.getCountryName()));
Country country = countryDictionary.get(airline.getCountryName());
if (country != null){
country.addAirline(airline);
}
}
//create Airport City and Country Link
HashMap<String, Airport> airportsByIATA = new HashMap<String, Airport>(); //this is used later for connecting the routes
@@ -757,6 +770,8 @@ public class Dataset {
//TODO Add City in country (This is extra work).
airport.setCity(cityDictionary.get(airport.getCityName()));
airport.getCity().addAirport(airport);
airport.setDepartureRoutes(new ArrayList<Route>());
airport.setArrivalRoutes(new ArrayList<Route>());
}
//set Airport variables for route
for (Route route: routes){
@@ -771,6 +786,10 @@ public class Dataset {
route.setDestinationAirport(airportsByIATA.get(route.getArrivalAirport()));
}
route.setAirline(airlineByIATA.get(route.getAirlineName()));
Airline airline = airlineByIATA.get(route.getAirlineName());
if (airline != null){
airline.addRoutes(route);
}
}
System.out.println("Links Made");
}
@@ -873,7 +892,11 @@ public class Dataset {
}
}
public void addAirport(Airport airportToAdd) throws DataException{
public String getName() {
return name;
}
private void addAirport(Airport airportToAdd) throws DataException{
if (airportToAdd.getIATA_FFA().length() != 0 && airportToAdd.getIATA_FFA().length() != 3){
throw new DataException("IATA/FFA either empty or 3 letters");
}
@@ -907,6 +930,7 @@ public class Dataset {
ResultSet airportIDRes= stmt.executeQuery(airportIDQuery);
int airportID = 0;
while (airportIDRes.next()){
airportID = Integer.parseInt(airportIDRes.getString("seq"));
}
airportToAdd.setID(airportID);
@@ -1040,7 +1064,7 @@ public class Dataset {
routeToAdd.setID(routeID);
routes.add(routeToAdd);
//routeAirline + routeSourceAirport + routeArrvAirport + routeCodeShare + routeStops + routeEquip
String routeKey = routeToAdd.getAirline() + routeToAdd.getDepartureAirport() + routeToAdd.getArrivalAirport() + routeToAdd.getCode() + routeToAdd.getStops() + routeToAdd.getEquipment();
String routeKey = routeToAdd.getAirlineName() + routeToAdd.getDepartureAirport() + routeToAdd.getArrivalAirport() + routeToAdd.getCode() + routeToAdd.getStops() + routeToAdd.getEquipment();
routeDictionary.put(routeKey, routeToAdd);
stmt.close();
c.close();
@@ -1100,7 +1124,7 @@ public class Dataset {
* @param totDist
*/
public void addFlightPointToPath(int id, String name, String type, String via, String altitude, String latitude, String longitude,
String heading, String legDist, String totDist) throws DataException{
String heading, String legDist, String totDist , int index) throws DataException{
double altitudeVal = 0.0;
double latitudeVal = 0.0;
double longitudeVal = 0.0;
@@ -1171,9 +1195,24 @@ public class Dataset {
FlightPoint pointToAdd = new FlightPoint(name, pointID+1, id, type, via, headingVal, altitudeVal, legDistVal,
totalDistVal,latitudeVal, longitudeVal);
flightPathDictionary.get(id).addFlightPoint(pointToAdd);
flightPathDictionary.get(Integer.valueOf(id)).addFlightPoint(pointToAdd, index);
}
public void addFlightPointToPath(FlightPoint point, int index) throws DataException{
addFlightPointToPath(point.getIndex(), point.getName(), point.getType(), point.getVia(), String.valueOf(point.getAltitude()),
String.valueOf( point.getLatitude()),String.valueOf(point.getLongitude()),
String.valueOf(point.getHeading()), String.valueOf(point.getLegDistance()), String.valueOf(point.getTotalDistance()), index);
}
public void addFlightPointToPath(FlightPoint point) throws DataException{
addFlightPointToPath(point.getIndex(), point.getName(), point.getType(), point.getVia(), String.valueOf(point.getAltitude()),
String.valueOf( point.getLatitude()),String.valueOf(point.getLongitude()),
String.valueOf(point.getHeading()), String.valueOf(point.getLegDistance()), String.valueOf(point.getTotalDistance()), -1);
}
public void addFlightPointToPath(int id, String name, String type, String via, String altitude, String latitude, String longitude,
String heading, String legDist, String totDist) throws DataException{
addFlightPointToPath(id, name, type, via, altitude, latitude, longitude, heading, legDist, totDist, -1);
}
/**
* This is called in conjunction to the App deleteDataset DO NOT CALL UNLESS THROUGH APP.DELETEDATASET
@@ -1259,6 +1298,8 @@ public class Dataset {
//System.exit(0);
}
airlines.remove(airline);
airlineDictionary.remove(airline.getName());
createDataLinks();
}
public void deleteAirline(int index){
@@ -1307,6 +1348,8 @@ public class Dataset {
String deleteCountry = "DELETE FROM `"+this.name+"_Country` WHERE `Country_Name` = \""+airport.getCountry().getName()+"\"";
stmt.execute(deleteCountry);
stmt.close();
countries.remove(countryDictionary.get(airport.getCountryName()));
countryDictionary.remove(airport.getCountryName());
}
//cehck if number cities that contain airports > 0 else delete the city
String countCity = "SELECT COUNT(*) FROM `"+this.name+"_Airport` JOIN `"+this.name+"_City` ON" +
@@ -1325,6 +1368,8 @@ public class Dataset {
String deleteCity = "DELETE FROM `"+this.name+"_City` WHERE `City_Name` = \""+airport.getCityName()+"\"";
stmt.execute(deleteCity);
stmt.close();
cities.remove(cityDictionary.get(airport.getCityName()));
cityDictionary.remove(airport.getCityName());
}
c.close();
} catch ( Exception e ) {
@@ -1332,6 +1377,8 @@ public class Dataset {
System.exit(0);
}
airports.remove(airport);
airportDictionary.remove(airport.getName());
createDataLinks();
}
public void deleteAirport(int index){
@@ -1357,6 +1404,10 @@ public class Dataset {
System.exit(0);
}
routes.remove(route);
//routeAirline + routeSourceAirport + routeArrvAirport + routeCodeShare + routeStops + routeEquip
String key = route.getAirlineName() + route.getDepartureAirport() + route.getArrivalAirport() + route.getCode() + route.getStops() + route.getEquipment();
routeDictionary.remove(key);
createDataLinks();
}
public void deleteRoute(int index){
@@ -1386,6 +1437,11 @@ public class Dataset {
System.exit(0);
}
flightPaths.remove(flightPath);
try {
flightPathDictionary.remove(flightPath.getID());
} catch (DataException e) {
e.printStackTrace();
}
}
public void deleteFlightPath(int index){
@@ -1415,7 +1471,7 @@ public class Dataset {
}
public void deleteFlightPoint(int pathIndex, int pointIndex){
deleteFlightPoint(flightPaths.get(pathIndex).getFlightPoints().get(pointIndex), flightPaths.get(pathIndex));
deleteFlightPoint(flightPathDictionary.get(pathIndex).getFlightPoints().get(pointIndex), flightPathDictionary.get(pathIndex));
}
public ArrayList<Airline> getAirlines() {
@@ -2,6 +2,7 @@ package seng202.group9.Core;
import seng202.group9.Controller.DataException;
import javax.xml.crypto.Data;
import java.util.ArrayList;
/**
@@ -251,8 +252,12 @@ public class Airline{
* deletes a route by matching index keep in mind that the array position will change for all indexs after this.
* @param index
*/
public void delRoutes(int index){
routes.remove(index);
public void delRoutes(int index) throws DataException{
if (routes.size() > index && index >= 0) {
routes.remove(index);
}else{
throw new DataException("The Route at index "+index+ "does not exist to be deleted.");
}
}
/**
@@ -264,7 +269,7 @@ public class Airline{
if (this.name.equals(airline.getName())){
throw new DataException("This Airline Name already Exists, Please Choose Another.");
}
if (this.name.equals("")){
if (airline.getName().equals("")){
throw new DataException("This Airline Name cannot be Empty");
}
if (!this.IATA.equals("") && this.IATA.equals(airline.getIATA())){
+37 -8
View File
@@ -2,6 +2,7 @@ package seng202.group9.Core;
import java.util.ArrayList;
import javafx.scene.chart.PieChart;
import seng202.group9.Controller.DataException;
/**
* Airport Class
@@ -363,8 +364,31 @@ public class Airport {
* deletes a member of arrival routes by index
* @param index
*/
public void delArrivalRoutes(int index){
arrivalRoutes.remove(index);
public void delArrivalRoutes(int index) throws DataException{
if (arrivalRoutes.size() > index && index >= 0) {
arrivalRoutes.remove(index);
}else{
throw new DataException("Index "+index+" of number of Arrival Routes array size.");
}
}
/**
* deletes a member of departure routes by matching route pointer
* @param route
*/
public void delDepartureRoutes(Route route){
departureRoutes.remove(route);
}
/**
* deletes a member of departure routes by index
* @param index
*/
public void delDepartureRoutes(int index) throws DataException{
if (departureRoutes.size() > index && index >= 0) {
departureRoutes.remove(index);
}else{
throw new DataException("Index "+index+" is out of number of Departure Routes array size.");
}
}
/**
@@ -376,8 +400,10 @@ public class Airport {
double distance = 0;
double dLong = this.longitude - airport.getLongitude();
double dLat = this.latitude - airport.getLatitude();
double a = Math.pow((Math.sin(dLat/2)), 2) + Math.cos(this.latitude) * Math.cos(airport.getLatitude()) * Math.pow(Math.sin(dLong/2), 2);
double c = a * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
dLong = Math.toRadians(dLong);
dLat = Math.toRadians(dLat);
double a = Math.pow((Math.sin(dLat/2)), 2) + Math.cos(Math.toRadians(this.latitude)) * Math.cos(Math.toRadians(airport.getLatitude())) * Math.pow(Math.sin(dLong/2), 2);
double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
distance = 6371 * c;
return distance;
}
@@ -388,13 +414,16 @@ public class Airport {
* @throws DataException
*/
public void hasDuplicate(Airport airport) throws DataException{
if (airport.getName().equals("") || airport.getName().equals(this.name)){
if (airport.getName().equals(this.name)){
throw new DataException("Airport Name already Exists, Please Choose Another.");
}
if (!airport.getIATA_FFA().equals("") && airport.getIATA_FFA().equals(this.name)){
if (airport.getName().equals("")){
throw new DataException("Airport name cannot be Empty. Please Choose Another.");
}
if (!airport.getIATA_FFA().equals("") && airport.getIATA_FFA().equals(this.IATA_FFA)){
throw new DataException("Airport IATA/FFA already Exists, Please Choose Another.");
}
if (!airport.getICAO().equals("") && airport.getICAO().equals(this.name)){
if (!airport.getICAO().equals("") && airport.getICAO().equals(this.ICAO)){
throw new DataException("Airport ICAO already Exists, Please Choose Another.");
}
}
@@ -403,7 +432,7 @@ public class Airport {
*/
@Override
public String toString(){
return this.cityName +" Airport has ICAO: "+this.ICAO+", IATA/FFA: "+this.IATA_FFA+" and is located at ("+this.latitude+", "+this.longitude
return this.name +" Airport has ICAO: "+this.ICAO+", IATA/FFA: "+this.IATA_FFA+" and is located at ("+this.latitude+", "+this.longitude
+ ").\n It has "+this.departureRoutes.size()+" departing routes and "+this.arrivalRoutes.size()+" arriving routes.";
}
}
+8 -2
View File
@@ -1,5 +1,7 @@
package seng202.group9.Core;
import seng202.group9.Controller.DataException;
import java.util.ArrayList;
public class City {
@@ -137,8 +139,12 @@ public class City {
* Deletes an Airport by Index from this City.
* @param index
*/
public void delAirport(int index) {
airports.remove(index);
public void delAirport(int index) throws DataException{
if (airports.size() > index && index >= 0) {
airports.remove(index);
}else{
throw new DataException("Index "+index+" is out of number of City Airports array size.");
}
}
@Override
public String toString(){
+31 -6
View File
@@ -1,11 +1,16 @@
package seng202.group9.Core;
import seng202.group9.Controller.DataException;
import java.util.ArrayList;
import java.util.HashMap;
public class Country {
private String DST, name;
private ArrayList<City> cities = new ArrayList<City>();
private ArrayList<Airline> airlines = new ArrayList<Airline>();
private HashMap<String, Airline> airlineDict = new HashMap<String, Airline>();
private HashMap<String, City> cityDict = new HashMap<String, City>();
private Position position;
/**
@@ -40,8 +45,10 @@ public class Country {
*/
public void setAirlines(ArrayList<Airline> airlines) {
this.airlines = new ArrayList<Airline>();
this.airlineDict = new HashMap<String, Airline>();
for (int i = 0; i < airlines.size(); i ++) {
this.airlines.add(airlines.get(i));
airlineDict.put(airlines.get(i).getName(), airlines.get(i));
}
}
@@ -74,7 +81,10 @@ public class Country {
* @param airline
*/
public void addAirline(Airline airline){
this.airlines.add(airline);
if (!airlineDict.containsKey(airline.getName())) {
this.airlines.add(airline);
airlineDict.put(airline.getName(), airline);
}
}
/**
@@ -93,14 +103,20 @@ public class Country {
*/
public void delAirline(Airline airline){
airlines.remove(airline);
airlineDict.remove(airline.getName());
}
/**
* deletes an Airline in this country.
* @param index
*/
public void delAirline(int index){
airlines.remove(index);
public void delAirline(int index) throws DataException{
if (airlines.size() > index && index >= 0) {
airlineDict.remove(airlines.get(index).getName());
airlines.remove(index);
}else{
throw new DataException("Index " + index + " does not exist in list of Airlines in this Country.");
}
}
/**
@@ -109,8 +125,10 @@ public class Country {
*/
public void setCities(ArrayList<City> cities){
this.cities = new ArrayList<City>();
this.cityDict = new HashMap<String, City>();
for (int i = 0; i < cities.size(); i++){
this.cities.add(cities.get(i));
cityDict.put(cities.get(i).getName(), cities.get(i));
}
}
@@ -119,7 +137,10 @@ public class Country {
* @param city
*/
public void addCities(City city){
this.cities.add(city);
if (!cityDict.containsKey(city.getName())) {
this.cities.add(city);
cityDict.put(city.getName(), city);
}
}
/**
@@ -144,8 +165,12 @@ public class Country {
* Deletes Cities in this Country
* @param index
*/
public void delCities(int index){
this.cities.remove(index);
public void delCities(int index) throws DataException{
if (cities.size() > index && index >= 0) {
this.cities.remove(index);
}else{
throw new DataException("City at Index "+ index + " does not exist.");
}
}
/**
@@ -1,5 +1,7 @@
package seng202.group9.Core;
import seng202.group9.Controller.DataException;
import java.util.ArrayList;
public class FlightPath {
@@ -49,7 +51,7 @@ public class FlightPath {
public void setFlightPoints(ArrayList<FlightPoint> flightPoints) {
this.flightPoints = new ArrayList<FlightPoint>();
for (int i = 0; i < flightPoints.size(); i ++) {
this.flightPoints = flightPoints;
this.flightPoints.add(flightPoints.get(i));
}
}
@@ -82,7 +84,10 @@ public class FlightPath {
* gets the ID of the Flight Path.
* @return
*/
public int getID(){
public int getID() throws DataException{
if (ID == -1){
throw new DataException("This Flight Path has no ID set yet");
}
return ID;
}
@@ -125,7 +130,11 @@ public class FlightPath {
* @param index
*/
public void addFlightPoint(FlightPoint flightPoint, int index){
flightPoints.add(index, flightPoint);
if (index >= flightPoints.size() || index < 0){
flightPoints.add(flightPoint);
}else {
flightPoints.add(index, flightPoint);
}
}
/**
@@ -140,8 +149,12 @@ public class FlightPath {
* delets a point from the flight at a specific index.
* @param index
*/
public void delFlightPoint(int index){
flightPoints.remove(index);
public void delFlightPoint(int index) throws DataException{
if (flightPoints.size() > index && index >= 0) {
flightPoints.remove(index);
}else{
throw new DataException("Flight Point at Index " + index + " does not exist for this flight Path.");
}
}
/**
@@ -197,7 +197,10 @@ public class FlightPoint {
* gets the Path Index ID at this point.
* @return
*/
public int getIndex(){
public int getIndex() throws DataException{
if (indexID == -1){
throw new DataException("Index ID is not set.");
}
return indexID;
}
@@ -268,6 +268,9 @@ public class Route {
* @return
*/
public RoutePath getRoutePath(){
if (getSourceAirport() == null || getDestinationAirport() == null){
return new RoutePath();
}
if (routePath == null) {
routePath = new RoutePath(
new Position(getSourceAirport().getLatitude(), getSourceAirport().getLongitude()),
@@ -9,6 +9,7 @@ import javafx.scene.control.*;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.input.MouseEvent;
import seng202.group9.Controller.App;
import seng202.group9.Controller.DataException;
import seng202.group9.Controller.Dataset;
import seng202.group9.Core.FlightPath;
import seng202.group9.Core.FlightPoint;
@@ -121,7 +122,11 @@ public class FlightRDController extends Controller {
*/
public void load() {
theDataSet = getParent().getCurrentDataset();
currentPathId = theDataSet.getFlightPaths().get(0).getID(); //Sets the default to the 1st Path
try {
currentPathId = theDataSet.getFlightPaths().get(0).getID(); //Sets the default to the 1st Path
} catch (DataException e) {
e.printStackTrace();
}
flightIdCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("ID"));
flightNameCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Name"));
flightTypeCol.setCellValueFactory(new PropertyValueFactory<FlightPoint, String>("Type"));
@@ -199,7 +204,14 @@ public class FlightRDController extends Controller {
*/
public void deletePoint() {
FlightPoint toDelete = flightTableView.getSelectionModel().getSelectedItem();
int pathID = toDelete.getIndex();
int pathID = 0;
try {
pathID = toDelete.getIndex();
} catch (DataException e) {
e.printStackTrace();
System.out.println("Point is Undeletable as the Index ID is not set.");
return;
}
LinkedHashMap<Integer, FlightPath> flightPathDict = theDataSet.getFlightPathDictionary();
FlightPath toDeletesPath = flightPathDict.get(pathID);
theDataSet.deleteFlightPoint(toDelete, toDeletesPath);