Class PilotReadDAO
java.lang.Object
org.deltava.dao.DAO
org.deltava.dao.PilotReadDAO
- Direct Known Subclasses:
GetInactivity, GetPilot, GetPilotOnline
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:
- 12.0
- Author:
- Luke
-
Field Summary
FieldsFields inherited from class DAO
_queryMax, _queryStart, _queryTimeout, WGS84_SRIDModifier and TypeFieldDescriptionprotected intThe maximum number of rows to return.protected intThe row number at which to start returning results.protected intThe query timeout, in seconds.protected static final intThe SRID used for geolocation queries. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreates the DAO from a JDBC connection. -
Method Summary
Modifier and TypeMethodDescriptionQuery pilot objects from the database, assuming a pre-prepared statement.final Pilotget(int id) Gets a pilot object based on a database ID.Returns a Pilot object which may be in another Airline's database.get(UserDataMap udm) Returns Pilot objects which may be in another Airline's database.getByID(Collection<?> ids, String tableName) Returns a Map of pilots based on a Set of pilot IDs.Returns a Pilot based on a given full name.protected final voidloadAccomplishments(Map<Integer, Pilot> pilots, String dbName) Load the accomplishment IDs for a group of Pilots.protected final voidloadChildRows(Pilot p, String dbName) Load the ratings, roles and accomplishment IDs for a Pilot.protected final voidloadIMAddrs(Map<Integer, Pilot> pilots, String dbName) Load social media addresses for a group of Pilots.protected final voidloadPushEndpoints(Map<Integer, Pilot> pilots, String dbName) Loads push notification endpoints for a group of Pilots.protected final voidloadRatings(Map<Integer, Pilot> pilots, String dbName) Load the equipment ratings for a group of Pilots.protected final voidLoad the security roles for a group of Pilots.protected static final voidupdatePilotCodes(Collection<Pilot> pilots, String dbName) Updates the Pilot codes when loading Pilots from different databases.Methods inherited from class DAO
commitTransaction, createTimestamp, executeIDs, executeUpdate, executeUpdate, expandDate, formatDBName, formatLocation, getNewID, getQueryCount, prepare, prepareWithoutLimits, rollbackTransaction, setQueryMax, setQueryStart, setQueryTimeout, startTransaction, toID, toID, toInstantModifier and TypeMethodDescriptionprotected voidCommits a multi-step transaction to the database.protected static TimestampNull-safe conversion of an Instant to a Timestamp.Helper method to extract database ID data from the result set.protected static intexecuteUpdate(PreparedStatement ps, int minUpdateCount) Executes an UPDATE transaction on a prepared statement, and throws aSQLExceptionif less than the expected number of rows were updated.protected static intexecuteUpdate(PreparedStatement ps, int minPerUpdate, int minTotal) Executes an batched UPDATE transaction on a prepared statement, and throws aSQLExceptionif less than the expected number of rows were updated per batch entry.protected static InstantexpandDate(Date dt) Converts a date-only JDBC value into a full timestamp.protected static StringformatDBName(String db) Formats a database name by converting to lowercase.protected static StringConverts a geographic location into a MySQL WKT formatted point.protected intgetNewID()Returns the AUTO_INC column value generated by the previous JDBC transaction.static final longReturns the total number of queries executed since the JVM was started.protected PreparedStatementInitialize the prepared statement with an arbitrary SQL statement.protected PreparedStatementInitialize the prepared statement with an abitrary SQL statement, without applying the DAO's query result limitations.protected voidRolls back a multi-step transaction before it is completed.final voidsetQueryMax(int maxRows) Sets the maximum number of rows in the returned result set.final voidsetQueryStart(int rowStart) Sets the first row of the results to return.voidsetQueryTimeout(int timeout) Sets the timeout for any SQL operations.protected voidMarks the start of a multi-step database transaction.protected static IntegerConverts a Database bean or an Integer into an Integer.protected static Collection<Integer> toID(Collection<?> ids) Converts a collection of Objects into Integer IDs.protected static InstantNull-safe conversion of a Timestamp to an Instant.
-
Field Details
-
_cache
-
-
Constructor Details
-
PilotReadDAO
Creates the DAO from a JDBC connection.- Parameters:
c- the JDBC connection to use
-
-
Method Details
-
get
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
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 PilotdbName- the database name to search- Returns:
- a Collection of Pilot beans
- Throws:
DAOException- if a JDBC error occurs
-
get
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
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
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 ofDatabaseBeanbeanstableName- 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
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
Load the ratings, roles and accomplishment IDs for a Pilot.- Parameters:
p- the Pilot beandbName- the database Name- Throws:
SQLException- if a JDBC error occurs
-
loadAccomplishments
protected final void loadAccomplishments(Map<Integer, Pilot> pilots, String dbName) throws SQLExceptionLoad the accomplishment IDs for a group of Pilots.- Parameters:
pilots- the Map of Pilots, indexed by database IDdbName- the database Name- Throws:
SQLException- if a JDBC error occurs
-
loadRoles
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
Load social media addresses for a group of Pilots.- Parameters:
pilots- the Map of Pilots, indexed by database IDdbName- the database name- Throws:
SQLException- if a JDBC error occurs
-
loadPushEndpoints
protected final void loadPushEndpoints(Map<Integer, Pilot> pilots, String dbName) throws SQLExceptionLoads push notification endpoints for a group of Pilots.- Parameters:
pilots- a Map of Pilots, indexed by database IDdbName- the database name- Throws:
SQLException- if a JDBC error occurs
-
loadRatings
Load the equipment ratings for a group of Pilots.- Parameters:
pilots- the Map of Pilots, indexed by database IDdbName- the database name- Throws:
SQLException- if a JDBC error occurs
-
updatePilotCodes
Updates the Pilot codes when loading Pilots from different databases.- Parameters:
pilots- a Collection of Pilot beans to updatedbName- the database name
-