Module sc2002_fypms
Package services

Class CsvDataService

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.util.List<java.lang.String> changeProjectTitleRequestCsvHeaders
      The list of headers for the CSV file that stores change project title request data.
      private static java.util.List<java.lang.String> fypCoordinatorCsvHeaders
      The list of headers for the CSV file that stores FYP coordinator data.
      private static java.util.List<java.lang.String> projectCsvHeaders
      The list of headers for the CSV file that stores project data.
      private static java.util.List<java.lang.String> requestCsvHeaders
      The list of headers for the CSV file that stores request data.
      private static java.util.List<java.lang.String> studentCsvHeaders
      The list of headers for the CSV file that stores student data.
      private static java.util.List<java.lang.String> supervisorCsvHeaders
      The list of headers for the CSV file that stores supervisor data.
      private static java.util.List<java.lang.String> transferStudentRequestCsvHeaders
      The list of headers for the CSV file that stores transfer student request data.
      private static java.util.List<java.lang.String> userCsvHeaders
      The list of headers for the CSV file that stores user data.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean exportFYPCoordinatorData​(java.lang.String usersFilePath, java.lang.String supervisorsFilePath, java.lang.String fypCoordinatorsFilePath, java.util.Map<java.lang.String,​FYPCoordinator> fypCoordinatorMap)
      Exports FYP Coordinator data to the specified file paths.
      boolean exportProjectData​(java.lang.String projectsFilePath, java.util.Map<java.lang.Integer,​Project> projectMap)
      Exports project data to the specified file path.
      boolean exportRequestData​(java.lang.String requestsFilePath, java.lang.String transferStudentRequestsFilePath, java.lang.String changeProjectTitleRequestsFilePath, java.util.Map<java.lang.Integer,​Request> requestMap)
      Exports request data to the specified file paths.
      boolean exportStudentData​(java.lang.String usersFilePath, java.lang.String studentsFilePath, java.util.Map<java.lang.String,​Student> studentMap)
      Exports student data to the specified file paths.
      boolean exportSupervisorData​(java.lang.String usersFilePath, java.lang.String supervisorsFilePath, java.util.Map<java.lang.String,​Supervisor> supervisorMap)
      Exports supervisor data to the specified file paths.
      java.util.Map<java.lang.String,​FYPCoordinator> importFYPCoordinatorData​(java.lang.String usersFilePath, java.lang.String supervisorsFilePath, java.lang.String fypCoordinatorsFilePath)
      Imports FYP Coordinator data from the specified file paths.
      java.util.Map<java.lang.Integer,​Project> importProjectData​(java.lang.String projectsFilePath, java.lang.String usersFilePath, java.lang.String studentsFilePath, java.lang.String supervisorsFilePath, java.lang.String fypCoordinatorsFilePath)
      Imports project data from the specified file paths.
      java.util.Map<java.lang.Integer,​Request> importRequestData​(java.lang.String requestsFilePath, java.lang.String transferStudentRequestsFilePath, java.lang.String changeProjectTitleRequestsFilePath)
      Imports request data from the specified file paths.
      java.util.Map<java.lang.String,​Student> importStudentData​(java.lang.String usersFilePath, java.lang.String studentsFilePath)
      Imports student data from the specified file paths.
      java.util.Map<java.lang.String,​Supervisor> importSupervisorData​(java.lang.String usersFilePath, java.lang.String supervisorsFilePath)
      Imports supervisor data from the specified file paths.
      private java.util.Map<java.lang.String,​java.lang.String> parseUserRow​(java.lang.String[] userRow)
      Parses a string array containing user data and returns a map of user information.
      java.util.List<java.lang.String[]> readCsvFile​(java.lang.String filePath, java.util.List<java.lang.String> headers)
      Reads data from the CSV file located at the given file path and returns it as a list of string arrays.
      boolean writeCsvFile​(java.lang.String filePath, java.util.List<java.lang.String> headers, java.util.List<java.lang.String> lines)
      Writes the given data to a CSV file located at the given file path.
      • Methods inherited from class java.lang.Object

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

      • userCsvHeaders

        private static java.util.List<java.lang.String> userCsvHeaders
        The list of headers for the CSV file that stores user data.
      • studentCsvHeaders

        private static java.util.List<java.lang.String> studentCsvHeaders
        The list of headers for the CSV file that stores student data.
      • supervisorCsvHeaders

        private static java.util.List<java.lang.String> supervisorCsvHeaders
        The list of headers for the CSV file that stores supervisor data.
      • fypCoordinatorCsvHeaders

        private static java.util.List<java.lang.String> fypCoordinatorCsvHeaders
        The list of headers for the CSV file that stores FYP coordinator data.
      • projectCsvHeaders

        private static java.util.List<java.lang.String> projectCsvHeaders
        The list of headers for the CSV file that stores project data.
      • requestCsvHeaders

        private static java.util.List<java.lang.String> requestCsvHeaders
        The list of headers for the CSV file that stores request data.
      • transferStudentRequestCsvHeaders

        private static java.util.List<java.lang.String> transferStudentRequestCsvHeaders
        The list of headers for the CSV file that stores transfer student request data.
      • changeProjectTitleRequestCsvHeaders

        private static java.util.List<java.lang.String> changeProjectTitleRequestCsvHeaders
        The list of headers for the CSV file that stores change project title request data.
    • Constructor Detail

      • CsvDataService

        public CsvDataService()
        Constructs an instance of the CsvDataService class.
    • Method Detail

      • readCsvFile

        public java.util.List<java.lang.String[]> readCsvFile​(java.lang.String filePath,
                                                              java.util.List<java.lang.String> headers)
        Reads data from the CSV file located at the given file path and returns it as a list of string arrays.
        Parameters:
        filePath - the file path of the CSV file to read
        headers - the list of headers for the CSV file
        Returns:
        a list of string arrays containing the CSV data
      • writeCsvFile

        public boolean writeCsvFile​(java.lang.String filePath,
                                    java.util.List<java.lang.String> headers,
                                    java.util.List<java.lang.String> lines)
        Writes the given data to a CSV file located at the given file path.
        Parameters:
        filePath - the file path of the CSV file to write
        headers - the list of headers for the CSV file
        lines - the list of lines to write to the CSV file
        Returns:
        true if the data is written successfully, false otherwise
      • parseUserRow

        private java.util.Map<java.lang.String,​java.lang.String> parseUserRow​(java.lang.String[] userRow)
        Parses a string array containing user data and returns a map of user information.
        Parameters:
        userRow - the string array containing the user data
        Returns:
        a map of user information, where the keys are "userID", "password", "email", "role", and "name" and the values are the corresponding values in the userRow array
      • importStudentData

        public java.util.Map<java.lang.String,​Student> importStudentData​(java.lang.String usersFilePath,
                                                                               java.lang.String studentsFilePath)
        Description copied from interface: IFileDataService
        Imports student data from the specified file paths.
        Specified by:
        importStudentData in interface IFileDataService
        Parameters:
        usersFilePath - the file path of the users file
        studentsFilePath - the file path of the students file
        Returns:
        a Map of Student objects with their IDs as keys
      • exportStudentData

        public boolean exportStudentData​(java.lang.String usersFilePath,
                                         java.lang.String studentsFilePath,
                                         java.util.Map<java.lang.String,​Student> studentMap)
        Description copied from interface: IFileDataService
        Exports student data to the specified file paths.
        Specified by:
        exportStudentData in interface IFileDataService
        Parameters:
        usersFilePath - the file path of the users file
        studentsFilePath - the file path of the students file
        studentMap - a Map of Student objects with their IDs as keys
        Returns:
        true if the data was exported successfully, false otherwise
      • importSupervisorData

        public java.util.Map<java.lang.String,​Supervisor> importSupervisorData​(java.lang.String usersFilePath,
                                                                                     java.lang.String supervisorsFilePath)
        Description copied from interface: IFileDataService
        Imports supervisor data from the specified file paths.
        Specified by:
        importSupervisorData in interface IFileDataService
        Parameters:
        usersFilePath - the file path of the users file
        supervisorsFilePath - the file path of the supervisors file
        Returns:
        a Map of Supervisor objects with their IDs as keys
      • exportSupervisorData

        public boolean exportSupervisorData​(java.lang.String usersFilePath,
                                            java.lang.String supervisorsFilePath,
                                            java.util.Map<java.lang.String,​Supervisor> supervisorMap)
        Description copied from interface: IFileDataService
        Exports supervisor data to the specified file paths.
        Specified by:
        exportSupervisorData in interface IFileDataService
        Parameters:
        usersFilePath - the file path of the users file
        supervisorsFilePath - the file path of the supervisors file
        supervisorMap - a Map of Supervisor objects with their IDs as keys
        Returns:
        true if the data was exported successfully, false otherwise
      • importFYPCoordinatorData

        public java.util.Map<java.lang.String,​FYPCoordinator> importFYPCoordinatorData​(java.lang.String usersFilePath,
                                                                                             java.lang.String supervisorsFilePath,
                                                                                             java.lang.String fypCoordinatorsFilePath)
        Description copied from interface: IFileDataService
        Imports FYP Coordinator data from the specified file paths.
        Specified by:
        importFYPCoordinatorData in interface IFileDataService
        Parameters:
        usersFilePath - the file path of the users file
        supervisorsFilePath - the file path of the supervisors file
        fypCoordinatorsFilePath - the file path of the FYP Coordinators file
        Returns:
        a Map of FYPCoordinator objects with their IDs as keys
      • exportFYPCoordinatorData

        public boolean exportFYPCoordinatorData​(java.lang.String usersFilePath,
                                                java.lang.String supervisorsFilePath,
                                                java.lang.String fypCoordinatorsFilePath,
                                                java.util.Map<java.lang.String,​FYPCoordinator> fypCoordinatorMap)
        Description copied from interface: IFileDataService
        Exports FYP Coordinator data to the specified file paths.
        Specified by:
        exportFYPCoordinatorData in interface IFileDataService
        Parameters:
        usersFilePath - the file path of the users file
        supervisorsFilePath - the file path of the supervisors file
        fypCoordinatorsFilePath - the file path of the FYP Coordinators file
        fypCoordinatorMap - a Map of FYPCoordinator objects with their IDs as keys
        Returns:
        true if the data was exported successfully, false otherwise
      • importProjectData

        public java.util.Map<java.lang.Integer,​Project> importProjectData​(java.lang.String projectsFilePath,
                                                                                java.lang.String usersFilePath,
                                                                                java.lang.String studentsFilePath,
                                                                                java.lang.String supervisorsFilePath,
                                                                                java.lang.String fypCoordinatorsFilePath)
        Description copied from interface: IFileDataService
        Imports project data from the specified file paths.
        Specified by:
        importProjectData in interface IFileDataService
        Parameters:
        projectsFilePath - the file path of the projects file
        usersFilePath - the file path of the users file
        studentsFilePath - the file path of the students file
        supervisorsFilePath - the file path of the supervisors file
        fypCoordinatorsFilePath - the file path of the FYP Coordinators file
        Returns:
        a Map of Project objects with their IDs as keys
      • exportProjectData

        public boolean exportProjectData​(java.lang.String projectsFilePath,
                                         java.util.Map<java.lang.Integer,​Project> projectMap)
        Description copied from interface: IFileDataService
        Exports project data to the specified file path.
        Specified by:
        exportProjectData in interface IFileDataService
        Parameters:
        projectsFilePath - the file path of the projects file
        projectMap - a Map of Project objects with their IDs as keys
        Returns:
        true if the data was exported successfully, false otherwise
      • importRequestData

        public java.util.Map<java.lang.Integer,​Request> importRequestData​(java.lang.String requestsFilePath,
                                                                                java.lang.String transferStudentRequestsFilePath,
                                                                                java.lang.String changeProjectTitleRequestsFilePath)
        Description copied from interface: IFileDataService
        Imports request data from the specified file paths.
        Specified by:
        importRequestData in interface IFileDataService
        Parameters:
        requestsFilePath - the file path of the requests file
        transferStudentRequestsFilePath - the file path of the transfer student requests file
        changeProjectTitleRequestsFilePath - the file path of the change project title requests file
        Returns:
        a Map of Request objects with their IDs as keys
      • exportRequestData

        public boolean exportRequestData​(java.lang.String requestsFilePath,
                                         java.lang.String transferStudentRequestsFilePath,
                                         java.lang.String changeProjectTitleRequestsFilePath,
                                         java.util.Map<java.lang.Integer,​Request> requestMap)
        Description copied from interface: IFileDataService
        Exports request data to the specified file paths.
        Specified by:
        exportRequestData in interface IFileDataService
        Parameters:
        requestsFilePath - the file path of the requests file
        transferStudentRequestsFilePath - the file path of the transfer student requests file
        changeProjectTitleRequestsFilePath - the file path of the change project title requests file
        requestMap - a Map of Request objects with their IDs as keys
        Returns:
        true if the data was exported successfully, false otherwise