Class TransactionManager

java.lang.Object
my.edu.tarc.dco.bookrentalpos.Manager<Transaction>
my.edu.tarc.dco.bookrentalpos.TransactionManager

public class TransactionManager
extends Manager<Transaction>
Used to load all transactions from the database
Version:
1.0
Author:
Looz
  • Field Details

  • Constructor Details

  • Method Details

    • reload

      public void reload()
      Reload all the data from database
      Specified by:
      reload in class Manager<Transaction>
    • add

      public boolean add​(Transaction trans)
      this function accepts transaction object where there is no id and date`
      Specified by:
      add in class Manager<Transaction>
      Parameters:
      trans - accept Transaction object
      Returns:
      Return true if the transaction was added into database successfully
    • getById

      public Transaction getById​(int id)
      get Transaction by ID
      Specified by:
      getById in class Manager<Transaction>
      Parameters:
      id - Transaction ID
      Returns:
      Transaction reference object if found, null if nothing was found
    • getCache

      public Transaction[] getCache()
      Get a cache of the transaction list
      Note: for the count of data you should get it from TransactionManager.getTransactionCount()
      Specified by:
      getCache in class Manager<Transaction>
      Returns:
      an copy of Transaction list array
      See Also:
      getTransactionCount()
    • update

      public boolean update​(Transaction ref)
      Update transaction table in database
      Specified by:
      update in class Manager<Transaction>
      Parameters:
      ref - Transaction reference object preferably from Transaction.getById
      Returns:
      true if update was successful, false if otherwise
      See Also:
      getById(int)
    • remove

      public boolean remove​(Transaction trans)
      Remove transaction of specific trans from database
      Specified by:
      remove in class Manager<Transaction>
      Parameters:
      trans - transaction trans
      Returns:
      true if it was removed successfully, false if otherwise
    • updateBookReservationStatus

      public void updateBookReservationStatus()
      This function is suppose to update the reservation status of all the books
      Criteria as stated below:
      - If the book is not reserved, dont touch it
      - If the book is reserved, check if the book is being rented at the moment
      - If the book is rented, dont touch it
      - If the book is not rented, or in other words it was returned, check if (return date - current date) > 7 days
      - If > 7 days, set reserved status as false
      - If !(> 7 days), dont touch it
    • getBookLastRentTransaction

      public RentTransaction getBookLastRentTransaction​(Book bk)
      This function returns transaction of the last renting record of a specific book
      Parameters:
      bk - book object to be checked
      Returns:
      Transaction reference object to the last renting record, return null if book is null or the book is not currently rented
    • getBookLastReservedTransaction

      public Transaction getBookLastReservedTransaction​(Book bk)
      This function returns Transaction of the last reserve record of a specific book
      Parameters:
      bk - book object to be checked
      Returns:
      Transaction reference object to the last reserve record, return null if book is null or the book is not reserved
    • getMemberActiveReservations

      public ArrayList<Book> getMemberActiveReservations​(Member mem)
      This function return an array list of books currently reserved by this member
      Parameters:
      mem - member object
      Returns:
      an arraylist of book reference from BookManager
    • getTransactionsByMember

      public ArrayList<Transaction> getTransactionsByMember​(Member memID)
      This function returns an array list of transactions for specific member id
      Parameters:
      memID - member id
      Returns:
      an array list of reference to transactions
    • getTransactionsByMember

      public ArrayList<Transaction> getTransactionsByMember​(Member mem, Date startDate, Date endDate)
      This function have the same behavior as getTransactionsByMemberID(int) except it accepts startDate and endDate filter
      Parameters:
      mem - member object
      startDate - date filter to filter out record before this date
      endDate - date filter to filter out record after this date
      Returns:
      an array list of reference to transactions
      See Also:
      getTransactionsByMember(Member)
    • getTransactionByStaff

      public ArrayList<Transaction> getTransactionByStaff​(Staff staff, Date startDate, Date endDate)
      This function returns an array list of transactions for specific staff ID
      Parameters:
      staff - staff Object
      startDate - add filter to the records by specifying start date
      endDate - add filter to the records by specifying end date
      Returns:
      an array list of transactions
    • getTransactionByDate

      public ArrayList<Transaction> getTransactionByDate​(Date startDate, Date endDate)
      This function returns an array list of transactions between specified date range
      Parameters:
      startDate - add filter to the records by specifying start date
      endDate - add filter to the records by specifying end date
      Returns:
      an arraylist of transaction
    • getTransactionCount

      public int getTransactionCount()
      Returns:
      transaction count loaded from database
    • getByName

      public Transaction getByName​(String name)
      Not implemented
      Reason: Transaction do not use the name field
      Specified by:
      getByName in class Manager<Transaction>
      Parameters:
      name - Not implemented
      Returns:
      null