Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete JsonAdaptedFreeTime #293

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified bin/main/seedu/address/logic/commands/AddEventCommand.class
Binary file not shown.
Binary file modified bin/main/seedu/address/logic/commands/AddScheduleCommand.class
Binary file not shown.
Binary file modified bin/main/seedu/address/logic/commands/RemoveEventCommand.class
Binary file not shown.
Binary file not shown.
Binary file modified bin/main/seedu/address/logic/parser/AddEventCommandParser.class
Binary file not shown.
Binary file not shown.
Binary file modified bin/main/seedu/address/logic/parser/EditUserCommandParser.class
Binary file not shown.
Binary file modified bin/main/seedu/address/logic/parser/RemoveEventCommandParser.class
Binary file not shown.
Binary file modified bin/main/seedu/address/model/person/timetable/FreeTime.class
Binary file not shown.
Binary file modified bin/main/seedu/address/model/person/timetable/Schedule.class
Binary file not shown.
Binary file not shown.
Binary file modified bin/main/seedu/address/storage/JsonAdaptedTag.class
Binary file not shown.
Binary file modified bin/main/seedu/address/storage/JsonAdaptedUser.class
Binary file not shown.
Binary file modified bin/main/seedu/address/storage/JsonAddressBookStorage.class
Binary file not shown.
Binary file modified bin/main/seedu/address/storage/JsonSerializableAddressBook.class
Binary file not shown.
Binary file modified bin/main/seedu/address/storage/JsonSerializableUserData.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
22 changes: 22 additions & 0 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,28 @@ who has birthdays on the day itself.

### Edit user details feature

#### Description
User can edit and add their own details, such as their phone numbers and birthdays, and also their schedules using this command, with the command word `user` and the following prefixes:
- `n\`: Name
- `p\`: Phone number
- `e\`: E-mail
- `t\`: Tags
- `a\`: Address

#### Implementation
- The `MainWindow#executeCommand()` calls `LogicManager#execute()` method, which proceeds
to call `AddressBookParser#parseCommand()` method, which then calls `EditUserCommandParser#parse()`.
- `EditUserCommandParser#parse()` then creates a `EditUserDescriptor` that stores the incoming data to edit user. It stores it using the `set` methods, with `setName()` shown in the diagram below.
- `EditUserCommandParser` then returns a `EditUserCommand` object using the `EditUserDescriptor`.
- The `EditUserCommand` is then passed up to `LogicManager`.
- `LogicManager#execute(editUserCommand)` is called, which then calls `Model#getUser()`. A new `User` object is created with existing user information and incoming data from the `EditUserDescriptor`.
- `Model#setUser(editedUser)` is then called to save the updated user into `Model`.
- `Model` then updates `Storage`, allowing users to save data across sessions.

<img src="images/EditUserSequenceDiagram.png" width="350" />

<img src="images/EditUserExecuteSequenceDiagram.png" width="350" />

### Model design considerations for schedule

### Click to View Friend Timetable Feature
Expand Down
48 changes: 48 additions & 0 deletions docs/diagrams/EditUserExecuteSequenceDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
@startuml
!include style.puml
skinparam ArrowFontStyle plain

mainframe Execute Command

box Logic LOGIC_COLOR_T1
participant ":EditUserCommand" as EditUserCommand LOGIC_COLOR
participant "result:CommandResult" as CommandResult LOGIC_COLOR
participant "editedUser:User" as User LOGIC_COLOR
end box

box Model MODEL_COLOR_T1
participant ":Model" as Model MODEL_COLOR
end box

activate EditUserCommand
EditUserCommand -> Model : getUser()
activate Model

Model --> EditUserCommand : user
deactivate Model

create User
EditUserCommand -> User : createEditedUser(user, editUserDescriptor)
activate User

User --> EditUserCommand : editedUser
deactivate User

EditUserCommand -> Model : setUser(editedUser)
activate Model



Model --> EditUserCommand :
deactivate Model

create CommandResult
EditUserCommand -> CommandResult
activate CommandResult

CommandResult --> EditUserCommand
deactivate CommandResult

<-- EditUserCommand : result

