YaFedImYaEatIm 9 years ago
commit 618afd4a92

Binary file not shown.

@ -1,6 +1,7 @@
package seng202.group9.Controller;
import javafx.scene.chart.PieChart;
import seng202.group9.Core.*;
import java.sql.Connection;
@ -787,6 +788,15 @@ public class Dataset {
*/
public void addAirline(String name, String alias, String IATA, String ICAO, String callsign, String country, String active) throws DataException{
Airline airlineToAdd = new Airline(name, alias, IATA, ICAO, callsign, country, active);
if (name.equals("")) {
throw new DataException("You cannot have a blank airline name.");
}
if (alias.length() <= 0) {
throw new DataException("Please insert '\\N' if the airline has no alias.");
}
if (country.equals("")) {
throw new DataException("You cannot have a blank country of origin field.");
}
addAirline(airlineToAdd);
}
@ -828,6 +838,8 @@ public class Dataset {
airlineToAdd.setID(airlineID);
airlines.add(airlineToAdd);
airlineDictionary.put(airlineToAdd.getName(), airlineToAdd);
stmt.close();
c.close();
} catch ( Exception e ) {
System.err.println( e.getClass().getName() + ": " + e.getMessage() );
System.exit(0);
@ -838,10 +850,17 @@ public class Dataset {
public void addAirport(String name, String city, String country, String IATA_FFA, String ICAO, String latitude, String longitude,
String altitude, String timezone, String DST, String olsonTz) throws DataException{
try{
//System.out.print(name + city + country + IATA_FFA + ICAO + latitude + longitude + altitude + timezone + DST + olsonTz);
double latitudeVal = Double.parseDouble(latitude);
double longitudeVal = Double.parseDouble(longitude);
double altitudeVal = Double.parseDouble(altitude);
double timezoneVal = Double.parseDouble(timezone);
if (city.equals("")) {
throw new DataException("You cannot have a blank city name.");
}
if (country.equals("")) {
throw new DataException("You cannot have a blank country name.");
}
Airport airportToAdd = new Airport(name, city, country, IATA_FFA, ICAO, latitudeVal, longitudeVal, altitudeVal);
City cityToAdd = new City(city, country, timezoneVal, olsonTz);
Country countryToAdd = new Country(DST, country);
@ -855,14 +874,14 @@ public class Dataset {
}
public void addAirport(Airport airportToAdd) throws DataException{
if (airportToAdd.getIATA_FFA() != "" && airportToAdd.getIATA_FFA().length() != 3){
if (airportToAdd.getIATA_FFA().length() != 0 && airportToAdd.getIATA_FFA().length() != 3){
throw new DataException("IATA/FFA either empty or 3 letters");
}
if (airportToAdd.getICAO() != "" && airportToAdd.getICAO().length() != 4){
if (airportToAdd.getICAO().length() != 0 && airportToAdd.getICAO().length() != 4){
throw new DataException("ICAO either empty or 4 letters");
}
if (airportToAdd.getName() == ""){
throw new DataException("An Airport cannot have no name.");
if (airportToAdd.getName().equals("")) {
throw new DataException("You cannot have an airport without a name.");
}
for (String key : airportDictionary.keySet()){
airportDictionary.get(key).hasDuplicate(airportToAdd);
@ -900,7 +919,6 @@ public class Dataset {
System.err.println( e.getClass().getName() + ": " + e.getMessage() );
System.exit(0);
}
createDataLinks();
}
public void addCity(City city){
@ -1024,6 +1042,8 @@ public class Dataset {
//routeAirline + routeSourceAirport + routeArrvAirport + routeCodeShare + routeStops + routeEquip
String routeKey = routeToAdd.getAirline() + routeToAdd.getDepartureAirport() + routeToAdd.getArrivalAirport() + routeToAdd.getCode() + routeToAdd.getStops() + routeToAdd.getEquipment();
routeDictionary.put(routeKey, routeToAdd);
stmt.close();
c.close();
} catch ( Exception e ) {
System.err.println( e.getClass().getName() + ": " + e.getMessage() );
System.exit(0);
@ -1206,19 +1226,19 @@ public class Dataset {
//check if number of countries that contain airlines > 0 else delete the country
String countCountry = "SELECT COUNT(*) FROM `"+this.name+"_Airline` JOIN `"+this.name+"_Country` ON" +
" `"+this.name+"_Country`.`Country_Name` = `"+this.name+"_Airline`.`Country`" +
" WHERE `"+this.name+"_Airline`.`Country` = \""+airline.getCountry().getName().replace("\"", "\"\"")+"\"";
" WHERE `"+this.name+"_Airline`.`Country` = \""+airline.getCountryName().replace("\"", "\"\"")+"\"";
ResultSet countCountryRes = stmt.executeQuery(countCountry);
int countryCount = 0;
while (countCountryRes.next()){
countryCount += countCountryRes.getInt("COUNT(*)");
while (countCountryRes.next()) {
countryCount += countCountryRes.getInt("COUNT(*)");
}
countCountryRes.close();
stmt.close();
stmt = c.createStatement();
//check if number of counties that contain airports > 0 else delete the country
String countCountryA = "SELECT COUNT(*) FROM `"+this.name+"_Airport` JOIN `"+this.name+"_Country` ON" +
" `"+this.name+"_Country`.`Country_Name` = `"+this.name+"_Airport`.`Country`" +
" WHERE `"+this.name+"_Airport`.`Country` = \""+airline.getCountry().getName().replace("\"", "\"\"")+"\"";
" WHERE `"+this.name+"_Airport`.`Country` = \""+airline.getCountryName().replace("\"", "\"\"")+"\"";
countCountryRes = stmt.executeQuery(countCountryA);
while (countCountryRes.next()){
countryCount += countCountryRes.getInt("COUNT(*)");
@ -1228,12 +1248,13 @@ public class Dataset {
//delete country if there are no matches
if (countryCount == 0){
stmt = c.createStatement();
String deleteCountry = "DELETE FROM `"+this.name+"_Country` WHERE `Country_Name` = \""+airline.getCountry().getName()+"\"";
String deleteCountry = "DELETE FROM `"+this.name+"_Country` WHERE `Country_Name` = \""+airline.getCountryName()+"\"";
stmt.execute(deleteCountry);
stmt.close();
}
c.close();
} catch ( Exception e ) {
e.printStackTrace();
System.err.println( e.getClass().getName() + ": " + e.getMessage() );
//System.exit(0);
}

@ -22,7 +22,7 @@ public class Airline{
private Country country = null;
/**
* Constructor
* Constructor for Airline when pulled from the database.
*
* @param ID
* @param name
@ -45,7 +45,16 @@ public class Airline{
this.routes = new ArrayList<Route>();
}
/**
* Constructor for Airline without ID this will be set later by the dataset from the dataset.
* @param name
* @param alias
* @param IATA
* @param ICAO
* @param callSign
* @param countryName
* @param active
*/
public Airline(String name, String alias, String IATA, String ICAO, String callSign, String countryName, String active){
this.ID = -1;
this.IATA = IATA;
@ -255,6 +264,9 @@ public class Airline{
if (this.name.equals(airline.getName())){
throw new DataException("This Airline Name already Exists, Please Choose Another.");
}
if (this.name.equals("")){
throw new DataException("This Airline Name cannot be Empty");
}
if (!this.IATA.equals("") && this.IATA.equals(airline.getIATA())){
throw new DataException("This IATA Code already Exists, Please Choose Another.");
}
@ -273,7 +285,7 @@ public class Airline{
*/
@Override
public String toString(){
return name;
return name + ", IATA:" + IATA + ", ICAO: " + ICAO;
}
}

@ -89,6 +89,11 @@ public class Airport {
public void setID(int iD) {
this.ID = iD;
}
/**
* Sets the Name of the Airport.
* @param name
*/
public void setName(String name){
this.name = name;
}
@ -148,10 +153,18 @@ public class Airport {
}
}
/**
* gets the country name
* @return
*/
public String getCountryName() {
return countryName;
}
/**
* sets the country name
* @param countryName
*/
public void setCountryName(String countryName) {
this.countryName = countryName;
}
@ -194,13 +207,6 @@ public class Airport {
public String getICAO(){
return ICAO;
}
/**
* gets the IATA/FFA of the airport
* @return IATA/FFA Code
*/
// public String IATA_FFA(){
// return IATA_FFA;
// }
/**
* gets the altitude of the airport
* @return Altitude of Airport
@ -254,7 +260,10 @@ public class Airport {
return country;
}
//JavaDoc needed
/**
* gets the timezone of the Airport
* @return
*/
public Double getTimezone() {
if (this.city != null) {
return this.city.getTimezone();
@ -262,7 +271,11 @@ public class Airport {
return 0.0;
}
}
//JavaDoc needed
/**
* gets the DST of the Country the Airport is in.
* @return
*/
public String getDST() {
if (this.country != null) {
return this.country.getDST();
@ -270,7 +283,11 @@ public class Airport {
return "";
}
}
//JavaDoc needed
/**
* gets the timezone in Olson format of the country the airport is in
* @return
*/
public String getTz() {
if (this.city != null) {
return this.city.getTimeOlson();
@ -364,6 +381,12 @@ public class Airport {
distance = 6371 * c;
return distance;
}
/**
* Checks if the airport is a semi duplicate of this class. Used to see if it passes to enter into the Database.
* @param airport
* @throws DataException
*/
public void hasDuplicate(Airport airport) throws DataException{
if (airport.getName().equals("") || airport.getName().equals(this.name)){
throw new DataException("Airport Name already Exists, Please Choose Another.");
@ -378,7 +401,6 @@ public class Airport {
/**
* Information of the airport returned in String format.
*/
@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

@ -8,7 +8,14 @@ public class City {
private double timezone;
private String timeOlson;
private ArrayList<Airport> airports;
/**
* City Constructor
* @param name
* @param country
* @param timezone
* @param timeOlson
*/
public City(String name, String country, double timezone, String timeOlson){
this.name = name;
this.country = country;
@ -16,23 +23,43 @@ public class City {
this.timeOlson = timeOlson;
this.airports = new ArrayList<Airport>();
}
/**
* Sets Name of the City
* @param name
*/
public void setName(String name) {
this.name = name;
}
/**
* Sets Country that the city is in.
* @param country
*/
public void setCountry(String country){
this.country = country;
}
/**
* Set Timezone that the City is in.
* @param timezone
*/
public void setTimezone(double timezone) {
this.timezone = timezone;
}
/**
* Sets the time olson the city is in.
* @param timeOlson
*/
public void setTimeOlson(String timeOlson) {
this.timeOlson = timeOlson;
}
/**
* Sets the airports the are in the city
* @param airports
*/
public void setAirports(ArrayList<Airport> airports) {
this.airports = new ArrayList<Airport>();
for (int i = 0; i < airports.size(); i ++) {
@ -40,46 +67,81 @@ public class City {
}
}
/**
* Gets the name of the city.
* @return
*/
public String getName(){
return name;
}
/**
* Gets the Country that the city is in.
* @return
*/
public String getCountry(){
return country;
}
/**
* gets the Timezone that the City is in.
* @return
*/
public double getTimezone(){
return timezone;
}
/**
* Gets the Timezone in Olson format the City is in.
* @return
*/
public String getTimeOlson(){
return timeOlson;
}
/**
* gets the Airports that are in this city.
* @return
*/
public ArrayList<Airport> getAirports(){
return airports;
}
/**
* adds an airport that is in this city.
* @param airport
*/
public void addAirport(Airport airport){
airports.add(airport);
}
/**
* adds multiple airports to this city.
* @param airports
*/
public void addAirport(ArrayList<Airport> airports){
for (int i = 0; i < airports.size(); i++){
addAirport(airports.get(i));
}
}
/**
* Deletes an Airport from this City.
* @param airport
*/
public void delAirport(Airport airport){
airports.remove(airport);
}
/**
* Deletes an Airport by Index from this City.
* @param index
*/
public void delAirport(int index) {
airports.remove(index);
}
@Override
public String toString(){
return this.name;
return this.name + " has " + airports.size() + " Airports and is in "+timeOlson;
}
}

@ -7,20 +7,37 @@ public class Country {
private ArrayList<City> cities = new ArrayList<City>();
private ArrayList<Airline> airlines = new ArrayList<Airline>();
private Position position;
/**
* Contructor for Country.
* @param DST
* @param name
*/
public Country(String DST, String name){
this.DST = DST;
this.name = name;
}
/**
* Sets the DST of the country.
* @param dST
*/
public void setDST(String dST) {
DST = dST;
}
/**
* Sets the name of the country.
* @param name
*/
public void setName(String name) {
this.name = name;
}
/**
* Set Airlines that are based in this country.
* @param airlines
*/
public void setAirlines(ArrayList<Airline> airlines) {
this.airlines = new ArrayList<Airline>();
for (int i = 0; i < airlines.size(); i ++) {
@ -28,36 +45,68 @@ public class Country {
}
}
/**
* Gets the DST of the Country.
* @return
*/
public String getDST(){
return this.DST;
}
/**
* Gets the Name of the Country.
* @return
*/
public String getName(){
return this.name;
}
/**
* gets the Airlines that belong in this Country.
* @return
*/
public ArrayList<Airline> getAirlines(){
return airlines;
}
/**
* Adds an Airline that is based in this country.
* @param airline
*/
public void addAirline(Airline airline){
this.airlines.add(airline);
}
/**
* Adds multiple Airlines to this Country.
* @param airlines
*/
public void addAirline(ArrayList<Airline> airlines){
for (int i = 0; i < airlines.size(); i++){
addAirline(airlines.get(i));
}
}
/**
* deletes an Airline based in this country.
* @param airline
*/
public void delAirline(Airline airline){
airlines.remove(airline);
}
/**
* deletes an Airline in this country.
* @param index
*/
public void delAirline(int index){
airlines.remove(index);
}
/**
* sets the cities of this country
* @param cities
*/
public void setCities(ArrayList<City> cities){
this.cities = new ArrayList<City>();
for (int i = 0; i < cities.size(); i++){
@ -65,32 +114,60 @@ public class Country {
}
}
/**
* adds a City to this country.
* @param city
*/
public void addCities(City city){
this.cities.add(city);
}
/**
* Add multiple Cities to this Country.
* @param cities
*/
public void addCities(ArrayList<City> cities){
for (int i = 0; i < cities.size(); i++){
this.cities.add(cities.get(i));
}
}
/**
* Deletes a city for this country.
* @param city
*/
public void delCities(City city){
this.cities.remove(city);
}
/**
* Deletes Cities in this Country
* @param index
*/
public void delCities(int index){
this.cities.remove(index);
}
/**
* Gets the CIties in this Country.
* @return
*/
public ArrayList<City> getCities() {
return cities;
}
/**
* gets the {@link Position}(double Latitude, double Longitude) of this Country.
* @return
*/
public Position getPosition() {
return position;
}
/**
* sets the {@link Position} of the Country.
* @param position
*/
public void setPosition(Position position) {
this.position = position;
}

@ -10,7 +10,7 @@ public class FlightPath {
final private RoutePath routePath = new RoutePath();
/**
*
* Constructor for this FLight Path from database
* @param ID id of the the flight path in the database
* @param departureAirport Iata/FFA of the airport
* @param arrivalAirport IATA/FFA of the airport
@ -22,17 +22,30 @@ public class FlightPath {
this.flightPoints = new ArrayList<FlightPoint>();
}
/**
* COnstructor for FlightPath from dataset add later the ID needs to be set from database.
* @param departureAirport
* @param arrivalAirport
*/
public FlightPath(String departureAirport, String arrivalAirport){
this.ID = -1;
this.departureAirport = departureAirport;
this.arrivalAirport = arrivalAirport;
this.flightPoints = new ArrayList<FlightPoint>();
}
/**
* Gets the {@link FlightPoint} of this flight Path.
* @return
*/
public ArrayList<FlightPoint> getFlightPoints() {
return flightPoints;
}
/**
* Sets the {@link FlightPoint} of this Flight Path.
* @param flightPoints
*/
public void setFlightPoints(ArrayList<FlightPoint> flightPoints) {
this.flightPoints = new ArrayList<FlightPoint>();
for (int i = 0; i < flightPoints.size(); i ++) {
@ -40,56 +53,112 @@ public class FlightPath {
}
}
/**
* Sets the {@link Airport} that the Flight Path leaves from.
* @param departureAirport
*/
public void setDepartureAirport(String departureAirport) {
this.departureAirport = departureAirport;
}
/**
* Sets the {@link Airport} that the Flight Path arrives at.
* @param arrivalAirport
*/
public void setArrivalAirport(String arrivalAirport) {
this.arrivalAirport = arrivalAirport;
}
/**
* Sets the ID that corresponds to the database for this flight path.
* Also the ID that corresponds to {@see FlightPoint} IndexID
* @param iD
*/
public void setID(int iD) {
ID = iD;
}
/**
* gets the ID of the Flight Path.
* @return
*/
public int getID(){
return ID;
}
/**
* gets the {@link Airport} that the FLight Departs from.
* @return
*/
public String departsFrom(){
return departureAirport;
}
/**
* gets the {@link Airport} that the flight arrives at.
* @return
*/
public String arrivesAt(){
return arrivalAirport;
}
/**
* Gets all the Points that the FLight passes
* {@link FlightPoint}
* @return
*/
public ArrayList<FlightPoint> getFlight(){
return flightPoints;
}
/**
* Adds a {@link FlightPoint} to the Flight Path.
* @param flightPoint
*/
public void addFlightPoint(FlightPoint flightPoint){
flightPoints.add(flightPoint);
}
/**
* Adds a {@link FlightPoint} to the Flight Path at a specific point of the flight.
* @param flightPoint
* @param index
*/
public void addFlightPoint(FlightPoint flightPoint, int index){
flightPoints.add(index, flightPoint);
}
/**
* deletes a point from the flight.
* @param flightPoint
*/
public void delFlightPoint(FlightPoint flightPoint){
flightPoints.remove(flightPoint);
}
/**
* delets a point from the flight at a specific index.
* @param index
*/
public void delFlightPoint(int index){
flightPoints.remove(index);
}
/**
* Adds multiple {@link FlightPoint} to the FlightPath.
* @param flightPoints
*/
public void addFlightPoint(ArrayList<FlightPoint> flightPoints){
for (int i = 0; i < flightPoints.size(); i ++){
this.flightPoints.add(flightPoints.get(i));
}
}
/**
* Gets the {@link RoutePath} that the FlightPath traverses.
* Also see {@see seng202.group9.Map.Map}
* @return
*/
public RoutePath getRoutePath(){
if (routePath.getRoute().size() == 0){
for (FlightPoint point: flightPoints){

@ -15,6 +15,14 @@ public class FlightPoint {
private double latitude;
private double longitude;
/**
* Constructor for FLight POint before set by the database.
* @param type
* @param name
* @param altitude
* @param latitude
* @param longitude
*/
public FlightPoint(String type, String name, double altitude, double latitude, double longitude){
//extra calculations will have to be used to find heading, legdistance and total distance. If necessary
//Type 1 file the file the lecturers gave us
@ -33,6 +41,20 @@ public class FlightPoint {
this.longitude = longitude;
}
/**
* Constructor when getting points from the database.
* @param name Name for the point.
* @param ID Unique ID from Database.
* @param indexID FOreighn key for {@link FlightPath}.
* @param type
* @param via
* @param heading
* @param altitude
* @param legDistance
* @param totalDistance
* @param latitude
* @param longitude
*/
public FlightPoint(String name, int ID, int indexID, String type, String via,
int heading, double altitude, double legDistance, double totalDistance,
double latitude, double longitude){
@ -49,6 +71,11 @@ public class FlightPoint {
this.longitude = longitude;
}
/**
* get the Path ID
* @return
* @throws DataException
*/
public int getIndexID() throws DataException {
if (this.ID == -1){
throw new DataException("ID not set.");
@ -57,54 +84,107 @@ public class FlightPoint {
}
}
/**
* sets the Path ID
* @param indexID
*/
public void setIndexID(int indexID) {
this.indexID = indexID;
}
/**
* sets the name of the path.
* @param name
*/
public void setName(String name) {
this.name = name;
}
/**
* sets the Unique Database ID of the Path
* @param iD
*/
public void setID(int iD) {
ID = iD;
}
/**
* Sets the type of the Point.
* @param type
*/
public void setType(String type) {
this.type = type;
}
/**
* set the VIA of the Point.
* @param via
*/
public void setVia(String via) {
this.via = via;
}
/**
* Sets bearing the flight is heading.
* @param heading
*/
public void setHeading(int heading) {
this.heading = heading;
}
/**
* sets the altitude of the flight at this point.
* @param altitude
*/
public void setAltitude(double altitude) {
this.altitude = altitude;
}
/**
* sets the distance this flight takes before the next point.
* @param legDistance
*/
public void setLegDistance(double legDistance) {
this.legDistance = legDistance;
}
/**
* sets total distance travelled at this point.
* @param totalDistance
*/
public void setTotalDistance(double totalDistance) {
this.totalDistance = totalDistance;
}
/**
* sets the latitude at this point.
* @param latitude
*/
public void setLatitude(double latitude) {
this.latitude = latitude;
}
/**
* Sets the Longitude at this point.
* @param longitude
*/
public void setLongitude(double longitude) {
this.longitude = longitude;
}
/**
* gets the name of this point.
* @return
*/
public String getName(){
return name;
}
/**
* gets the UNIQUE ID at this point.
* @return
* @throws DataException
*/
public int getID() throws DataException {
if (this.ID == -1){
throw new DataException("ID not set.");
@ -112,39 +192,75 @@ public class FlightPoint {
return ID;
}
}
/**
* gets the Path Index ID at this point.
* @return
*/
public int getIndex(){
return indexID;
}
/**
* gets the type of this point.
* @return
*/
public String getType(){
return type;
}
/**
* gets where the plane is via at this point.
* @return
*/
public String getVia(){
return via;
}
/**
* gets the Heading bearing at this point
* @return
*/
public int getHeading(){
return heading;
}
/**
* gets the altitude at this poitn.
* @return
*/
public double getAltitude(){
return altitude;
}
/**
* gets the leg distance at this point.
* @return
*/
public double getLegDistance(){
return legDistance;
}
/**
* gets total distance travelled by this flight so far.
* @return
*/
public double getTotalDistance(){
return totalDistance;
}
/**
* gets longitude of this point.
* @return
*/
public double getLongitude(){
return longitude;
}
/**
* gets the latitude of this point.
* @return
*/
public double getLatitude(){
return latitude;
}

@ -121,7 +121,12 @@ public class Route {
return ID;
}
}
//JavaDoc needed
/**
* Gets this ID of the Airline.
* @return
* @throws DataException
*/
public int getAirlineID() throws DataException {
if (this.getAirline() != null) {
return this.getAirline().getID();
@ -130,6 +135,11 @@ public class Route {
}
}
/**
* Gets the ID of the Airport that the Route leaves from.
* @return
* @throws DataException
*/
public int getSourceID() throws DataException {
if (this.getSourceAirport() != null) {
return this.getSourceAirport().getID();
@ -138,6 +148,11 @@ public class Route {
}
}
/**
* gets the destination ID of the Airport the Route is arriving at.
* @return
* @throws DataException
*/
public int getDestID() throws DataException {
if (this.getDestinationAirport() != null) {
return this.getDestinationAirport().getID();
@ -248,6 +263,10 @@ public class Route {
}
}
/**
* gets the RoutePath to be passed into {@link seng202.group9.Map.Map}.
* @return
*/
public RoutePath getRoutePath(){
if (routePath == null) {
routePath = new RoutePath(
@ -258,6 +277,10 @@ public class Route {
return routePath;
}
/**
* What to print if printed as a string.
* @return
*/
@Override
public String toString(){

@ -10,22 +10,41 @@ import java.util.Collections;
public class RoutePath {
private ArrayList<Position> route = new ArrayList<Position>();
/**
* Route Path constructor when the user knows the points.
* @param points
*/
public RoutePath(Position ...points) {
Collections.addAll(route, points);
}
/**
* Route Path constructor when the user doesn't know the points.
*/
public RoutePath(){
}
/**
* adds a {@link Position} to the RoutePath.
* @param position
*/
public void addPosition(Position position){
route.add(position);
}
/**
* Gets the RoutePath positions.
* @return
*/
public ArrayList<Position> getRoute() {
return route;
}
/**
* Converts the RoutePath to an Array in JSON which can then be passed to the Map to display.
* @return
*/
public String toJSONArray() {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("[");

@ -9,6 +9,8 @@ import seng202.group9.Controller.Dataset;
import seng202.group9.Core.Airline;
/**
* The GUI controller class for airline_raw_data.fxml.
* Extends from the abstract class {@link Controller}.
* Created by Sunguin on 2016/09/13.
*/
public class AirlineRDController extends Controller {
@ -64,8 +66,32 @@ public class AirlineRDController extends Controller {
private Dataset theDataSet = null;
//Dummy function to test the add button.
//Will edit when ID is added automatically.
/**
* Loads the initial airline data to the GUI table.
* Also sets up the dropdown menu options.
*/
public void load() {
airlIDcol.setCellValueFactory(new PropertyValueFactory<Airline, String>("ID"));
airlNamecol.setCellValueFactory(new PropertyValueFactory<Airline, String>("Name"));
airlAliascol.setCellValueFactory(new PropertyValueFactory<Airline, String>("Alias"));
airlIATAcol.setCellValueFactory(new PropertyValueFactory<Airline, String>("IATA"));
airlICAOcol.setCellValueFactory(new PropertyValueFactory<Airline, String>("ICAO"));
airlCallsigncol.setCellValueFactory(new PropertyValueFactory<Airline, String>("CallSign"));
airlCountrycol.setCellValueFactory(new PropertyValueFactory<Airline, String>("CountryName"));
airlActivecol.setCellValueFactory(new PropertyValueFactory<Airline, String>("Active"));
theDataSet = getParent().getCurrentDataset();
tableViewAirlineRD.setItems(FXCollections.observableArrayList(theDataSet.getAirlines()));
airlActiveCBox.setValue("Y");
airlActiveCBox.getItems().addAll("Y", "N");
}
/**
* Adds a single airline entry to the database.
* Takes in values from the GUI the user has typed in.
* @see Dataset
*/
public void addAirlineSingle() {
try {
theDataSet.addAirline(
@ -83,6 +109,7 @@ public class AirlineRDController extends Controller {
airlCallsignBox.clear();
airlCountryBox.clear();
airlActiveCBox.getSelectionModel().clearSelection();
airlActiveCBox.setValue("Y");
tableViewAirlineRD.setItems(FXCollections.observableArrayList(theDataSet.getAirlines()));
} catch ( Exception e ) {
Alert alert = new Alert(Alert.AlertType.ERROR);
@ -93,29 +120,23 @@ public class AirlineRDController extends Controller {
}
}
public void load() {
airlIDcol.setCellValueFactory(new PropertyValueFactory<Airline, String>("ID"));
airlNamecol.setCellValueFactory(new PropertyValueFactory<Airline, String>("Name"));
airlAliascol.setCellValueFactory(new PropertyValueFactory<Airline, String>("Alias"));
airlIATAcol.setCellValueFactory(new PropertyValueFactory<Airline, String>("IATA"));
airlICAOcol.setCellValueFactory(new PropertyValueFactory<Airline, String>("ICAO"));
airlCallsigncol.setCellValueFactory(new PropertyValueFactory<Airline, String>("CallSign"));
airlCountrycol.setCellValueFactory(new PropertyValueFactory<Airline, String>("CountryName"));
airlActivecol.setCellValueFactory(new PropertyValueFactory<Airline, String>("Active"));
theDataSet = getParent().getCurrentDataset();
tableViewAirlineRD.setItems(FXCollections.observableArrayList(theDataSet.getAirlines()));
airlActiveCBox.setValue("Y");
airlActiveCBox.getItems().addAll("Y", "N");
}
/**
* Deletes a single selected airline entry from the database.
* Updates the GUI accordingly.
* @see Dataset
*/
public void deleteAirline() {
Airline toDelete = tableViewAirlineRD.getSelectionModel().getSelectedItem();
theDataSet.deleteAirline(toDelete);
tableViewAirlineRD.setItems(FXCollections.observableArrayList(theDataSet.getAirlines()));
}
/**
* Filters airlines by any field.
* These are specified by what the user has typed in the filter boxes.
* Updates the GUI accordingly.
* @see AirlineFilter
*/
public void filterAirlines() {
AirlineFilter filter = new AirlineFilter(theDataSet.getAirlines());
if (airlNameFilter.getText() != null) {

@ -1,27 +1,19 @@
package seng202.group9.GUI;
import com.sun.javafx.collections.ObservableListWrapper;
import javafx.beans.InvalidationListener;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.value.ObservableStringValue;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.collections.ListChangeListener;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.scene.control.*;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.util.Callback;
import seng202.group9.Controller.AirportFilter;
import seng202.group9.Controller.App;
import seng202.group9.Controller.Dataset;
import seng202.group9.Controller.SceneCode;
import seng202.group9.Core.Airport;
import seng202.group9.Core.City;
import seng202.group9.Core.Country;
import static javafx.collections.FXCollections.observableArrayList;
/**
* The GUI controller class for airport_raw_data.fxml.
* Extends from the abstract class {@link Controller}.
* Created by Sunguin on 2016/09/13.
*/
public class AirportRDController extends Controller{
@ -101,6 +93,10 @@ public class AirportRDController extends Controller{
private Dataset theDataSet = null;
/**
* Loads the initial airport data to the GUI table.
* Also sets up the dropdown menu options.
*/
public void load() {
airpIDcol.setCellValueFactory(new PropertyValueFactory<Airport, String>("ID"));
airpNamecol.setCellValueFactory(new PropertyValueFactory<Airport, String>("Name"));
@ -116,12 +112,17 @@ public class AirportRDController extends Controller{
airpTzcol.setCellValueFactory(new PropertyValueFactory<Airport, String>("Tz"));
theDataSet = getParent().getCurrentDataset();
tableViewAirportRD.setItems(FXCollections.observableArrayList(theDataSet.getAirports()));
tableViewAirportRD.setItems(observableArrayList(theDataSet.getAirports()));
airpDSTCBox.setValue("E");
airpDSTCBox.getItems().addAll("E", "A", "S", "O", "Z", "N", "U");
}
/**
* Adds a single airport entry in the database.
* Takes in values from the GUI the user has typed in.
* @see Dataset
*/
public void addAirportSingle() {
try {
theDataSet.addAirport(
@ -145,6 +146,7 @@ public class AirportRDController extends Controller{
airpAltitudeBox.clear();
airpTimezoneBox.clear();
airpDSTCBox.getSelectionModel().clearSelection();
airpDSTCBox.setValue("E");
airpTzBox.clear();
tableViewAirportRD.setItems(FXCollections.observableArrayList(theDataSet.getAirports()));
} catch ( Exception e ) {
@ -155,16 +157,28 @@ public class AirportRDController extends Controller{
alert.showAndWait();
}
}
public void airportAnalyserButton() {
replaceSceneContent(SceneCode.AIRPORT_ANALYSER);
}
/**
* Deletes a single selected airport entry from the database.
* Updates the GUI accordingly.
* @see Dataset
*/
public void deleteAirport(){
Airport toDelete = tableViewAirportRD.getSelectionModel().getSelectedItem();
theDataSet.deleteAirport(toDelete);
tableViewAirportRD.setItems(FXCollections.observableArrayList(theDataSet.getAirports()));
tableViewAirportRD.setItems(observableArrayList(theDataSet.getAirports()));
}
/**
* Filters the airports table by any field.
* These are specified by what the user has typed in the filter boxes.
* Updates the GUI accordingly.
* @see AirportFilter
*/
public void filterAirports() {
AirportFilter filter = new AirportFilter(theDataSet.getAirports());
if (airpNameFilter.getText() != null) {

@ -4,16 +4,14 @@ import javafx.collections.FXCollections;
import javafx.fxml.FXML;
import javafx.scene.control.*;
import javafx.scene.control.cell.PropertyValueFactory;
import seng202.group9.Controller.App;
import seng202.group9.Controller.DataException;
import seng202.group9.Controller.Dataset;
import seng202.group9.Controller.SceneCode;
import seng202.group9.Controller.RouteFilter;
import seng202.group9.Core.Route;
import java.util.ArrayList;
/**
* The GUI controller class for route_raw_data.fxml.
* Extends from the abstract class {@link Controller}.
* Created by Sunguin on 2016/09/14.
*/
public class RouteRDController extends Controller {
@ -64,9 +62,36 @@ public class RouteRDController extends Controller {
private TextField rStopsFilter;
@FXML
private TextField rEquipmentFilter;
@FXML
private Dataset theDataSet = null;
/**
* Loads the initial route data to the GUI table.
* Also sets up the dropdown menu options.
*/
public void load() {
rAirlineCol.setCellValueFactory(new PropertyValueFactory<Route, String>("AirlineName"));
rAirlineIDCol.setCellValueFactory(new PropertyValueFactory<Route, String>("AirlineID"));
rSourceCol.setCellValueFactory(new PropertyValueFactory<Route, String>("DepartureAirport"));
rSourceIDCol.setCellValueFactory(new PropertyValueFactory<Route, String>("SourceID"));
rDestCol.setCellValueFactory(new PropertyValueFactory<Route, String>("ArrivalAirport"));
rDestIDCol.setCellValueFactory(new PropertyValueFactory<Route, String>("DestID"));
rCodeshareCol.setCellValueFactory(new PropertyValueFactory<Route, String>("Code"));
rStopsCol.setCellValueFactory(new PropertyValueFactory<Route, String>("Stops"));
rEquipmentCol.setCellValueFactory(new PropertyValueFactory<Route, String>("Equipment"));
theDataSet = getParent().getCurrentDataset();
tableViewRouteRD.setItems(FXCollections.observableArrayList(theDataSet.getRoutes()));
rCodeshareCBox.setValue("");
rCodeshareCBox.getItems().addAll("Y", "");
}
/**
* Adds a single route entry in the database.
* Takes in values from the GUI the user has typed in.
* @see Dataset
*/
public void addRouteSingle() {
try {
theDataSet.addRoute(
@ -81,54 +106,39 @@ public class RouteRDController extends Controller {
rSourceBox.clear();
rDestBox.clear();
rCodeshareCBox.getSelectionModel().clearSelection();
rCodeshareCBox.setValue("");
rStopsBox.clear();
rEquipmentBox.clear();
tableViewRouteRD.setItems(FXCollections.observableArrayList(theDataSet.getRoutes()));
} catch (DataException e){
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle("Route Data Error");
alert.setHeaderText("Error adding a custom route entry.");
alert.setContentText(e.getMessage());
alert.showAndWait();
} catch ( Exception e ) {
e.printStackTrace();
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle("Route Error");
alert.setTitle("Route Data Error");
alert.setHeaderText("Error adding a custom route entry.");
alert.setContentText(e.getMessage());
alert.showAndWait();
}
}
public void load() {
rAirlineCol.setCellValueFactory(new PropertyValueFactory<Route, String>("AirlineName"));
rAirlineIDCol.setCellValueFactory(new PropertyValueFactory<Route, String>("AirlineID"));
rSourceCol.setCellValueFactory(new PropertyValueFactory<Route, String>("DepartureAirport"));
rSourceIDCol.setCellValueFactory(new PropertyValueFactory<Route, String>("SourceID"));
rDestCol.setCellValueFactory(new PropertyValueFactory<Route, String>("ArrivalAirport"));
rDestIDCol.setCellValueFactory(new PropertyValueFactory<Route, String>("DestID"));
rCodeshareCol.setCellValueFactory(new PropertyValueFactory<Route, String>("Code"));
rStopsCol.setCellValueFactory(new PropertyValueFactory<Route, String>("Stops"));
rEquipmentCol.setCellValueFactory(new PropertyValueFactory<Route, String>("Equipment"));
theDataSet = getParent().getCurrentDataset();
tableViewRouteRD.setItems(FXCollections.observableArrayList(theDataSet.getRoutes()));
rCodeshareCBox.setValue("");
rCodeshareCBox.getItems().addAll("Y", "");
}
/**
* Deletes a single selected route entry from the database.
* Updates the GUI accordingly.
* @see Dataset
*/
public void deleteRoute(){
Route toDelete = tableViewRouteRD.getSelectionModel().getSelectedItem();
theDataSet.deleteRoute(toDelete);
tableViewRouteRD.setItems(FXCollections.observableArrayList(theDataSet.getRoutes()));
}
/**
* Filters the routes table by any field.
* These are specified by what the user has typed in the filter boxes.
* Updates the GUI accordingly.
* @see RouteFilter
*/
public void filterRoutes(){
RouteFilter filter = new RouteFilter(theDataSet.getRoutes());
if (rAirlineFilter.getText() != null) {
//System.out.println("Hello over here");
filter.filterAirline(rAirlineFilter.getText());
}
if (rSourceFilter.getText() != null) {
@ -146,8 +156,6 @@ public class RouteRDController extends Controller {
if (rEquipmentFilter.getText() != null) {
filter.filterEquipment(rEquipmentFilter.getText());
}
// System.out.println("Hello");
// filter.printFilter();
tableViewRouteRD.setItems(FXCollections.<Route>observableArrayList(filter.getFilteredData()));
}

@ -93,7 +93,7 @@
</padding>
</TextField>
<Label layoutX="14.0" layoutY="6.0" prefHeight="25.0" prefWidth="84.0" text="Add Airline:" />
<ComboBox fx:id="airlActiveCBox" layoutX="1330.0" layoutY="-1.0" prefHeight="31.0" prefWidth="102.0" promptText="Active" />
<ComboBox fx:id="airlActiveCBox" layoutX="1330.0" layoutY="3.0" prefHeight="31.0" prefWidth="102.0" promptText="Active" />
</children>
</Pane>
</content>

@ -93,15 +93,9 @@
</Pane>
</content>
</ScrollPane>
<<<<<<< HEAD
<Button layoutX="14.0" layoutY="526.0" mnemonicParsing="false" onAction="#airportAnalyserButton" prefHeight="25.0" prefWidth="125.0" text="Analyse" />
<Button layoutX="662.0" layoutY="526.0" mnemonicParsing="false" onAction="#addAirportSingle" prefHeight="25.0" prefWidth="125.0" text="Add" />
<Pane layoutX="15.0" layoutY="60.0" prefHeight="403.0" prefWidth="772.0">
=======
<Button layoutX="14.0" layoutY="526.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="125.0" text="Analyse" />
<Button layoutX="653.0" layoutY="526.0" mnemonicParsing="false" onAction="#addAirportSingle" prefHeight="25.0" prefWidth="125.0" text="Add" />
<Pane layoutX="15.0" layoutY="60.0" prefHeight="342.0" prefWidth="764.0">
>>>>>>> raw_data_fixes
<children>
<TableView fx:id="tableViewAirportRD" prefHeight="340.0" prefWidth="765.0">
<columns>

Loading…
Cancel
Save