From 30f1c5bf65cf3972cd10dfdab1fb4962916b190e Mon Sep 17 00:00:00 2001 From: Nicholas Date: Fri, 10 Nov 2023 20:11:18 +0800 Subject: [PATCH] Fix invalid handling of data file upon application launch and minor changes --- docs/UserGuide.md | 2 +- docs/team/nikele2001.md | 14 +++++++++++--- docs/team/sopa301.md | 1 + src/main/java/seedu/address/MainApp.java | 12 ++++++++++++ 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/docs/UserGuide.md b/docs/UserGuide.md index 1a8d0ee4fdc..666709c2a0f 100644 --- a/docs/UserGuide.md +++ b/docs/UserGuide.md @@ -412,7 +412,7 @@ UNOFAS data are saved in the hard disk automatically after any command that chan UNOFAS data are saved automatically as a JSON file `[JAR file location]/data/addressbook.json`. Advanced users are welcome to update data directly by editing that data file.
:exclamation: **Caution:** -If your changes to the data file makes its format invalid, UNOFAS will discard all data when a command is executed with the corrupted file and start with an empty data file at the next run. Hence, it is recommended to take a backup of the file before editing it. +If your changes to the data file makes its format invalid, UNOFAS will discard all data and start with an empty data file at the next run. Hence, it is recommended to take a backup of the file before editing it.
### Archiving data files `[coming in v2.0]` diff --git a/docs/team/nikele2001.md b/docs/team/nikele2001.md index d8846913e53..96e1667d0f6 100644 --- a/docs/team/nikele2001.md +++ b/docs/team/nikele2001.md @@ -13,12 +13,20 @@ such as sorting, scheduling and other commands to query information quickly requ Given below are my contributions to the project. +* **New Feature**: Added `FinancialPlan` field and wrote tests + * Justification: As a financial advisor, it would be convenient to have a person's current financial plans available for business purposes. + * (Pull request [#69](https://github.com/AY2324S1-CS2103T-F12-1/tp/pull/69)) + +* **New Feature**: Added appointment sidebar that shows upcoming appointments of clients in chronological order and wrote tests + * Justification: Financial advisors may want to view all upcoming appointments easily in chronological order so that it is easier for them to plan their timetables. + * Highlights: This enhancement creates another UI element to show various other appointment-specific details in the future. It requires an understanding of ObservableList interface and the way the list is being tracked by JavaFX. + * (Pull request [#110](https://github.com/AY2324S1-CS2103T-F12-1/tp/pull/110)) + * **Code Contributed**: [RepoSense](https://nus-cs2103-ay2324s1.github.io/tp-dashboard/?search=nikele2001&breakdown=true) * **Enhancements Implemented**: - * Added `FinancialPlan` field and wrote tests - (Pull request [#69](https://github.com/AY2324S1-CS2103T-F12-1/tp/pull/69)) - * Added appointment sidebar that shows upcoming appointments of clients in chronological order and wrote tests (Pull request [#110](https://github.com/AY2324S1-CS2103T-F12-1/tp/pull/110)) + * `FinancialPlan` field to allow financial advisors to execute commands specific to financial plans subscribed by clients + * Override prompt to ask user for confirmation before overriding an appointment. * **Contributions to the UG**: * Added and updated all UI images. diff --git a/docs/team/sopa301.md b/docs/team/sopa301.md index 11e33e3d825..780e13010cf 100644 --- a/docs/team/sopa301.md +++ b/docs/team/sopa301.md @@ -24,6 +24,7 @@ Given below are my contributions to the project. * Justification: `clear` is a very powerful command that can delete the entirety of a user's work in an instant. To safeguard against mistakes, we decided to add an extra confirmation requirement to ensure that the user actually wants to wipe the contact book. + * Highlights: This feature causes the logic flow of the method to change if the clear command is about to be executed, getting a response from the user before deciding whether to continue the execution of the program. * Pull request [#75](https://github.com/AY2324S1-CS2103T-F12-1/tp/pull/75) * Added available keywords for `help` command * Pull request [#67](https://github.com/AY2324S1-CS2103T-F12-1/tp/pull/67) diff --git a/src/main/java/seedu/address/MainApp.java b/src/main/java/seedu/address/MainApp.java index e645d997555..ec21d93f75f 100644 --- a/src/main/java/seedu/address/MainApp.java +++ b/src/main/java/seedu/address/MainApp.java @@ -88,11 +88,23 @@ private Model initModelManager(Storage storage, ReadOnlyUserPrefs userPrefs) { logger.warning("Data file at " + storage.getAddressBookFilePath() + " could not be loaded." + " Will be starting with an empty AddressBook."); initialData = new AddressBook(); + this.saveEmptyAddressBook(initialData); } return new ModelManager(initialData, userPrefs); } + /** + * Wipes corrupted data in addressbook.json when starting the application with corrupted data. + */ + private void saveEmptyAddressBook(ReadOnlyAddressBook initialData) { + try { + storage.saveAddressBook(initialData); + } catch (IOException e) { + logger.warning("Failed to locate filepath."); + } + } + private void initLogging(Config config) { LogsCenter.init(config); }