Package src.database
Class Database
Object
Database
The database of the application.
A buffer in the form of HashMap is used for handling intermediary data
transfers.
DAT files are used for storing persistent data.
This class is equipped with functions to facilitate the read and write
between program, buffer and the DAT database.
- Version:
- 1.0
- Author:
- Lee Juin
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic HashMap<String,BookingHistory> Booking History Model in databaseCinema Model in databasestatic HashMap<String,CinemaStaff> Cinema Staff in databaseCineplex Model in databaseAll the holidaysMovie Model in databaseMovie Goer in databasestatic HashMap<String,MovieReview> Movie Review in databasestatic HashMap<String,MovieSchedule> Movie Schedule Model in databasestatic HashMap<String,MovieTicket> Movie Ticket in databasestatic intTotal number of couple rows in a cinemastatic intTotal number of rows in a cinemaPayment Model in databasestatic PermissionAll the permissions of a movie goerstatic intPre-defined variables for the number of rows of seats in a platinum cinemastatic intPre-defined variables for the number of seats per row in a platinum cinemastatic PricesAll the price weights of cinema class, movie goer age, seat type, movie typeSeat Model in databasestatic intTotal number of seats for every cinema -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <K,V> String getKeyByValue(V value, HashMap<K, V> data) Method to retrieve the key of a value in the HashMap databasegetKeyList(Collection keySet) Method to return an ArrayList of HashMap keys for the collectionkeySetstatic <K,V> V getValueByKey(K key, HashMap<K, V> data) Method to retrieve the value of a key in the HashMap databasestatic <V> ArrayList<V>getValueList(Collection valueSet) Method to return an ArrayList of HashMap values for the collectionvalueSetstatic booleanMethod to read serialized data from database filestatic booleanMethod to reload the database.static voidMethod to reset the databasestatic booleanMethod to write serialized data into database filestatic booleanMethod to save all changes to database.
-
Field Details
-
CINEPLEX
Cineplex Model in database -
CINEMA
Cinema Model in database -
SEAT
Seat Model in database -
MOVIE_SCHEDULE
Movie Schedule Model in database -
BOOKING_HISTORY
Booking History Model in database -
PAYMENT
Payment Model in database -
MOVIE
Movie Model in database -
MOVIE_GOER
Movie Goer in database -
MOVIE_REVIEW
Movie Review in database -
CINEMA_STAFF
Cinema Staff in database -
MOVIE_TICKET
Movie Ticket in database -
totalNumOfSeats
public static int totalNumOfSeatsTotal number of seats for every cinema -
numOfRows
public static int numOfRowsTotal number of rows in a cinema -
numOfCoupleRows
public static int numOfCoupleRowsTotal number of couple rows in a cinema -
holidays
All the holidays -
PRICES
All the price weights of cinema class, movie goer age, seat type, movie type -
PERMISSION
All the permissions of a movie goer -
platinumNumOfRow
public static int platinumNumOfRowPre-defined variables for the number of rows of seats in a platinum cinema -
platinumNumOfSeatsPerRow
public static int platinumNumOfSeatsPerRowPre-defined variables for the number of seats per row in a platinum cinema
-
-
Constructor Details
-
Database
public Database()Constructor for database. Call this when startup to load all data from DAT into HashMap buffer
-
-
Method Details
-
readData
Method to read serialized data from database file- Parameters:
modelType- is the model to be read- Returns:
trueif read is successful;falseotherwise
-
writeData
Method to write serialized data into database file- Parameters:
modelType- is the model to be written- Returns:
trueif write is successful;falseotherwise
-
remountDatabase
public static boolean remountDatabase()Method to reload the database. Useful when a change was recently made and user requires immediate reflected changes.- Returns:
truewhen reload is successful;falseotherwise
-
writeToDatabase
public static boolean writeToDatabase()Method to save all changes to database. Useful on first load to save dummy data.- Returns:
- {code true} if write is successful;
falseotherwise
-
resetDatabase
public static void resetDatabase()Method to reset the database -
getKeyList
Method to return an ArrayList of HashMap keys for the collectionkeySet- Parameters:
keySet- a HashMap keys collection- Returns:
- ArrayList of
Stringcontaining HashMap keys
-
getValueList
Method to return an ArrayList of HashMap values for the collectionvalueSet- Type Parameters:
V- generic form for value- Parameters:
valueSet- a HashMap values collection- Returns:
- ArrayList of
Valuecontaining HashMap values
-
getValueByKey
Method to retrieve the value of a key in the HashMap database- Type Parameters:
K- generic form for KeyV- generic form for value- Parameters:
key- the key we wish to search the value fordata- the database- Returns:
Vthat is the value of the keykey
-
getKeyByValue
Method to retrieve the key of a value in the HashMap database- Type Parameters:
K- generic form for KeyV- generic form for value- Parameters:
value- the value we wish to search the key fordata- the database- Returns:
Stringthat is the key of the valuevalue
-