Package stores

Class DataStore


  • public class DataStore
    extends java.lang.Object
    The DataStore 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
      A Map containing a numerical Camp ID as the key and Camp objects as the value
      private static java.util.Map<java.lang.String,​Committee> committeeData
      A Map containing comittee ID as the key and Committee objects as the value.
      private static java.util.Map<java.lang.Integer,​Enquiry> enquiryData
      A Map containing a numerical Enquiry ID as the key and Enquiry objects as the value
      private static IFileDataService fileDataService
      The IFileDataService instance used for data operations
      private static java.util.Map<java.lang.String,​java.lang.String> filePathsMap
      A Map containing file paths for various data types.
      private static java.util.Map<java.lang.String,​Staff> staffData
      A Map containing staff ID as the key and Staff objects as the value.
      private static java.util.Map<java.lang.String,​Student> studentData
      A Map containing student ID as the key and Student objects as the value.
      private static java.util.Map<java.lang.Integer,​Suggestion> suggestionData
      A Map containing a numerical Suggestion ID as the key and Suggestion objects as the value
      private static java.util.Map<java.lang.String,​User> userData
      A Map containing user ID as the key and User 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 map
      static java.util.Map<java.lang.String,​Committee> getCommitteeData()
      Gets the committee data map
      static java.util.Map<java.lang.Integer,​Enquiry> getEnquiryData()
      Gets the request data map
      static java.util.Map<java.lang.String,​Staff> getStaffData()
      Gets the staff data map
      static java.util.Map<java.lang.String,​Student> getStudentData()
      Gets the student data map
      static java.util.Map<java.lang.Integer,​Suggestion> getSuggestionData()
      Gets the suggestion data map
      static java.util.Map<java.lang.String,​User> getUserData()
      Get the users data map
      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
      static 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • filePathsMap

        private static java.util.Map<java.lang.String,​java.lang.String> filePathsMap
        A Map containing file paths for various data types.
      • userData

        private static java.util.Map<java.lang.String,​User> userData
        A Map containing user ID as the key and User objects as the value
      • studentData

        private static java.util.Map<java.lang.String,​Student> studentData
        A Map containing student ID as the key and Student objects as the value.
      • staffData

        private static java.util.Map<java.lang.String,​Staff> staffData
        A Map containing staff ID as the key and Staff objects as the value.
      • committeeData

        private static java.util.Map<java.lang.String,​Committee> committeeData
        A Map containing comittee ID as the key and Committee objects as the value.
      • campData

        private static java.util.Map<java.lang.Integer,​Camp> campData
        A Map containing a numerical Camp ID as the key and Camp objects as the value
      • enquiryData

        private static java.util.Map<java.lang.Integer,​Enquiry> enquiryData
        A Map containing a numerical Enquiry ID as the key and Enquiry objects as the value
      • suggestionData

        private static java.util.Map<java.lang.Integer,​Suggestion> suggestionData
        A Map containing a numerical Suggestion ID as the key and Suggestion objects as the value
    • Constructor Detail

      • DataStore

        private DataStore()
        Private constructor to prevent instantiation of the class
    • 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 - the IFileDataService instance to use for data operations
        filePathsMap - the Map 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 and User 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 a Map containing user ID as the key and User 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 and Student 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 a Map containing student ID as the key and Student 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 and Staff 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 a Map containing staff ID as the key and Staff 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 and Committee 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 a Map containing committee ID as the key and Committee 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 and Camp 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 a Map containing a numeric camp ID as the key and Camp 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 and Enquiry 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 a Map containing a numeric enquiry ID as the key and Enquiry 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 and Suggestion 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 a Map containing a numeric suggestion ID as the key and Suggestion objects as the value