Module sc2002_fypms
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.
    • 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.String,​FYPCoordinator> getFYPCoordinatorsData()
      Gets the FYP coordinators data map.
      static java.util.Map<java.lang.Integer,​Project> getProjectsData()
      Gets the projects data map.
      static java.util.Map<java.lang.Integer,​Request> getRequestsData()
      Gets the requests data map.
      static java.util.Map<java.lang.String,​Student> getStudentsData()
      Gets the students data map.
      static java.util.Map<java.lang.String,​Supervisor> getSupervisorsData()
      Gets the supervisors 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()
      Saves the data from the DataStore to the file system.
      static void setFYPCoordinatorsData​(java.util.Map<java.lang.String,​FYPCoordinator> fypcoordinatorsData)
      Sets the FYP coordinators data map and saves the data to the file system.
      static void setProjectsData​(java.util.Map<java.lang.Integer,​Project> projectsData)
      Sets the projects data map and saves the data to the file system.
      static void setRequestsData​(java.util.Map<java.lang.Integer,​Request> requestData)
      Sets the requests data map and saves the data to the file system.
      static void setStudentsData​(java.util.Map<java.lang.String,​Student> studentsData)
      Sets the students data map and saves the data to the file system.
      static void setSupervisorsData​(java.util.Map<java.lang.String,​Supervisor> supervisorsData)
      Sets the supervisors 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.
      • studentsData

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

        private static java.util.Map<java.lang.String,​Supervisor> supervisorsData
        A Map containing supervisor ID as the key and Supervisor objects as the value.
      • fypcoordinatorsData

        private static java.util.Map<java.lang.String,​FYPCoordinator> fypcoordinatorsData
        A Map containing FYP coordinator ID as the key and FYPCoordinator objects as the value.
      • projectsData

        private static java.util.Map<java.lang.Integer,​Project> projectsData
        A Map containing project ID as the key and Project objects as the value.
      • requestData

        private static java.util.Map<java.lang.Integer,​Request> requestData
        A Map containing request ID as the key and Request 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 initialization is successful, false otherwise
      • saveData

        public static boolean saveData()
        Saves the data from the DataStore to the file system.
        Returns:
        true if the data is saved successfully, false otherwise
      • getStudentsData

        public static java.util.Map<java.lang.String,​Student> getStudentsData()
        Gets the students data map.
        Returns:
        a Map containing student ID as the key and Student objects as the value
      • setStudentsData

        public static void setStudentsData​(java.util.Map<java.lang.String,​Student> studentsData)
        Sets the students data map and saves the data to the file system.
        Parameters:
        studentsData - a Map containing student ID as the key and Student objects as the value
      • getSupervisorsData

        public static java.util.Map<java.lang.String,​Supervisor> getSupervisorsData()
        Gets the supervisors data map.
        Returns:
        a Map containing supervisor ID as the key and Supervisor objects as the value
      • setSupervisorsData

        public static void setSupervisorsData​(java.util.Map<java.lang.String,​Supervisor> supervisorsData)
        Sets the supervisors data map and saves the data to the file system.
        Parameters:
        supervisorsData - a Map containing supervisor ID as the key and Supervisor objects as the value
      • getFYPCoordinatorsData

        public static java.util.Map<java.lang.String,​FYPCoordinator> getFYPCoordinatorsData()
        Gets the FYP coordinators data map.
        Returns:
        a Map containing FYP coordinator ID as the key and FYPCoordinator objects as the value
      • setFYPCoordinatorsData

        public static void setFYPCoordinatorsData​(java.util.Map<java.lang.String,​FYPCoordinator> fypcoordinatorsData)
        Sets the FYP coordinators data map and saves the data to the file system.
        Parameters:
        fypcoordinatorsData - a Map containing FYP coordinator ID as the key and FYPCoordinator objects as the value
      • getProjectsData

        public static java.util.Map<java.lang.Integer,​Project> getProjectsData()
        Gets the projects data map.
        Returns:
        a Map containing project ID as the key and Project objects as the value
      • setProjectsData

        public static void setProjectsData​(java.util.Map<java.lang.Integer,​Project> projectsData)
        Sets the projects data map and saves the data to the file system.
        Parameters:
        projectsData - a Map containing project ID as the key and Project objects as the value
      • getRequestsData

        public static java.util.Map<java.lang.Integer,​Request> getRequestsData()
        Gets the requests data map.
        Returns:
        a Map containing requestID as the key and Request objects as the value
      • setRequestsData

        public static void setRequestsData​(java.util.Map<java.lang.Integer,​Request> requestData)
        Sets the requests data map and saves the data to the file system.
        Parameters:
        requestData - a Map containing request ID as the key and Request objects as the value