Class GetApplicant

java.lang.Object
org.deltava.dao.DAO
org.deltava.dao.GetApplicant
All Implemented Interfaces:
PersonUniquenessDAO

public class GetApplicant extends DAO implements PersonUniquenessDAO
A Data Access Object to read Applicant data.
Since:
1.0
Version:
11.1
Author:
Luke
  • Constructor Details

    • GetApplicant

      public GetApplicant(Connection c)
      Initialize the Data Access Object.
      Parameters:
      c - the JDBC connection to use
  • Method Details

    • get

      public Applicant get(int id) throws DAOException
      Loads an Applicant from the database.
      Parameters:
      id - the Applicant's database ID
      Returns:
      an Applicant, or null if not found
      Throws:
      DAOException - if a JDBC error occurs
    • getByName

      public Collection<Applicant> getByName(String fName, String lName) throws DAOException
      Searches for pending Applicants by first/last name.
      Parameters:
      fName - the first name
      lName - the last name
      Returns:
      a Collection of Applicants
      Throws:
      DAOException - if a JDBC error occurs
    • getByPilotID

      public Applicant getByPilotID(int pilotID) throws DAOException
      Loads an Applicant record for an existing Pilot from the database.
      Parameters:
      pilotID - the database ID of the Applicant's Pilot record
      Returns:
      an Applicant, or null if not found
      Throws:
      DAOException - if a JDBC error occurs
    • getByID

      public Map<Integer, Applicant> getByID(Collection<?> ids, String tableName) throws DAOException
      Returns a Map of applicant based on a group of database IDs. This is typically called by a Water Cooler thread/channel list command.
      Parameters:
      ids - a Collection of database IDs. These can either be Integers, or UserData beans
      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 Applicants, indexed by the pilot code
      Throws:
      DAOException - if a JDBC error occurs
    • get

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

      public Map<Integer, Applicant> get(UserDataMap udm) throws DAOException
      Returns Applicant objects which may be in another Airline's database.
      Specified by:
      get in interface PersonUniquenessDAO
      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
    • getFromDirectory

      public Applicant getFromDirectory(String directoryName) throws DAOException
      Loads an applicant based on a directory name.
      Parameters:
      directoryName - the directory name.
      Returns:
      an Applicant, or null if not found
      Throws:
      DAOException - if a JDBC error occurs
    • getByLetter

      public List<Applicant> getByLetter(String letter) throws DAOException
      Returns Applicants whose last name begins with a particular letter.
      Parameters:
      letter - the first Letter of the last name
      Returns:
      a List of Applicants
      Throws:
      DAOException - if a JDBC error occurs
      IllegalArgumentException - if letter isn't a letter according to Character.isLetter(char)
      NullPointerException - if letter is null
    • getByStatus

      public List<Applicant> getByStatus(ApplicantStatus status, String orderBy) throws DAOException
      Returns all Applicants with a particular status.
      Parameters:
      status - the ApplicantStatus
      orderBy - the sort column
      Returns:
      a List of Applicants
      Throws:
      DAOException - if a JDBC error occurs
    • getByEquipmentType

      public List<Applicant> getByEquipmentType(String eqType) throws DAOException
      Returns all Applicants hired into a particular equipment program.
      Parameters:
      eqType - the equipment program code
      Returns:
      a List of Applicants
      Throws:
      DAOException - if a JDBC error occurs
    • isIPRegistered

      public boolean isIPRegistered(String addr, int days) throws DAOException
      Checks if this IP address had been used to register in the past few days.
      Parameters:
      addr - the IP address
      days - the number of days to check
      Returns:
      TRUE if the IP address was used, otherwise FALSE
      Throws:
      DAOException - if a JDBC error occurs
    • checkUnique

      public Collection<Integer> checkUnique(Person p, String dbName) throws DAOException
      Checks if an Applicant is unique, by checking the first/last names and the e-mail address. This will not return a match against rejected Applicants.
      Specified by:
      checkUnique in interface PersonUniquenessDAO
      Parameters:
      p - the Person
      dbName - the database to search
      Returns:
      a Collection of database IDs
      Throws:
      DAOException - if a JDBC error occurs
    • checkUnique

      public Collection<Integer> checkUnique(Person p, String dbName, int days) throws DAOException
      Checks if an Applicant is unique, by checking the first/last names and the e-mail address. This will not return a match against rejected Applicants.
      Specified by:
      checkUnique in interface PersonUniquenessDAO
      Parameters:
      p - the Person
      dbName - the database to search
      days - restrict uniqueness search to users created in the last number of days, or -1 for all
      Returns:
      a Collection of database IDs
      Throws:
      DAOException - if a JDBC error occurs
    • checkAddress

      public Collection<Integer> checkAddress(IPBlock addrBlock, String dbName) throws DAOException
      Searches for Applicants registering from the same TCP/IP network. If the Applicant has been hired, this will return the Pilot database ID, instead of the Applicant database ID.
      Parameters:
      addrBlock - the network block
      dbName - the database name
      Returns:
      a Collection of Database IDs as Integers
      Throws:
      DAOException - if a JDBC error occurs
    • checkSoundex

      public Collection<Integer> checkSoundex(Person usr, String dbName) throws DAOException
      Performs a soundex search on a Person's last name to detect possible matches. The soundex implementation is dependent on the capabilities of the underlying database engine, and is not guaranteed to be consistent (or even supported) across different database servers.
      Specified by:
      checkSoundex in interface PersonUniquenessDAO
      Parameters:
      usr - the Person to check for
      dbName - the database name
      Returns:
      a Collection of Database IDs as Integers
      Throws:
      DAOException - if a JDBC error occurs
    • getAutoRejected

      public Collection<Applicant> getAutoRejected(int hours) throws DAOException
      Retrieves Applicants automatically rejected more than a particular number of hours ago.
      Parameters:
      hours - the number of hours ago
      Returns:
      a Collection of Applicants
      Throws:
      DAOException - if a JDBC error occurs