diff --git a/.project b/.project index 1c9339c5f927..6692e9c722f6 100644 --- a/.project +++ b/.project @@ -1,6 +1,6 @@ - addressbook-level4 + main Project addressbook-level4 created by Buildship. diff --git a/LICENSE b/LICENSE index 39b3478982c3..eddc9532c817 100644 --- a/LICENSE +++ b/LICENSE @@ -2,11 +2,11 @@ MIT License Copyright (c) 2016 Software Engineering Education - FOSS Resources -Permission is hereby granted, free of charge, to any person obtaining a copy +Permission is hereby granted, free of charge, to any task obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is +copies of the Software, and to permit tasks to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all diff --git a/README.md b/README.md index 249a00b3899c..ef7ceabb7959 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,22 @@ -[![Build Status](https://travis-ci.org/se-edu/addressbook-level4.svg?branch=master)](https://travis-ci.org/se-edu/addressbook-level4) + [![Build Status](https://travis-ci.org/se-edu/addressbook-level4.svg?branch=master)](https://travis-ci.org/se-edu/addressbook-level4) [![Coverage Status](https://coveralls.io/repos/github/se-edu/addressbook-level4/badge.svg?branch=master)](https://coveralls.io/github/se-edu/addressbook-level4?branch=master) -# Address Book (Level 4) +# Scheduler -
+
-* This is a desktop Address Book application. It has a GUI but most of the user interactions happen using - a CLI (Command Line Interface). +* This is a desktop Scheduler application. It has a GUI but most of the user interactions happen using +a CLI (Command Line Interface). * It is a Java sample application intended for students learning Software Engineering while using Java as - the main programming language. +the main programming language. * It is **written in OOP fashion**. It provides a **reasonably well-written** code example that is - **significantly bigger** (around 6 KLoC)than what students usually write in beginner-level SE modules. -* What's different from [level 3](https://github.com/se-edu/addressbook-level3): - * A more sophisticated GUI that includes a list panel and an in-built Browser. - * More test cases, including automated GUI testing. - * Support for *Build Automation* using Gradle and for *Continuous Integration* using Travis CI. +**significantly bigger** (around 6 KLoC)than what students usually write in beginner-level SE modules. +* It consists of: +* A more sophisticated GUI that includes a list panel and an in-built Browser. +* More test cases, including automated GUI testing. +* Support for *Build Automation* using Gradle and for *Continuous Integration* using Travis CI. + - #### Site Map * [User Guide](docs/UserGuide.md) * [Developer Guide](docs/DeveloperGuide.md) @@ -28,7 +28,11 @@ #### Acknowledgements * Some parts of this sample application were inspired by the excellent - [Java FX tutorial](http://code.makery.ch/library/javafx-8-tutorial/) by *Marco Jakob*. +[Java FX tutorial](http://code.makery.ch/library/javafx-8-tutorial/) by *Marco Jakob*. + +* This project is built on top of the base +[addressbook-level4 project](https://github.com/se-edu/addressbook-level4) from the NUS CS2103 Course. #### Licence : [MIT](LICENSE) + diff --git a/docs/AboutUs.md b/docs/AboutUs.md index 33df65bea583..960088f7b687 100644 --- a/docs/AboutUs.md +++ b/docs/AboutUs.md @@ -1,46 +1,45 @@ + + # About Us We are a team based in the [School of Computing, National University of Singapore](http://www.comp.nus.edu.sg). ## Project Team -#### [Damith C. Rajapakse](http://www.comp.nus.edu.sg/~damithch)
-
-**Role**: Project Advisor +#### [Ang Kiang Siang](https://docs.google.com/document/u/1/d/1O3HF7qsh6KVeLesPmcQ0nPxSqhrkJxvS-OA_g-k-two/pub?embedded=true)
+
+Role: Project Mentor
----- -#### [Joshua Lee](http://github.com/lejolly) -
-Role: Developer
-Responsibilities: UI + +#### [Chankyu Oh](github.com/chankyuoh)
+
+Role: Code Quality Manager
+Responsibilities: Look after code quality, ensures adherence to coding standards, etc. +Deliverables and deadlines: Ensure project deliverables are done on time and in the right format. ----- -#### [Leow Yijin](http://github.com/yijinl) -
-Role: Developer
-Responsibilities: Data +#### [Leow Zheng Yu](http://github.com/zhengyu92) +
+Role: Integration Manager
+Responsibilities: In charge of versioning of the code, maintaining the code repository, integrating various parts of the software to create a whole. ----- -#### [Martin Choo](http://github.com/m133225) -
-Role: Developer
-Responsibilities: Dev Ops +#### [Niveetha](http://github.com/niveetha) +
+Role: Team Lead
+Responsibilities: Responsible for overall project coordination. ----- -#### [Thien Nguyen](https://github.com/ndt93) - Role: Developer
- Responsibilities: Threading - - ----- +#### [Henderson](http://github.com/takukou) +
+Role: Testing Manager
+Responsibilities: Ensures the testing of the project is done properly and on time. -#### [You Liang](http://github.com/yl-coder) -
- Role: Developer
- Responsibilities: UI ----- @@ -48,5 +47,4 @@ Responsibilities: Dev Ops We welcome contributions. See [Contact Us](ContactUs.md) page for more info. -* [Akshay Narayan](https://github.com/se-edu/addressbook-level4/pulls?q=is%3Apr+author%3Aokkhoy) -* [Sam Yong](https://github.com/se-edu/addressbook-level4/pulls?q=is%3Apr+author%3Amauris) \ No newline at end of file + diff --git a/docs/ContactUs.md b/docs/ContactUs.md index 866d0de3fddc..7affea9a05b4 100644 --- a/docs/ContactUs.md +++ b/docs/ContactUs.md @@ -5,4 +5,4 @@ * **Contributing** : We welcome pull requests. Follow the process described [here](https://github.com/oss-generic/process) -* **Email us** : You can also reach us at `damith [at] comp.nus.edu.sg` \ No newline at end of file +* **EndDateTime us** : You can also reach us at `damith [at] comp.nus.edu.sg` \ No newline at end of file diff --git a/docs/DeveloperGuide.md b/docs/DeveloperGuide.md index bc710ed45eb9..e0984ab68121 100644 --- a/docs/DeveloperGuide.md +++ b/docs/DeveloperGuide.md @@ -256,26 +256,106 @@ Priorities: High (must have) - `* * *`, Medium (nice to have) - `* *`, Low (un Priority | As a ... | I want to ... | So that I can... -------- | :-------- | :--------- | :----------- `* * *` | new user | see usage instructions | refer to instructions when I forget how to use the App -`* * *` | user | add a new person | -`* * *` | user | delete a person | remove entries that I no longer need -`* * *` | user | find a person by name | locate details of persons without having to go through the entire list -`* *` | user | hide [private contact details](#private-contact-detail) by default | minimize chance of someone else seeing them by accident -`*` | user with many persons in the address book | sort persons by name | locate a person easily +`* * *` | user | add an event, a task and a floating task | so that I can record tasks that need to be done some day +`* * *` | user | list all items | view all entries and dates that are due sorted by date and time and know what needs to be done next +`* * *` | user | edit an item | update entries that are outdated +`* * *` | user | delete an item | remove entries that I no longer need +`* * *` | user | undo an operation | have read-consistency and data changes should not be visible to queries that started running before committing them +`* * *` | advanced user | use flexible commands | type a command faster +`* * *` | user | find an item by name | locate details of item without having to go through the entire list +`* * *` | user | track items | keep track of items that have been completed/uncompleted to filter items based on completion +`* * *` | user | path items | save my files on shared folders for accessibility on other devices +`* *` | user | clear all items | clear all my list in the scheduler +`*` | user | exit the program | exit the program conveniently {More to be added} ## Appendix B : Use Cases -(For all use cases below, the **System** is the `AddressBook` and the **Actor** is the `user`, unless specified otherwise) +(For all use cases below, the **System** is the `Scheduler` and the **Actor** is the `user`, unless specified otherwise) -#### Use case: Delete person +#### Use case: Open Help documentation **MSS** -1. User requests to list persons -2. AddressBook shows a list of persons -3. User requests to delete a specific person in the list -4. AddressBook deletes the person
+1. User requests for help documentation +2. Scheduler opens window displaying all program commands and its functionality
+Use case ends. + +**Extensions** + +#### Use case: Add item + +**MSS** + +1. User calls the add function +2. Scheduler displays added item
+Use case ends. + +**Extensions** + +2a. The user adds an events + +> 2a1. Scheduler displays item as a calendar
+ +2b. The user adds a task with a deadline + +> 2b1. Scheduler displays item in a list with a date
+ +2c. The user adds a task + +> 2c1. Scheduler displays item in a list
+ +> Use case ends + +#### Use case: List items + +**MSS** + +1. User calls the list function +2. Scheduler displays all items as a list
+Use case ends. + +**Extensions** + +2a. The list is empty + +> 2a1. Scheduler displays empty list
+ +#### Use case: Edit items + +**MSS** + +1. User requests to list items or find item +2. Scheduler shows a list of items or the item +3. User calls the edit function +4. User types in index of item and inputs new values for the item +5. Scheduler displays updated list of items
+Use case ends. + +**Extensions** + +4a. The item is an event + +> 4a1. The function requires an input “'NAME OF EVENT' 'START DATE AND TIME' 'END DATE AND TIME'"
+ +4b. The item is a task with a deadline + +> 4b1. The function requires an input “'NAME OF TASK' 'DEADLINE'”
+ +4c. The item is a floating task + +> 4c1. The function requires an input “'NAME OF TASK'”
+ +#### Use case: Delete item + +**MSS** + +1. User requests to list items or find item +2. Scheduler shows a list of items or the item +3. User requests to delete a specific item in the list based on the index +4. Scheduler deletes the item +5. Scheduler displays updated list of items
Use case ends. **Extensions** @@ -284,12 +364,90 @@ Use case ends. > Use case ends -3a. The given index is invalid +5a. The list is empty -> 3a1. AddressBook shows an error message
- Use case resumes at step 2 +> Use case ends -{More to be added} +#### Use case: Undo action + +**MSS** + +1. User requests to undo most recently executed action +2. System reverts back to previous state in history +3. Scheduler displays updated list
+Use case ends. + +**Extensions** + +1a. The scheduler is new and no previous actions were executed + +> Use case ends + +#### Use case: Find item + +**MSS** + +1. User calls the find function +2. Scheduler displays the items that are word related with no case sensitive +
+Use case ends. + +**Extensions** + +2a. The list is empty + +> 2a1. Scheduler displays empty list
+ +#### Use case: Track items + +**MSS** + +1. User calls the track function +2. Scheduler displays the items which are done and yet to be done
+Use case ends. + +**Extensions** + +2a. The list is empty + +> 2a1. Scheduler displays empty list
+ +#### Use case: Path item + +**MSS** + +1. User calls the path function +2. Scheduler creates a folder in specified path
+Use case ends. + +**Extensions** + +2a. The folder does not exist + +> 2a1. Scheduler will create a folder
+ +#### Use case: Clear items + +**MSS** + +1. User requests to clear items +2. Scheduler deletes all items +3. Scheduler displays empty list
+Use case ends. + +**Extensions** + +1a. The list is empty + +> Use case ends + +#### Use case: Exit + +**MSS** + +1. User requests to exit program +2. Scheduler exits program
+Use case ends. ## Appendix C : Non Functional Requirements @@ -297,6 +455,10 @@ Use case ends. 2. Should be able to hold up to 1000 persons. 3. Should come with automated unit tests and open source code. 4. Should favor DOS style commands over Unix-style commands. +5. Synchronization capability to other task management sites (ex: Google calendar) +6. Back-up data that can be used to recover if original copy gets deleted +7. Able to migrate all items into .txt file + {More to be added} diff --git a/docs/UserGuide.md b/docs/UserGuide.md index 0cf4b84f7470..a848e7058456 100644 --- a/docs/UserGuide.md +++ b/docs/UserGuide.md @@ -12,17 +12,17 @@ This app will not work with earlier versions of Java 8. 1. Download the latest `addressbook.jar` from the [releases](../../../releases) tab. -2. Copy the file to the folder you want to use as the home folder for your Address Book. +2. Copy the file to the folder you want to use as the home folder for your Scheduler. 3. Double-click the file to start the app. The GUI should appear in a few seconds. > 4. Type the command in the command box and press Enter to execute it.
e.g. typing **`help`** and pressing Enter will open the help window. 5. Some example commands you can try: - * **`list`** : lists all contacts - * **`add`**` John Doe p/98765432 e/johnd@gmail.com a/John street, block 123, #01-01` : - adds a contact named `John Doe` to the Address Book. - * **`delete`**` 3` : deletes the 3rd contact shown in the current list + * **`list`** : lists all items + * **`add`**` `add Meeting st/ 19-02-12 13:00 et/19-02-12 14:00` : + adds an item named `Meeting` to the scheduler. + * **`delete`**` 3` : deletes the 3rd item shown in the scheduler * **`exit`** : exits the app 6. Refer to the [Features](#features) section below for details of each command.
@@ -40,95 +40,98 @@ Format: `help` > Help is also shown if you enter an incorrect command e.g. `abcd` -#### Adding a person: `add` -Adds a person to the address book
-Format: `add NAME p/PHONE_NUMBER e/EMAIL a/ADDRESS [t/TAG]...` +#### Adding an item: `add` +Adds an event to the scheduler
+Format: `add NAME st/START_DATE_TIME et/END_DATE_TIME` -> Persons can have any number of tags (including 0) +Adds a task to the scheduler
+Format: `add NAME d/DATE` + +Adds a floating task to the scheduler
+Format: `add NAME` Examples: -* `add John Doe p/98765432 e/johnd@gmail.com a/John street, block 123, #01-01` -* `add Betsy Crowe p/1234567 e/betsycrowe@gmail.com a/Newgate Prison t/criminal t/friend` +* `add Meeting st/20-03-12 13:00 et/20-03-12 14:00` +* `add Do Homework1 d/19-02-12` +* `add Do Homework2` -#### Listing all persons : `list` -Shows a list of all persons in the address book.
-Format: `list` +#### Listing all items: `list` +Shows a list of all items in the scheduler.
+Format: `list [by/SORT_CATEGORY]` +Examples: +* `list` +* `list by/date` -#### Finding all persons containing any keyword in their name: `find` -Finds persons whose names contain any of the given keywords.
-Format: `find KEYWORD [MORE_KEYWORDS]` +#### Editing an item : `edit` +Edits an event to the scheduler specified by the index
+Format: `edit INDEX NAME st/START_DATE_TIME et/END_DATE_TIME` -> * The search is case sensitive. e.g `hans` will not match `Hans` -> * The order of the keywords does not matter. e.g. `Hans Bo` will match `Bo Hans` -> * Only the name is searched. -> * Only full words will be matched e.g. `Han` will not match `Hans` -> * Persons matching at least one keyword will be returned (i.e. `OR` search). - e.g. `Hans` will match `Hans Bo` +Edits a task to the scheduler specified by the index
+Format: `edit INDEX NAME d/DATE` + +Edits a floating task to the scheduler specified by the index
+Format: `edit INDEX NAME` Examples: -* `find John`
- Returns `John Doe` but not `john` -* `find Betsy Tim John`
- Returns Any person having names `Betsy`, `Tim`, or `John` +* `edit 1 Meeting st/20-03-12 13:00 et/20-03-12 14:00` +* `edit 3 Do Homework1 d/19-02-12` +* `edit 2 Do Homework2` -#### Deleting a person : `delete` -Deletes the specified person from the address book. Irreversible.
+#### Deleting an item: `delete` +Delete the item selected by the user.
Format: `delete INDEX` -> Deletes the person at the specified `INDEX`. - The index refers to the index number shown in the most recent listing.
- The index **must be a positive integer** 1, 2, 3, ... +> * The user needs to view Scheduler in a list to find index of item Examples: -* `list`
- `delete 2`
- Deletes the 2nd person in the address book. -* `find Betsy`
- `delete 1`
- Deletes the 1st person in the results of the `find` command. +* `delete 23` -#### Select a person : `select` -Selects the person identified by the index number used in the last person listing.
-Format: `select INDEX` +#### Finding all items containing any keyword in their name: `find` +Finds items where their item names contain any of the given keywords.
+Format: `find KEYWORD [MORE_KEYWORDS]` -> Selects the person and loads the Google search page the person at the specified `INDEX`. - The index refers to the index number shown in the most recent listing.
- The index **must be a positive integer** 1, 2, 3, ... +> * The search is non-case sensitive. e.g `homework` will match `Homework` +> * Only the name is searched. +> * Only full words will be matched e.g. `CS` will not match `CS2103` +> * Persons matching at least one keyword will be returned (i.e. `OR` search). + e.g. `Midterm` will match `Midterm Review` Examples: -* `list`
- `select 2`
- Selects the 2nd person in the address book. -* `find Betsy`
- `select 1`
- Selects the 1st person in the results of the `find` command. - -#### Clearing all entries : `clear` -Clears all entries from the address book.
-Format: `clear` +* `find Tutorial`
+ Returns `CS2103 Tutorial` and words related to `tutorial` +* `find CS Assignment Errand`
+ Returns Any item having names `CS`, `Assignment`, or `Errand` #### Exiting the program : `exit` Exits the program.
Format: `exit` -#### Saving the data -Address book data are saved in the hard disk automatically after any command that changes the data.
-There is no need to save manually. +#### Saving the data: `save` +Scheduler data are saved in the hard disk automatically after any command that changes the data. Data is saved at path previously assigned by the user.
+Format: `save FILE_SAVE` + +#### Changing the file save path: `path` +File path can be manually changed to a user-specified location.
+Format: `path FILE_PATH` ## FAQ **Q**: How do I transfer my data to another Computer?
**A**: Install the app in the other computer and overwrite the empty data file it creates with - the file that contains the data of your previous Address Book folder. + the file that contains the data of your previous Scheduler folder. ## Command Summary Command | Format -------- | :-------- -Add | `add NAME p/PHONE_NUMBER e/EMAIL a/ADDRESS [t/TAG]...` -Clear | `clear` +Add | `add NAME st/START_DATE_TIME et/END_DATE_TIME` +Add | `add NAME d/DATE` +Add | `add NAME` Delete | `delete INDEX` Find | `find KEYWORD [MORE_KEYWORDS]` -List | `list` +Edit | `edit INDEX NAME st/START_DATE_TIME et/END_DATE_TIME` +Edit | `edit INDEX NAME d/DATE` +Edit | `edit INDEX NAME` +List | `list [by/SORT_CATEGORY]` +Path | `path FILE_PATH` Help | `help` -Select | `select INDEX` diff --git a/docs/images/MockUpUi.png b/docs/images/MockUpUi.png new file mode 100644 index 000000000000..3831a3ceb22c Binary files /dev/null and b/docs/images/MockUpUi.png differ diff --git a/docs/images/PD1.jpg b/docs/images/PD1.jpg new file mode 100644 index 000000000000..bbd2e5282ccd Binary files /dev/null and b/docs/images/PD1.jpg differ diff --git a/docs/images/ZhengYu.jpg b/docs/images/ZhengYu.jpg new file mode 100644 index 000000000000..b50402849a2c Binary files /dev/null and b/docs/images/ZhengYu.jpg differ diff --git a/docs/images/angkiangsiang.png b/docs/images/angkiangsiang.png new file mode 100644 index 000000000000..6c5ab2f6a1be Binary files /dev/null and b/docs/images/angkiangsiang.png differ diff --git a/docs/images/hendersenlam.jpg b/docs/images/hendersenlam.jpg new file mode 100644 index 000000000000..a551437787b7 Binary files /dev/null and b/docs/images/hendersenlam.jpg differ diff --git a/docs/images/profilePicture.jpg b/docs/images/profilePicture.jpg new file mode 100644 index 000000000000..e24d6779acaf Binary files /dev/null and b/docs/images/profilePicture.jpg differ diff --git a/src/main/java/seedu/address/commons/core/Messages.java b/src/main/java/seedu/address/commons/core/Messages.java index 1deb3a1e4695..6284389d4d90 100644 --- a/src/main/java/seedu/address/commons/core/Messages.java +++ b/src/main/java/seedu/address/commons/core/Messages.java @@ -7,7 +7,7 @@ public class Messages { public static final String MESSAGE_UNKNOWN_COMMAND = "Unknown command"; public static final String MESSAGE_INVALID_COMMAND_FORMAT = "Invalid command format! \n%1$s"; - public static final String MESSAGE_INVALID_PERSON_DISPLAYED_INDEX = "The person index provided is invalid"; - public static final String MESSAGE_PERSONS_LISTED_OVERVIEW = "%1$d persons listed!"; + public static final String MESSAGE_INVALID_TASK_DISPLAYED_INDEX = "The task index provided is invalid"; + public static final String MESSAGE_TASKS_LISTED_OVERVIEW = "%1$d tasks listed!"; } diff --git a/src/main/java/seedu/address/commons/events/model/AddressBookChangedEvent.java b/src/main/java/seedu/address/commons/events/model/AddressBookChangedEvent.java index 347a8359e0d5..16c6d50aa98b 100644 --- a/src/main/java/seedu/address/commons/events/model/AddressBookChangedEvent.java +++ b/src/main/java/seedu/address/commons/events/model/AddressBookChangedEvent.java @@ -14,6 +14,6 @@ public AddressBookChangedEvent(ReadOnlyAddressBook data){ @Override public String toString() { - return "number of persons " + data.getPersonList().size() + ", number of tags " + data.getTagList().size(); + return "number of tasks " + data.getTaskList().size() + ", number of tags " + data.getTagList().size(); } } diff --git a/src/main/java/seedu/address/commons/events/ui/JumpToListRequestEvent.java b/src/main/java/seedu/address/commons/events/ui/JumpToListRequestEvent.java index 0580d27aecf5..450534e2e16d 100644 --- a/src/main/java/seedu/address/commons/events/ui/JumpToListRequestEvent.java +++ b/src/main/java/seedu/address/commons/events/ui/JumpToListRequestEvent.java @@ -3,7 +3,7 @@ import seedu.address.commons.events.BaseEvent; /** - * Indicates a request to jump to the list of persons + * Indicates a request to jump to the list of tasks */ public class JumpToListRequestEvent extends BaseEvent { diff --git a/src/main/java/seedu/address/commons/events/ui/PersonPanelSelectionChangedEvent.java b/src/main/java/seedu/address/commons/events/ui/PersonPanelSelectionChangedEvent.java deleted file mode 100644 index 95377b326fa6..000000000000 --- a/src/main/java/seedu/address/commons/events/ui/PersonPanelSelectionChangedEvent.java +++ /dev/null @@ -1,26 +0,0 @@ -package seedu.address.commons.events.ui; - -import seedu.address.commons.events.BaseEvent; -import seedu.address.model.person.ReadOnlyPerson; - -/** - * Represents a selection change in the Person List Panel - */ -public class PersonPanelSelectionChangedEvent extends BaseEvent { - - - private final ReadOnlyPerson newSelection; - - public PersonPanelSelectionChangedEvent(ReadOnlyPerson newSelection){ - this.newSelection = newSelection; - } - - @Override - public String toString() { - return this.getClass().getSimpleName(); - } - - public ReadOnlyPerson getNewSelection() { - return newSelection; - } -} diff --git a/src/main/java/seedu/address/commons/events/ui/TaskPanelSelectionChangedEvent.java b/src/main/java/seedu/address/commons/events/ui/TaskPanelSelectionChangedEvent.java new file mode 100644 index 000000000000..50860ddb3e0b --- /dev/null +++ b/src/main/java/seedu/address/commons/events/ui/TaskPanelSelectionChangedEvent.java @@ -0,0 +1,26 @@ +package seedu.address.commons.events.ui; + +import seedu.address.commons.events.BaseEvent; +import seedu.address.model.task.ReadOnlyTask; + +/** + * Represents a selection change in the Task List Panel + */ +public class TaskPanelSelectionChangedEvent extends BaseEvent { + + + private final ReadOnlyTask newSelection; + + public TaskPanelSelectionChangedEvent(ReadOnlyTask newSelection){ + this.newSelection = newSelection; + } + + @Override + public String toString() { + return this.getClass().getSimpleName(); + } + + public ReadOnlyTask getNewSelection() { + return newSelection; + } +} diff --git a/src/main/java/seedu/address/logic/Logic.java b/src/main/java/seedu/address/logic/Logic.java index 4df1bc65cabb..1240859f9b37 100644 --- a/src/main/java/seedu/address/logic/Logic.java +++ b/src/main/java/seedu/address/logic/Logic.java @@ -2,7 +2,7 @@ import javafx.collections.ObservableList; import seedu.address.logic.commands.CommandResult; -import seedu.address.model.person.ReadOnlyPerson; +import seedu.address.model.task.ReadOnlyTask; /** * API of the Logic component @@ -15,7 +15,7 @@ public interface Logic { */ CommandResult execute(String commandText); - /** Returns the filtered list of persons */ - ObservableList getFilteredPersonList(); + /** Returns the filtered list of tasks */ + ObservableList getFilteredTaskList(); } diff --git a/src/main/java/seedu/address/logic/LogicManager.java b/src/main/java/seedu/address/logic/LogicManager.java index ce4dc1903cff..d1d477a1b24c 100644 --- a/src/main/java/seedu/address/logic/LogicManager.java +++ b/src/main/java/seedu/address/logic/LogicManager.java @@ -7,7 +7,7 @@ import seedu.address.logic.commands.CommandResult; import seedu.address.logic.parser.Parser; import seedu.address.model.Model; -import seedu.address.model.person.ReadOnlyPerson; +import seedu.address.model.task.ReadOnlyTask; import seedu.address.storage.Storage; import java.util.logging.Logger; @@ -35,7 +35,7 @@ public CommandResult execute(String commandText) { } @Override - public ObservableList getFilteredPersonList() { - return model.getFilteredPersonList(); + public ObservableList getFilteredTaskList() { + return model.getFilteredTaskList(); } } diff --git a/src/main/java/seedu/address/logic/commands/AddCommand.java b/src/main/java/seedu/address/logic/commands/AddCommand.java index 2860a9ab2a85..2a6de83c9e24 100644 --- a/src/main/java/seedu/address/logic/commands/AddCommand.java +++ b/src/main/java/seedu/address/logic/commands/AddCommand.java @@ -1,46 +1,46 @@ package seedu.address.logic.commands; import seedu.address.commons.exceptions.IllegalValueException; -import seedu.address.model.person.*; import seedu.address.model.tag.Tag; import seedu.address.model.tag.UniqueTagList; +import seedu.address.model.task.*; import java.util.HashSet; import java.util.Set; /** - * Adds a person to the address book. + * Adds an item to the scheduler. */ public class AddCommand extends Command { public static final String COMMAND_WORD = "add"; - public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a person to the address book. " - + "Parameters: NAME p/PHONE e/EMAIL a/ADDRESS [t/TAG]...\n" + public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds an item to the scheduler. " + + "Parameters: NAME st/START_DATE_TIME et/END_DATE_TIME\n or NAME d/DATE\n or NAME \n" + "Example: " + COMMAND_WORD - + " John Doe p/98765432 e/johnd@gmail.com a/311, Clementi Ave 2, #02-25 t/friends t/owesMoney"; + + " Meeting st/20-09-14 14:00 et/20-09-14 15:00\n or Assignment1 d/23-09-12\n or Read Hamlet"; - public static final String MESSAGE_SUCCESS = "New person added: %1$s"; - public static final String MESSAGE_DUPLICATE_PERSON = "This person already exists in the address book"; + public static final String MESSAGE_SUCCESS = "New item added: %1$s"; + public static final String MESSAGE_DUPLICATE_TASK = "This item already exists in the scheduler"; - private final Person toAdd; + private final Task toAdd; /** * Convenience constructor using raw values. * * @throws IllegalValueException if any of the raw values are invalid */ - public AddCommand(String name, String phone, String email, String address, Set tags) + public AddCommand(String name, String startDateTime, String endDateTime, String date, Set tags) throws IllegalValueException { final Set tagSet = new HashSet<>(); for (String tagName : tags) { tagSet.add(new Tag(tagName)); } - this.toAdd = new Person( + this.toAdd = new Task( new Name(name), - new Phone(phone), - new Email(email), - new Address(address), + new StartDateTime(startDateTime), + new EndDateTime(endDateTime), + new Date(date), new UniqueTagList(tagSet) ); } @@ -49,10 +49,10 @@ public AddCommand(String name, String phone, String email, String address, Set lastShownList = model.getFilteredPersonList(); + UnmodifiableObservableList lastShownList = model.getFilteredTaskList(); if (lastShownList.size() < targetIndex) { indicateAttemptToExecuteIncorrectCommand(); - return new CommandResult(Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); + return new CommandResult(Messages.MESSAGE_INVALID_TASK_DISPLAYED_INDEX); } - ReadOnlyPerson personToDelete = lastShownList.get(targetIndex - 1); + ReadOnlyTask taskToDelete = lastShownList.get(targetIndex - 1); try { - model.deletePerson(personToDelete); - } catch (PersonNotFoundException pnfe) { - assert false : "The target person cannot be missing"; + model.deleteTask(taskToDelete); + } catch (TaskNotFoundException pnfe) { + assert false : "The target task cannot be missing"; } - return new CommandResult(String.format(MESSAGE_DELETE_PERSON_SUCCESS, personToDelete)); + return new CommandResult(String.format(MESSAGE_DELETE_TASK_SUCCESS, taskToDelete)); } } diff --git a/src/main/java/seedu/address/logic/commands/FindCommand.java b/src/main/java/seedu/address/logic/commands/FindCommand.java index 1d61bf6cc857..cad939e52765 100644 --- a/src/main/java/seedu/address/logic/commands/FindCommand.java +++ b/src/main/java/seedu/address/logic/commands/FindCommand.java @@ -3,14 +3,14 @@ import java.util.Set; /** - * Finds and lists all persons in address book whose name contains any of the argument keywords. + * Finds and lists all tasks in address book whose name contains any of the argument keywords. * Keyword matching is case sensitive. */ public class FindCommand extends Command { public static final String COMMAND_WORD = "find"; - public static final String MESSAGE_USAGE = COMMAND_WORD + ": Finds all persons whose names contain any of " + public static final String MESSAGE_USAGE = COMMAND_WORD + ": Finds all tasks whose names contain any of " + "the specified keywords (case-sensitive) and displays them as a list with index numbers.\n" + "Parameters: KEYWORD [MORE_KEYWORDS]...\n" + "Example: " + COMMAND_WORD + " alice bob charlie"; @@ -23,8 +23,8 @@ public FindCommand(Set keywords) { @Override public CommandResult execute() { - model.updateFilteredPersonList(keywords); - return new CommandResult(getMessageForPersonListShownSummary(model.getFilteredPersonList().size())); + model.updateFilteredTaskList(keywords); + return new CommandResult(getMessageForTaskListShownSummary(model.getFilteredTaskList().size())); } } diff --git a/src/main/java/seedu/address/logic/commands/ListCommand.java b/src/main/java/seedu/address/logic/commands/ListCommand.java index 9bdd457a1b01..0dd3947eaec7 100644 --- a/src/main/java/seedu/address/logic/commands/ListCommand.java +++ b/src/main/java/seedu/address/logic/commands/ListCommand.java @@ -2,13 +2,13 @@ /** - * Lists all persons in the address book to the user. + * Lists all tasks in the address book to the user. */ public class ListCommand extends Command { public static final String COMMAND_WORD = "list"; - public static final String MESSAGE_SUCCESS = "Listed all persons"; + public static final String MESSAGE_SUCCESS = "Listed all tasks"; public ListCommand() {} diff --git a/src/main/java/seedu/address/logic/commands/SelectCommand.java b/src/main/java/seedu/address/logic/commands/SelectCommand.java deleted file mode 100644 index 9ca0551f1951..000000000000 --- a/src/main/java/seedu/address/logic/commands/SelectCommand.java +++ /dev/null @@ -1,44 +0,0 @@ -package seedu.address.logic.commands; - -import seedu.address.commons.core.EventsCenter; -import seedu.address.commons.core.Messages; -import seedu.address.commons.events.ui.JumpToListRequestEvent; -import seedu.address.commons.core.UnmodifiableObservableList; -import seedu.address.model.person.ReadOnlyPerson; - -/** - * Selects a person identified using it's last displayed index from the address book. - */ -public class SelectCommand extends Command { - - public final int targetIndex; - - public static final String COMMAND_WORD = "select"; - - public static final String MESSAGE_USAGE = COMMAND_WORD - + ": Selects the person identified by the index number used in the last person listing.\n" - + "Parameters: INDEX (must be a positive integer)\n" - + "Example: " + COMMAND_WORD + " 1"; - - public static final String MESSAGE_SELECT_PERSON_SUCCESS = "Selected Person: %1$s"; - - public SelectCommand(int targetIndex) { - this.targetIndex = targetIndex; - } - - @Override - public CommandResult execute() { - - UnmodifiableObservableList lastShownList = model.getFilteredPersonList(); - - if (lastShownList.size() < targetIndex) { - indicateAttemptToExecuteIncorrectCommand(); - return new CommandResult(Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); - } - - EventsCenter.getInstance().post(new JumpToListRequestEvent(targetIndex - 1)); - return new CommandResult(String.format(MESSAGE_SELECT_PERSON_SUCCESS, targetIndex)); - - } - -} diff --git a/src/main/java/seedu/address/logic/parser/Parser.java b/src/main/java/seedu/address/logic/parser/Parser.java index 959b2cd0383c..3caf6148515f 100644 --- a/src/main/java/seedu/address/logic/parser/Parser.java +++ b/src/main/java/seedu/address/logic/parser/Parser.java @@ -21,15 +21,15 @@ public class Parser { */ private static final Pattern BASIC_COMMAND_FORMAT = Pattern.compile("(?\\S+)(?.*)"); - private static final Pattern PERSON_INDEX_ARGS_FORMAT = Pattern.compile("(?.+)"); + private static final Pattern TASK_INDEX_ARGS_FORMAT = Pattern.compile("(?.+)"); private static final Pattern KEYWORDS_ARGS_FORMAT = Pattern.compile("(?\\S+(?:\\s+\\S+)*)"); // one or more keywords separated by whitespace - private static final Pattern PERSON_DATA_ARGS_FORMAT = // '/' forward slashes are reserved for delimiter prefixes + private static final Pattern TASK_DATA_ARGS_FORMAT = // '/' forward slashes are reserved for delimiter prefixes Pattern.compile("(?[^/]+)" - + " (?p?)p/(?[^/]+)" - + " (?p?)e/(?[^/]+)" + + " (?p?)p/(?[^/]+)" + + " (?p?)e/(?[^/]+)" + " (?p?)a/(?
[^/]+)" + "(?(?: t/[^/]+)*)"); // variable number of tags @@ -54,9 +54,6 @@ public Command parseCommand(String userInput) { case AddCommand.COMMAND_WORD: return prepareAdd(arguments); - case SelectCommand.COMMAND_WORD: - return prepareSelect(arguments); - case DeleteCommand.COMMAND_WORD: return prepareDelete(arguments); @@ -81,13 +78,13 @@ public Command parseCommand(String userInput) { } /** - * Parses arguments in the context of the add person command. + * Parses arguments in the context of the add task command. * * @param args full command args string * @return the prepared command */ private Command prepareAdd(String args){ - final Matcher matcher = PERSON_DATA_ARGS_FORMAT.matcher(args.trim()); + final Matcher matcher = TASK_DATA_ARGS_FORMAT.matcher(args.trim()); // Validate arg string format if (!matcher.matches()) { return new IncorrectCommand(String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE)); @@ -95,8 +92,8 @@ private Command prepareAdd(String args){ try { return new AddCommand( matcher.group("name"), - matcher.group("phone"), - matcher.group("email"), + matcher.group("startDateTime"), + matcher.group("endDateTime"), matcher.group("address"), getTagsFromArgs(matcher.group("tagArguments")) ); @@ -106,7 +103,7 @@ private Command prepareAdd(String args){ } /** - * Extracts the new person's tags from the add command's tag arguments string. + * Extracts the new task's tags from the add command's tag arguments string. * Merges duplicate tag strings. */ private static Set getTagsFromArgs(String tagArguments) throws IllegalValueException { @@ -120,7 +117,7 @@ private static Set getTagsFromArgs(String tagArguments) throws IllegalVa } /** - * Parses arguments in the context of the delete person command. + * Parses arguments in the context of the delete task command. * * @param args full command args string * @return the prepared command @@ -136,28 +133,12 @@ private Command prepareDelete(String args) { return new DeleteCommand(index.get()); } - /** - * Parses arguments in the context of the select person command. - * - * @param args full command args string - * @return the prepared command - */ - private Command prepareSelect(String args) { - Optional index = parseIndex(args); - if(!index.isPresent()){ - return new IncorrectCommand( - String.format(MESSAGE_INVALID_COMMAND_FORMAT, SelectCommand.MESSAGE_USAGE)); - } - - return new SelectCommand(index.get()); - } - /** * Returns the specified index in the {@code command} IF a positive unsigned integer is given as the index. * Returns an {@code Optional.empty()} otherwise. */ private Optional parseIndex(String command) { - final Matcher matcher = PERSON_INDEX_ARGS_FORMAT.matcher(command.trim()); + final Matcher matcher = TASK_INDEX_ARGS_FORMAT.matcher(command.trim()); if (!matcher.matches()) { return Optional.empty(); } @@ -171,7 +152,7 @@ private Optional parseIndex(String command) { } /** - * Parses arguments in the context of the find person command. + * Parses arguments in the context of the find task command. * * @param args full command args string * @return the prepared command diff --git a/src/main/java/seedu/address/model/AddressBook.java b/src/main/java/seedu/address/model/AddressBook.java index 298cc1b82ce8..2de9593a1814 100644 --- a/src/main/java/seedu/address/model/AddressBook.java +++ b/src/main/java/seedu/address/model/AddressBook.java @@ -1,11 +1,11 @@ package seedu.address.model; import javafx.collections.ObservableList; -import seedu.address.model.person.Person; -import seedu.address.model.person.ReadOnlyPerson; -import seedu.address.model.person.UniquePersonList; import seedu.address.model.tag.Tag; import seedu.address.model.tag.UniqueTagList; +import seedu.address.model.task.Task; +import seedu.address.model.task.ReadOnlyTask; +import seedu.address.model.task.UniqueTaskList; import java.util.*; import java.util.stream.Collectors; @@ -16,28 +16,28 @@ */ public class AddressBook implements ReadOnlyAddressBook { - private final UniquePersonList persons; + private final UniqueTaskList tasks; private final UniqueTagList tags; { - persons = new UniquePersonList(); + tasks = new UniqueTaskList(); tags = new UniqueTagList(); } public AddressBook() {} /** - * Persons and Tags are copied into this addressbook + * Tasks and Tags are copied into this addressbook */ public AddressBook(ReadOnlyAddressBook toBeCopied) { - this(toBeCopied.getUniquePersonList(), toBeCopied.getUniqueTagList()); + this(toBeCopied.getUniqueTaskList(), toBeCopied.getUniqueTagList()); } /** - * Persons and Tags are copied into this addressbook + * Tasks and Tags are copied into this addressbook */ - public AddressBook(UniquePersonList persons, UniqueTagList tags) { - resetData(persons.getInternalList(), tags.getInternalList()); + public AddressBook(UniqueTaskList tasks, UniqueTagList tags) { + resetData(tasks.getInternalList(), tags.getInternalList()); } public static ReadOnlyAddressBook getEmptyAddressBook() { @@ -46,49 +46,49 @@ public static ReadOnlyAddressBook getEmptyAddressBook() { //// list overwrite operations - public ObservableList getPersons() { - return persons.getInternalList(); + public ObservableList getTasks() { + return tasks.getInternalList(); } - public void setPersons(List persons) { - this.persons.getInternalList().setAll(persons); + public void setTasks(List tasks) { + this.tasks.getInternalList().setAll(tasks); } public void setTags(Collection tags) { this.tags.getInternalList().setAll(tags); } - public void resetData(Collection newPersons, Collection newTags) { - setPersons(newPersons.stream().map(Person::new).collect(Collectors.toList())); + public void resetData(Collection newTasks, Collection newTags) { + setTasks(newTasks.stream().map(Task::new).collect(Collectors.toList())); setTags(newTags); } public void resetData(ReadOnlyAddressBook newData) { - resetData(newData.getPersonList(), newData.getTagList()); + resetData(newData.getTaskList(), newData.getTagList()); } -//// person-level operations +//// task-level operations /** - * Adds a person to the address book. - * Also checks the new person's tags and updates {@link #tags} with any new tags found, - * and updates the Tag objects in the person to point to those in {@link #tags}. + * Adds a task to the address book. + * Also checks the new task's tags and updates {@link #tags} with any new tags found, + * and updates the Tag objects in the task to point to those in {@link #tags}. * - * @throws UniquePersonList.DuplicatePersonException if an equivalent person already exists. + * @throws UniqueTaskList.DuplicateTaskException if an equivalent task already exists. */ - public void addPerson(Person p) throws UniquePersonList.DuplicatePersonException { + public void addTask(Task p) throws UniqueTaskList.DuplicateTaskException { syncTagsWithMasterList(p); - persons.add(p); + tasks.add(p); } /** - * Ensures that every tag in this person: + * Ensures that every tag in this task: * - exists in the master list {@link #tags} * - points to a Tag object in the master list */ - private void syncTagsWithMasterList(Person person) { - final UniqueTagList personTags = person.getTags(); - tags.mergeFrom(personTags); + private void syncTagsWithMasterList(Task task) { + final UniqueTagList taskTags = task.getTags(); + tags.mergeFrom(taskTags); // Create map with values = tag object references in the master list final Map masterTagObjects = new HashMap<>(); @@ -96,19 +96,19 @@ private void syncTagsWithMasterList(Person person) { masterTagObjects.put(tag, tag); } - // Rebuild the list of person tags using references from the master list + // Rebuild the list of task tags using references from the master list final Set commonTagReferences = new HashSet<>(); - for (Tag tag : personTags) { + for (Tag tag : taskTags) { commonTagReferences.add(masterTagObjects.get(tag)); } - person.setTags(new UniqueTagList(commonTagReferences)); + task.setTags(new UniqueTagList(commonTagReferences)); } - public boolean removePerson(ReadOnlyPerson key) throws UniquePersonList.PersonNotFoundException { - if (persons.remove(key)) { + public boolean removeTask(ReadOnlyTask key) throws UniqueTaskList.TaskNotFoundException { + if (tasks.remove(key)) { return true; } else { - throw new UniquePersonList.PersonNotFoundException(); + throw new UniqueTaskList.TaskNotFoundException(); } } @@ -122,13 +122,13 @@ public void addTag(Tag t) throws UniqueTagList.DuplicateTagException { @Override public String toString() { - return persons.getInternalList().size() + " persons, " + tags.getInternalList().size() + " tags"; + return tasks.getInternalList().size() + " tasks, " + tags.getInternalList().size() + " tags"; // TODO: refine later } @Override - public List getPersonList() { - return Collections.unmodifiableList(persons.getInternalList()); + public List getTaskList() { + return Collections.unmodifiableList(tasks.getInternalList()); } @Override @@ -137,8 +137,8 @@ public List getTagList() { } @Override - public UniquePersonList getUniquePersonList() { - return this.persons; + public UniqueTaskList getUniqueTaskList() { + return this.tasks; } @Override @@ -151,13 +151,13 @@ public UniqueTagList getUniqueTagList() { public boolean equals(Object other) { return other == this // short circuit if same object || (other instanceof AddressBook // instanceof handles nulls - && this.persons.equals(((AddressBook) other).persons) + && this.tasks.equals(((AddressBook) other).tasks) && this.tags.equals(((AddressBook) other).tags)); } @Override public int hashCode() { // use this method for custom fields hashing instead of implementing your own - return Objects.hash(persons, tags); + return Objects.hash(tasks, tags); } } diff --git a/src/main/java/seedu/address/model/Model.java b/src/main/java/seedu/address/model/Model.java index d14a27a93b5e..3654dbd91f03 100644 --- a/src/main/java/seedu/address/model/Model.java +++ b/src/main/java/seedu/address/model/Model.java @@ -1,9 +1,9 @@ package seedu.address.model; import seedu.address.commons.core.UnmodifiableObservableList; -import seedu.address.model.person.Person; -import seedu.address.model.person.ReadOnlyPerson; -import seedu.address.model.person.UniquePersonList; +import seedu.address.model.task.Task; +import seedu.address.model.task.ReadOnlyTask; +import seedu.address.model.task.UniqueTaskList; import java.util.Set; @@ -17,19 +17,19 @@ public interface Model { /** Returns the AddressBook */ ReadOnlyAddressBook getAddressBook(); - /** Deletes the given person. */ - void deletePerson(ReadOnlyPerson target) throws UniquePersonList.PersonNotFoundException; + /** Deletes the given Task. */ + void deleteTask(ReadOnlyTask target) throws UniqueTaskList.TaskNotFoundException; - /** Adds the given person */ - void addPerson(Person person) throws UniquePersonList.DuplicatePersonException; + /** Adds the given Task */ + void addTask(Task Task) throws UniqueTaskList.DuplicateTaskException; - /** Returns the filtered person list as an {@code UnmodifiableObservableList} */ - UnmodifiableObservableList getFilteredPersonList(); + /** Returns the filtered Task list as an {@code UnmodifiableObservableList} */ + UnmodifiableObservableList getFilteredTaskList(); - /** Updates the filter of the filtered person list to show all persons */ + /** Updates the filter of the filtered Task list to show all Tasks */ void updateFilteredListToShowAll(); - /** Updates the filter of the filtered person list to filter by the given keywords*/ - void updateFilteredPersonList(Set keywords); + /** Updates the filter of the filtered Task list to filter by the given keywords*/ + void updateFilteredTaskList(Set keywords); } diff --git a/src/main/java/seedu/address/model/ModelManager.java b/src/main/java/seedu/address/model/ModelManager.java index 869226d02bf1..34e09687011c 100644 --- a/src/main/java/seedu/address/model/ModelManager.java +++ b/src/main/java/seedu/address/model/ModelManager.java @@ -4,12 +4,12 @@ import seedu.address.commons.core.LogsCenter; import seedu.address.commons.core.UnmodifiableObservableList; import seedu.address.commons.util.StringUtil; +import seedu.address.model.task.Task; +import seedu.address.model.task.ReadOnlyTask; +import seedu.address.model.task.UniqueTaskList; +import seedu.address.model.task.UniqueTaskList.TaskNotFoundException; import seedu.address.commons.events.model.AddressBookChangedEvent; import seedu.address.commons.core.ComponentManager; -import seedu.address.model.person.Person; -import seedu.address.model.person.ReadOnlyPerson; -import seedu.address.model.person.UniquePersonList; -import seedu.address.model.person.UniquePersonList.PersonNotFoundException; import java.util.Set; import java.util.logging.Logger; @@ -22,7 +22,7 @@ public class ModelManager extends ComponentManager implements Model { private static final Logger logger = LogsCenter.getLogger(ModelManager.class); private final AddressBook addressBook; - private final FilteredList filteredPersons; + private final FilteredList filteredTasks; /** * Initializes a ModelManager with the given AddressBook @@ -36,7 +36,7 @@ public ModelManager(AddressBook src, UserPrefs userPrefs) { logger.fine("Initializing with address book: " + src + " and user prefs " + userPrefs); addressBook = new AddressBook(src); - filteredPersons = new FilteredList<>(addressBook.getPersons()); + filteredTasks = new FilteredList<>(addressBook.getTasks()); } public ModelManager() { @@ -45,7 +45,7 @@ public ModelManager() { public ModelManager(ReadOnlyAddressBook initialData, UserPrefs userPrefs) { addressBook = new AddressBook(initialData); - filteredPersons = new FilteredList<>(addressBook.getPersons()); + filteredTasks = new FilteredList<>(addressBook.getTasks()); } @Override @@ -65,43 +65,43 @@ private void indicateAddressBookChanged() { } @Override - public synchronized void deletePerson(ReadOnlyPerson target) throws PersonNotFoundException { - addressBook.removePerson(target); + public synchronized void deleteTask(ReadOnlyTask target) throws TaskNotFoundException { + addressBook.removeTask(target); indicateAddressBookChanged(); } @Override - public synchronized void addPerson(Person person) throws UniquePersonList.DuplicatePersonException { - addressBook.addPerson(person); + public synchronized void addTask(Task task) throws UniqueTaskList.DuplicateTaskException { + addressBook.addTask(task); updateFilteredListToShowAll(); indicateAddressBookChanged(); } - //=========== Filtered Person List Accessors =============================================================== + //=========== Filtered Task List Accessors =============================================================== @Override - public UnmodifiableObservableList getFilteredPersonList() { - return new UnmodifiableObservableList<>(filteredPersons); + public UnmodifiableObservableList getFilteredTaskList() { + return new UnmodifiableObservableList<>(filteredTasks); } @Override public void updateFilteredListToShowAll() { - filteredPersons.setPredicate(null); + filteredTasks.setPredicate(null); } @Override - public void updateFilteredPersonList(Set keywords){ - updateFilteredPersonList(new PredicateExpression(new NameQualifier(keywords))); + public void updateFilteredTaskList(Set keywords){ + updateFilteredTaskList(new PredicateExpression(new NameQualifier(keywords))); } - private void updateFilteredPersonList(Expression expression) { - filteredPersons.setPredicate(expression::satisfies); + private void updateFilteredTaskList(Expression expression) { + filteredTasks.setPredicate(expression::satisfies); } //========== Inner classes/interfaces used for filtering ================================================== interface Expression { - boolean satisfies(ReadOnlyPerson person); + boolean satisfies(ReadOnlyTask task); String toString(); } @@ -114,8 +114,8 @@ private class PredicateExpression implements Expression { } @Override - public boolean satisfies(ReadOnlyPerson person) { - return qualifier.run(person); + public boolean satisfies(ReadOnlyTask task) { + return qualifier.run(task); } @Override @@ -125,7 +125,7 @@ public String toString() { } interface Qualifier { - boolean run(ReadOnlyPerson person); + boolean run(ReadOnlyTask task); String toString(); } @@ -137,9 +137,9 @@ private class NameQualifier implements Qualifier { } @Override - public boolean run(ReadOnlyPerson person) { + public boolean run(ReadOnlyTask task) { return nameKeyWords.stream() - .filter(keyword -> StringUtil.containsIgnoreCase(person.getName().fullName, keyword)) + .filter(keyword -> StringUtil.containsIgnoreCase(task.getName().fullName, keyword)) .findAny() .isPresent(); } diff --git a/src/main/java/seedu/address/model/ReadOnlyAddressBook.java b/src/main/java/seedu/address/model/ReadOnlyAddressBook.java index bfca099b1e81..86d1508afc21 100644 --- a/src/main/java/seedu/address/model/ReadOnlyAddressBook.java +++ b/src/main/java/seedu/address/model/ReadOnlyAddressBook.java @@ -1,10 +1,10 @@ package seedu.address.model; -import seedu.address.model.person.ReadOnlyPerson; -import seedu.address.model.person.UniquePersonList; import seedu.address.model.tag.Tag; import seedu.address.model.tag.UniqueTagList; +import seedu.address.model.task.ReadOnlyTask; +import seedu.address.model.task.UniqueTaskList; import java.util.List; @@ -15,12 +15,12 @@ public interface ReadOnlyAddressBook { UniqueTagList getUniqueTagList(); - UniquePersonList getUniquePersonList(); + UniqueTaskList getUniqueTaskList(); /** - * Returns an unmodifiable view of persons list + * Returns an unmodifiable view of tasks list */ - List getPersonList(); + List getTaskList(); /** * Returns an unmodifiable view of tags list diff --git a/src/main/java/seedu/address/model/person/Address.java b/src/main/java/seedu/address/model/person/Address.java deleted file mode 100644 index a2bd109c005e..000000000000 --- a/src/main/java/seedu/address/model/person/Address.java +++ /dev/null @@ -1,54 +0,0 @@ -package seedu.address.model.person; - - -import seedu.address.commons.exceptions.IllegalValueException; - -/** - * Represents a Person's address in the address book. - * Guarantees: immutable; is valid as declared in {@link #isValidAddress(String)} - */ -public class Address { - - public static final String MESSAGE_ADDRESS_CONSTRAINTS = "Person addresses can be in any format"; - public static final String ADDRESS_VALIDATION_REGEX = ".+"; - - public final String value; - - /** - * Validates given address. - * - * @throws IllegalValueException if given address string is invalid. - */ - public Address(String address) throws IllegalValueException { - assert address != null; - if (!isValidAddress(address)) { - throw new IllegalValueException(MESSAGE_ADDRESS_CONSTRAINTS); - } - this.value = address; - } - - /** - * Returns true if a given string is a valid person email. - */ - public static boolean isValidAddress(String test) { - return test.matches(ADDRESS_VALIDATION_REGEX); - } - - @Override - public String toString() { - return value; - } - - @Override - public boolean equals(Object other) { - return other == this // short circuit if same object - || (other instanceof Address // instanceof handles nulls - && this.value.equals(((Address) other).value)); // state check - } - - @Override - public int hashCode() { - return value.hashCode(); - } - -} \ No newline at end of file diff --git a/src/main/java/seedu/address/model/person/Email.java b/src/main/java/seedu/address/model/person/Email.java deleted file mode 100644 index 5da4d1078236..000000000000 --- a/src/main/java/seedu/address/model/person/Email.java +++ /dev/null @@ -1,56 +0,0 @@ -package seedu.address.model.person; - - -import seedu.address.commons.exceptions.IllegalValueException; - -/** - * Represents a Person's phone number in the address book. - * Guarantees: immutable; is valid as declared in {@link #isValidEmail(String)} - */ -public class Email { - - public static final String MESSAGE_EMAIL_CONSTRAINTS = - "Person emails should be 2 alphanumeric/period strings separated by '@'"; - public static final String EMAIL_VALIDATION_REGEX = "[\\w\\.]+@[\\w\\.]+"; - - public final String value; - - /** - * Validates given email. - * - * @throws IllegalValueException if given email address string is invalid. - */ - public Email(String email) throws IllegalValueException { - assert email != null; - email = email.trim(); - if (!isValidEmail(email)) { - throw new IllegalValueException(MESSAGE_EMAIL_CONSTRAINTS); - } - this.value = email; - } - - /** - * Returns if a given string is a valid person email. - */ - public static boolean isValidEmail(String test) { - return test.matches(EMAIL_VALIDATION_REGEX); - } - - @Override - public String toString() { - return value; - } - - @Override - public boolean equals(Object other) { - return other == this // short circuit if same object - || (other instanceof Email // instanceof handles nulls - && this.value.equals(((Email) other).value)); // state check - } - - @Override - public int hashCode() { - return value.hashCode(); - } - -} diff --git a/src/main/java/seedu/address/model/person/Phone.java b/src/main/java/seedu/address/model/person/Phone.java deleted file mode 100644 index d27b2244b727..000000000000 --- a/src/main/java/seedu/address/model/person/Phone.java +++ /dev/null @@ -1,54 +0,0 @@ -package seedu.address.model.person; - -import seedu.address.commons.exceptions.IllegalValueException; - -/** - * Represents a Person's phone number in the address book. - * Guarantees: immutable; is valid as declared in {@link #isValidPhone(String)} - */ -public class Phone { - - public static final String MESSAGE_PHONE_CONSTRAINTS = "Person phone numbers should only contain numbers"; - public static final String PHONE_VALIDATION_REGEX = "\\d+"; - - public final String value; - - /** - * Validates given phone number. - * - * @throws IllegalValueException if given phone string is invalid. - */ - public Phone(String phone) throws IllegalValueException { - assert phone != null; - phone = phone.trim(); - if (!isValidPhone(phone)) { - throw new IllegalValueException(MESSAGE_PHONE_CONSTRAINTS); - } - this.value = phone; - } - - /** - * Returns true if a given string is a valid person phone number. - */ - public static boolean isValidPhone(String test) { - return test.matches(PHONE_VALIDATION_REGEX); - } - - @Override - public String toString() { - return value; - } - - @Override - public boolean equals(Object other) { - return other == this // short circuit if same object - || (other instanceof Phone // instanceof handles nulls - && this.value.equals(((Phone) other).value)); // state check - } - - @Override - public int hashCode() { - return value.hashCode(); - } - -} diff --git a/src/main/java/seedu/address/model/person/UniquePersonList.java b/src/main/java/seedu/address/model/person/UniquePersonList.java deleted file mode 100644 index 263f1fcc7dd5..000000000000 --- a/src/main/java/seedu/address/model/person/UniquePersonList.java +++ /dev/null @@ -1,98 +0,0 @@ -package seedu.address.model.person; - -import javafx.collections.FXCollections; -import javafx.collections.ObservableList; -import seedu.address.commons.util.CollectionUtil; -import seedu.address.commons.exceptions.DuplicateDataException; - -import java.util.*; - -/** - * A list of persons that enforces uniqueness between its elements and does not allow nulls. - * - * Supports a minimal set of list operations. - * - * @see Person#equals(Object) - * @see CollectionUtil#elementsAreUnique(Collection) - */ -public class UniquePersonList implements Iterable { - - /** - * Signals that an operation would have violated the 'no duplicates' property of the list. - */ - public static class DuplicatePersonException extends DuplicateDataException { - protected DuplicatePersonException() { - super("Operation would result in duplicate persons"); - } - } - - /** - * Signals that an operation targeting a specified person in the list would fail because - * there is no such matching person in the list. - */ - public static class PersonNotFoundException extends Exception {} - - private final ObservableList internalList = FXCollections.observableArrayList(); - - /** - * Constructs empty PersonList. - */ - public UniquePersonList() {} - - /** - * Returns true if the list contains an equivalent person as the given argument. - */ - public boolean contains(ReadOnlyPerson toCheck) { - assert toCheck != null; - return internalList.contains(toCheck); - } - - /** - * Adds a person to the list. - * - * @throws DuplicatePersonException if the person to add is a duplicate of an existing person in the list. - */ - public void add(Person toAdd) throws DuplicatePersonException { - assert toAdd != null; - if (contains(toAdd)) { - throw new DuplicatePersonException(); - } - internalList.add(toAdd); - } - - /** - * Removes the equivalent person from the list. - * - * @throws PersonNotFoundException if no such person could be found in the list. - */ - public boolean remove(ReadOnlyPerson toRemove) throws PersonNotFoundException { - assert toRemove != null; - final boolean personFoundAndDeleted = internalList.remove(toRemove); - if (!personFoundAndDeleted) { - throw new PersonNotFoundException(); - } - return personFoundAndDeleted; - } - - public ObservableList getInternalList() { - return internalList; - } - - @Override - public Iterator iterator() { - return internalList.iterator(); - } - - @Override - public boolean equals(Object other) { - return other == this // short circuit if same object - || (other instanceof UniquePersonList // instanceof handles nulls - && this.internalList.equals( - ((UniquePersonList) other).internalList)); - } - - @Override - public int hashCode() { - return internalList.hashCode(); - } -} diff --git a/src/main/java/seedu/address/model/task/Date.java b/src/main/java/seedu/address/model/task/Date.java new file mode 100644 index 000000000000..8a8fcf2da2a5 --- /dev/null +++ b/src/main/java/seedu/address/model/task/Date.java @@ -0,0 +1,54 @@ +package seedu.address.model.task; + + +import seedu.address.commons.exceptions.IllegalValueException; + +/** + * Represents a task's date in the scheduler. + * Guarantees: immutable; is valid as declared in {@link #isValidDate(String)} + */ +public class Date { + + public static final String MESSAGE_DATE_CONSTRAINTS = "Task dates can be in any format"; + public static final String DATE_VALIDATION_REGEX = ".+"; + + public final String value; + + /** + * Validates given date. + * + * @throws IllegalValueException if given date string is invalid. + */ + public Date(String date) throws IllegalValueException { + assert date != null; + if (!isValidDate(date)) { + throw new IllegalValueException(MESSAGE_DATE_CONSTRAINTS); + } + this.value = date; + } + + /** + * Returns true if a given string is a valid task endDateTime. + */ + public static boolean isValidDate(String test) { + return test.matches(DATE_VALIDATION_REGEX); + } + + @Override + public String toString() { + return value; + } + + @Override + public boolean equals(Object other) { + return other == this // short circuit if same object + || (other instanceof Date // instanceof handles nulls + && this.value.equals(((Date) other).value)); // state check + } + + @Override + public int hashCode() { + return value.hashCode(); + } + +} \ No newline at end of file diff --git a/src/main/java/seedu/address/model/task/EndDateTime.java b/src/main/java/seedu/address/model/task/EndDateTime.java new file mode 100644 index 000000000000..6fb455c37255 --- /dev/null +++ b/src/main/java/seedu/address/model/task/EndDateTime.java @@ -0,0 +1,56 @@ +package seedu.address.model.task; + + +import seedu.address.commons.exceptions.IllegalValueException; + +/** + * Represents a Task's startDateTime number in the address book. + * Guarantees: immutable; is valid as declared in {@link #isValidEndDateTime(String)} + */ +public class EndDateTime { + + public static final String MESSAGE_END_DATE_TIME_CONSTRAINTS = + "Task endDateTimes should be 2 alphanumeric/period strings separated by '@'"; + public static final String END_DATE_TIME_VALIDATION_REGEX = "[\\w\\.]+@[\\w\\.]+"; + + public final String value; + + /** + * Validates given endDateTime. + * + * @throws IllegalValueException if given endDateTime address string is invalid. + */ + public EndDateTime(String endDateTime) throws IllegalValueException { + assert endDateTime != null; + endDateTime = endDateTime.trim(); + if (!isValidEndDateTime(endDateTime)) { + throw new IllegalValueException(MESSAGE_END_DATE_TIME_CONSTRAINTS); + } + this.value = endDateTime; + } + + /** + * Returns if a given string is a valid task endDateTime. + */ + public static boolean isValidEndDateTime(String test) { + return test.matches(END_DATE_TIME_VALIDATION_REGEX); + } + + @Override + public String toString() { + return value; + } + + @Override + public boolean equals(Object other) { + return other == this // short circuit if same object + || (other instanceof EndDateTime // instanceof handles nulls + && this.value.equals(((EndDateTime) other).value)); // state check + } + + @Override + public int hashCode() { + return value.hashCode(); + } + +} diff --git a/src/main/java/seedu/address/model/person/Name.java b/src/main/java/seedu/address/model/task/Name.java similarity index 82% rename from src/main/java/seedu/address/model/person/Name.java rename to src/main/java/seedu/address/model/task/Name.java index 4f30033e70fe..81be0b755587 100644 --- a/src/main/java/seedu/address/model/person/Name.java +++ b/src/main/java/seedu/address/model/task/Name.java @@ -1,14 +1,14 @@ -package seedu.address.model.person; +package seedu.address.model.task; import seedu.address.commons.exceptions.IllegalValueException; /** - * Represents a Person's name in the address book. + * Represents a Task's name in the address book. * Guarantees: immutable; is valid as declared in {@link #isValidName(String)} */ public class Name { - public static final String MESSAGE_NAME_CONSTRAINTS = "Person names should be spaces or alphanumeric characters"; + public static final String MESSAGE_NAME_CONSTRAINTS = "Task names should be spaces or alphanumeric characters"; public static final String NAME_VALIDATION_REGEX = "[\\p{Alnum} ]+"; public final String fullName; @@ -28,7 +28,7 @@ public Name(String name) throws IllegalValueException { } /** - * Returns true if a given string is a valid person name. + * Returns true if a given string is a valid task name. */ public static boolean isValidName(String test) { return test.matches(NAME_VALIDATION_REGEX); diff --git a/src/main/java/seedu/address/model/person/ReadOnlyPerson.java b/src/main/java/seedu/address/model/task/ReadOnlyTask.java similarity index 57% rename from src/main/java/seedu/address/model/person/ReadOnlyPerson.java rename to src/main/java/seedu/address/model/task/ReadOnlyTask.java index d45be4b5fe36..4ff8f45b8006 100644 --- a/src/main/java/seedu/address/model/person/ReadOnlyPerson.java +++ b/src/main/java/seedu/address/model/task/ReadOnlyTask.java @@ -1,55 +1,55 @@ -package seedu.address.model.person; +package seedu.address.model.task; import seedu.address.model.tag.UniqueTagList; /** - * A read-only immutable interface for a Person in the addressbook. + * A read-only immutable interface for a Task in the addressbook. * Implementations should guarantee: details are present and not null, field values are validated. */ -public interface ReadOnlyPerson { +public interface ReadOnlyTask { Name getName(); - Phone getPhone(); - Email getEmail(); - Address getAddress(); + StartDateTime getStartDateTime(); + EndDateTime getEndDateTime(); + Date getDate(); /** * The returned TagList is a deep copy of the internal TagList, - * changes on the returned list will not affect the person's internal tags. + * changes on the returned list will not affect the task's internal tags. */ UniqueTagList getTags(); /** * Returns true if both have the same state. (interfaces cannot override .equals) */ - default boolean isSameStateAs(ReadOnlyPerson other) { + default boolean isSameStateAs(ReadOnlyTask other) { return other == this // short circuit if same object || (other != null // this is first to avoid NPE below && other.getName().equals(this.getName()) // state checks here onwards - && other.getPhone().equals(this.getPhone()) - && other.getEmail().equals(this.getEmail()) - && other.getAddress().equals(this.getAddress())); + && other.getStartDateTime().equals(this.getStartDateTime()) + && other.getEndDateTime().equals(this.getEndDateTime()) + && other.getDate().equals(this.getDate())); } /** - * Formats the person as text, showing all contact details. + * Formats the task as text, showing all contact details. */ default String getAsText() { final StringBuilder builder = new StringBuilder(); builder.append(getName()) - .append(" Phone: ") - .append(getPhone()) - .append(" Email: ") - .append(getEmail()) - .append(" Address: ") - .append(getAddress()) + .append(" StartDateTime: ") + .append(getStartDateTime()) + .append(" EndDateTime: ") + .append(getEndDateTime()) + .append(" Date: ") + .append(getDate()) .append(" Tags: "); getTags().forEach(builder::append); return builder.toString(); } /** - * Returns a string representation of this Person's tags + * Returns a string representation of this Task's tags */ default String tagsString() { final StringBuffer buffer = new StringBuffer(); diff --git a/src/main/java/seedu/address/model/task/StartDateTime.java b/src/main/java/seedu/address/model/task/StartDateTime.java new file mode 100644 index 000000000000..817fa5b5ee69 --- /dev/null +++ b/src/main/java/seedu/address/model/task/StartDateTime.java @@ -0,0 +1,54 @@ +package seedu.address.model.task; + +import seedu.address.commons.exceptions.IllegalValueException; + +/** + * Represents a Task's startDateTime number in the address book. + * Guarantees: immutable; is valid as declared in {@link #isValidStartDateTime(String)} + */ +public class StartDateTime { + + public static final String MESSAGE_START_DATE_TIME_CONSTRAINTS = "Task startDateTime numbers should only contain numbers"; + public static final String START_DATE_TIME_VALIDATION_REGEX = "\\d+"; + + public final String value; + + /** + * Validates given startDateTime number. + * + * @throws IllegalValueException if given startDateTime string is invalid. + */ + public StartDateTime(String startDateTime) throws IllegalValueException { + assert startDateTime != null; + startDateTime = startDateTime.trim(); + if (!isValidStartDateTime(startDateTime)) { + throw new IllegalValueException(MESSAGE_START_DATE_TIME_CONSTRAINTS); + } + this.value = startDateTime; + } + + /** + * Returns true if a given string is a valid task startDateTime number. + */ + public static boolean isValidStartDateTime(String test) { + return test.matches(START_DATE_TIME_VALIDATION_REGEX); + } + + @Override + public String toString() { + return value; + } + + @Override + public boolean equals(Object other) { + return other == this // short circuit if same object + || (other instanceof StartDateTime // instanceof handles nulls + && this.value.equals(((StartDateTime) other).value)); // state check + } + + @Override + public int hashCode() { + return value.hashCode(); + } + +} diff --git a/src/main/java/seedu/address/model/person/Person.java b/src/main/java/seedu/address/model/task/Task.java similarity index 50% rename from src/main/java/seedu/address/model/person/Person.java rename to src/main/java/seedu/address/model/task/Task.java index 03ffce7d2e79..8b1da0f1e086 100644 --- a/src/main/java/seedu/address/model/person/Person.java +++ b/src/main/java/seedu/address/model/task/Task.java @@ -1,4 +1,4 @@ -package seedu.address.model.person; +package seedu.address.model.task; import seedu.address.commons.util.CollectionUtil; import seedu.address.model.tag.UniqueTagList; @@ -6,35 +6,35 @@ import java.util.Objects; /** - * Represents a Person in the address book. + * Represents a Task in the address book. * Guarantees: details are present and not null, field values are validated. */ -public class Person implements ReadOnlyPerson { +public class Task implements ReadOnlyTask { private Name name; - private Phone phone; - private Email email; - private Address address; + private StartDateTime startDateTime; + private EndDateTime endDateTime; + private Date date; private UniqueTagList tags; /** * Every field must be present and not null. */ - public Person(Name name, Phone phone, Email email, Address address, UniqueTagList tags) { - assert !CollectionUtil.isAnyNull(name, phone, email, address, tags); + public Task(Name name, StartDateTime startDateTime, EndDateTime endDateTime, Date date, UniqueTagList tags) { + assert !CollectionUtil.isAnyNull(name, startDateTime, endDateTime, date, tags); this.name = name; - this.phone = phone; - this.email = email; - this.address = address; + this.startDateTime = startDateTime; + this.endDateTime = endDateTime; + this.date = date; this.tags = new UniqueTagList(tags); // protect internal tags from changes in the arg list } /** * Copy constructor. */ - public Person(ReadOnlyPerson source) { - this(source.getName(), source.getPhone(), source.getEmail(), source.getAddress(), source.getTags()); + public Task(ReadOnlyTask source) { + this(source.getName(), source.getStartDateTime(), source.getEndDateTime(), source.getDate(), source.getTags()); } @Override @@ -43,18 +43,18 @@ public Name getName() { } @Override - public Phone getPhone() { - return phone; + public StartDateTime getStartDateTime() { + return startDateTime; } @Override - public Email getEmail() { - return email; + public EndDateTime getEndDateTime() { + return endDateTime; } @Override - public Address getAddress() { - return address; + public Date getDate() { + return date; } @Override @@ -63,7 +63,7 @@ public UniqueTagList getTags() { } /** - * Replaces this person's tags with the tags in the argument tag list. + * Replaces this task's tags with the tags in the argument tag list. */ public void setTags(UniqueTagList replacement) { tags.setTags(replacement); @@ -72,14 +72,14 @@ public void setTags(UniqueTagList replacement) { @Override public boolean equals(Object other) { return other == this // short circuit if same object - || (other instanceof ReadOnlyPerson // instanceof handles nulls - && this.isSameStateAs((ReadOnlyPerson) other)); + || (other instanceof ReadOnlyTask // instanceof handles nulls + && this.isSameStateAs((ReadOnlyTask) other)); } @Override public int hashCode() { // use this method for custom fields hashing instead of implementing your own - return Objects.hash(name, phone, email, address, tags); + return Objects.hash(name, startDateTime, endDateTime, date, tags); } @Override diff --git a/src/main/java/seedu/address/model/task/UniqueTaskList.java b/src/main/java/seedu/address/model/task/UniqueTaskList.java new file mode 100644 index 000000000000..acd5df5dad9b --- /dev/null +++ b/src/main/java/seedu/address/model/task/UniqueTaskList.java @@ -0,0 +1,98 @@ +package seedu.address.model.task; + +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import seedu.address.commons.util.CollectionUtil; +import seedu.address.commons.exceptions.DuplicateDataException; + +import java.util.*; + +/** + * A list of Tasks that enforces uniqueness between its elements and does not allow nulls. + * + * Supports a minimal set of list operations. + * + * @see Task#equals(Object) + * @see CollectionUtil#elementsAreUnique(Collection) + */ +public class UniqueTaskList implements Iterable { + + /** + * Signals that an operation would have violated the 'no duplicates' property of the list. + */ + public static class DuplicateTaskException extends DuplicateDataException { + protected DuplicateTaskException() { + super("Operation would result in duplicate Tasks"); + } + } + + /** + * Signals that an operation targeting a specified Task in the list would fail because + * there is no such matching Task in the list. + */ + public static class TaskNotFoundException extends Exception {} + + private final ObservableList internalList = FXCollections.observableArrayList(); + + /** + * Constructs empty TaskList. + */ + public UniqueTaskList() {} + + /** + * Returns true if the list contains an equivalent Task as the given argument. + */ + public boolean contains(ReadOnlyTask toCheck) { + assert toCheck != null; + return internalList.contains(toCheck); + } + + /** + * Adds a Task to the list. + * + * @throws DuplicateTaskException if the Task to add is a duplicate of an existing Task in the list. + */ + public void add(Task toAdd) throws DuplicateTaskException { + assert toAdd != null; + if (contains(toAdd)) { + throw new DuplicateTaskException(); + } + internalList.add(toAdd); + } + + /** + * Removes the equivalent Task from the list. + * + * @throws TaskNotFoundException if no such Task could be found in the list. + */ + public boolean remove(ReadOnlyTask toRemove) throws TaskNotFoundException { + assert toRemove != null; + final boolean TaskFoundAndDeleted = internalList.remove(toRemove); + if (!TaskFoundAndDeleted) { + throw new TaskNotFoundException(); + } + return TaskFoundAndDeleted; + } + + public ObservableList getInternalList() { + return internalList; + } + + @Override + public Iterator iterator() { + return internalList.iterator(); + } + + @Override + public boolean equals(Object other) { + return other == this // short circuit if same object + || (other instanceof UniqueTaskList // instanceof handles nulls + && this.internalList.equals( + ((UniqueTaskList) other).internalList)); + } + + @Override + public int hashCode() { + return internalList.hashCode(); + } +} diff --git a/src/main/java/seedu/address/storage/XmlAdaptedPerson.java b/src/main/java/seedu/address/storage/XmlAdaptedPerson.java deleted file mode 100644 index f2167ec201b4..000000000000 --- a/src/main/java/seedu/address/storage/XmlAdaptedPerson.java +++ /dev/null @@ -1,68 +0,0 @@ -package seedu.address.storage; - -import seedu.address.commons.exceptions.IllegalValueException; -import seedu.address.model.person.*; -import seedu.address.model.tag.Tag; -import seedu.address.model.tag.UniqueTagList; - -import javax.xml.bind.annotation.XmlElement; -import java.util.ArrayList; -import java.util.List; - -/** - * JAXB-friendly version of the Person. - */ -public class XmlAdaptedPerson { - - @XmlElement(required = true) - private String name; - @XmlElement(required = true) - private String phone; - @XmlElement(required = true) - private String email; - @XmlElement(required = true) - private String address; - - @XmlElement - private List tagged = new ArrayList<>(); - - /** - * No-arg constructor for JAXB use. - */ - public XmlAdaptedPerson() {} - - - /** - * Converts a given Person into this class for JAXB use. - * - * @param source future changes to this will not affect the created XmlAdaptedPerson - */ - public XmlAdaptedPerson(ReadOnlyPerson source) { - name = source.getName().fullName; - phone = source.getPhone().value; - email = source.getEmail().value; - address = source.getAddress().value; - tagged = new ArrayList<>(); - for (Tag tag : source.getTags()) { - tagged.add(new XmlAdaptedTag(tag)); - } - } - - /** - * Converts this jaxb-friendly adapted person object into the model's Person object. - * - * @throws IllegalValueException if there were any data constraints violated in the adapted person - */ - public Person toModelType() throws IllegalValueException { - final List personTags = new ArrayList<>(); - for (XmlAdaptedTag tag : tagged) { - personTags.add(tag.toModelType()); - } - final Name name = new Name(this.name); - final Phone phone = new Phone(this.phone); - final Email email = new Email(this.email); - final Address address = new Address(this.address); - final UniqueTagList tags = new UniqueTagList(personTags); - return new Person(name, phone, email, address, tags); - } -} diff --git a/src/main/java/seedu/address/storage/XmlAdaptedTag.java b/src/main/java/seedu/address/storage/XmlAdaptedTag.java index b9723fafbc67..fe1061e8be7d 100644 --- a/src/main/java/seedu/address/storage/XmlAdaptedTag.java +++ b/src/main/java/seedu/address/storage/XmlAdaptedTag.java @@ -31,7 +31,7 @@ public XmlAdaptedTag(Tag source) { /** * Converts this jaxb-friendly adapted tag object into the model's Tag object. * - * @throws IllegalValueException if there were any data constraints violated in the adapted person + * @throws IllegalValueException if there were any data constraints violated in the adapted task */ public Tag toModelType() throws IllegalValueException { return new Tag(tagName); diff --git a/src/main/java/seedu/address/storage/XmlAdaptedTask.java b/src/main/java/seedu/address/storage/XmlAdaptedTask.java new file mode 100644 index 000000000000..0829b7ff28de --- /dev/null +++ b/src/main/java/seedu/address/storage/XmlAdaptedTask.java @@ -0,0 +1,68 @@ +package seedu.address.storage; + +import seedu.address.commons.exceptions.IllegalValueException; +import seedu.address.model.tag.Tag; +import seedu.address.model.tag.UniqueTagList; +import seedu.address.model.task.*; + +import javax.xml.bind.annotation.XmlElement; +import java.util.ArrayList; +import java.util.List; + +/** + * JAXB-friendly version of the Task. + */ +public class XmlAdaptedTask { + + @XmlElement(required = true) + private String name; + @XmlElement(required = true) + private String startDateTime; + @XmlElement(required = true) + private String endDateTime; + @XmlElement(required = true) + private String date; + + @XmlElement + private List tagged = new ArrayList<>(); + + /** + * No-arg constructor for JAXB use. + */ + public XmlAdaptedTask() {} + + + /** + * Converts a given Task into this class for JAXB use. + * + * @param source future changes to this will not affect the created XmlAdaptedTask + */ + public XmlAdaptedTask(ReadOnlyTask source) { + name = source.getName().fullName; + startDateTime = source.getStartDateTime().value; + endDateTime = source.getEndDateTime().value; + date = source.getDate().value; + tagged = new ArrayList<>(); + for (Tag tag : source.getTags()) { + tagged.add(new XmlAdaptedTag(tag)); + } + } + + /** + * Converts this jaxb-friendly adapted task object into the model's Task object. + * + * @throws IllegalValueException if there were any data constraints violated in the adapted task + */ + public Task toModelType() throws IllegalValueException { + final List taskTags = new ArrayList<>(); + for (XmlAdaptedTag tag : tagged) { + taskTags.add(tag.toModelType()); + } + final Name name = new Name(this.name); + final StartDateTime startDateTime = new StartDateTime(this.startDateTime); + final EndDateTime endDateTime = new EndDateTime(this.endDateTime); + final Date date = new Date(this.date); + final UniqueTagList tags = new UniqueTagList(taskTags); + return new Task(name, startDateTime, endDateTime, date, tags); + } +} diff --git a/src/main/java/seedu/address/storage/XmlSerializableAddressBook.java b/src/main/java/seedu/address/storage/XmlSerializableAddressBook.java index b7ec533a3a1e..aac1f03b3678 100644 --- a/src/main/java/seedu/address/storage/XmlSerializableAddressBook.java +++ b/src/main/java/seedu/address/storage/XmlSerializableAddressBook.java @@ -3,9 +3,9 @@ import seedu.address.commons.exceptions.IllegalValueException; import seedu.address.model.tag.Tag; import seedu.address.model.tag.UniqueTagList; +import seedu.address.model.task.ReadOnlyTask; +import seedu.address.model.task.UniqueTaskList; import seedu.address.model.ReadOnlyAddressBook; -import seedu.address.model.person.ReadOnlyPerson; -import seedu.address.model.person.UniquePersonList; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; @@ -21,12 +21,12 @@ public class XmlSerializableAddressBook implements ReadOnlyAddressBook { @XmlElement - private List persons; + private List tasks; @XmlElement private List tags; { - persons = new ArrayList<>(); + tasks = new ArrayList<>(); tags = new ArrayList<>(); } @@ -39,7 +39,7 @@ public XmlSerializableAddressBook() {} * Conversion */ public XmlSerializableAddressBook(ReadOnlyAddressBook src) { - persons.addAll(src.getPersonList().stream().map(XmlAdaptedPerson::new).collect(Collectors.toList())); + tasks.addAll(src.getTaskList().stream().map(XmlAdaptedTask::new).collect(Collectors.toList())); tags = src.getTagList(); } @@ -55,9 +55,9 @@ public UniqueTagList getUniqueTagList() { } @Override - public UniquePersonList getUniquePersonList() { - UniquePersonList lists = new UniquePersonList(); - for (XmlAdaptedPerson p : persons) { + public UniqueTaskList getUniqueTaskList() { + UniqueTaskList lists = new UniqueTaskList(); + for (XmlAdaptedTask p : tasks) { try { lists.add(p.toModelType()); } catch (IllegalValueException e) { @@ -68,8 +68,8 @@ public UniquePersonList getUniquePersonList() { } @Override - public List getPersonList() { - return persons.stream().map(p -> { + public List getTaskList() { + return tasks.stream().map(p -> { try { return p.toModelType(); } catch (IllegalValueException e) { diff --git a/src/main/java/seedu/address/ui/BrowserPanel.java b/src/main/java/seedu/address/ui/BrowserPanel.java index 54b88318019b..61bf8a5a64d4 100644 --- a/src/main/java/seedu/address/ui/BrowserPanel.java +++ b/src/main/java/seedu/address/ui/BrowserPanel.java @@ -5,7 +5,7 @@ import javafx.scene.layout.AnchorPane; import javafx.scene.web.WebView; import seedu.address.commons.util.FxViewUtil; -import seedu.address.model.person.ReadOnlyPerson; +import seedu.address.model.task.ReadOnlyTask; import seedu.address.commons.core.LogsCenter; import java.util.logging.Logger; @@ -50,8 +50,8 @@ public static BrowserPanel load(AnchorPane placeholder){ return browserPanel; } - public void loadPersonPage(ReadOnlyPerson person) { - loadPage("https://www.google.com.sg/#safe=off&q=" + person.getName().fullName.replaceAll(" ", "+")); + public void loadTaskPage(ReadOnlyTask task) { + loadPage("https://www.google.com.sg/#safe=off&q=" + task.getName().fullName.replaceAll(" ", "+")); } public void loadPage(String url){ diff --git a/src/main/java/seedu/address/ui/MainWindow.java b/src/main/java/seedu/address/ui/MainWindow.java index 2c76aced3b04..fa8fcc3d3e5c 100644 --- a/src/main/java/seedu/address/ui/MainWindow.java +++ b/src/main/java/seedu/address/ui/MainWindow.java @@ -13,7 +13,7 @@ import seedu.address.commons.events.ui.ExitAppRequestEvent; import seedu.address.logic.Logic; import seedu.address.model.UserPrefs; -import seedu.address.model.person.ReadOnlyPerson; +import seedu.address.model.task.ReadOnlyTask; /** * The Main Window. Provides the basic application layout containing @@ -30,7 +30,7 @@ public class MainWindow extends UiPart { // Independent Ui parts residing in this Ui container private BrowserPanel browserPanel; - private PersonListPanel personListPanel; + private TaskListPanel taskListPanel; private ResultDisplay resultDisplay; private StatusBarFooter statusBarFooter; private CommandBox commandBox; @@ -53,7 +53,7 @@ public class MainWindow extends UiPart { private MenuItem helpMenuItem; @FXML - private AnchorPane personListPanelPlaceholder; + private AnchorPane taskListPanelPlaceholder; @FXML private AnchorPane resultDisplayPlaceholder; @@ -109,7 +109,7 @@ private void setAccelerators() { void fillInnerParts() { browserPanel = BrowserPanel.load(browserPlaceholder); - personListPanel = PersonListPanel.load(primaryStage, getPersonListPlaceholder(), logic.getFilteredPersonList()); + taskListPanel = TaskListPanel.load(primaryStage, getTaskListPlaceholder(), logic.getFilteredTaskList()); resultDisplay = ResultDisplay.load(primaryStage, getResultDisplayPlaceholder()); statusBarFooter = StatusBarFooter.load(primaryStage, getStatusbarPlaceholder(), config.getAddressBookFilePath()); commandBox = CommandBox.load(primaryStage, getCommandBoxPlaceholder(), resultDisplay, logic); @@ -127,8 +127,8 @@ private AnchorPane getResultDisplayPlaceholder() { return resultDisplayPlaceholder; } - public AnchorPane getPersonListPlaceholder() { - return personListPanelPlaceholder; + public AnchorPane getTaskListPlaceholder() { + return taskListPanelPlaceholder; } public void hide() { @@ -182,12 +182,12 @@ private void handleExit() { raise(new ExitAppRequestEvent()); } - public PersonListPanel getPersonListPanel() { - return this.personListPanel; + public TaskListPanel getTaskListPanel() { + return this.taskListPanel; } - public void loadPersonPage(ReadOnlyPerson person) { - browserPanel.loadPersonPage(person); + public void loadTaskPage(ReadOnlyTask task) { + browserPanel.loadTaskPage(task); } public void releaseResources() { diff --git a/src/main/java/seedu/address/ui/PersonListPanel.java b/src/main/java/seedu/address/ui/PersonListPanel.java deleted file mode 100644 index 27d9381c47b5..000000000000 --- a/src/main/java/seedu/address/ui/PersonListPanel.java +++ /dev/null @@ -1,108 +0,0 @@ -package seedu.address.ui; - -import javafx.application.Platform; -import javafx.collections.ObservableList; -import javafx.fxml.FXML; -import javafx.scene.Node; -import javafx.scene.control.ListCell; -import javafx.scene.control.ListView; -import javafx.scene.control.SplitPane; -import javafx.scene.layout.AnchorPane; -import javafx.scene.layout.VBox; -import javafx.stage.Stage; -import seedu.address.commons.events.ui.PersonPanelSelectionChangedEvent; -import seedu.address.model.person.ReadOnlyPerson; -import seedu.address.commons.core.LogsCenter; - -import java.util.logging.Logger; - -/** - * Panel containing the list of persons. - */ -public class PersonListPanel extends UiPart { - private final Logger logger = LogsCenter.getLogger(PersonListPanel.class); - private static final String FXML = "PersonListPanel.fxml"; - private VBox panel; - private AnchorPane placeHolderPane; - - @FXML - private ListView personListView; - - public PersonListPanel() { - super(); - } - - @Override - public void setNode(Node node) { - panel = (VBox) node; - } - - @Override - public String getFxmlPath() { - return FXML; - } - - @Override - public void setPlaceholder(AnchorPane pane) { - this.placeHolderPane = pane; - } - - public static PersonListPanel load(Stage primaryStage, AnchorPane personListPlaceholder, - ObservableList personList) { - PersonListPanel personListPanel = - UiPartLoader.loadUiPart(primaryStage, personListPlaceholder, new PersonListPanel()); - personListPanel.configure(personList); - return personListPanel; - } - - private void configure(ObservableList personList) { - setConnections(personList); - addToPlaceholder(); - } - - private void setConnections(ObservableList personList) { - personListView.setItems(personList); - personListView.setCellFactory(listView -> new PersonListViewCell()); - setEventHandlerForSelectionChangeEvent(); - } - - private void addToPlaceholder() { - SplitPane.setResizableWithParent(placeHolderPane, false); - placeHolderPane.getChildren().add(panel); - } - - private void setEventHandlerForSelectionChangeEvent() { - personListView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> { - if (newValue != null) { - logger.fine("Selection in person list panel changed to : '" + newValue + "'"); - raise(new PersonPanelSelectionChangedEvent(newValue)); - } - }); - } - - public void scrollTo(int index) { - Platform.runLater(() -> { - personListView.scrollTo(index); - personListView.getSelectionModel().clearAndSelect(index); - }); - } - - class PersonListViewCell extends ListCell { - - public PersonListViewCell() { - } - - @Override - protected void updateItem(ReadOnlyPerson person, boolean empty) { - super.updateItem(person, empty); - - if (empty || person == null) { - setGraphic(null); - setText(null); - } else { - setGraphic(PersonCard.load(person, getIndex() + 1).getLayout()); - } - } - } - -} diff --git a/src/main/java/seedu/address/ui/PersonCard.java b/src/main/java/seedu/address/ui/TaskCard.java similarity index 53% rename from src/main/java/seedu/address/ui/PersonCard.java rename to src/main/java/seedu/address/ui/TaskCard.java index 259e9ad0d333..615bf1c19a6a 100644 --- a/src/main/java/seedu/address/ui/PersonCard.java +++ b/src/main/java/seedu/address/ui/TaskCard.java @@ -4,11 +4,11 @@ import javafx.scene.Node; import javafx.scene.control.Label; import javafx.scene.layout.HBox; -import seedu.address.model.person.ReadOnlyPerson; +import seedu.address.model.task.ReadOnlyTask; -public class PersonCard extends UiPart{ +public class TaskCard extends UiPart{ - private static final String FXML = "PersonListCard.fxml"; + private static final String FXML = "TaskListCard.fxml"; @FXML private HBox cardPane; @@ -17,36 +17,36 @@ public class PersonCard extends UiPart{ @FXML private Label id; @FXML - private Label phone; + private Label startDateTime; @FXML - private Label address; + private Label date; @FXML - private Label email; + private Label endDateTime; @FXML private Label tags; - private ReadOnlyPerson person; + private ReadOnlyTask task; private int displayedIndex; - public PersonCard(){ + public TaskCard(){ } - public static PersonCard load(ReadOnlyPerson person, int displayedIndex){ - PersonCard card = new PersonCard(); - card.person = person; + public static TaskCard load(ReadOnlyTask task, int displayedIndex){ + TaskCard card = new TaskCard(); + card.task = task; card.displayedIndex = displayedIndex; return UiPartLoader.loadUiPart(card); } @FXML public void initialize() { - name.setText(person.getName().fullName); + name.setText(task.getName().fullName); id.setText(displayedIndex + ". "); - phone.setText(person.getPhone().value); - address.setText(person.getAddress().value); - email.setText(person.getEmail().value); - tags.setText(person.tagsString()); + startDateTime.setText(task.getStartDateTime().value); + date.setText(task.getDate().value); + endDateTime.setText(task.getEndDateTime().value); + tags.setText(task.tagsString()); } public HBox getLayout() { diff --git a/src/main/java/seedu/address/ui/TaskListPanel.java b/src/main/java/seedu/address/ui/TaskListPanel.java new file mode 100644 index 000000000000..856244de151f --- /dev/null +++ b/src/main/java/seedu/address/ui/TaskListPanel.java @@ -0,0 +1,108 @@ +package seedu.address.ui; + +import javafx.application.Platform; +import javafx.collections.ObservableList; +import javafx.fxml.FXML; +import javafx.scene.Node; +import javafx.scene.control.ListCell; +import javafx.scene.control.ListView; +import javafx.scene.control.SplitPane; +import javafx.scene.layout.AnchorPane; +import javafx.scene.layout.VBox; +import javafx.stage.Stage; +import seedu.address.commons.events.ui.TaskPanelSelectionChangedEvent; +import seedu.address.model.task.ReadOnlyTask; +import seedu.address.commons.core.LogsCenter; + +import java.util.logging.Logger; + +/** + * Panel containing the list of tasks. + */ +public class TaskListPanel extends UiPart { + private final Logger logger = LogsCenter.getLogger(TaskListPanel.class); + private static final String FXML = "TaskListPanel.fxml"; + private VBox panel; + private AnchorPane placeHolderPane; + + @FXML + private ListView taskListView; + + public TaskListPanel() { + super(); + } + + @Override + public void setNode(Node node) { + panel = (VBox) node; + } + + @Override + public String getFxmlPath() { + return FXML; + } + + @Override + public void setPlaceholder(AnchorPane pane) { + this.placeHolderPane = pane; + } + + public static TaskListPanel load(Stage primaryStage, AnchorPane taskListPlaceholder, + ObservableList taskList) { + TaskListPanel taskListPanel = + UiPartLoader.loadUiPart(primaryStage, taskListPlaceholder, new TaskListPanel()); + taskListPanel.configure(taskList); + return taskListPanel; + } + + private void configure(ObservableList taskList) { + setConnections(taskList); + addToPlaceholder(); + } + + private void setConnections(ObservableList taskList) { + taskListView.setItems(taskList); + taskListView.setCellFactory(listView -> new TaskListViewCell()); + setEventHandlerForSelectionChangeEvent(); + } + + private void addToPlaceholder() { + SplitPane.setResizableWithParent(placeHolderPane, false); + placeHolderPane.getChildren().add(panel); + } + + private void setEventHandlerForSelectionChangeEvent() { + taskListView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> { + if (newValue != null) { + logger.fine("Selection in task list panel changed to : '" + newValue + "'"); + raise(new TaskPanelSelectionChangedEvent(newValue)); + } + }); + } + + public void scrollTo(int index) { + Platform.runLater(() -> { + taskListView.scrollTo(index); + taskListView.getSelectionModel().clearAndSelect(index); + }); + } + + class TaskListViewCell extends ListCell { + + public TaskListViewCell() { + } + + @Override + protected void updateItem(ReadOnlyTask task, boolean empty) { + super.updateItem(task, empty); + + if (empty || task == null) { + setGraphic(null); + setText(null); + } else { + setGraphic(TaskCard.load(task, getIndex() + 1).getLayout()); + } + } + } + +} diff --git a/src/main/java/seedu/address/ui/UiManager.java b/src/main/java/seedu/address/ui/UiManager.java index 4a4dba3a2f6e..b32cbf0618a5 100644 --- a/src/main/java/seedu/address/ui/UiManager.java +++ b/src/main/java/seedu/address/ui/UiManager.java @@ -12,7 +12,7 @@ import seedu.address.commons.core.LogsCenter; import seedu.address.commons.events.storage.DataSavingExceptionEvent; import seedu.address.commons.events.ui.JumpToListRequestEvent; -import seedu.address.commons.events.ui.PersonPanelSelectionChangedEvent; +import seedu.address.commons.events.ui.TaskPanelSelectionChangedEvent; import seedu.address.commons.events.ui.ShowHelpRequestEvent; import seedu.address.commons.util.StringUtil; import seedu.address.logic.Logic; @@ -114,13 +114,13 @@ private void handleShowHelpEvent(ShowHelpRequestEvent event) { @Subscribe private void handleJumpToListRequestEvent(JumpToListRequestEvent event) { logger.info(LogsCenter.getEventHandlingLogMessage(event)); - mainWindow.getPersonListPanel().scrollTo(event.targetIndex); + mainWindow.getTaskListPanel().scrollTo(event.targetIndex); } @Subscribe - private void handlePersonPanelSelectionChangedEvent(PersonPanelSelectionChangedEvent event){ + private void handleTaskPanelSelectionChangedEvent(TaskPanelSelectionChangedEvent event){ logger.info(LogsCenter.getEventHandlingLogMessage(event)); - mainWindow.loadPersonPage(event.getNewSelection()); + mainWindow.loadTaskPage(event.getNewSelection()); } } diff --git a/src/main/resources/view/DarkTheme.css b/src/main/resources/view/DarkTheme.css index 8043b344253a..0d3593de87f1 100644 --- a/src/main/resources/view/DarkTheme.css +++ b/src/main/resources/view/DarkTheme.css @@ -283,6 +283,6 @@ -fx-text-fill: #F70D1A; } -#filterField, #personListPanel, #personWebpage { +#filterField, #taskListPanel, #taskWebpage { -fx-effect: innershadow(gaussian, black, 10, 0, 0, 0); } \ No newline at end of file diff --git a/src/main/resources/view/MainWindow.fxml b/src/main/resources/view/MainWindow.fxml index 2f9235c621d8..a6f45fffa038 100644 --- a/src/main/resources/view/MainWindow.fxml +++ b/src/main/resources/view/MainWindow.fxml @@ -36,12 +36,12 @@ - + - + diff --git a/src/main/resources/view/PersonListCard.fxml b/src/main/resources/view/TaskListCard.fxml similarity index 89% rename from src/main/resources/view/PersonListCard.fxml rename to src/main/resources/view/TaskListCard.fxml index 13d4b149651b..5f9345851063 100644 --- a/src/main/resources/view/PersonListCard.fxml +++ b/src/main/resources/view/TaskListCard.fxml @@ -31,9 +31,9 @@ diff --git a/src/main/resources/view/PersonListPanel.fxml b/src/main/resources/view/TaskListPanel.fxml similarity index 59% rename from src/main/resources/view/PersonListPanel.fxml rename to src/main/resources/view/TaskListPanel.fxml index 000c4c999b65..a0493198176e 100644 --- a/src/main/resources/view/PersonListPanel.fxml +++ b/src/main/resources/view/TaskListPanel.fxml @@ -3,12 +3,12 @@ - + - + diff --git a/src/test/data/XmlUtilTest/tempAddressBook.xml b/src/test/data/XmlUtilTest/tempAddressBook.xml index 41eeb8eb391a..54df0d9b04d7 100644 --- a/src/test/data/XmlUtilTest/tempAddressBook.xml +++ b/src/test/data/XmlUtilTest/tempAddressBook.xml @@ -1,6 +1,6 @@ - + 1 John Doe @@ -8,7 +8,7 @@ - + Friends diff --git a/src/test/data/XmlUtilTest/validAddressBook.xml b/src/test/data/XmlUtilTest/validAddressBook.xml index eafca730fb1e..267969939d95 100644 --- a/src/test/data/XmlUtilTest/validAddressBook.xml +++ b/src/test/data/XmlUtilTest/validAddressBook.xml @@ -1,57 +1,57 @@ - + Hans Muster - 9482424 - hans@google.com + 9482424 + hans@google.com
4th street
-
- + + Ruth Mueller - 87249245 - ruth@google.com + 87249245 + ruth@google.com
81th street
-
- + + Heinz Kurz - 95352563 - heinz@yahoo.com + 95352563 + heinz@yahoo.com
wall street
-
- + + Cornelia Meier - 87652533 - cornelia@google.com + 87652533 + cornelia@google.com
10th street
-
- + + Werner Meyer - 9482224 - werner@gmail.com + 9482224 + werner@gmail.com
michegan ave
-
- + + Lydia Kunz - 9482427 - lydia@gmail.com + 9482427 + lydia@gmail.com
little tokyo
-
- + + Anna Best - 9482442 - anna@google.com + 9482442 + anna@google.com
4th street
-
- + + Stefan Meier - 8482424 - stefan@mail.com + 8482424 + stefan@mail.com
little india
-
- + + Martin Mueller - 8482131 - hans@google.com + 8482131 + hans@google.com
chicago ave
-
+
diff --git a/src/test/java/guitests/AddCommandTest.java b/src/test/java/guitests/AddCommandTest.java index 3b2e1844bd0d..8b948aa1db36 100644 --- a/src/test/java/guitests/AddCommandTest.java +++ b/src/test/java/guitests/AddCommandTest.java @@ -1,10 +1,10 @@ package guitests; -import guitests.guihandles.PersonCardHandle; +import guitests.guihandles.TaskCardHandle; import org.junit.Test; import seedu.address.logic.commands.AddCommand; import seedu.address.commons.core.Messages; -import seedu.address.testutil.TestPerson; +import seedu.address.testutil.TestTask; import seedu.address.testutil.TestUtil; import static org.junit.Assert.assertTrue; @@ -13,21 +13,21 @@ public class AddCommandTest extends AddressBookGuiTest { @Test public void add() { - //add one person - TestPerson[] currentList = td.getTypicalPersons(); - TestPerson personToAdd = td.hoon; - assertAddSuccess(personToAdd, currentList); - currentList = TestUtil.addPersonsToList(currentList, personToAdd); - - //add another person - personToAdd = td.ida; - assertAddSuccess(personToAdd, currentList); - currentList = TestUtil.addPersonsToList(currentList, personToAdd); - - //add duplicate person + //add one task + TestTask[] currentList = td.getTypicalTasks(); + TestTask taskToAdd = td.hoon; + assertAddSuccess(taskToAdd, currentList); + currentList = TestUtil.addTasksToList(currentList, taskToAdd); + + //add another task + taskToAdd = td.ida; + assertAddSuccess(taskToAdd, currentList); + currentList = TestUtil.addTasksToList(currentList, taskToAdd); + + //add duplicate task commandBox.runCommand(td.hoon.getAddCommand()); - assertResultMessage(AddCommand.MESSAGE_DUPLICATE_PERSON); - assertTrue(personListPanel.isListMatching(currentList)); + assertResultMessage(AddCommand.MESSAGE_DUPLICATE_TASK); + assertTrue(taskListPanel.isListMatching(currentList)); //add to empty list commandBox.runCommand("clear"); @@ -38,16 +38,16 @@ public void add() { assertResultMessage(Messages.MESSAGE_UNKNOWN_COMMAND); } - private void assertAddSuccess(TestPerson personToAdd, TestPerson... currentList) { - commandBox.runCommand(personToAdd.getAddCommand()); + private void assertAddSuccess(TestTask taskToAdd, TestTask... currentList) { + commandBox.runCommand(taskToAdd.getAddCommand()); //confirm the new card contains the right data - PersonCardHandle addedCard = personListPanel.navigateToPerson(personToAdd.getName().fullName); - assertMatching(personToAdd, addedCard); + TaskCardHandle addedCard = taskListPanel.navigateToTask(taskToAdd.getName().fullName); + assertMatching(taskToAdd, addedCard); - //confirm the list now contains all previous persons plus the new person - TestPerson[] expectedList = TestUtil.addPersonsToList(currentList, personToAdd); - assertTrue(personListPanel.isListMatching(expectedList)); + //confirm the list now contains all previous tasks plus the new task + TestTask[] expectedList = TestUtil.addTasksToList(currentList, taskToAdd); + assertTrue(taskListPanel.isListMatching(expectedList)); } } diff --git a/src/test/java/guitests/AddressBookGuiTest.java b/src/test/java/guitests/AddressBookGuiTest.java index b9cf9ca092eb..c80eebdaa2a7 100644 --- a/src/test/java/guitests/AddressBookGuiTest.java +++ b/src/test/java/guitests/AddressBookGuiTest.java @@ -11,9 +11,9 @@ import seedu.address.TestApp; import seedu.address.commons.core.EventsCenter; import seedu.address.model.AddressBook; -import seedu.address.model.person.ReadOnlyPerson; +import seedu.address.model.task.ReadOnlyTask; import seedu.address.testutil.TestUtil; -import seedu.address.testutil.TypicalTestPersons; +import seedu.address.testutil.TypicalTestTasks; import java.util.concurrent.TimeoutException; @@ -31,7 +31,7 @@ public abstract class AddressBookGuiTest { TestApp testApp; - protected TypicalTestPersons td = new TypicalTestPersons(); + protected TypicalTestTasks td = new TypicalTestTasks(); /* * Handles to GUI elements present at the start up are created in advance @@ -39,7 +39,7 @@ public abstract class AddressBookGuiTest { */ protected MainGuiHandle mainGui; protected MainMenuHandle mainMenu; - protected PersonListPanelHandle personListPanel; + protected TaskListPanelHandle taskListPanel; protected ResultDisplayHandle resultDisplay; protected CommandBoxHandle commandBox; private Stage stage; @@ -59,7 +59,7 @@ public void setup() throws Exception { FxToolkit.setupStage((stage) -> { mainGui = new MainGuiHandle(new GuiRobot(), stage); mainMenu = mainGui.getMainMenu(); - personListPanel = mainGui.getPersonListPanel(); + taskListPanel = mainGui.getTaskListPanel(); resultDisplay = mainGui.getResultDisplay(); commandBox = mainGui.getCommandBox(); this.stage = stage; @@ -77,7 +77,7 @@ public void setup() throws Exception { */ protected AddressBook getInitialData() { AddressBook ab = TestUtil.generateEmptyAddressBook(); - TypicalTestPersons.loadAddressBookWithSampleData(ab); + TypicalTestTasks.loadAddressBookWithSampleData(ab); return ab; } @@ -95,17 +95,17 @@ public void cleanup() throws TimeoutException { } /** - * Asserts the person shown in the card is same as the given person + * Asserts the task shown in the card is same as the given task */ - public void assertMatching(ReadOnlyPerson person, PersonCardHandle card) { - assertTrue(TestUtil.compareCardAndPerson(card, person)); + public void assertMatching(ReadOnlyTask task, TaskCardHandle card) { + assertTrue(TestUtil.compareCardAndTask(card, task)); } /** - * Asserts the size of the person list is equal to the given number. + * Asserts the size of the task list is equal to the given number. */ protected void assertListSize(int size) { - int numberOfPeople = personListPanel.getNumberOfPeople(); + int numberOfPeople = taskListPanel.getNumberOfPeople(); assertEquals(size, numberOfPeople); } diff --git a/src/test/java/guitests/ClearCommandTest.java b/src/test/java/guitests/ClearCommandTest.java index 9d52b427659c..a5e6fe642011 100644 --- a/src/test/java/guitests/ClearCommandTest.java +++ b/src/test/java/guitests/ClearCommandTest.java @@ -10,12 +10,12 @@ public class ClearCommandTest extends AddressBookGuiTest { public void clear() { //verify a non-empty list can be cleared - assertTrue(personListPanel.isListMatching(td.getTypicalPersons())); + assertTrue(taskListPanel.isListMatching(td.getTypicalTasks())); assertClearCommandSuccess(); //verify other commands can work after a clear command commandBox.runCommand(td.hoon.getAddCommand()); - assertTrue(personListPanel.isListMatching(td.hoon)); + assertTrue(taskListPanel.isListMatching(td.hoon)); commandBox.runCommand("delete 1"); assertListSize(0); diff --git a/src/test/java/guitests/DeleteCommandTest.java b/src/test/java/guitests/DeleteCommandTest.java index 10c7b9e0dbea..b74c7669d822 100644 --- a/src/test/java/guitests/DeleteCommandTest.java +++ b/src/test/java/guitests/DeleteCommandTest.java @@ -1,11 +1,11 @@ package guitests; import org.junit.Test; -import seedu.address.testutil.TestPerson; +import seedu.address.testutil.TestTask; import seedu.address.testutil.TestUtil; import static org.junit.Assert.assertTrue; -import static seedu.address.logic.commands.DeleteCommand.MESSAGE_DELETE_PERSON_SUCCESS; +import static seedu.address.logic.commands.DeleteCommand.MESSAGE_DELETE_TASK_SUCCESS; public class DeleteCommandTest extends AddressBookGuiTest { @@ -13,42 +13,42 @@ public class DeleteCommandTest extends AddressBookGuiTest { public void delete() { //delete the first in the list - TestPerson[] currentList = td.getTypicalPersons(); + TestTask[] currentList = td.getTypicalTasks(); int targetIndex = 1; assertDeleteSuccess(targetIndex, currentList); //delete the last in the list - currentList = TestUtil.removePersonFromList(currentList, targetIndex); + currentList = TestUtil.removeTaskFromList(currentList, targetIndex); targetIndex = currentList.length; assertDeleteSuccess(targetIndex, currentList); //delete from the middle of the list - currentList = TestUtil.removePersonFromList(currentList, targetIndex); + currentList = TestUtil.removeTaskFromList(currentList, targetIndex); targetIndex = currentList.length/2; assertDeleteSuccess(targetIndex, currentList); //invalid index commandBox.runCommand("delete " + currentList.length + 1); - assertResultMessage("The person index provided is invalid"); + assertResultMessage("The task index provided is invalid"); } /** - * Runs the delete command to delete the person at specified index and confirms the result is correct. - * @param targetIndexOneIndexed e.g. to delete the first person in the list, 1 should be given as the target index. - * @param currentList A copy of the current list of persons (before deletion). + * Runs the delete command to delete the task at specified index and confirms the result is correct. + * @param targetIndexOneIndexed e.g. to delete the first task in the list, 1 should be given as the target index. + * @param currentList A copy of the current list of tasks (before deletion). */ - private void assertDeleteSuccess(int targetIndexOneIndexed, final TestPerson[] currentList) { - TestPerson personToDelete = currentList[targetIndexOneIndexed-1]; //-1 because array uses zero indexing - TestPerson[] expectedRemainder = TestUtil.removePersonFromList(currentList, targetIndexOneIndexed); + private void assertDeleteSuccess(int targetIndexOneIndexed, final TestTask[] currentList) { + TestTask taskToDelete = currentList[targetIndexOneIndexed-1]; //-1 because array uses zero indexing + TestTask[] expectedRemainder = TestUtil.removeTaskFromList(currentList, targetIndexOneIndexed); commandBox.runCommand("delete " + targetIndexOneIndexed); - //confirm the list now contains all previous persons except the deleted person - assertTrue(personListPanel.isListMatching(expectedRemainder)); + //confirm the list now contains all previous tasks except the deleted task + assertTrue(taskListPanel.isListMatching(expectedRemainder)); //confirm the result message is correct - assertResultMessage(String.format(MESSAGE_DELETE_PERSON_SUCCESS, personToDelete)); + assertResultMessage(String.format(MESSAGE_DELETE_TASK_SUCCESS, taskToDelete)); } } diff --git a/src/test/java/guitests/FindCommandTest.java b/src/test/java/guitests/FindCommandTest.java index 441a6dbed666..d79c26edbdac 100644 --- a/src/test/java/guitests/FindCommandTest.java +++ b/src/test/java/guitests/FindCommandTest.java @@ -2,7 +2,7 @@ import org.junit.Test; import seedu.address.commons.core.Messages; -import seedu.address.testutil.TestPerson; +import seedu.address.testutil.TestTask; import static org.junit.Assert.assertTrue; @@ -30,10 +30,10 @@ public void find_invalidCommand_fail() { assertResultMessage(Messages.MESSAGE_UNKNOWN_COMMAND); } - private void assertFindResult(String command, TestPerson... expectedHits ) { + private void assertFindResult(String command, TestTask... expectedHits ) { commandBox.runCommand(command); assertListSize(expectedHits.length); - assertResultMessage(expectedHits.length + " persons listed!"); - assertTrue(personListPanel.isListMatching(expectedHits)); + assertResultMessage(expectedHits.length + " tasks listed!"); + assertTrue(taskListPanel.isListMatching(expectedHits)); } } diff --git a/src/test/java/guitests/HelpWindowTest.java b/src/test/java/guitests/HelpWindowTest.java index 258d9d628d80..436c485f1efe 100644 --- a/src/test/java/guitests/HelpWindowTest.java +++ b/src/test/java/guitests/HelpWindowTest.java @@ -10,7 +10,7 @@ public class HelpWindowTest extends AddressBookGuiTest { @Test public void openHelpWindow() { - personListPanel.clickOnListView(); + taskListPanel.clickOnListView(); assertHelpWindowOpen(mainMenu.openHelpWindowUsingAccelerator()); diff --git a/src/test/java/guitests/SelectCommandTest.java b/src/test/java/guitests/SelectCommandTest.java index 5273552056ce..0063fbd69e91 100644 --- a/src/test/java/guitests/SelectCommandTest.java +++ b/src/test/java/guitests/SelectCommandTest.java @@ -1,7 +1,8 @@ package guitests; import org.junit.Test; -import seedu.address.model.person.ReadOnlyPerson; + +import seedu.address.model.task.ReadOnlyTask; import static org.junit.Assert.assertEquals; @@ -9,25 +10,25 @@ public class SelectCommandTest extends AddressBookGuiTest { @Test - public void selectPerson_nonEmptyList() { + public void selectTask_nonEmptyList() { assertSelectionInvalid(10); //invalid index - assertNoPersonSelected(); + assertNoTaskSelected(); - assertSelectionSuccess(1); //first person in the list - int personCount = td.getTypicalPersons().length; - assertSelectionSuccess(personCount); //last person in the list - int middleIndex = personCount / 2; - assertSelectionSuccess(middleIndex); //a person in the middle of the list + assertSelectionSuccess(1); //first task in the list + int taskCount = td.getTypicalTasks().length; + assertSelectionSuccess(taskCount); //last task in the list + int middleIndex = taskCount / 2; + assertSelectionSuccess(middleIndex); //a task in the middle of the list - assertSelectionInvalid(personCount + 1); //invalid index - assertPersonSelected(middleIndex); //assert previous selection remains + assertSelectionInvalid(taskCount + 1); //invalid index + assertTaskSelected(middleIndex); //assert previous selection remains /* Testing other invalid indexes such as -1 should be done when testing the SelectCommand */ } @Test - public void selectPerson_emptyList(){ + public void selectTask_emptyList(){ commandBox.runCommand("clear"); assertListSize(0); assertSelectionInvalid(1); //invalid index @@ -35,24 +36,24 @@ public void selectPerson_emptyList(){ private void assertSelectionInvalid(int index) { commandBox.runCommand("select " + index); - assertResultMessage("The person index provided is invalid"); + assertResultMessage("The task index provided is invalid"); } private void assertSelectionSuccess(int index) { commandBox.runCommand("select " + index); - assertResultMessage("Selected Person: "+index); - assertPersonSelected(index); + assertResultMessage("Selected Task: "+index); + assertTaskSelected(index); } - private void assertPersonSelected(int index) { - assertEquals(personListPanel.getSelectedPersons().size(), 1); - ReadOnlyPerson selectedPerson = personListPanel.getSelectedPersons().get(0); - assertEquals(personListPanel.getPerson(index-1), selectedPerson); + private void assertTaskSelected(int index) { + assertEquals(taskListPanel.getSelectedTasks().size(), 1); + ReadOnlyTask selectedTask = taskListPanel.getSelectedTasks().get(0); + assertEquals(taskListPanel.getTask(index-1), selectedTask); //TODO: confirm the correct page is loaded in the Browser Panel } - private void assertNoPersonSelected() { - assertEquals(personListPanel.getSelectedPersons().size(), 0); + private void assertNoTaskSelected() { + assertEquals(taskListPanel.getSelectedTasks().size(), 0); } } diff --git a/src/test/java/guitests/guihandles/MainGuiHandle.java b/src/test/java/guitests/guihandles/MainGuiHandle.java index 45802c5135c7..411bde4af5da 100644 --- a/src/test/java/guitests/guihandles/MainGuiHandle.java +++ b/src/test/java/guitests/guihandles/MainGuiHandle.java @@ -13,8 +13,8 @@ public MainGuiHandle(GuiRobot guiRobot, Stage primaryStage) { super(guiRobot, primaryStage, TestApp.APP_TITLE); } - public PersonListPanelHandle getPersonListPanel() { - return new PersonListPanelHandle(guiRobot, primaryStage); + public TaskListPanelHandle getTaskListPanel() { + return new TaskListPanelHandle(guiRobot, primaryStage); } public ResultDisplayHandle getResultDisplay() { diff --git a/src/test/java/guitests/guihandles/PersonCardHandle.java b/src/test/java/guitests/guihandles/PersonCardHandle.java deleted file mode 100644 index fae22a45ae2f..000000000000 --- a/src/test/java/guitests/guihandles/PersonCardHandle.java +++ /dev/null @@ -1,63 +0,0 @@ -package guitests.guihandles; - -import guitests.GuiRobot; -import javafx.scene.Node; -import javafx.stage.Stage; -import seedu.address.model.person.ReadOnlyPerson; - -/** - * Provides a handle to a person card in the person list panel. - */ -public class PersonCardHandle extends GuiHandle { - private static final String NAME_FIELD_ID = "#name"; - private static final String ADDRESS_FIELD_ID = "#address"; - private static final String PHONE_FIELD_ID = "#phone"; - private static final String EMAIL_FIELD_ID = "#email"; - - private Node node; - - public PersonCardHandle(GuiRobot guiRobot, Stage primaryStage, Node node){ - super(guiRobot, primaryStage, null); - this.node = node; - } - - protected String getTextFromLabel(String fieldId) { - return getTextFromLabel(fieldId, node); - } - - public String getFullName() { - return getTextFromLabel(NAME_FIELD_ID); - } - - public String getAddress() { - return getTextFromLabel(ADDRESS_FIELD_ID); - } - - public String getPhone() { - return getTextFromLabel(PHONE_FIELD_ID); - } - - public String getEmail() { - return getTextFromLabel(EMAIL_FIELD_ID); - } - - public boolean isSamePerson(ReadOnlyPerson person){ - return getFullName().equals(person.getName().fullName) && getPhone().equals(person.getPhone().value) - && getEmail().equals(person.getEmail().value) && getAddress().equals(person.getAddress().value); - } - - @Override - public boolean equals(Object obj) { - if(obj instanceof PersonCardHandle) { - PersonCardHandle handle = (PersonCardHandle) obj; - return getFullName().equals(handle.getFullName()) - && getAddress().equals(handle.getAddress()); //TODO: compare the rest - } - return super.equals(obj); - } - - @Override - public String toString() { - return getFullName() + " " + getAddress(); - } -} diff --git a/src/test/java/guitests/guihandles/PersonListPanelHandle.java b/src/test/java/guitests/guihandles/PersonListPanelHandle.java deleted file mode 100644 index 3451992cf735..000000000000 --- a/src/test/java/guitests/guihandles/PersonListPanelHandle.java +++ /dev/null @@ -1,172 +0,0 @@ -package guitests.guihandles; - - -import guitests.GuiRobot; -import javafx.geometry.Point2D; -import javafx.scene.Node; -import javafx.scene.control.ListView; -import javafx.stage.Stage; -import seedu.address.TestApp; -import seedu.address.model.person.Person; -import seedu.address.model.person.ReadOnlyPerson; -import seedu.address.testutil.TestUtil; - -import java.util.List; -import java.util.Optional; -import java.util.Set; - -import static org.junit.Assert.assertTrue; - -/** - * Provides a handle for the panel containing the person list. - */ -public class PersonListPanelHandle extends GuiHandle { - - public static final int NOT_FOUND = -1; - public static final String CARD_PANE_ID = "#cardPane"; - - private static final String PERSON_LIST_VIEW_ID = "#personListView"; - - public PersonListPanelHandle(GuiRobot guiRobot, Stage primaryStage) { - super(guiRobot, primaryStage, TestApp.APP_TITLE); - } - - public List getSelectedPersons() { - ListView personList = getListView(); - return personList.getSelectionModel().getSelectedItems(); - } - - public ListView getListView() { - return (ListView) getNode(PERSON_LIST_VIEW_ID); - } - - /** - * Returns true if the list is showing the person details correctly and in correct order. - * @param persons A list of person in the correct order. - */ - public boolean isListMatching(ReadOnlyPerson... persons) { - return this.isListMatching(0, persons); - } - - /** - * Clicks on the ListView. - */ - public void clickOnListView() { - Point2D point= TestUtil.getScreenMidPoint(getListView()); - guiRobot.clickOn(point.getX(), point.getY()); - } - - /** - * Returns true if the {@code persons} appear as the sub list (in that order) at position {@code startPosition}. - */ - public boolean containsInOrder(int startPosition, ReadOnlyPerson... persons) { - List personsInList = getListView().getItems(); - - // Return false if the list in panel is too short to contain the given list - if (startPosition + persons.length > personsInList.size()){ - return false; - } - - // Return false if any of the persons doesn't match - for (int i = 0; i < persons.length; i++) { - if (!personsInList.get(startPosition + i).getName().fullName.equals(persons[i].getName().fullName)){ - return false; - } - } - - return true; - } - - /** - * Returns true if the list is showing the person details correctly and in correct order. - * @param startPosition The starting position of the sub list. - * @param persons A list of person in the correct order. - */ - public boolean isListMatching(int startPosition, ReadOnlyPerson... persons) throws IllegalArgumentException { - if (persons.length + startPosition != getListView().getItems().size()) { - throw new IllegalArgumentException("List size mismatched\n" + - "Expected " + (getListView().getItems().size() - 1) + " persons"); - } - assertTrue(this.containsInOrder(startPosition, persons)); - for (int i = 0; i < persons.length; i++) { - final int scrollTo = i + startPosition; - guiRobot.interact(() -> getListView().scrollTo(scrollTo)); - guiRobot.sleep(200); - if (!TestUtil.compareCardAndPerson(getPersonCardHandle(startPosition + i), persons[i])) { - return false; - } - } - return true; - } - - - public PersonCardHandle navigateToPerson(String name) { - guiRobot.sleep(500); //Allow a bit of time for the list to be updated - final Optional person = getListView().getItems().stream().filter(p -> p.getName().fullName.equals(name)).findAny(); - if (!person.isPresent()) { - throw new IllegalStateException("Name not found: " + name); - } - - return navigateToPerson(person.get()); - } - - /** - * Navigates the listview to display and select the person. - */ - public PersonCardHandle navigateToPerson(ReadOnlyPerson person) { - int index = getPersonIndex(person); - - guiRobot.interact(() -> { - getListView().scrollTo(index); - guiRobot.sleep(150); - getListView().getSelectionModel().select(index); - }); - guiRobot.sleep(100); - return getPersonCardHandle(person); - } - - - /** - * Returns the position of the person given, {@code NOT_FOUND} if not found in the list. - */ - public int getPersonIndex(ReadOnlyPerson targetPerson) { - List personsInList = getListView().getItems(); - for (int i = 0; i < personsInList.size(); i++) { - if(personsInList.get(i).getName().equals(targetPerson.getName())){ - return i; - } - } - return NOT_FOUND; - } - - /** - * Gets a person from the list by index - */ - public ReadOnlyPerson getPerson(int index) { - return getListView().getItems().get(index); - } - - public PersonCardHandle getPersonCardHandle(int index) { - return getPersonCardHandle(new Person(getListView().getItems().get(index))); - } - - public PersonCardHandle getPersonCardHandle(ReadOnlyPerson person) { - Set nodes = getAllCardNodes(); - Optional personCardNode = nodes.stream() - .filter(n -> new PersonCardHandle(guiRobot, primaryStage, n).isSamePerson(person)) - .findFirst(); - if (personCardNode.isPresent()) { - return new PersonCardHandle(guiRobot, primaryStage, personCardNode.get()); - } else { - return null; - } - } - - protected Set getAllCardNodes() { - return guiRobot.lookup(CARD_PANE_ID).queryAll(); - } - - public int getNumberOfPeople() { - return getListView().getItems().size(); - } -} diff --git a/src/test/java/guitests/guihandles/TaskCardHandle.java b/src/test/java/guitests/guihandles/TaskCardHandle.java new file mode 100644 index 000000000000..532583f126c7 --- /dev/null +++ b/src/test/java/guitests/guihandles/TaskCardHandle.java @@ -0,0 +1,63 @@ +package guitests.guihandles; + +import guitests.GuiRobot; +import javafx.scene.Node; +import javafx.stage.Stage; +import seedu.address.model.task.ReadOnlyTask; + +/** + * Provides a handle to a task card in the task list panel. + */ +public class TaskCardHandle extends GuiHandle { + private static final String NAME_FIELD_ID = "#name"; + private static final String DATE_FIELD_ID = "#date"; + private static final String START_DATE_TIME_FIELD_ID = "#startDateTime"; + private static final String END_DATE_TIME_FIELD_ID = "#endDateTime"; + + private Node node; + + public TaskCardHandle(GuiRobot guiRobot, Stage primaryStage, Node node){ + super(guiRobot, primaryStage, null); + this.node = node; + } + + protected String getTextFromLabel(String fieldId) { + return getTextFromLabel(fieldId, node); + } + + public String getFullName() { + return getTextFromLabel(NAME_FIELD_ID); + } + + public String getDate() { + return getTextFromLabel(DATE_FIELD_ID); + } + + public String getStartDateTime() { + return getTextFromLabel(START_DATE_TIME_FIELD_ID); + } + + public String getEndDateTime() { + return getTextFromLabel(END_DATE_TIME_FIELD_ID); + } + + public boolean isSameTask(ReadOnlyTask task){ + return getFullName().equals(task.getName().fullName) && getStartDateTime().equals(task.getStartDateTime().value) + && getEndDateTime().equals(task.getEndDateTime().value) && getDate().equals(task.getDate().value); + } + + @Override + public boolean equals(Object obj) { + if(obj instanceof TaskCardHandle) { + TaskCardHandle handle = (TaskCardHandle) obj; + return getFullName().equals(handle.getFullName()) + && getDate().equals(handle.getDate()); //TODO: compare the rest + } + return super.equals(obj); + } + + @Override + public String toString() { + return getFullName() + " " + getDate(); + } +} diff --git a/src/test/java/guitests/guihandles/TaskListPanelHandle.java b/src/test/java/guitests/guihandles/TaskListPanelHandle.java new file mode 100644 index 000000000000..3b652aab58f8 --- /dev/null +++ b/src/test/java/guitests/guihandles/TaskListPanelHandle.java @@ -0,0 +1,172 @@ +package guitests.guihandles; + + +import guitests.GuiRobot; +import javafx.geometry.Point2D; +import javafx.scene.Node; +import javafx.scene.control.ListView; +import javafx.stage.Stage; +import seedu.address.TestApp; +import seedu.address.model.task.Task; +import seedu.address.model.task.ReadOnlyTask; +import seedu.address.testutil.TestUtil; + +import java.util.List; +import java.util.Optional; +import java.util.Set; + +import static org.junit.Assert.assertTrue; + +/** + * Provides a handle for the panel containing the task list. + */ +public class TaskListPanelHandle extends GuiHandle { + + public static final int NOT_FOUND = -1; + public static final String CARD_PANE_ID = "#cardPane"; + + private static final String TASK_LIST_VIEW_ID = "#taskListView"; + + public TaskListPanelHandle(GuiRobot guiRobot, Stage primaryStage) { + super(guiRobot, primaryStage, TestApp.APP_TITLE); + } + + public List getSelectedTasks() { + ListView taskList = getListView(); + return taskList.getSelectionModel().getSelectedItems(); + } + + public ListView getListView() { + return (ListView) getNode(TASK_LIST_VIEW_ID); + } + + /** + * Returns true if the list is showing the task details correctly and in correct order. + * @param tasks A list of task in the correct order. + */ + public boolean isListMatching(ReadOnlyTask... tasks) { + return this.isListMatching(0, tasks); + } + + /** + * Clicks on the ListView. + */ + public void clickOnListView() { + Point2D point= TestUtil.getScreenMidPoint(getListView()); + guiRobot.clickOn(point.getX(), point.getY()); + } + + /** + * Returns true if the {@code tasks} appear as the sub list (in that order) at position {@code startPosition}. + */ + public boolean containsInOrder(int startPosition, ReadOnlyTask... tasks) { + List tasksInList = getListView().getItems(); + + // Return false if the list in panel is too short to contain the given list + if (startPosition + tasks.length > tasksInList.size()){ + return false; + } + + // Return false if any of the tasks doesn't match + for (int i = 0; i < tasks.length; i++) { + if (!tasksInList.get(startPosition + i).getName().fullName.equals(tasks[i].getName().fullName)){ + return false; + } + } + + return true; + } + + /** + * Returns true if the list is showing the task details correctly and in correct order. + * @param startPosition The starting position of the sub list. + * @param tasks A list of task in the correct order. + */ + public boolean isListMatching(int startPosition, ReadOnlyTask... tasks) throws IllegalArgumentException { + if (tasks.length + startPosition != getListView().getItems().size()) { + throw new IllegalArgumentException("List size mismatched\n" + + "Expected " + (getListView().getItems().size() - 1) + " tasks"); + } + assertTrue(this.containsInOrder(startPosition, tasks)); + for (int i = 0; i < tasks.length; i++) { + final int scrollTo = i + startPosition; + guiRobot.interact(() -> getListView().scrollTo(scrollTo)); + guiRobot.sleep(200); + if (!TestUtil.compareCardAndTask(getTaskCardHandle(startPosition + i), tasks[i])) { + return false; + } + } + return true; + } + + + public TaskCardHandle navigateToTask(String name) { + guiRobot.sleep(500); //Allow a bit of time for the list to be updated + final Optional task = getListView().getItems().stream().filter(p -> p.getName().fullName.equals(name)).findAny(); + if (!task.isPresent()) { + throw new IllegalStateException("Name not found: " + name); + } + + return navigateToTask(task.get()); + } + + /** + * Navigates the listview to display and select the task. + */ + public TaskCardHandle navigateToTask(ReadOnlyTask task) { + int index = getTaskIndex(task); + + guiRobot.interact(() -> { + getListView().scrollTo(index); + guiRobot.sleep(150); + getListView().getSelectionModel().select(index); + }); + guiRobot.sleep(100); + return getTaskCardHandle(task); + } + + + /** + * Returns the position of the task given, {@code NOT_FOUND} if not found in the list. + */ + public int getTaskIndex(ReadOnlyTask targetTask) { + List tasksInList = getListView().getItems(); + for (int i = 0; i < tasksInList.size(); i++) { + if(tasksInList.get(i).getName().equals(targetTask.getName())){ + return i; + } + } + return NOT_FOUND; + } + + /** + * Gets a task from the list by index + */ + public ReadOnlyTask getTask(int index) { + return getListView().getItems().get(index); + } + + public TaskCardHandle getTaskCardHandle(int index) { + return getTaskCardHandle(new Task(getListView().getItems().get(index))); + } + + public TaskCardHandle getTaskCardHandle(ReadOnlyTask task) { + Set nodes = getAllCardNodes(); + Optional taskCardNode = nodes.stream() + .filter(n -> new TaskCardHandle(guiRobot, primaryStage, n).isSameTask(task)) + .findFirst(); + if (taskCardNode.isPresent()) { + return new TaskCardHandle(guiRobot, primaryStage, taskCardNode.get()); + } else { + return null; + } + } + + protected Set getAllCardNodes() { + return guiRobot.lookup(CARD_PANE_ID).queryAll(); + } + + public int getNumberOfPeople() { + return getListView().getItems().size(); + } +} diff --git a/src/test/java/seedu/address/commons/util/XmlUtilTest.java b/src/test/java/seedu/address/commons/util/XmlUtilTest.java index dc4fd886c23e..7e326032700b 100644 --- a/src/test/java/seedu/address/commons/util/XmlUtilTest.java +++ b/src/test/java/seedu/address/commons/util/XmlUtilTest.java @@ -52,7 +52,7 @@ public void getDataFromFile_emptyFile_DataFormatMismatchException() throws Excep @Test public void getDataFromFile_validFile_validResult() throws Exception { XmlSerializableAddressBook dataFromFile = XmlUtil.getDataFromFile(VALID_FILE, XmlSerializableAddressBook.class); - assertEquals(9, dataFromFile.getPersonList().size()); + assertEquals(9, dataFromFile.getTaskList().size()); assertEquals(0, dataFromFile.getTagList().size()); } @@ -84,7 +84,7 @@ public void saveDataToFile_validFile_dataSaved() throws Exception { //TODO: use equality instead of string comparisons AddressBookBuilder builder = new AddressBookBuilder(new AddressBook()); - dataToWrite = new XmlSerializableAddressBook(builder.withPerson(TestUtil.generateSamplePersonData().get(0)).withTag("Friends").build()); + dataToWrite = new XmlSerializableAddressBook(builder.withTask(TestUtil.generateSampleTaskData().get(0)).withTag("Friends").build()); XmlUtil.saveDataToFile(TEMP_FILE, dataToWrite); dataFromFile = XmlUtil.getDataFromFile(TEMP_FILE, XmlSerializableAddressBook.class); diff --git a/src/test/java/seedu/address/logic/LogicManagerTest.java b/src/test/java/seedu/address/logic/LogicManagerTest.java index e1ee0cfb4051..f3f4e91f524c 100644 --- a/src/test/java/seedu/address/logic/LogicManagerTest.java +++ b/src/test/java/seedu/address/logic/LogicManagerTest.java @@ -15,9 +15,9 @@ import seedu.address.model.Model; import seedu.address.model.ModelManager; import seedu.address.model.ReadOnlyAddressBook; -import seedu.address.model.person.*; import seedu.address.model.tag.Tag; import seedu.address.model.tag.UniqueTagList; +import seedu.address.model.task.*; import seedu.address.storage.StorageManager; import java.util.ArrayList; @@ -103,14 +103,14 @@ private void assertCommandBehavior(String inputCommand, String expectedMessage) */ private void assertCommandBehavior(String inputCommand, String expectedMessage, ReadOnlyAddressBook expectedAddressBook, - List expectedShownList) throws Exception { + List expectedShownList) throws Exception { //Execute the command CommandResult result = logic.execute(inputCommand); //Confirm the ui display elements should contain the right data assertEquals(expectedMessage, result.feedbackToUser); - assertEquals(expectedShownList, model.getFilteredPersonList()); + assertEquals(expectedShownList, model.getFilteredTaskList()); //Confirm the state of data (saved and in-memory) is as expected assertEquals(expectedAddressBook, model.getAddressBook()); @@ -138,9 +138,9 @@ public void execute_exit() throws Exception { @Test public void execute_clear() throws Exception { TestDataHelper helper = new TestDataHelper(); - model.addPerson(helper.generatePerson(1)); - model.addPerson(helper.generatePerson(2)); - model.addPerson(helper.generatePerson(3)); + model.addTask(helper.generateTask(1)); + model.addTask(helper.generateTask(2)); + model.addTask(helper.generateTask(3)); assertCommandBehavior("clear", ClearCommand.MESSAGE_SUCCESS, new AddressBook(), Collections.emptyList()); } @@ -152,21 +152,21 @@ public void execute_add_invalidArgsFormat() throws Exception { assertCommandBehavior( "add wrong args wrong args", expectedMessage); assertCommandBehavior( - "add Valid Name 12345 e/valid@email.butNoPhonePrefix a/valid, address", expectedMessage); + "add Valid Name 12345 e/valid@endDateTime.butNoStartDateTimePrefix a/valid, address", expectedMessage); assertCommandBehavior( - "add Valid Name p/12345 valid@email.butNoPrefix a/valid, address", expectedMessage); + "add Valid Name p/12345 valid@endDateTime.butNoPrefix a/valid, address", expectedMessage); assertCommandBehavior( - "add Valid Name p/12345 e/valid@email.butNoAddressPrefix valid, address", expectedMessage); + "add Valid Name p/12345 e/valid@endDateTime.butNoAddressPrefix valid, address", expectedMessage); } @Test - public void execute_add_invalidPersonData() throws Exception { + public void execute_add_invalidTaskData() throws Exception { assertCommandBehavior( "add []\\[;] p/12345 e/valid@e.mail a/valid, address", Name.MESSAGE_NAME_CONSTRAINTS); assertCommandBehavior( - "add Valid Name p/not_numbers e/valid@e.mail a/valid, address", Phone.MESSAGE_PHONE_CONSTRAINTS); + "add Valid Name p/not_numbers e/valid@e.mail a/valid, address", StartDateTime.MESSAGE_START_DATE_TIME_CONSTRAINTS); assertCommandBehavior( - "add Valid Name p/12345 e/notAnEmail a/valid, address", Email.MESSAGE_EMAIL_CONSTRAINTS); + "add Valid Name p/12345 e/notAnEndDateTime a/valid, address", EndDateTime.MESSAGE_END_DATE_TIME_CONSTRAINTS); assertCommandBehavior( "add Valid Name p/12345 e/valid@e.mail a/valid, address t/invalid_-[.tag", Tag.MESSAGE_TAG_CONSTRAINTS); @@ -176,15 +176,15 @@ public void execute_add_invalidPersonData() throws Exception { public void execute_add_successful() throws Exception { // setup expectations TestDataHelper helper = new TestDataHelper(); - Person toBeAdded = helper.adam(); + Task toBeAdded = helper.adam(); AddressBook expectedAB = new AddressBook(); - expectedAB.addPerson(toBeAdded); + expectedAB.addTask(toBeAdded); // execute command and verify result assertCommandBehavior(helper.generateAddCommand(toBeAdded), String.format(AddCommand.MESSAGE_SUCCESS, toBeAdded), expectedAB, - expectedAB.getPersonList()); + expectedAB.getTaskList()); } @@ -192,29 +192,29 @@ public void execute_add_successful() throws Exception { public void execute_addDuplicate_notAllowed() throws Exception { // setup expectations TestDataHelper helper = new TestDataHelper(); - Person toBeAdded = helper.adam(); + Task toBeAdded = helper.adam(); AddressBook expectedAB = new AddressBook(); - expectedAB.addPerson(toBeAdded); + expectedAB.addTask(toBeAdded); // setup starting state - model.addPerson(toBeAdded); // person already in internal address book + model.addTask(toBeAdded); // task already in internal address book // execute command and verify result assertCommandBehavior( helper.generateAddCommand(toBeAdded), - AddCommand.MESSAGE_DUPLICATE_PERSON, + AddCommand.MESSAGE_DUPLICATE_TASK, expectedAB, - expectedAB.getPersonList()); + expectedAB.getTaskList()); } @Test - public void execute_list_showsAllPersons() throws Exception { + public void execute_list_showsAllTasks() throws Exception { // prepare expectations TestDataHelper helper = new TestDataHelper(); AddressBook expectedAB = helper.generateAddressBook(2); - List expectedList = expectedAB.getPersonList(); + List expectedList = expectedAB.getTaskList(); // prepare address book state helper.addToModel(model, 2); @@ -228,8 +228,8 @@ public void execute_list_showsAllPersons() throws Exception { /** * Confirms the 'invalid argument index number behaviour' for the given command - * targeting a single person in the shown list, using visible index. - * @param commandWord to test assuming it targets a single person in the last shown list based on visible index. + * targeting a single task in the shown list, using visible index. + * @param commandWord to test assuming it targets a single task in the last shown list based on visible index. */ private void assertIncorrectIndexFormatBehaviorForCommand(String commandWord, String expectedMessage) throws Exception { assertCommandBehavior(commandWord , expectedMessage); //index missing @@ -241,27 +241,21 @@ private void assertIncorrectIndexFormatBehaviorForCommand(String commandWord, St /** * Confirms the 'invalid argument index number behaviour' for the given command - * targeting a single person in the shown list, using visible index. - * @param commandWord to test assuming it targets a single person in the last shown list based on visible index. + * targeting a single task in the shown list, using visible index. + * @param commandWord to test assuming it targets a single task in the last shown list based on visible index. */ private void assertIndexNotFoundBehaviorForCommand(String commandWord) throws Exception { - String expectedMessage = MESSAGE_INVALID_PERSON_DISPLAYED_INDEX; + String expectedMessage = MESSAGE_INVALID_TASK_DISPLAYED_INDEX; TestDataHelper helper = new TestDataHelper(); - List personList = helper.generatePersonList(2); + List taskList = helper.generateTaskList(2); - // set AB state to 2 persons + // set AB state to 2 tasks model.resetData(new AddressBook()); - for (Person p : personList) { - model.addPerson(p); + for (Task p : taskList) { + model.addTask(p); } - assertCommandBehavior(commandWord + " 3", expectedMessage, model.getAddressBook(), personList); - } - - @Test - public void execute_selectInvalidArgsFormat_errorMessageShown() throws Exception { - String expectedMessage = String.format(MESSAGE_INVALID_COMMAND_FORMAT, SelectCommand.MESSAGE_USAGE); - assertIncorrectIndexFormatBehaviorForCommand("select", expectedMessage); + assertCommandBehavior(commandWord + " 3", expectedMessage, model.getAddressBook(), taskList); } @Test @@ -270,19 +264,15 @@ public void execute_selectIndexNotFound_errorMessageShown() throws Exception { } @Test - public void execute_select_jumpsToCorrectPerson() throws Exception { + public void execute_select_jumpsToCorrectTask() throws Exception { TestDataHelper helper = new TestDataHelper(); - List threePersons = helper.generatePersonList(3); + List threeTasks = helper.generateTaskList(3); - AddressBook expectedAB = helper.generateAddressBook(threePersons); - helper.addToModel(model, threePersons); + AddressBook expectedAB = helper.generateAddressBook(threeTasks); + helper.addToModel(model, threeTasks); - assertCommandBehavior("select 2", - String.format(SelectCommand.MESSAGE_SELECT_PERSON_SUCCESS, 2), - expectedAB, - expectedAB.getPersonList()); assertEquals(1, targetedJumpIndex); - assertEquals(model.getFilteredPersonList().get(1), threePersons.get(1)); + assertEquals(model.getFilteredTaskList().get(1), threeTasks.get(1)); } @@ -298,18 +288,18 @@ public void execute_deleteIndexNotFound_errorMessageShown() throws Exception { } @Test - public void execute_delete_removesCorrectPerson() throws Exception { + public void execute_delete_removesCorrectTask() throws Exception { TestDataHelper helper = new TestDataHelper(); - List threePersons = helper.generatePersonList(3); + List threeTasks = helper.generateTaskList(3); - AddressBook expectedAB = helper.generateAddressBook(threePersons); - expectedAB.removePerson(threePersons.get(1)); - helper.addToModel(model, threePersons); + AddressBook expectedAB = helper.generateAddressBook(threeTasks); + expectedAB.removeTask(threeTasks.get(1)); + helper.addToModel(model, threeTasks); assertCommandBehavior("delete 2", - String.format(DeleteCommand.MESSAGE_DELETE_PERSON_SUCCESS, threePersons.get(1)), + String.format(DeleteCommand.MESSAGE_DELETE_TASK_SUCCESS, threeTasks.get(1)), expectedAB, - expectedAB.getPersonList()); + expectedAB.getTaskList()); } @@ -322,18 +312,18 @@ public void execute_find_invalidArgsFormat() throws Exception { @Test public void execute_find_onlyMatchesFullWordsInNames() throws Exception { TestDataHelper helper = new TestDataHelper(); - Person pTarget1 = helper.generatePersonWithName("bla bla KEY bla"); - Person pTarget2 = helper.generatePersonWithName("bla KEY bla bceofeia"); - Person p1 = helper.generatePersonWithName("KE Y"); - Person p2 = helper.generatePersonWithName("KEYKEYKEY sduauo"); + Task pTarget1 = helper.generateTaskWithName("bla bla KEY bla"); + Task pTarget2 = helper.generateTaskWithName("bla KEY bla bceofeia"); + Task p1 = helper.generateTaskWithName("KE Y"); + Task p2 = helper.generateTaskWithName("KEYKEYKEY sduauo"); - List fourPersons = helper.generatePersonList(p1, pTarget1, p2, pTarget2); - AddressBook expectedAB = helper.generateAddressBook(fourPersons); - List expectedList = helper.generatePersonList(pTarget1, pTarget2); - helper.addToModel(model, fourPersons); + List fourTasks = helper.generateTaskList(p1, pTarget1, p2, pTarget2); + AddressBook expectedAB = helper.generateAddressBook(fourTasks); + List expectedList = helper.generateTaskList(pTarget1, pTarget2); + helper.addToModel(model, fourTasks); assertCommandBehavior("find KEY", - Command.getMessageForPersonListShownSummary(expectedList.size()), + Command.getMessageForTaskListShownSummary(expectedList.size()), expectedAB, expectedList); } @@ -341,18 +331,18 @@ public void execute_find_onlyMatchesFullWordsInNames() throws Exception { @Test public void execute_find_isNotCaseSensitive() throws Exception { TestDataHelper helper = new TestDataHelper(); - Person p1 = helper.generatePersonWithName("bla bla KEY bla"); - Person p2 = helper.generatePersonWithName("bla KEY bla bceofeia"); - Person p3 = helper.generatePersonWithName("key key"); - Person p4 = helper.generatePersonWithName("KEy sduauo"); + Task p1 = helper.generateTaskWithName("bla bla KEY bla"); + Task p2 = helper.generateTaskWithName("bla KEY bla bceofeia"); + Task p3 = helper.generateTaskWithName("key key"); + Task p4 = helper.generateTaskWithName("KEy sduauo"); - List fourPersons = helper.generatePersonList(p3, p1, p4, p2); - AddressBook expectedAB = helper.generateAddressBook(fourPersons); - List expectedList = fourPersons; - helper.addToModel(model, fourPersons); + List fourTasks = helper.generateTaskList(p3, p1, p4, p2); + AddressBook expectedAB = helper.generateAddressBook(fourTasks); + List expectedList = fourTasks; + helper.addToModel(model, fourTasks); assertCommandBehavior("find KEY", - Command.getMessageForPersonListShownSummary(expectedList.size()), + Command.getMessageForTaskListShownSummary(expectedList.size()), expectedAB, expectedList); } @@ -360,18 +350,18 @@ public void execute_find_isNotCaseSensitive() throws Exception { @Test public void execute_find_matchesIfAnyKeywordPresent() throws Exception { TestDataHelper helper = new TestDataHelper(); - Person pTarget1 = helper.generatePersonWithName("bla bla KEY bla"); - Person pTarget2 = helper.generatePersonWithName("bla rAnDoM bla bceofeia"); - Person pTarget3 = helper.generatePersonWithName("key key"); - Person p1 = helper.generatePersonWithName("sduauo"); + Task pTarget1 = helper.generateTaskWithName("bla bla KEY bla"); + Task pTarget2 = helper.generateTaskWithName("bla rAnDoM bla bceofeia"); + Task pTarget3 = helper.generateTaskWithName("key key"); + Task p1 = helper.generateTaskWithName("sduauo"); - List fourPersons = helper.generatePersonList(pTarget1, p1, pTarget2, pTarget3); - AddressBook expectedAB = helper.generateAddressBook(fourPersons); - List expectedList = helper.generatePersonList(pTarget1, pTarget2, pTarget3); - helper.addToModel(model, fourPersons); + List fourTasks = helper.generateTaskList(pTarget1, p1, pTarget2, pTarget3); + AddressBook expectedAB = helper.generateAddressBook(fourTasks); + List expectedList = helper.generateTaskList(pTarget1, pTarget2, pTarget3); + helper.addToModel(model, fourTasks); assertCommandBehavior("find key rAnDoM", - Command.getMessageForPersonListShownSummary(expectedList.size()), + Command.getMessageForTaskListShownSummary(expectedList.size()), expectedAB, expectedList); } @@ -382,44 +372,44 @@ public void execute_find_matchesIfAnyKeywordPresent() throws Exception { */ class TestDataHelper{ - Person adam() throws Exception { + Task adam() throws Exception { Name name = new Name("Adam Brown"); - Phone privatePhone = new Phone("111111"); - Email email = new Email("adam@gmail.com"); - Address privateAddress = new Address("111, alpha street"); + StartDateTime privateStartDateTime = new StartDateTime("111111"); + EndDateTime endDateTime = new EndDateTime("adam@gmail.com"); + Date privateDate = new Date("111, alpha street"); Tag tag1 = new Tag("tag1"); Tag tag2 = new Tag("tag2"); UniqueTagList tags = new UniqueTagList(tag1, tag2); - return new Person(name, privatePhone, email, privateAddress, tags); + return new Task(name, privateStartDateTime, endDateTime, privateDate, tags); } /** - * Generates a valid person using the given seed. - * Running this function with the same parameter values guarantees the returned person will have the same state. - * Each unique seed will generate a unique Person object. + * Generates a valid task using the given seed. + * Running this function with the same parameter values guarantees the returned task will have the same state. + * Each unique seed will generate a unique Task object. * - * @param seed used to generate the person data field values + * @param seed used to generate the task data field values */ - Person generatePerson(int seed) throws Exception { - return new Person( - new Name("Person " + seed), - new Phone("" + Math.abs(seed)), - new Email(seed + "@email"), - new Address("House of " + seed), + Task generateTask(int seed) throws Exception { + return new Task( + new Name("Task " + seed), + new StartDateTime("" + Math.abs(seed)), + new EndDateTime(seed + "@endDateTime"), + new Date("House of " + seed), new UniqueTagList(new Tag("tag" + Math.abs(seed)), new Tag("tag" + Math.abs(seed + 1))) ); } - /** Generates the correct add command based on the person given */ - String generateAddCommand(Person p) { + /** Generates the correct add command based on the task given */ + String generateAddCommand(Task p) { StringBuffer cmd = new StringBuffer(); cmd.append("add "); cmd.append(p.getName().toString()); - cmd.append(" p/").append(p.getPhone()); - cmd.append(" e/").append(p.getEmail()); - cmd.append(" a/").append(p.getAddress()); + cmd.append(" p/").append(p.getStartDateTime()); + cmd.append(" e/").append(p.getEndDateTime()); + cmd.append(" a/").append(p.getDate()); UniqueTagList tags = p.getTags(); for(Tag t: tags){ @@ -430,7 +420,7 @@ String generateAddCommand(Person p) { } /** - * Generates an AddressBook with auto-generated persons. + * Generates an AddressBook with auto-generated tasks. */ AddressBook generateAddressBook(int numGenerated) throws Exception{ AddressBook addressBook = new AddressBook(); @@ -439,72 +429,72 @@ AddressBook generateAddressBook(int numGenerated) throws Exception{ } /** - * Generates an AddressBook based on the list of Persons given. + * Generates an AddressBook based on the list of Tasks given. */ - AddressBook generateAddressBook(List persons) throws Exception{ + AddressBook generateAddressBook(List tasks) throws Exception{ AddressBook addressBook = new AddressBook(); - addToAddressBook(addressBook, persons); + addToAddressBook(addressBook, tasks); return addressBook; } /** - * Adds auto-generated Person objects to the given AddressBook - * @param addressBook The AddressBook to which the Persons will be added + * Adds auto-generated Task objects to the given AddressBook + * @param addressBook The AddressBook to which the Tasks will be added */ void addToAddressBook(AddressBook addressBook, int numGenerated) throws Exception{ - addToAddressBook(addressBook, generatePersonList(numGenerated)); + addToAddressBook(addressBook, generateTaskList(numGenerated)); } /** - * Adds the given list of Persons to the given AddressBook + * Adds the given list of Tasks to the given AddressBook */ - void addToAddressBook(AddressBook addressBook, List personsToAdd) throws Exception{ - for(Person p: personsToAdd){ - addressBook.addPerson(p); + void addToAddressBook(AddressBook addressBook, List TasksToAdd) throws Exception{ + for(Task p: TasksToAdd){ + addressBook.addTask(p); } } /** - * Adds auto-generated Person objects to the given model - * @param model The model to which the Persons will be added + * Adds auto-generated Task objects to the given model + * @param model The model to which the Tasks will be added */ void addToModel(Model model, int numGenerated) throws Exception{ - addToModel(model, generatePersonList(numGenerated)); + addToModel(model, generateTaskList(numGenerated)); } /** - * Adds the given list of Persons to the given model + * Adds the given list of Tasks to the given model */ - void addToModel(Model model, List personsToAdd) throws Exception{ - for(Person p: personsToAdd){ - model.addPerson(p); + void addToModel(Model model, List tasksToAdd) throws Exception{ + for(Task p: tasksToAdd){ + model.addTask(p); } } /** - * Generates a list of Persons based on the flags. + * Generates a list of Tasks based on the flags. */ - List generatePersonList(int numGenerated) throws Exception{ - List persons = new ArrayList<>(); + List generateTaskList(int numGenerated) throws Exception{ + List tasks = new ArrayList<>(); for(int i = 1; i <= numGenerated; i++){ - persons.add(generatePerson(i)); + tasks.add(generateTask(i)); } - return persons; + return tasks; } - List generatePersonList(Person... persons) { - return Arrays.asList(persons); + List generateTaskList(Task... tasks) { + return Arrays.asList(tasks); } /** - * Generates a Person object with given name. Other fields will have some dummy values. + * Generates a Task object with given name. Other fields will have some dummy values. */ - Person generatePersonWithName(String name) throws Exception { - return new Person( + Task generateTaskWithName(String name) throws Exception { + return new Task( new Name(name), - new Phone("1"), - new Email("1@email"), - new Address("House of 1"), + new StartDateTime("1"), + new EndDateTime("1@endDateTime"), + new Date("House of 1"), new UniqueTagList(new Tag("tag")) ); } diff --git a/src/test/java/seedu/address/storage/StorageManagerTest.java b/src/test/java/seedu/address/storage/StorageManagerTest.java index 6780feab6afc..503aacd88d05 100644 --- a/src/test/java/seedu/address/storage/StorageManagerTest.java +++ b/src/test/java/seedu/address/storage/StorageManagerTest.java @@ -10,7 +10,7 @@ import seedu.address.model.AddressBook; import seedu.address.model.ReadOnlyAddressBook; import seedu.address.model.UserPrefs; -import seedu.address.testutil.TypicalTestPersons; +import seedu.address.testutil.TypicalTestTasks; import seedu.address.testutil.EventsCollector; import java.io.IOException; @@ -55,7 +55,7 @@ public void prefsReadSave() throws Exception { @Test public void addressBookReadSave() throws Exception { - AddressBook original = new TypicalTestPersons().getTypicalAddressBook(); + AddressBook original = new TypicalTestTasks().getTypicalAddressBook(); storageManager.saveAddressBook(original); ReadOnlyAddressBook retrieved = storageManager.readAddressBook().get(); assertEquals(original, new AddressBook(retrieved)); diff --git a/src/test/java/seedu/address/storage/XmlAddressBookStorageTest.java b/src/test/java/seedu/address/storage/XmlAddressBookStorageTest.java index 04b0db1ce1c7..e24ec65f8307 100644 --- a/src/test/java/seedu/address/storage/XmlAddressBookStorageTest.java +++ b/src/test/java/seedu/address/storage/XmlAddressBookStorageTest.java @@ -9,8 +9,8 @@ import seedu.address.commons.util.FileUtil; import seedu.address.model.AddressBook; import seedu.address.model.ReadOnlyAddressBook; -import seedu.address.model.person.Person; -import seedu.address.testutil.TypicalTestPersons; +import seedu.address.model.task.Task; +import seedu.address.testutil.TypicalTestTasks; import java.io.IOException; @@ -61,7 +61,7 @@ public void read_notXmlFormat_exceptionThrown() throws Exception { @Test public void readAndSaveAddressBook_allInOrder_success() throws Exception { String filePath = testFolder.getRoot().getPath() + "TempAddressBook.xml"; - TypicalTestPersons td = new TypicalTestPersons(); + TypicalTestTasks td = new TypicalTestTasks(); AddressBook original = td.getTypicalAddressBook(); XmlAddressBookStorage xmlAddressBookStorage = new XmlAddressBookStorage(filePath); @@ -71,14 +71,14 @@ public void readAndSaveAddressBook_allInOrder_success() throws Exception { assertEquals(original, new AddressBook(readBack)); //Modify data, overwrite exiting file, and read back - original.addPerson(new Person(TypicalTestPersons.hoon)); - original.removePerson(new Person(TypicalTestPersons.alice)); + original.addTask(new Task(TypicalTestTasks.hoon)); + original.removeTask(new Task(TypicalTestTasks.alice)); xmlAddressBookStorage.saveAddressBook(original, filePath); readBack = xmlAddressBookStorage.readAddressBook(filePath).get(); assertEquals(original, new AddressBook(readBack)); //Save and read without specifying file path - original.addPerson(new Person(TypicalTestPersons.ida)); + original.addTask(new Task(TypicalTestTasks.ida)); xmlAddressBookStorage.saveAddressBook(original); //file path not specified readBack = xmlAddressBookStorage.readAddressBook().get(); //file path not specified assertEquals(original, new AddressBook(readBack)); diff --git a/src/test/java/seedu/address/testutil/AddressBookBuilder.java b/src/test/java/seedu/address/testutil/AddressBookBuilder.java index a623b81c878f..91071d03ddb5 100644 --- a/src/test/java/seedu/address/testutil/AddressBookBuilder.java +++ b/src/test/java/seedu/address/testutil/AddressBookBuilder.java @@ -2,14 +2,14 @@ import seedu.address.commons.exceptions.IllegalValueException; import seedu.address.model.tag.Tag; +import seedu.address.model.task.Task; +import seedu.address.model.task.UniqueTaskList; import seedu.address.model.AddressBook; -import seedu.address.model.person.Person; -import seedu.address.model.person.UniquePersonList; /** * A utility class to help with building Addressbook objects. * Example usage:
- * {@code AddressBook ab = new AddressBookBuilder().withPerson("John", "Doe").withTag("Friend").build();} + * {@code AddressBook ab = new AddressBookBuilder().withTask("John", "Doe").withTag("Friend").build();} */ public class AddressBookBuilder { @@ -19,8 +19,8 @@ public AddressBookBuilder(AddressBook addressBook){ this.addressBook = addressBook; } - public AddressBookBuilder withPerson(Person person) throws UniquePersonList.DuplicatePersonException { - addressBook.addPerson(person); + public AddressBookBuilder withTask(Task task) throws UniqueTaskList.DuplicateTaskException { + addressBook.addTask(task); return this; } diff --git a/src/test/java/seedu/address/testutil/PersonBuilder.java b/src/test/java/seedu/address/testutil/PersonBuilder.java deleted file mode 100644 index 8b02a1668ef6..000000000000 --- a/src/test/java/seedu/address/testutil/PersonBuilder.java +++ /dev/null @@ -1,49 +0,0 @@ -package seedu.address.testutil; - -import seedu.address.commons.exceptions.IllegalValueException; -import seedu.address.model.tag.Tag; -import seedu.address.model.person.*; - -/** - * - */ -public class PersonBuilder { - - private TestPerson person; - - public PersonBuilder() { - this.person = new TestPerson(); - } - - public PersonBuilder withName(String name) throws IllegalValueException { - this.person.setName(new Name(name)); - return this; - } - - public PersonBuilder withTags(String ... tags) throws IllegalValueException { - for (String tag: tags) { - person.getTags().add(new Tag(tag)); - } - return this; - } - - public PersonBuilder withAddress(String address) throws IllegalValueException { - this.person.setAddress(new Address(address)); - return this; - } - - public PersonBuilder withPhone(String phone) throws IllegalValueException { - this.person.setPhone(new Phone(phone)); - return this; - } - - public PersonBuilder withEmail(String email) throws IllegalValueException { - this.person.setEmail(new Email(email)); - return this; - } - - public TestPerson build() { - return this.person; - } - -} diff --git a/src/test/java/seedu/address/testutil/TaskBuilder.java b/src/test/java/seedu/address/testutil/TaskBuilder.java new file mode 100644 index 000000000000..fc17077f003e --- /dev/null +++ b/src/test/java/seedu/address/testutil/TaskBuilder.java @@ -0,0 +1,49 @@ +package seedu.address.testutil; + +import seedu.address.commons.exceptions.IllegalValueException; +import seedu.address.model.tag.Tag; +import seedu.address.model.task.*; + +/** + * + */ +public class TaskBuilder { + + private TestTask task; + + public TaskBuilder() { + this.task = new TestTask(); + } + + public TaskBuilder withName(String name) throws IllegalValueException { + this.task.setName(new Name(name)); + return this; + } + + public TaskBuilder withTags(String ... tags) throws IllegalValueException { + for (String tag: tags) { + task.getTags().add(new Tag(tag)); + } + return this; + } + + public TaskBuilder withDate(String date) throws IllegalValueException { + this.task.setDate(new Date(date)); + return this; + } + + public TaskBuilder withStartDateTime(String startDateTime) throws IllegalValueException { + this.task.setStartDateTime(new StartDateTime(startDateTime)); + return this; + } + + public TaskBuilder withEndDateTime(String endDateTime) throws IllegalValueException { + this.task.setEndDateTime(new EndDateTime(endDateTime)); + return this; + } + + public TestTask build() { + return this.task; + } + +} diff --git a/src/test/java/seedu/address/testutil/TestPerson.java b/src/test/java/seedu/address/testutil/TestPerson.java deleted file mode 100644 index 19ee5ded1cd3..000000000000 --- a/src/test/java/seedu/address/testutil/TestPerson.java +++ /dev/null @@ -1,76 +0,0 @@ -package seedu.address.testutil; - -import seedu.address.model.tag.UniqueTagList; -import seedu.address.model.person.*; - -/** - * A mutable person object. For testing only. - */ -public class TestPerson implements ReadOnlyPerson { - - private Name name; - private Address address; - private Email email; - private Phone phone; - private UniqueTagList tags; - - public TestPerson() { - tags = new UniqueTagList(); - } - - public void setName(Name name) { - this.name = name; - } - - public void setAddress(Address address) { - this.address = address; - } - - public void setEmail(Email email) { - this.email = email; - } - - public void setPhone(Phone phone) { - this.phone = phone; - } - - @Override - public Name getName() { - return name; - } - - @Override - public Phone getPhone() { - return phone; - } - - @Override - public Email getEmail() { - return email; - } - - @Override - public Address getAddress() { - return address; - } - - @Override - public UniqueTagList getTags() { - return tags; - } - - @Override - public String toString() { - return getAsText(); - } - - public String getAddCommand() { - StringBuilder sb = new StringBuilder(); - sb.append("add " + this.getName().fullName + " "); - sb.append("p/" + this.getPhone().value + " "); - sb.append("e/" + this.getEmail().value + " "); - sb.append("a/" + this.getAddress().value + " "); - this.getTags().getInternalList().stream().forEach(s -> sb.append("t/" + s.tagName + " ")); - return sb.toString(); - } -} diff --git a/src/test/java/seedu/address/testutil/TestTask.java b/src/test/java/seedu/address/testutil/TestTask.java new file mode 100644 index 000000000000..71b23e0a68b4 --- /dev/null +++ b/src/test/java/seedu/address/testutil/TestTask.java @@ -0,0 +1,76 @@ +package seedu.address.testutil; + +import seedu.address.model.tag.UniqueTagList; +import seedu.address.model.task.*; + +/** + * A mutable task object. For testing only. + */ +public class TestTask implements ReadOnlyTask { + + private Name name; + private Date date; + private EndDateTime endDateTime; + private StartDateTime startDateTime; + private UniqueTagList tags; + + public TestTask() { + tags = new UniqueTagList(); + } + + public void setName(Name name) { + this.name = name; + } + + public void setDate(Date date) { + this.date = date; + } + + public void setEndDateTime(EndDateTime endDateTime) { + this.endDateTime = endDateTime; + } + + public void setStartDateTime(StartDateTime startDateTime) { + this.startDateTime = startDateTime; + } + + @Override + public Name getName() { + return name; + } + + @Override + public StartDateTime getStartDateTime() { + return startDateTime; + } + + @Override + public EndDateTime getEndDateTime() { + return endDateTime; + } + + @Override + public Date getDate() { + return date; + } + + @Override + public UniqueTagList getTags() { + return tags; + } + + @Override + public String toString() { + return getAsText(); + } + + public String getAddCommand() { + StringBuilder sb = new StringBuilder(); + sb.append("add " + this.getName().fullName + " "); + sb.append("p/" + this.getStartDateTime().value + " "); + sb.append("e/" + this.getEndDateTime().value + " "); + sb.append("a/" + this.getDate().value + " "); + this.getTags().getInternalList().stream().forEach(s -> sb.append("t/" + s.tagName + " ")); + return sb.toString(); + } +} diff --git a/src/test/java/seedu/address/testutil/TestUtil.java b/src/test/java/seedu/address/testutil/TestUtil.java index 17c92d66398a..7b9181076694 100644 --- a/src/test/java/seedu/address/testutil/TestUtil.java +++ b/src/test/java/seedu/address/testutil/TestUtil.java @@ -1,7 +1,7 @@ package seedu.address.testutil; import com.google.common.io.Files; -import guitests.guihandles.PersonCardHandle; +import guitests.guihandles.TaskCardHandle; import javafx.geometry.Bounds; import javafx.geometry.Point2D; import javafx.scene.Node; @@ -17,9 +17,9 @@ import seedu.address.commons.util.FileUtil; import seedu.address.commons.util.XmlUtil; import seedu.address.model.AddressBook; -import seedu.address.model.person.*; import seedu.address.model.tag.Tag; import seedu.address.model.tag.UniqueTagList; +import seedu.address.model.task.*; import seedu.address.storage.XmlSerializableAddressBook; import java.io.File; @@ -60,20 +60,20 @@ public static void assertThrows(Class expected, Runnable ex */ public static String SANDBOX_FOLDER = FileUtil.getPath("./src/test/data/sandbox/"); - public static final Person[] samplePersonData = getSamplePersonData(); + public static final Task[] sampleTaskData = getSampleTaskData(); - private static Person[] getSamplePersonData() { + private static Task[] getSampleTaskData() { try { - return new Person[]{ - new Person(new Name("Ali Muster"), new Phone("9482424"), new Email("hans@google.com"), new Address("4th street"), new UniqueTagList()), - new Person(new Name("Boris Mueller"), new Phone("87249245"), new Email("ruth@google.com"), new Address("81th street"), new UniqueTagList()), - new Person(new Name("Carl Kurz"), new Phone("95352563"), new Email("heinz@yahoo.com"), new Address("wall street"), new UniqueTagList()), - new Person(new Name("Daniel Meier"), new Phone("87652533"), new Email("cornelia@google.com"), new Address("10th street"), new UniqueTagList()), - new Person(new Name("Elle Meyer"), new Phone("9482224"), new Email("werner@gmail.com"), new Address("michegan ave"), new UniqueTagList()), - new Person(new Name("Fiona Kunz"), new Phone("9482427"), new Email("lydia@gmail.com"), new Address("little tokyo"), new UniqueTagList()), - new Person(new Name("George Best"), new Phone("9482442"), new Email("anna@google.com"), new Address("4th street"), new UniqueTagList()), - new Person(new Name("Hoon Meier"), new Phone("8482424"), new Email("stefan@mail.com"), new Address("little india"), new UniqueTagList()), - new Person(new Name("Ida Mueller"), new Phone("8482131"), new Email("hans@google.com"), new Address("chicago ave"), new UniqueTagList()) + return new Task[]{ + new Task(new Name("Ali Muster"), new StartDateTime("9482424"), new EndDateTime("hans@google.com"), new Date("4th street"), new UniqueTagList()), + new Task(new Name("Boris Mueller"), new StartDateTime("87249245"), new EndDateTime("ruth@google.com"), new Date("81th street"), new UniqueTagList()), + new Task(new Name("Carl Kurz"), new StartDateTime("95352563"), new EndDateTime("heinz@yahoo.com"), new Date("wall street"), new UniqueTagList()), + new Task(new Name("Daniel Meier"), new StartDateTime("87652533"), new EndDateTime("cornelia@google.com"), new Date("10th street"), new UniqueTagList()), + new Task(new Name("Elle Meyer"), new StartDateTime("9482224"), new EndDateTime("werner@gmail.com"), new Date("michegan ave"), new UniqueTagList()), + new Task(new Name("Fiona Kunz"), new StartDateTime("9482427"), new EndDateTime("lydia@gmail.com"), new Date("little tokyo"), new UniqueTagList()), + new Task(new Name("George Best"), new StartDateTime("9482442"), new EndDateTime("anna@google.com"), new Date("4th street"), new UniqueTagList()), + new Task(new Name("Hoon Meier"), new StartDateTime("8482424"), new EndDateTime("stefan@mail.com"), new Date("little india"), new UniqueTagList()), + new Task(new Name("Ida Mueller"), new StartDateTime("8482131"), new EndDateTime("hans@google.com"), new Date("chicago ave"), new UniqueTagList()) }; } catch (IllegalValueException e) { assert false; @@ -97,8 +97,8 @@ private static Tag[] getSampleTagData() { } } - public static List generateSamplePersonData() { - return Arrays.asList(samplePersonData); + public static List generateSampleTaskData() { + return Arrays.asList(sampleTaskData); } /** @@ -135,7 +135,7 @@ public static void main(String... s) { } public static AddressBook generateEmptyAddressBook() { - return new AddressBook(new UniquePersonList(), new UniqueTagList()); + return new AddressBook(new UniqueTaskList(), new UniqueTagList()); } public static XmlSerializableAddressBook generateSampleStorageAddressBook() { @@ -273,49 +273,49 @@ public static Object getLastElement(List list) { } /** - * Removes a subset from the list of persons. - * @param persons The list of persons - * @param personsToRemove The subset of persons. - * @return The modified persons after removal of the subset from persons. + * Removes a subset from the list of tasks. + * @param tasks The list of tasks + * @param tasksToRemove The subset of tasks. + * @return The modified tasks after removal of the subset from tasks. */ - public static TestPerson[] removePersonsFromList(final TestPerson[] persons, TestPerson... personsToRemove) { - List listOfPersons = asList(persons); - listOfPersons.removeAll(asList(personsToRemove)); - return listOfPersons.toArray(new TestPerson[listOfPersons.size()]); + public static TestTask[] removeTasksFromList(final TestTask[] tasks, TestTask... tasksToRemove) { + List listOfTasks = asList(tasks); + listOfTasks.removeAll(asList(tasksToRemove)); + return listOfTasks.toArray(new TestTask[listOfTasks.size()]); } /** - * Returns a copy of the list with the person at specified index removed. + * Returns a copy of the list with the task at specified index removed. * @param list original list to copy from * @param targetIndexInOneIndexedFormat e.g. if the first element to be removed, 1 should be given as index. */ - public static TestPerson[] removePersonFromList(final TestPerson[] list, int targetIndexInOneIndexedFormat) { - return removePersonsFromList(list, list[targetIndexInOneIndexedFormat-1]); + public static TestTask[] removeTaskFromList(final TestTask[] list, int targetIndexInOneIndexedFormat) { + return removeTasksFromList(list, list[targetIndexInOneIndexedFormat-1]); } /** - * Replaces persons[i] with a person. - * @param persons The array of persons. - * @param person The replacement person - * @param index The index of the person to be replaced. + * Replaces tasks[i] with a task. + * @param tasks The array of tasks. + * @param task The replacement task + * @param index The index of the task to be replaced. * @return */ - public static TestPerson[] replacePersonFromList(TestPerson[] persons, TestPerson person, int index) { - persons[index] = person; - return persons; + public static TestTask[] replaceTaskFromList(TestTask[] tasks, TestTask task, int index) { + tasks[index] = task; + return tasks; } /** - * Appends persons to the array of persons. - * @param persons A array of persons. - * @param personsToAdd The persons that are to be appended behind the original array. - * @return The modified array of persons. + * Appends tasks to the array of tasks. + * @param tasks A array of tasks. + * @param tasksToAdd The tasks that are to be appended behind the original array. + * @return The modified array of tasks. */ - public static TestPerson[] addPersonsToList(final TestPerson[] persons, TestPerson... personsToAdd) { - List listOfPersons = asList(persons); - listOfPersons.addAll(asList(personsToAdd)); - return listOfPersons.toArray(new TestPerson[listOfPersons.size()]); + public static TestTask[] addTasksToList(final TestTask[] tasks, TestTask... tasksToAdd) { + List listOfTasks = asList(tasks); + listOfTasks.addAll(asList(tasksToAdd)); + return listOfTasks.toArray(new TestTask[listOfTasks.size()]); } private static List asList(T[] objs) { @@ -326,8 +326,8 @@ private static List asList(T[] objs) { return list; } - public static boolean compareCardAndPerson(PersonCardHandle card, ReadOnlyPerson person) { - return card.isSamePerson(person); + public static boolean compareCardAndTask(TaskCardHandle card, ReadOnlyTask task) { + return card.isSameTask(task); } public static Tag[] getTagList(String tags) { diff --git a/src/test/java/seedu/address/testutil/TypicalTestPersons.java b/src/test/java/seedu/address/testutil/TypicalTestPersons.java deleted file mode 100644 index 773f64a98cc3..000000000000 --- a/src/test/java/seedu/address/testutil/TypicalTestPersons.java +++ /dev/null @@ -1,61 +0,0 @@ -package seedu.address.testutil; - -import seedu.address.commons.exceptions.IllegalValueException; -import seedu.address.model.AddressBook; -import seedu.address.model.person.*; - -/** - * - */ -public class TypicalTestPersons { - - public static TestPerson alice, benson, carl, daniel, elle, fiona, george, hoon, ida; - - public TypicalTestPersons() { - try { - alice = new PersonBuilder().withName("Alice Pauline").withAddress("123, Jurong West Ave 6, #08-111") - .withEmail("alice@gmail.com").withPhone("85355255") - .withTags("friends").build(); - benson = new PersonBuilder().withName("Benson Meier").withAddress("311, Clementi Ave 2, #02-25") - .withEmail("johnd@gmail.com").withPhone("98765432") - .withTags("owesMoney", "friends").build(); - carl = new PersonBuilder().withName("Carl Kurz").withPhone("95352563").withEmail("heinz@yahoo.com").withAddress("wall street").build(); - daniel = new PersonBuilder().withName("Daniel Meier").withPhone("87652533").withEmail("cornelia@google.com").withAddress("10th street").build(); - elle = new PersonBuilder().withName("Elle Meyer").withPhone("9482224").withEmail("werner@gmail.com").withAddress("michegan ave").build(); - fiona = new PersonBuilder().withName("Fiona Kunz").withPhone("9482427").withEmail("lydia@gmail.com").withAddress("little tokyo").build(); - george = new PersonBuilder().withName("George Best").withPhone("9482442").withEmail("anna@google.com").withAddress("4th street").build(); - - //Manually added - hoon = new PersonBuilder().withName("Hoon Meier").withPhone("8482424").withEmail("stefan@mail.com").withAddress("little india").build(); - ida = new PersonBuilder().withName("Ida Mueller").withPhone("8482131").withEmail("hans@google.com").withAddress("chicago ave").build(); - } catch (IllegalValueException e) { - e.printStackTrace(); - assert false : "not possible"; - } - } - - public static void loadAddressBookWithSampleData(AddressBook ab) { - - try { - ab.addPerson(new Person(alice)); - ab.addPerson(new Person(benson)); - ab.addPerson(new Person(carl)); - ab.addPerson(new Person(daniel)); - ab.addPerson(new Person(elle)); - ab.addPerson(new Person(fiona)); - ab.addPerson(new Person(george)); - } catch (UniquePersonList.DuplicatePersonException e) { - assert false : "not possible"; - } - } - - public TestPerson[] getTypicalPersons() { - return new TestPerson[]{alice, benson, carl, daniel, elle, fiona, george}; - } - - public AddressBook getTypicalAddressBook(){ - AddressBook ab = new AddressBook(); - loadAddressBookWithSampleData(ab); - return ab; - } -} diff --git a/src/test/java/seedu/address/testutil/TypicalTestTasks.java b/src/test/java/seedu/address/testutil/TypicalTestTasks.java new file mode 100644 index 000000000000..783e73e925cf --- /dev/null +++ b/src/test/java/seedu/address/testutil/TypicalTestTasks.java @@ -0,0 +1,61 @@ +package seedu.address.testutil; + +import seedu.address.commons.exceptions.IllegalValueException; +import seedu.address.model.AddressBook; +import seedu.address.model.task.*; + +/** + * + */ +public class TypicalTestTasks { + + public static TestTask alice, benson, carl, daniel, elle, fiona, george, hoon, ida; + + public TypicalTestTasks() { + try { + alice = new TaskBuilder().withName("Alice Pauline").withDate("123, Jurong West Ave 6, #08-111") + .withEndDateTime("alice@gmail.com").withStartDateTime("85355255") + .withTags("friends").build(); + benson = new TaskBuilder().withName("Benson Meier").withDate("311, Clementi Ave 2, #02-25") + .withEndDateTime("johnd@gmail.com").withStartDateTime("98765432") + .withTags("owesMoney", "friends").build(); + carl = new TaskBuilder().withName("Carl Kurz").withStartDateTime("95352563").withEndDateTime("heinz@yahoo.com").withDate("wall street").build(); + daniel = new TaskBuilder().withName("Daniel Meier").withStartDateTime("87652533").withEndDateTime("cornelia@google.com").withDate("10th street").build(); + elle = new TaskBuilder().withName("Elle Meyer").withStartDateTime("9482224").withEndDateTime("werner@gmail.com").withDate("michegan ave").build(); + fiona = new TaskBuilder().withName("Fiona Kunz").withStartDateTime("9482427").withEndDateTime("lydia@gmail.com").withDate("little tokyo").build(); + george = new TaskBuilder().withName("George Best").withStartDateTime("9482442").withEndDateTime("anna@google.com").withDate("4th street").build(); + + //Manually added + hoon = new TaskBuilder().withName("Hoon Meier").withStartDateTime("8482424").withEndDateTime("stefan@mail.com").withDate("little india").build(); + ida = new TaskBuilder().withName("Ida Mueller").withStartDateTime("8482131").withEndDateTime("hans@google.com").withDate("chicago ave").build(); + } catch (IllegalValueException e) { + e.printStackTrace(); + assert false : "not possible"; + } + } + + public static void loadAddressBookWithSampleData(AddressBook ab) { + + try { + ab.addTask(new Task(alice)); + ab.addTask(new Task(benson)); + ab.addTask(new Task(carl)); + ab.addTask(new Task(daniel)); + ab.addTask(new Task(elle)); + ab.addTask(new Task(fiona)); + ab.addTask(new Task(george)); + } catch (UniqueTaskList.DuplicateTaskException e) { + assert false : "not possible"; + } + } + + public TestTask[] getTypicalTasks() { + return new TestTask[]{alice, benson, carl, daniel, elle, fiona, george}; + } + + public AddressBook getTypicalAddressBook(){ + AddressBook ab = new AddressBook(); + loadAddressBookWithSampleData(ab); + return ab; + } +}