Class GetSchedule

java.lang.Object
org.deltava.dao.DAO
org.deltava.dao.GetSchedule
Direct Known Subclasses:
GetScheduleSearch

public class GetSchedule extends DAO
A Data Access Object to search the Flight Schedule.
Since:
1.0
Version:
11.2
Author:
Luke
  • Constructor Details

    • GetSchedule

      public GetSchedule(Connection c)
      Initialize the Data Access Object.
      Parameters:
      c - the JDBC connection to use
  • Method Details

    • setSources

      public void setSources(Collection<ScheduleSourceInfo> srcs)
      Sets the raw schedule sources in use, for DST calculatiuons.
      Parameters:
      srcs - a Collection of ScheduleSourceInfo beans
    • get

      public ScheduleEntry get(Flight f, String dbName) throws DAOException
      Return a particular flight from the Schedule database.
      Parameters:
      f - the Flight to return, using the airline code, flight number and leg
      dbName - the database name
      Returns:
      a ScheduleEntry matching the criteria, or null if not found
      Throws:
      DAOException - if a JDBC error occurs
      NullPointerException - if f is null
    • getFlights

      public Collection<ScheduleEntry> getFlights(Airport a) throws DAOException
      Returns all flights from a particular airport, sorted by Airline and Flight Number.
      Parameters:
      a - the origin Airport bean
      Returns:
      a Collection of ScheduleEntry beans
      Throws:
      DAOException - if a JDBC error occurs
    • getFlights

      public Collection<ScheduleEntry> getFlights(Airport a, Airline al) throws DAOException
      Returns all flights from a particular airport with a particular airline, sorted by Airline and Flight Number.
      Parameters:
      a - the origin Airport bean
      al - the Airline bean
      Returns:
      a Collection of ScheduleEntry beans
      Throws:
      DAOException - if a JDBC error occurs
    • get

      public ScheduleEntry get(String aCode, int flightNumber, int leg) throws DAOException
      Return a particular flight from the Schedule database.
      Parameters:
      aCode - the Airline Code
      flightNumber - the Flight Number
      leg - the Leg
      Returns:
      a ScheduleEntry matching the criteria, or null if not found
      Throws:
      DAOException - if a JDBC error occurs
    • getAirlines

      public Collection<Airline> getAirlines(RoutePair rp) throws DAOException
      Returns the Airlines that provide service on a particular route.
      Parameters:
      rp - the RoutePair
      Returns:
      a Collection of Airline beans
      Throws:
      DAOException - if a JDBC error occurs
      NullPointerException - if airportD or airportA are null
    • getAcademyAirports

      public Collection<Airport> getAcademyAirports() throws DAOException
      Returns Airports only serviced by Flight Academy flights.
      Returns:
      a Collection of Airports
      Throws:
      DAOException - if a JDBC error occurs
    • getFlightTime

      public FlightTime getFlightTime(RoutePair rp, String dbName) throws DAOException
      Returns the average flight time for all flights in the Schedule database between two airports.
      Parameters:
      rp - the RoutePair
      dbName - the database name
      Returns:
      a FlightTime bean
      Throws:
      DAOException - if a JDBC error occurs
    • getFlightNumber

      public ScheduleEntry getFlightNumber(ScheduleRoute sr, int hourOfDay, String dbName) throws DAOException
      Returns the most appropriate flight/leg number between two airports.
      Parameters:
      sr - the ScheduleRoute
      hourOfDay - the preferred hour of day (0-23)
      dbName - the database name
      Returns:
      a ScheduleEntry bean with the Airline, Flight and Leg number or null if none found
      Throws:
      DAOException - if a JDBC error occurs
      NullPointerException - if airportD or airportA are null
    • getFlightNumber

      public ScheduleEntry getFlightNumber(RoutePair rp, String dbName) throws DAOException
      Returns the lowest flight/leg number between two airports.
      Parameters:
      rp - the RoutePair
      dbName - the database name
      Returns:
      a ScheduleEntry bean with the Airline, Flight and Leg number or null if none found
      Throws:
      DAOException - if a JDBC error occurs
      NullPointerException - if airportD or airportA are null
    • export

      public Collection<ScheduleEntry> export() throws DAOException
      Exports the entire Flight Schedule.
      Returns:
      a Collection of ScheduleEntry beans
      Throws:
      DAOException - if a JDBC error occurs
    • getRoutePairs

      public Collection<ScheduleRoute> getRoutePairs(Inclusion includeHistoric) throws DAOException
      Returns all Airports and the Airports they are directly connected to.
      Parameters:
      includeHistoric - an Inclusion to exclude/include Historic flights
      Returns:
      a Collection of ScheduleRoutes
      Throws:
      DAOException - if a JDBC error occurs
    • execute

      protected List<ScheduleEntry> execute(PreparedStatement ps) throws SQLException
      Helper method to parse schedule entry result sets.
      Parameters:
      ps - a PreparedStatement
      Returns:
      a List of ScheduleEntry beans
      Throws:
      SQLException - if an error occurs