Class DatabaseManager

Object
DatabaseManager

public class DatabaseManager extends Object
Controller class for handling all logics related to the Database
Version:
1.0
Author:
Lee Juin
  • Constructor Details

    • DatabaseManager

      public DatabaseManager()
      Constructor
  • Method Details

    • initializeCineplexData

      public static boolean initializeCineplexData()
      Method to load initial cineplex data into database
      Returns:
      true if initialization is successful, false otherwise
    • initializeCinemaData

      public static Cinema initializeCinemaData(int choice)
      Method to load inital cinema data into database
      Parameters:
      choice - is the choice of CinemaClass to be initialized
      Returns:
      Cinema instance created
    • initializeSeatData

      public static ArrayList<Seat> initializeSeatData(CinemaClass cinemaClass)
      Method to initialize the initial seat data into database
      Parameters:
      cinemaClass - is the CinemaClass of the cinema the seats belong to
      Returns:
      ArrayList of Seat instances created
    • initializeMovieScheduleData

      public static boolean initializeMovieScheduleData()
      Method to initialize the initial movie schedule data into database
      Returns:
      true if initialization is successful, false otherwise
    • initializeMovie

      public static boolean initializeMovie()
      Method to initialize the initial movie data into database
      Returns:
      true if initialization is successful, false otherwise
    • initalizeCinemaStaff

      public static boolean initalizeCinemaStaff()
      Method to initialize the initial cinema staff data into database
      Returns:
      true if initialization is successful, false otherwise
    • initializePrices

      public static void initializePrices()
      Method to initialize the default prices
    • saveUpdateToDatabase

      public static <K, V> void saveUpdateToDatabase(K UUID, V object, HashMap<K,V> data)
      Generic helper function to save written changes into the database
      Type Parameters:
      K - is the generic form for key
      V - is the generic form for value
      Parameters:
      UUID - is the unique ID of the object to be updated
      object - is the object to be updated
      data - is the HashMap database to be updated
    • resetDatabase

      public static void resetDatabase()
      Helper function to reset the database
    • reloadDatabase

      public static void reloadDatabase()
      Helper function to reload the database. Useful upon saved changes
    • saveUpdateToBuffer

      public static <K, V> void saveUpdateToBuffer(K UUID, V object, HashMap<K,V> data)
      Similar to saveUpdateToDatabase, except save to buffer instead. Useful for updating large data
      Type Parameters:
      K - is the generic form for key
      V - is the generic form for value
      Parameters:
      UUID - is the unique ID of the object to be updated
      object - is the object to be updated
      data - is the HashMap database to be updated