- java.lang.Object
-
- stores.DataStore
-
public class DataStore extends java.lang.ObjectTheDataStoreclass 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>campDataAMapcontaining a numerical Camp ID as the key andCampobjects as the valueprivate static java.util.Map<java.lang.String,Committee>committeeDataAMapcontaining comittee ID as the key andCommitteeobjects as the value.private static java.util.Map<java.lang.Integer,Enquiry>enquiryDataAMapcontaining a numerical Enquiry ID as the key andEnquiryobjects as the valueprivate static IFileDataServicefileDataServiceTheIFileDataServiceinstance used for data operationsprivate static java.util.Map<java.lang.String,java.lang.String>filePathsMapAMapcontaining file paths for various data types.private static java.util.Map<java.lang.String,Staff>staffDataAMapcontaining staff ID as the key andStaffobjects as the value.private static java.util.Map<java.lang.String,Student>studentDataAMapcontaining student ID as the key andStudentobjects as the value.private static java.util.Map<java.lang.Integer,Suggestion>suggestionDataAMapcontaining a numerical Suggestion ID as the key andSuggestionobjects as the valueprivate static java.util.Map<java.lang.String,User>userDataAMapcontaining user ID as the key andUserobjects as the value
-
Constructor Summary
Constructors Modifier Constructor Description privateDataStore()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 booleaninitDataStore(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 booleansaveData()Save the data from the DataStore to the file system.static voidsetCampData(java.util.Map<java.lang.Integer,Camp> campData)Sets the camp data map and saves the data to the file system.static voidsetCommitteeData(java.util.Map<java.lang.String,Committee> committeeData)Sets the committee data map and saves the data to the file system.static voidsetEnquiryData(java.util.Map<java.lang.Integer,Enquiry> enquiryData)Sets the request data map and saves the data to the file system.static voidsetStaffData(java.util.Map<java.lang.String,Staff> staffData)Sets the staff data map and saves the data to the file system.static voidsetStudentData(java.util.Map<java.lang.String,Student> studentData)Sets the student data map and saves the data to the file system.static voidsetSuggestionData(java.util.Map<java.lang.Integer,Suggestion> suggestionData)Sets the suggestion data map and saves the data to the file system.static voidsetUserData(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
TheIFileDataServiceinstance used for data operations
-
filePathsMap
private static java.util.Map<java.lang.String,java.lang.String> filePathsMap
AMapcontaining file paths for various data types.
-
userData
private static java.util.Map<java.lang.String,User> userData
AMapcontaining user ID as the key andUserobjects as the value
-
studentData
private static java.util.Map<java.lang.String,Student> studentData
AMapcontaining student ID as the key andStudentobjects as the value.
-
staffData
private static java.util.Map<java.lang.String,Staff> staffData
AMapcontaining staff ID as the key andStaffobjects as the value.
-
committeeData
private static java.util.Map<java.lang.String,Committee> committeeData
AMapcontaining comittee ID as the key andCommitteeobjects as the value.
-
campData
private static java.util.Map<java.lang.Integer,Camp> campData
AMapcontaining a numerical Camp ID as the key andCampobjects as the value
-
enquiryData
private static java.util.Map<java.lang.Integer,Enquiry> enquiryData
AMapcontaining a numerical Enquiry ID as the key andEnquiryobjects as the value
-
suggestionData
private static java.util.Map<java.lang.Integer,Suggestion> suggestionData
AMapcontaining a numerical Suggestion ID as the key andSuggestionobjects 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- theIFileDataServiceinstance to use for data operationsfilePathsMap- theMapcontaining file paths for various data types- Returns:
trueif the initialisation is successful,falseotherwise
-
saveData
public static boolean saveData()
Save the data from the DataStore to the file system.- Returns:
trueif the data is saved successfully,falseotherwise
-
getUserData
public static java.util.Map<java.lang.String,User> getUserData()
Get the users data map- Returns:
- a
Mapcontaining user ID as the key andUserobjects 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 aMapcontaining user ID as the key andUserobjects as the value
-
getStudentData
public static java.util.Map<java.lang.String,Student> getStudentData()
Gets the student data map- Returns:
- a
Mapcontaining student ID as the key andStudentobjects 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 aMapcontaining student ID as the key andStudentobjects as the value
-
getStaffData
public static java.util.Map<java.lang.String,Staff> getStaffData()
Gets the staff data map- Returns:
- a
Mapcontaining staff ID as the key andStaffobjects 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 aMapcontaining staff ID as the key andStaffobjects as the value
-
getCommitteeData
public static java.util.Map<java.lang.String,Committee> getCommitteeData()
Gets the committee data map- Returns:
- a
Mapcontaining committee ID as the key andCommitteeobjects 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 aMapcontaining committee ID as the key andCommitteeobjects as the value
-
getCampData
public static java.util.Map<java.lang.Integer,Camp> getCampData()
Gets the camp data map- Returns:
- a
Mapcontaining a numeric camp ID as the key andCampobjects 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 aMapcontaining a numeric camp ID as the key andCampobjects as the value
-
getEnquiryData
public static java.util.Map<java.lang.Integer,Enquiry> getEnquiryData()
Gets the request data map- Returns:
- a
Mapcontaining a numeric enquiry ID as the key andEnquiryobjects 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 aMapcontaining a numeric enquiry ID as the key andEnquiryobjects as the value
-
getSuggestionData
public static java.util.Map<java.lang.Integer,Suggestion> getSuggestionData()
Gets the suggestion data map- Returns:
- a
Mapcontaining a numeric suggestion ID as the key andSuggestionobjects 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 aMapcontaining a numeric suggestion ID as the key andSuggestionobjects as the value
-
-