Class PilotWriteDAO
java.lang.Object
org.deltava.dao.DAO
org.deltava.dao.PilotWriteDAO
- Direct Known Subclasses:
SetApplicant, SetPilot, SetPilotLogin, SetPilotMerge, SetPilotPush
A Data Access Object to support writing Pilot objects to the database.
- Since:
- 1.0
- Version:
- 10.3
- Author:
- Luke
-
Field Summary
Fields 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
ConstructorsModifierConstructorDescriptionprotectedInitializes the Data Access Object. -
Method Summary
Modifier and TypeMethodDescriptionvoidsetStatus(int id, PilotStatus status) Updates a Pilots' status in the database.protected voidwriteAlias(int id, String... aliases) Writes a Pilot's alias to the AUTH_ALIAS table if present.protected voidwriteExternalIDs(int id, Map<ExternalID, String> addrs, String db, boolean doClear) Writes a Pilot's external IDs to the database.protected voidwriteRatings(int id, Collection<String> ratings, String db, boolean doClear) Writes a Pilot's equipment type ratings to the database.protected voidwriteRoles(int id, Collection<Role> roles) Writes a Pilot's security roles to the database.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.
-
Constructor Details
-
PilotWriteDAO
Initializes the Data Access Object.- Parameters:
c- the JDBC connection to use
-
-
Method Details
-
writeRoles
Writes a Pilot's security roles to the database.- Parameters:
id- the Pilot's database IDroles- a Collection of security role names- Throws:
SQLException- if a JDBC error occurs
-
writeRatings
protected void writeRatings(int id, Collection<String> ratings, String db, boolean doClear) throws SQLException Writes a Pilot's equipment type ratings to the database.- Parameters:
id- the Pilot's database IDratings- a Collection of aircraft typesdb- the database to write todoClear- TRUE if existing ratings should be cleared, otherwise FALSE- Throws:
SQLException- if a JDBC error occurs
-
writeExternalIDs
protected void writeExternalIDs(int id, Map<ExternalID, String> addrs, String db, boolean doClear) throws SQLException Writes a Pilot's external IDs to the database.- Parameters:
id- the Pilot's database IDaddrs- a Map of IM addresses, keyed by typedb- the database to write todoClear- TRUE if existing ratings should be cleared, otherwise FALSE- Throws:
SQLException- if a JDBC error occurs
-
writeAlias
Writes a Pilot's alias to the AUTH_ALIAS table if present.- Parameters:
id- the Pilot's database IDaliases- an array of aliases- Throws:
SQLException- if a JDBC error occurs
-
setStatus
Updates a Pilots' status in the database.- Parameters:
id- the pilot database IDstatus- the PilotStatus- Throws:
DAOException- if a JDBC error occurs
-