Class GetFlightReports
java.lang.Object
org.deltava.dao.DAO
org.deltava.dao.GetFlightReports
- Direct Known Subclasses:
GetFlightReportACARS
A Data Access Object to load Flight Reports.
- Since:
- 1.0
- Version:
- 12.2
- 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
ConstructorsConstructorDescriptionInitializes the DAO with a given JDBC connection. -
Method Summary
Modifier and TypeMethodDescriptionprotected static List<FlightReport> Helper method to load PIREP data.Returns a PIREP with a particular database ID.Returns an ACARS-logged PIREP with a particular ACARS Flight ID.getByAssignment(int id, String dbName) Returns all Flight Reports associated with a particular Flight Assignment.getByEvent(int id, String dbName) Returns all Flight Reports associated with a particular Online Event.getByNetwork(OnlineNetwork net, String dbName) Returns approved Flight Reports flown on a particular Online Network.getByPilot(int id, LogbookSearchCriteria criteria) Returns all Flight Reports for a particular Pilot, using a sort column.getByStatus(Collection<FlightStatus> status, String orderBy) Returns all Flight Reports in particular statuses.Returns all Flight Reports associated with a particular Pilot and Flight Tour.voidgetCaptEQType(Collection<FlightReport> pireps) Populates the Equipment Types a collection of PIREPs counts towards promotion in.intgetCheckRideQueueSize(String eqType, boolean includeAcademy) Returns the number of Flight Reports awaiting disposition.getDiversion(Airport a, int pilotID, String db) Retrieves held/submitted Flight diversions for a particular Pilot.Loads a Draft Flight Report.getDraftReports(int pilotID, RoutePair rp, String dbName) Returns Draft Flight Reports for a particular Pilot (with optional city pair).getElite(int id) Returns the Elite program score for a Flight Report.getEliteFlights(int id, int year) Returns all Flight Reports for a given Elite program year.intReturns the number of held Flight Reports for a particular Pilot.getLogbookCalendar(int id, String dbName, Instant startDate, int days) Loads all Flight Reports for a Pilot for a particular date range.voidgetOnlineTotals(Map<Integer, Pilot> pilots, String dbName) Returns online and ACARS legs/hours for a group of Pilots.voidgetOnlineTotals(Pilot p, String dbName) Gets online and ACARS legs/hours for a particular Pilot.getRoutePairs(int pilotID, int days) Returns the city pairs flown by a particular Pilot.voidloadCaptEQTypes(int pilotID, Collection<FlightReport> pireps, String dbName) Load promotion flags for a large number of Flight Reports from a single Pilot.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
-
GetFlightReports
Initializes the DAO with a given JDBC connection.- Parameters:
c- the JDBC connection to use
-
-
Method Details
-
get
Returns a PIREP with a particular database ID.- Parameters:
id- the database IDdbName- the database Name- Returns:
- the Flight Report, or null if not found
- Throws:
DAOException- if a JDBC error occurs
-
getACARS
Returns an ACARS-logged PIREP with a particular ACARS Flight ID.- Parameters:
dbName- the database NameacarsID- 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 codesorderBy- the ORDER BY SQL statement- Returns:
- a List of FlightReports in the specified statuses
- Throws:
DAOException- if a JDBC error occurs
-
getCheckRideQueueSize
Returns the number of Flight Reports awaiting disposition.- Parameters:
eqType- the equipment type, or null if allincludeAcademy- 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
Returns the number of held Flight Reports for a particular Pilot.- Parameters:
pilotID- the Pilot's database IDdbName- the database name- Returns:
- the number of Flight Reports in HOLD status
- Throws:
DAOException- if a JDBC error occurs
-
getByAssignment
Returns all Flight Reports associated with a particular Flight Assignment.- Parameters:
id- the Flight Assignment database IDdbName- the database name- Returns:
- a List of FlightReports
- Throws:
DAOException- if a JDBC error occurs
-
getByNetwork
Returns approved Flight Reports flown on a particular Online Network.- Parameters:
net- the OnlineNetworkdbName- the database name- Returns:
- a List of FlightReport beans
- Throws:
DAOException- if a JDBC error occurs
-
getByEvent
Returns all Flight Reports associated with a particular Online Event.- Parameters:
id- the Online Event database IDdbName- the database name- Returns:
- a List of FlightReports
- Throws:
DAOException- if a JDBC error occurs
-
getByTour
Returns all Flight Reports associated with a particular Pilot and Flight Tour.- Parameters:
pilotID- the Pilot database IDtourID- the Tour database IDdbName- 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 IDdbName- the database namestartDate- the start datedays- the number of days forward to include- Returns:
- a List of FlightReports
- Throws:
DAOException- if a JDBC error occurs
-
getEliteFlights
Returns all Flight Reports for a given Elite program year.- Parameters:
id- the Pilot database IDyear- the Elite Program year- Returns:
- a List of FlightREports
- Throws:
DAOException- if a JDBC error occurs
-
getByPilot
Returns all Flight Reports for a particular Pilot, using a sort column.- Parameters:
id- the Pilot database IDcriteria- the search criteria- Returns:
- a List of FlightReports
- Throws:
DAOException- if a JDBC error occurs
-
getOnlineTotals
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
Returns online and ACARS legs/hours for a group of Pilots.- Parameters:
pilots- a Map of Pilot objects to populate with resultsdbName- the database name- Throws:
DAOException- if a JDBC error occurs
-
getDraft
Loads a Draft Flight Report.- Parameters:
id- the Flight Report database IDdbName- 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 IDrp- the RoutePair, or null if nonedbName- the database Name- Returns:
- a List of Draft FlightReports matching the above criteria
- Throws:
DAOException- if a JDBC error occurs
-
getDiversion
Retrieves held/submitted Flight diversions for a particular Pilot.- Parameters:
a- the Airport diverted topilotID- the Pilot's database IDdb- the database- Returns:
- a FlightReport, or null if not found
- Throws:
DAOException- if a JDBC error occurs
-
getRoutePairs
Returns the city pairs flown by a particular Pilot.- Parameters:
pilotID- the Pilot database IDdays- the number of days back to search- Returns:
- a Collection of RoutePair beans
- Throws:
DAOException- if a JDBC error occurs
-
execute
Helper method to load PIREP data.- Parameters:
ps- a PreparedStatement- Returns:
- a List of FlightReport beans
- Throws:
SQLException- if an error occurs
-
getCaptEQType
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
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 IDpireps- a Collection of FlightReport beansdbName- the database name- Throws:
DAOException- if a JDBC error occurs
-