- java.lang.Object
-
- stores.DataStore
-
public class DataStore extends java.lang.Object
TheDataStore
class provides utility methods for managing data storage within the application. It offers methods to initialize the data store, import and export data to and from the file system, and interact with data maps for various data types.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.Map<java.lang.Integer,Camp>
campData
AMap
containing a numerical Camp ID as the key andCamp
objects as the valueprivate static java.util.Map<java.lang.String,Committee>
committeeData
AMap
containing comittee ID as the key andCommittee
objects as the value.private static java.util.Map<java.lang.Integer,Enquiry>
enquiryData
AMap
containing a numerical Enquiry ID as the key andEnquiry
objects as the valueprivate static IFileDataService
fileDataService
TheIFileDataService
instance used for data operationsprivate static java.util.Map<java.lang.String,java.lang.String>
filePathsMap
AMap
containing file paths for various data types.private static java.util.Map<java.lang.String,Staff>
staffData
AMap
containing staff ID as the key andStaff
objects as the value.private static java.util.Map<java.lang.String,Student>
studentData
AMap
containing student ID as the key andStudent
objects as the value.private static java.util.Map<java.lang.Integer,Suggestion>
suggestionData
AMap
containing a numerical Suggestion ID as the key andSuggestion
objects as the valueprivate static java.util.Map<java.lang.String,User>
userData
AMap
containing user ID as the key andUser
objects as the value
-
Constructor Summary
Constructors Modifier Constructor Description private
DataStore()
Private constructor to prevent instantiation of the class
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.Map<java.lang.Integer,Camp>
getCampData()
Gets the camp data mapstatic java.util.Map<java.lang.String,Committee>
getCommitteeData()
Gets the committee data mapstatic java.util.Map<java.lang.Integer,Enquiry>
getEnquiryData()
Gets the request data mapstatic java.util.Map<java.lang.String,Staff>
getStaffData()
Gets the staff data mapstatic java.util.Map<java.lang.String,Student>
getStudentData()
Gets the student data mapstatic java.util.Map<java.lang.Integer,Suggestion>
getSuggestionData()
Gets the suggestion data mapstatic java.util.Map<java.lang.String,User>
getUserData()
Get the users data mapstatic boolean
initDataStore(IFileDataService fileDataService, java.util.Map<java.lang.String,java.lang.String> filePathsMap)
Initializes the DataStore by setting up the file data service, file paths map, and importing data from the file systemstatic boolean
saveData()
Save the data from the DataStore to the file system.static void
setCampData(java.util.Map<java.lang.Integer,Camp> campData)
Sets the camp data map and saves the data to the file system.static void
setCommitteeData(java.util.Map<java.lang.String,Committee> committeeData)
Sets the committee data map and saves the data to the file system.static void
setEnquiryData(java.util.Map<java.lang.Integer,Enquiry> enquiryData)
Sets the request data map and saves the data to the file system.static void
setStaffData(java.util.Map<java.lang.String,Staff> staffData)
Sets the staff data map and saves the data to the file system.static void
setStudentData(java.util.Map<java.lang.String,Student> studentData)
Sets the student data map and saves the data to the file system.static void
setSuggestionData(java.util.Map<java.lang.Integer,Suggestion> suggestionData)
Sets the suggestion data map and saves the data to the file system.static void
setUserData(java.util.Map<java.lang.String,User> userData)
Sets the user data map and saves the data to the file system.
-
-
-
Field Detail
-
fileDataService
private static IFileDataService fileDataService
TheIFileDataService
instance used for data operations
-
filePathsMap
private static java.util.Map<java.lang.String,java.lang.String> filePathsMap
AMap
containing file paths for various data types.
-
userData
private static java.util.Map<java.lang.String,User> userData
AMap
containing user ID as the key andUser
objects as the value
-
studentData
private static java.util.Map<java.lang.String,Student> studentData
AMap
containing student ID as the key andStudent
objects as the value.
-
staffData
private static java.util.Map<java.lang.String,Staff> staffData
AMap
containing staff ID as the key andStaff
objects as the value.
-
committeeData
private static java.util.Map<java.lang.String,Committee> committeeData
AMap
containing comittee ID as the key andCommittee
objects as the value.
-
campData
private static java.util.Map<java.lang.Integer,Camp> campData
AMap
containing a numerical Camp ID as the key andCamp
objects as the value
-
enquiryData
private static java.util.Map<java.lang.Integer,Enquiry> enquiryData
AMap
containing a numerical Enquiry ID as the key andEnquiry
objects as the value
-
suggestionData
private static java.util.Map<java.lang.Integer,Suggestion> suggestionData
AMap
containing a numerical Suggestion ID as the key andSuggestion
objects as the value
-
-
Method Detail
-
initDataStore
public static boolean initDataStore(IFileDataService fileDataService, java.util.Map<java.lang.String,java.lang.String> filePathsMap)
Initializes the DataStore by setting up the file data service, file paths map, and importing data from the file system- Parameters:
fileDataService
- theIFileDataService
instance to use for data operationsfilePathsMap
- theMap
containing file paths for various data types- Returns:
true
if the initialisation is successful,false
otherwise
-
saveData
public static boolean saveData()
Save the data from the DataStore to the file system.- Returns:
true
if the data is saved successfully,false
otherwise
-
getUserData
public static java.util.Map<java.lang.String,User> getUserData()
Get the users data map- Returns:
- a
Map
containing user ID as the key andUser
objects as the value
-
setUserData
public static void setUserData(java.util.Map<java.lang.String,User> userData)
Sets the user data map and saves the data to the file system.- Parameters:
userData
- to set aMap
containing user ID as the key andUser
objects as the value
-
getStudentData
public static java.util.Map<java.lang.String,Student> getStudentData()
Gets the student data map- Returns:
- a
Map
containing student ID as the key andStudent
objects as the value
-
setStudentData
public static void setStudentData(java.util.Map<java.lang.String,Student> studentData)
Sets the student data map and saves the data to the file system.- Parameters:
studentData
- to set aMap
containing student ID as the key andStudent
objects as the value
-
getStaffData
public static java.util.Map<java.lang.String,Staff> getStaffData()
Gets the staff data map- Returns:
- a
Map
containing staff ID as the key andStaff
objects as the value
-
setStaffData
public static void setStaffData(java.util.Map<java.lang.String,Staff> staffData)
Sets the staff data map and saves the data to the file system.- Parameters:
staffData
- to set aMap
containing staff ID as the key andStaff
objects as the value
-
getCommitteeData
public static java.util.Map<java.lang.String,Committee> getCommitteeData()
Gets the committee data map- Returns:
- a
Map
containing committee ID as the key andCommittee
objects as the value
-
setCommitteeData
public static void setCommitteeData(java.util.Map<java.lang.String,Committee> committeeData)
Sets the committee data map and saves the data to the file system.- Parameters:
committeeData
- to set aMap
containing committee ID as the key andCommittee
objects as the value
-
getCampData
public static java.util.Map<java.lang.Integer,Camp> getCampData()
Gets the camp data map- Returns:
- a
Map
containing a numeric camp ID as the key andCamp
objects as the value
-
setCampData
public static void setCampData(java.util.Map<java.lang.Integer,Camp> campData)
Sets the camp data map and saves the data to the file system.- Parameters:
campData
- to set aMap
containing a numeric camp ID as the key andCamp
objects as the value
-
getEnquiryData
public static java.util.Map<java.lang.Integer,Enquiry> getEnquiryData()
Gets the request data map- Returns:
- a
Map
containing a numeric enquiry ID as the key andEnquiry
objects as the value
-
setEnquiryData
public static void setEnquiryData(java.util.Map<java.lang.Integer,Enquiry> enquiryData)
Sets the request data map and saves the data to the file system.- Parameters:
enquiryData
- to set aMap
containing a numeric enquiry ID as the key andEnquiry
objects as the value
-
getSuggestionData
public static java.util.Map<java.lang.Integer,Suggestion> getSuggestionData()
Gets the suggestion data map- Returns:
- a
Map
containing a numeric suggestion ID as the key andSuggestion
objects as the value
-
setSuggestionData
public static void setSuggestionData(java.util.Map<java.lang.Integer,Suggestion> suggestionData)
Sets the suggestion data map and saves the data to the file system.- Parameters:
suggestionData
- to set aMap
containing a numeric suggestion ID as the key andSuggestion
objects as the value
-
-