@enduml
66 changes: 66 additions & 0 deletions docs/diagrams/EditUserSequenceDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
@startuml
!include style.puml
skinparam ArrowFontStyle plain

skinparam backgroundColor<<frame>> #FFFFFF
skinparam styleName<<frame>> frame

box Logic LOGIC_COLOR_T1
participant ":LogicManager" as LogicManager LOGIC_COLOR
participant ":AddressBookParser" as AddressBookParser LOGIC_COLOR
participant ":EditUserCommandParser" as EditUserCommandParser LOGIC_COLOR
participant "editUserDescriptor:EditUserDescriptor" as EditUserDescriptor LOGIC_COLOR
participant ":EditUserCommand" as EditUserCommand LOGIC_COLOR
end box

[-> LogicManager : execute("user n/John Doe")
activate LogicManager

LogicManager -> AddressBookParser : parseCommand("user n/John Doe")
activate AddressBookParser

create EditUserCommandParser
AddressBookParser -> EditUserCommandParser
activate EditUserCommandParser

EditUserCommandParser --> AddressBookParser
deactivate EditUserCommandParser

AddressBookParser -> EditUserCommandParser : parse("n/John Doe")
activate EditUserCommandParser

create EditUserDescriptor
EditUserCommandParser -> EditUserDescriptor
activate EditUserDescriptor

EditUserDescriptor --> EditUserCommandParser : editUserDescriptor
deactivate EditUserDescriptor

EditUserCommandParser -> EditUserDescriptor : setName("John Doe")
activate EditUserDescriptor

EditUserDescriptor --> EditUserCommandParser : editUserDescriptor
deactivate EditUserDescriptor

create EditUserCommand
EditUserCommandParser -> EditUserCommand : EditUserCommand(editUserDescriptor)
activate EditUserCommand

EditUserCommand --> EditUserCommandParser : e
deactivate EditUserCommand

EditUserCommandParser --> AddressBookParser : e
deactivate EditUserCommandParser

AddressBookParser --> LogicManager : e
deactivate AddressBookParser

LogicManager -> EditUserCommand : execute(model)
activate EditUserCommand
ref over EditUserCommand : Execute Command

EditUserCommand --> LogicManager : result
deactivate EditUserCommand

<-- LogicManager
@enduml
Binary file added docs/images/EditUserExecuteSequenceDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/EditUserSequenceDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 26 additions & 14 deletions docs/team/owenyeo.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,54 @@ title: Owen Yeo's Project Portfolio Page

### Overview

TimetaBRO, your ultimate companion for managing your university life, social interactions, and schedules.
TimetaBRO, your ultimate companion for managing your university life, social interactions, and schedules. It allows for easy storage and perusal of your own schedule and your friends! Arrange meetings with ease, and never forget anything!

### Summary of Contributions

**Code contributed:**
https://nus-cs2103-ay2324s1.github.io/tp-dashboard/?search=owenyeo&sort=groupTitle&sortWithin=title&timeframe=commit&mergegroup=&groupSelect=groupByRepos&breakdown=true&checkedFileTypes=docs~functional-code~test-code&since=2023-09-22

**Enhancements implemented:**
* Implemented the User, UserData, and ReadOnlyUserData to save user details and schedule.
* Implemented the EditUserCommand to allow for editing of user details.
* Implemented UserDataStorage and updated Storage, StorageManager to support it.
* Created the follow Json related classes:
* JsonAdaptedCca
* JsonAdaptedDatedEvent
* JsonAdaptedModule
* JsonAdaptedSchedule
* JsonAdaptedUser
* JsonUserDataStorage
* JsonSerializableUserData.java
* **New Feature**: Added the ability to store user data, such as birthdays and schedules. It is stored in a Jackson file `userdata.json`
* What it does: Allows the user to store their own data and schedules in TimetaBRO across sessions.
* Justification: This feature allows users to quickly access their data and schedules should they need it, and allows for schedule comparisons to occur in other commands. Users also do not need to re-key their information every time they use the app.
* Highlights: This enhancement required knowledge about Jackson files, and how to convert models into JSON adapted versions to save on a hard disk. It also required the implementation of a user class. It took me quite long for this.
* **New Feature**: Added ability to edit user data stored in the app itself.
* What it does: Allows user to edit saved data straight from the app's CLI.
* Justification: This makes the user experience a lot more smooth as the user does not need to access the `userdata.json` file to update their details.
* Highlights: This enhancement required knowledge and tracing of the EditCommand to implement. This was relatively easier as we implemented a command in the codebase tutorial.
* **JsonAdapted classes**: Added JsonAdapted classes to translate models made by my team to Json friendly formats, and vice versa.
* What it does: Allows user to store friends' and their own schedules and data in Json files.
* Justification: This allows our new model, the schedule, and its related models to be able to be stored in a data.
* Created the follow Json related classes:
* JsonAdaptedCca
* JsonAdaptedDatedEvent
* JsonAdaptedModule
* JsonAdaptedSchedule
* JsonAdaptedUser
* JsonUserDataStorage
* JsonSerializableUserData
* Wrote testcases for storage
* Changed Add and Edit to only require names
* **Modify person and AddressBook**: Disallowed duplicate phone numbers and emails. Changed notion of equality of same birthday AND same full name.
* Justification: It is impossible for 2 different people to have the same phone number or the same email. It is also possible for people to have the same first name. Thus, adding birthday would mitigate this to a higher degree.


**Contributions to the User Guide (UG):**
* Wrote the introduction
* Wrote About
* Wrote the Quickstart
* Updated tone throughout the UG.

**Contributions to the Developer Guide (DG):**
* Adjusted the diagrams in Storage and Model
* Updated the diagrams in Storage and Model
* Added details about UserDataStorage
* Added implementation of EditUserCommand

**Contributions to team-based tasks:**
* Delegated work to teammates
* Created issues and assigned them to teammates
* Kept track of code deadlines
* Reviewed, approved, and merged pull requests from other tea members.

**Contributions beyond the project team:**
* Took part in Bug CATcher stress test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,31 +43,31 @@ public EditUserCommand parse(String args) throws ParseException {
argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NAME, PREFIX_PHONE,
PREFIX_EMAIL, PREFIX_ADDRESS, PREFIX_BIRTHDAY);

EditUserDescriptor editPersonDescriptor = new EditUserDescriptor();
EditUserDescriptor editUserDescriptor = new EditUserDescriptor();

// Check if all present prefixes are valid
if (argMultimap.getValue(PREFIX_NAME).isPresent()) {
editPersonDescriptor.setName(ParserUtil.parseName(argMultimap.getValue(PREFIX_NAME).get()));
editUserDescriptor.setName(ParserUtil.parseName(argMultimap.getValue(PREFIX_NAME).get()));
}
if (argMultimap.getValue(PREFIX_PHONE).isPresent()) {
editPersonDescriptor.setPhone(ParserUtil.parsePhone(argMultimap.getValue(PREFIX_PHONE).get()));
editUserDescriptor.setPhone(ParserUtil.parsePhone(argMultimap.getValue(PREFIX_PHONE).get()));
}
if (argMultimap.getValue(PREFIX_EMAIL).isPresent()) {
editPersonDescriptor.setEmail(ParserUtil.parseEmail(argMultimap.getValue(PREFIX_EMAIL).get()));
editUserDescriptor.setEmail(ParserUtil.parseEmail(argMultimap.getValue(PREFIX_EMAIL).get()));
}
if (argMultimap.getValue(PREFIX_ADDRESS).isPresent()) {
editPersonDescriptor.setAddress(ParserUtil.parseAddress(argMultimap.getValue(PREFIX_ADDRESS).get()));
editUserDescriptor.setAddress(ParserUtil.parseAddress(argMultimap.getValue(PREFIX_ADDRESS).get()));
}
if (argMultimap.getValue(PREFIX_BIRTHDAY).isPresent()) {
editPersonDescriptor.setBirthday(ParserUtil.parseBirthday(argMultimap.getValue(PREFIX_BIRTHDAY).get()));
editUserDescriptor.setBirthday(ParserUtil.parseBirthday(argMultimap.getValue(PREFIX_BIRTHDAY).get()));
}
parseTagsForEdit(argMultimap.getAllValues(PREFIX_TAG)).ifPresent(editPersonDescriptor::setTags);
parseTagsForEdit(argMultimap.getAllValues(PREFIX_TAG)).ifPresent(editUserDescriptor::setTags);

if (!editPersonDescriptor.isAnyFieldEdited()) {
if (!editUserDescriptor.isAnyFieldEdited()) {
throw new ParseException(EditUserCommand.MESSAGE_NOT_EDITED);
}

return new EditUserCommand(editPersonDescriptor);
return new EditUserCommand(editUserDescriptor);
}

/**
Expand Down
47 changes: 0 additions & 47 deletions src/main/java/seedu/address/storage/JsonAdaptedFreeTime.java

This file was deleted.

1 change: 1 addition & 0 deletions src/main/java/seedu/address/storage/JsonAdaptedTag.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public String getTagName() {
* Converts this Jackson-friendly adapted tag object into the model's {@code Tag} object.
*
* @throws IllegalValueException if there were any data constraints violated in the adapted tag.
* @return Tag object.
*/
public Tag toModelType() throws IllegalValueException {
if (!Tag.isValidTagName(tagName)) {
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/seedu/address/storage/JsonAdaptedUser.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public JsonAdaptedUser(User source) {
* Converts this Jackson-friendly adapted person object into the model's {@code User} object.
*
* @throws IllegalValueException if there were any data constraints violated in the adapted person.
* @return User object.
*/
public User toModelType() throws IllegalValueException {
final List<Tag> personTags = new ArrayList<>();
Expand All @@ -104,6 +105,7 @@ public User toModelType() throws IllegalValueException {
if (!Name.isValidName(name)) {
throw new IllegalValueException(Name.MESSAGE_CONSTRAINTS);
}

final Name modelName = new Name(name);

if (phone == null) {
Expand All @@ -112,6 +114,7 @@ public User toModelType() throws IllegalValueException {
if (!Phone.isValidPhone(phone)) {
throw new IllegalValueException(Phone.MESSAGE_CONSTRAINTS);
}

final Phone modelPhone = new Phone(phone);

if (email == null) {
Expand All @@ -120,6 +123,7 @@ public User toModelType() throws IllegalValueException {
if (!Email.isValidEmail(email)) {
throw new IllegalValueException(Email.MESSAGE_CONSTRAINTS);
}

final Email modelEmail = new Email(email);

if (address == null) {
Expand All @@ -128,6 +132,7 @@ public User toModelType() throws IllegalValueException {
if (!Address.isValidAddress(address)) {
throw new IllegalValueException(Address.MESSAGE_CONSTRAINTS);
}

final Address modelAddress = new Address(address);

if (birthday == null) {
Expand All @@ -137,11 +142,13 @@ public User toModelType() throws IllegalValueException {
if (!Birthday.isValidBirthday(birthday)) {
throw new IllegalValueException(Birthday.MESSAGE_CONSTRAINTS);
}

final Birthday modelBirthday = new Birthday(birthday);

if (schedule == null) {
throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, "Schedule"));
}

final Schedule modelSchedule = schedule.toModelType();

final Set<Tag> modelTags = new HashSet<>(personTags);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public Optional<ReadOnlyAddressBook> readAddressBook() throws DataLoadingExcepti
*
* @param filePath location of the data. Cannot be null.
* @throws DataLoadingException if loading the data from storage failed.
* @return AddressBook object wrapped with an Optional.
*/
public Optional<ReadOnlyAddressBook> readAddressBook(Path filePath) throws DataLoadingException {
requireNonNull(filePath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public JsonSerializableAddressBook(ReadOnlyAddressBook source) {
* Converts this address book into the model's {@code AddressBook} object.
*
* @throws IllegalValueException if there were any data constraints violated.
* @return AddressBook object.
*/
public AddressBook toModelType() throws IllegalValueException {
AddressBook addressBook = new AddressBook();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public JsonSerializableUserData(ReadOnlyUserData source) {
* Converts this address book into the model's {@code UserData} object.
*
* @throws IllegalValueException if there were any data constraints violated.
* @return UserData object.
*/
public UserData toModelType() throws IllegalValueException {
UserData userData = new UserData(this.user.toModelType());
Expand Down
Loading
Loading