Class GetFlightReports

java.lang.Object
org.deltava.dao.DAO
org.deltava.dao.GetFlightReports
Direct Known Subclasses:
GetFlightReportACARS

public class GetFlightReports extends DAO
A Data Access Object to load Flight Reports.
Since:
1.0
Version:
11.5
Author:
Luke
  • Constructor Details

    • GetFlightReports

      public GetFlightReports(Connection c)
      Initializes the DAO with a given JDBC connection.
      Parameters:
      c - the JDBC connection to use
  • Method Details

    • get

      public FlightReport get(int id, String dbName) throws DAOException
      Returns a PIREP with a particular database ID.
      Parameters:
      id - the database ID
      dbName - the database Name
      Returns:
      the Flight Report, or null if not found
      Throws:
      DAOException - if a JDBC error occurs
    • getACARS

      public FDRFlightReport getACARS(String dbName, int acarsID) throws DAOException
      Returns an ACARS-logged PIREP with a particular ACARS Flight ID.
      Parameters:
      dbName - the database Name
      acarsID - the ACARS flight ID
      Returns:
      the ACARSFlightReport, or null if not found
      Throws:
      DAOException - if a JDBC error occurs
    • getByStatus

      public List<FlightReport> getByStatus(Collection<FlightStatus> status, String orderBy) throws DAOException
      Returns all Flight Reports in particular statuses.
      Parameters:
      status - a Collection of Integer status codes
      orderBy - the ORDER BY SQL statement
      Returns:
      a List of FlightReports in the specified statuses
      Throws:
      DAOException - if a JDBC error occurs
    • getCheckRideQueueSize

      public int getCheckRideQueueSize(String eqType, boolean includeAcademy) throws DAOException
      Returns the number of Flight Reports awaiting disposition.
      Parameters:
      eqType - the equipment type, or null if all
      includeAcademy - TRUE if Flight Academy check rides should be counted, otherwise FALSE
      Returns:
      the number Check Ride Flight Reports in SUBMITTED status
      Throws:
      DAOException - if a JDBC error occurs
    • getHeld

      public int getHeld(int pilotID, String dbName) throws DAOException
      Returns the number of held Flight Reports for a particular Pilot.
      Parameters:
      pilotID - the Pilot's database ID
      dbName - the database name
      Returns:
      the number of Flight Reports in HOLD status
      Throws:
      DAOException - if a JDBC error occurs
    • getByAssignment

      public List<FlightReport> getByAssignment(int id, String dbName) throws DAOException
      Returns all Flight Reports associated with a particular Flight Assignment.
      Parameters:
      id - the Flight Assignment database ID
      dbName - the database name
      Returns:
      a List of FlightReports
      Throws:
      DAOException - if a JDBC error occurs
    • getByNetwork

      public List<FlightReport> getByNetwork(OnlineNetwork net, String dbName) throws DAOException
      Returns approved Flight Reports flown on a particular Online Network.
      Parameters:
      net - the OnlineNetwork
      dbName - the database name
      Returns:
      a List of FlightReport beans
      Throws:
      DAOException - if a JDBC error occurs
    • getByEvent

      public List<FlightReport> getByEvent(int id, String dbName) throws DAOException
      Returns all Flight Reports associated with a particular Online Event.
      Parameters:
      id - the Online Event database ID
      dbName - the database name
      Returns:
      a List of FlightReports
      Throws:
      DAOException - if a JDBC error occurs
    • getByTour

      public List<FlightReport> getByTour(int pilotID, int tourID, String dbName) throws DAOException
      Returns all Flight Reports associated with a particular Pilot and Flight Tour.
      Parameters:
      pilotID - the Pilot database ID
      tourID - the Tour database ID
      dbName - the database name
      Returns:
      a List of Flight Reports, ordered by submission date
      Throws:
      DAOException - if a JDBC error occurs
    • getLogbookCalendar

      public List<FlightReport> getLogbookCalendar(int id, String dbName, Instant startDate, int days) throws DAOException
      Loads all Flight Reports for a Pilot for a particular date range.
      Parameters:
      id - the Pilot database ID
      dbName - the database name
      startDate - the start date
      days - the number of days forward to include
      Returns:
      a List of FlightReports
      Throws:
      DAOException - if a JDBC error occurs
    • getEliteFlights

      public List<FlightReport> getEliteFlights(int id, int year) throws DAOException
      Returns all Flight Reports for a given Elite program year.
      Parameters:
      id - the Pilot database ID
      year - the Elite Program year
      Returns:
      a List of FlightREports
      Throws:
      DAOException - if a JDBC error occurs
    • getByPilot

      public List<FlightReport> getByPilot(int id, LogbookSearchCriteria criteria) throws DAOException
      Returns all Flight Reports for a particular Pilot, using a sort column.
      Parameters:
      id - the Pilot database ID
      criteria - the search criteria
      Returns:
      a List of FlightReports
      Throws:
      DAOException - if a JDBC error occurs
    • getOnlineTotals

      public void getOnlineTotals(Pilot p, String dbName) throws DAOException
      Gets online and ACARS legs/hours for a particular Pilot.
      Parameters:
      p - the Pilot to query for (the object will be updated)
      dbName - the database name
      Throws:
      DAOException - if a JDBC error occurs
      See Also:
    • getOnlineTotals

      public void getOnlineTotals(Map<Integer,Pilot> pilots, String dbName) throws DAOException
      Returns online and ACARS legs/hours for a group of Pilots.
      Parameters:
      pilots - a Map of Pilot objects to populate with results
      dbName - the database name
      Throws:
      DAOException - if a JDBC error occurs
    • getDraft

      public DraftFlightReport getDraft(int id, String dbName) throws DAOException
      Loads a Draft Flight Report.
      Parameters:
      id - the Flight Report database ID
      dbName - the database name
      Returns:
      a DraftFlightReport, or null if not found or the Flight Report is not in draft status
      Throws:
      DAOException - if a JDBC error occurs
    • getDraftReports

      public List<FlightReport> getDraftReports(int pilotID, RoutePair rp, String dbName) throws DAOException
      Returns Draft Flight Reports for a particular Pilot (with optional city pair).
      Parameters:
      pilotID - the Pilot's Database ID
      rp - the RoutePair, or null if none
      dbName - the database Name
      Returns:
      a List of Draft FlightReports matching the above criteria
      Throws:
      DAOException - if a JDBC error occurs
    • getDiversion

      public FlightReport getDiversion(Airport a, int pilotID, String db) throws DAOException
      Retrieves held/submitted Flight diversions for a particular Pilot.
      Parameters:
      a - the Airport diverted to
      pilotID - the Pilot's database ID
      db - the database
      Returns:
      a FlightReport, or null if not found
      Throws:
      DAOException - if a JDBC error occurs
    • getRoutePairs

      public Collection<RouteStats> getRoutePairs(int pilotID, int days) throws DAOException
      Returns the city pairs flown by a particular Pilot.
      Parameters:
      pilotID - the Pilot database ID
      days - the number of days back to search
      Returns:
      a Collection of RoutePair beans
      Throws:
      DAOException - if a JDBC error occurs
    • execute

      protected static List<FlightReport> execute(PreparedStatement ps) throws SQLException
      Helper method to load PIREP data.
      Parameters:
      ps - a PreparedStatement
      Returns:
      a List of FlightReport beans
      Throws:
      SQLException - if an error occurs
    • getCaptEQType

      public void getCaptEQType(Collection<FlightReport> pireps) throws DAOException
      Populates the Equipment Types a collection of PIREPs counts towards promotion in.
      Parameters:
      pireps - a Collection of FlightReport beans
      Throws:
      DAOException - if a JDBC error occurs
    • getElite

      public FlightEliteScore getElite(int id) throws DAOException
      Returns the Elite program score for a Flight Report.
      Parameters:
      id - the Flight Report database ID
      Returns:
      a FlightEliteScore bean, or null if not found
      Throws:
      DAOException - if a JDBC error occurs
    • loadCaptEQTypes

      public void loadCaptEQTypes(int pilotID, Collection<FlightReport> pireps, String dbName) throws DAOException
      Load promotion flags for a large number of Flight Reports from a single Pilot. This is usally more efficient than a large set query.
      Parameters:
      pilotID - the Pilot's database ID
      pireps - a Collection of FlightReport beans
      dbName - the database name
      Throws:
      DAOException - if a JDBC error occurs