Package services

Class CsvDataService

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.util.List<java.lang.String> campCsvHeaders
      List of headers for the CSV file that stores camp data.
      private static java.util.List<java.lang.String> committeeCsvHeaders
      List of headers for the CSV file that stores camp committee member data.
      private static java.util.List<java.lang.String> enquiryCsvHeaders
      List of headers for the CSV file that stores enquiry data.
      private static java.util.List<java.lang.String> staffCsvHeaders
      List of headers for the CSV file that stores staff data.
      private static java.util.List<java.lang.String> studentCsvHeaders
      List of headers for the CSV file that stores student data.
      private static java.util.List<java.lang.String> suggestionCsvHeaders
      List of headers for the CSV file that stores suggestion data.
      private static java.util.List<java.lang.String> userCsvHeaders
      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 exportCampData​(java.lang.String campsFilePath, java.util.Map<java.lang.Integer,​Camp> campMap)
      Exports camp data to the specified file.
      boolean exportCommitteeData​(java.lang.String usersFilePath, java.lang.String committeesFilePath, java.util.Map<java.lang.String,​Committee> committeeMap)
      Exports committee data to specified files.
      boolean exportEnquiryData​(java.lang.String enquiryFilePath, java.util.Map<java.lang.Integer,​Enquiry> enquiryMap)
      Exports enquiry data to the specified file.
      boolean exportStaffData​(java.lang.String usersFilePath, java.lang.String staffsFilePath, java.util.Map<java.lang.String,​Staff> staffMap)
      Exports staff data to specified files.
      boolean exportStudentData​(java.lang.String usersFilePath, java.lang.String studentsFilePath, java.util.Map<java.lang.String,​Student> studentMap)
      Exports student data to specified files.
      boolean exportSuggestionData​(java.lang.String suggestionFilePath, java.util.Map<java.lang.Integer,​Suggestion> suggestionMap)
      Exports suggestion data to the specified file.
      java.util.Map<java.lang.Integer,​Camp> importCampData​(java.lang.String campsFilePath)
      Imports camp data from the specified file.
      java.util.Map<java.lang.String,​Committee> importCommitteeData​(java.lang.String usersFilePath, java.lang.String committeesFilePath)
      Imports committee data from specified files.
      java.util.Map<java.lang.Integer,​Enquiry> importEnquiryData​(java.lang.String enquiryFilePath)
      Imports enquiry data from the specified file.
      java.util.Map<java.lang.String,​Staff> importStaffData​(java.lang.String usersFilePath, java.lang.String staffsFilePath)
      Imports staff data from specified files.
      java.util.Map<java.lang.String,​Student> importStudentData​(java.lang.String usersFilePath, java.lang.String studentsFilePath)
      Imports student data from specified files.
      java.util.Map<java.lang.Integer,​Suggestion> importSuggestionData​(java.lang.String suggestionFilePath)
      Imports suggestion data from the specified file.
      private java.util.Map<java.lang.String,​java.lang.String> parseUserRow​(java.lang.String[] userRow)
      parse string into a map for code
      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
        List of headers for the CSV file that stores user data.
      • studentCsvHeaders

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

        private static java.util.List<java.lang.String> staffCsvHeaders
        List of headers for the CSV file that stores staff data.
      • committeeCsvHeaders

        private static java.util.List<java.lang.String> committeeCsvHeaders
        List of headers for the CSV file that stores camp committee member data.
      • campCsvHeaders

        private static java.util.List<java.lang.String> campCsvHeaders
        List of headers for the CSV file that stores camp data.
      • enquiryCsvHeaders

        private static java.util.List<java.lang.String> enquiryCsvHeaders
        List of headers for the CSV file that stores enquiry data.
      • suggestionCsvHeaders

        private static java.util.List<java.lang.String> suggestionCsvHeaders
        List of headers for the CSV file that stores suggestion 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)
        parse string into a map for code
        Parameters:
        userRow - string from csv file
        Returns:
        map for code
      • 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 specified files.
        Specified by:
        importStudentData in interface IFileDataService
        Parameters:
        usersFilePath - The file path for user data.
        studentsFilePath - The file path for student data.
        Returns:
        A Map containing Student data with user 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 specified files.
        Specified by:
        exportStudentData in interface IFileDataService
        Parameters:
        usersFilePath - The file path for user data.
        studentsFilePath - The file path for student data.
        studentMap - A Map containing Student data with user IDs as keys.
        Returns:
        true if the export is successful, false otherwise.
      • importStaffData

        public java.util.Map<java.lang.String,​Staff> importStaffData​(java.lang.String usersFilePath,
                                                                           java.lang.String staffsFilePath)
        Description copied from interface: IFileDataService
        Imports staff data from specified files.
        Specified by:
        importStaffData in interface IFileDataService
        Parameters:
        usersFilePath - The file path for user data.
        staffsFilePath - The file path for staff data.
        Returns:
        A Map containing Staff data with user IDs as keys.
      • exportStaffData

        public boolean exportStaffData​(java.lang.String usersFilePath,
                                       java.lang.String staffsFilePath,
                                       java.util.Map<java.lang.String,​Staff> staffMap)
        Description copied from interface: IFileDataService
        Exports staff data to specified files.
        Specified by:
        exportStaffData in interface IFileDataService
        Parameters:
        usersFilePath - The file path for user data.
        staffsFilePath - The file path for staff data.
        staffMap - A Map containing Staff data with user IDs as keys.
        Returns:
        true if the export is successful, false otherwise.
      • importCommitteeData

        public java.util.Map<java.lang.String,​Committee> importCommitteeData​(java.lang.String usersFilePath,
                                                                                   java.lang.String committeesFilePath)
        Description copied from interface: IFileDataService
        Imports committee data from specified files.
        Specified by:
        importCommitteeData in interface IFileDataService
        Parameters:
        usersFilePath - The file path for user data.
        committeesFilePath - The file path for committee data.
        Returns:
        A Map containing Committee data with user IDs as keys.
      • exportCommitteeData

        public boolean exportCommitteeData​(java.lang.String usersFilePath,
                                           java.lang.String committeesFilePath,
                                           java.util.Map<java.lang.String,​Committee> committeeMap)
        Description copied from interface: IFileDataService
        Exports committee data to specified files.
        Specified by:
        exportCommitteeData in interface IFileDataService
        Parameters:
        usersFilePath - The file path for user data.
        committeesFilePath - The file path for committee data.
        committeeMap - A Map containing Committee data with user IDs as keys.
        Returns:
        true if the export is successful, false otherwise.
      • importCampData

        public java.util.Map<java.lang.Integer,​Camp> importCampData​(java.lang.String campsFilePath)
        Description copied from interface: IFileDataService
        Imports camp data from the specified file.
        Specified by:
        importCampData in interface IFileDataService
        Parameters:
        campsFilePath - The file path for camp data.
        Returns:
        A Map containing Camp data with camp IDs as keys.
      • exportCampData

        public boolean exportCampData​(java.lang.String campsFilePath,
                                      java.util.Map<java.lang.Integer,​Camp> campMap)
        Description copied from interface: IFileDataService
        Exports camp data to the specified file.
        Specified by:
        exportCampData in interface IFileDataService
        Parameters:
        campsFilePath - The file path for camp data.
        campMap - A Map containing Camp data with camp IDs as keys.
        Returns:
        true if the export is successful, false otherwise.
      • importEnquiryData

        public java.util.Map<java.lang.Integer,​Enquiry> importEnquiryData​(java.lang.String enquiryFilePath)
        Description copied from interface: IFileDataService
        Imports enquiry data from the specified file.
        Specified by:
        importEnquiryData in interface IFileDataService
        Parameters:
        enquiryFilePath - The file path for enquiry data.
        Returns:
        A Map containing Enquiry data with enquiry IDs as keys.
      • exportEnquiryData

        public boolean exportEnquiryData​(java.lang.String enquiryFilePath,
                                         java.util.Map<java.lang.Integer,​Enquiry> enquiryMap)
        Description copied from interface: IFileDataService
        Exports enquiry data to the specified file.
        Specified by:
        exportEnquiryData in interface IFileDataService
        Parameters:
        enquiryFilePath - The file path for enquiry data.
        enquiryMap - A Map containing Enquiry data with enquiry IDs as keys.
        Returns:
        true if the export is successful, false otherwise.
      • importSuggestionData

        public java.util.Map<java.lang.Integer,​Suggestion> importSuggestionData​(java.lang.String suggestionFilePath)
        Description copied from interface: IFileDataService
        Imports suggestion data from the specified file.
        Specified by:
        importSuggestionData in interface IFileDataService
        Parameters:
        suggestionFilePath - The file path for suggestion data.
        Returns:
        A Map containing Suggestion data with suggestion IDs as keys.
      • exportSuggestionData

        public boolean exportSuggestionData​(java.lang.String suggestionFilePath,
                                            java.util.Map<java.lang.Integer,​Suggestion> suggestionMap)
        Description copied from interface: IFileDataService
        Exports suggestion data to the specified file.
        Specified by:
        exportSuggestionData in interface IFileDataService
        Parameters:
        suggestionFilePath - The file path for suggestion data.
        suggestionMap - A Map containing Suggestion data with suggestion IDs as keys.
        Returns:
        true if the export is successful, false otherwise.