Class PilotReadDAO

java.lang.Object
org.deltava.dao.DAO
org.deltava.dao.PilotReadDAO
Direct Known Subclasses:
GetInactivity, GetPilot, GetPilotOnline

abstract class PilotReadDAO extends DAO
A DAO to support reading Pilot object(s) from the database. This class contains methods to read an individual Pilot from the database; implementing subclasses typically add methods to retrieve Lists of pilots based on particular criteria.
Since:
1.0
Version:
11.3
Author:
Luke
  • Field Details

    • _cache

      protected static final Cache<Pilot> _cache
  • Constructor Details

    • PilotReadDAO

      protected PilotReadDAO(Connection c)
      Creates the DAO from a JDBC connection.
      Parameters:
      c - the JDBC connection to use
  • Method Details

    • get

      public final Pilot get(int id) throws DAOException
      Gets a pilot object based on a database ID. This uses a cached query, and populates ratings and roles.
      Parameters:
      id - the database ID of the Pilot object
      Returns:
      the Pilot object, or null if the ID was not found
      Throws:
      DAOException - if a JDBC error occured
    • getByName

      public final List<Pilot> getByName(String fullName, String dbName) throws DAOException
      Returns a Pilot based on a given full name. This method does not use first/last name splitting since this can be unpredictable.
      Parameters:
      fullName - the Full Name of the Pilot
      dbName - the database name to search
      Returns:
      a Collection of Pilot beans
      Throws:
      DAOException - if a JDBC error occurs
    • get

      public Pilot get(UserData ud) throws DAOException
      Returns a Pilot object which may be in another Airline's database.
      Parameters:
      ud - the UserData bean containg the Pilot location
      Returns:
      the Pilot bean, or null if not found
      Throws:
      DAOException - if a JDBC error occurs
    • get

      public Map<Integer,Pilot> get(UserDataMap udm) throws DAOException
      Returns Pilot objects which may be in another Airline's database.
      Parameters:
      udm - the UserDataMap bean containg the Pilot locations
      Returns:
      a Map of Pilots indexed by database ID
      Throws:
      DAOException - if a JDBC error occurs
    • getByID

      public Map<Integer,Pilot> getByID(Collection<?> ids, String tableName) throws DAOException
      Returns a Map of pilots based on a Set of pilot IDs. This is typically called by a Water Cooler thread/channel list command.
      Parameters:
      ids - a Collection of pilot IDs. This can either be a Collection of Integers, a Collection of DatabaseBeanbeans
      tableName - the table to read from, in DATABASE.TABLE format for a remote database, or TABLE for a table in the current airline's database.
      Returns:
      a Map of Pilots, indexed by the pilot code
      Throws:
      DAOException - if a JDBC error occurs
    • execute

      protected static final List<Pilot> execute(PreparedStatement ps) throws SQLException
      Query pilot objects from the database, assuming a pre-prepared statement.
      Parameters:
      ps - a PreparedStatement
      Returns:
      a List of Pilot objects
      Throws:
      SQLException - if a JDBC error occurs
    • loadChildRows

      protected final void loadChildRows(Pilot p, String dbName) throws SQLException
      Load the ratings, roles and accomplishment IDs for a Pilot.
      Parameters:
      p - the Pilot bean
      dbName - the database Name
      Throws:
      SQLException - if a JDBC error occurs
    • loadAccomplishments

      protected final void loadAccomplishments(Map<Integer,Pilot> pilots, String dbName) throws SQLException
      Load the accomplishment IDs for a group of Pilots.
      Parameters:
      pilots - the Map of Pilots, indexed by database ID
      dbName - the database Name
      Throws:
      SQLException - if a JDBC error occurs
    • loadRoles

      protected final void loadRoles(Map<Integer,Pilot> pilots) throws SQLException
      Load the security roles for a group of Pilots.
      Parameters:
      pilots - the Map of Pilots, indexed by database ID
      Throws:
      SQLException - if a JDBC error occurs
    • loadIMAddrs

      protected final void loadIMAddrs(Map<Integer,Pilot> pilots, String dbName) throws SQLException
      Load social media addresses for a group of Pilots.
      Parameters:
      pilots - the Map of Pilots, indexed by database ID
      dbName - the database name
      Throws:
      SQLException - if a JDBC error occurs
    • loadPushEndpoints

      protected final void loadPushEndpoints(Map<Integer,Pilot> pilots, String dbName) throws SQLException
      Loads push notification endpoints for a group of Pilots.
      Parameters:
      pilots - a Map of Pilots, indexed by database ID
      dbName - the database name
      Throws:
      SQLException - if a JDBC error occurs
    • loadRatings

      protected final void loadRatings(Map<Integer,Pilot> pilots, String dbName) throws SQLException
      Load the equipment ratings for a group of Pilots.
      Parameters:
      pilots - the Map of Pilots, indexed by database ID
      dbName - the database name
      Throws:
      SQLException - if a JDBC error occurs
    • updatePilotCodes

      protected static final void updatePilotCodes(Collection<Pilot> pilots, String dbName)
      Updates the Pilot codes when loading Pilots from different databases.
      Parameters:
      pilots - a Collection of Pilot beans to update
      dbName - the database name