Repository: AY2425S2-CS2103T-T08-1/tp
Pull request #93: update model class diagrams
Author: login: SanShaoQian
Created: 2025-03-25T09:59:49Z | Merged: 2025-03-25T10:30:58Z

Update model class diagrams

The model class diagrams are outdated and do not accurately reflect recent changes in the codebase, making them less useful for documentation and understanding the system design.

Update the model class diagrams to align with the latest implementation. Modify class relationships, attributes, and methods as needed to match the current structure.

This ensures that the documentation remains accurate and useful for developers working on the project. Keeping diagrams up to date helps with onboarding and system maintenance.

This change improves clarity and prevents confusion caused by outdated documentation.


Diff:
diff --git a/docs/diagrams/BetterModelClassDiagram.puml b/docs/diagrams/BetterModelClassDiagram.puml
index ac6841ec8e1..4fe265572e8 100644
--- a/docs/diagrams/BetterModelClassDiagram.puml
+++ b/docs/diagrams/BetterModelClassDiagram.puml
@@ -4,18 +4,14 @@ skinparam arrowThickness 1.1
 skinparam arrowColor MODEL_COLOR
 skinparam classBackgroundColor MODEL_COLOR
 
-BiteBook *-right-> "1" UniquePersonList
-BiteBook *-right-> "1" UniqueTagList
-UniqueTagList -[hidden]down- UniquePersonList
-UniqueTagList -[hidden]down- UniquePersonList
+BiteBook *-down-> "1" UniquePersonList
 
-UniqueTagList -right-> "*" Tag
 UniquePersonList -right-> Person
 
-Person -up-> "*" Tag
+Person -up-> "0..1" Tag
 
 Person *--> Name
 Person *--> Phone
-Person *--> Email
-Person *--> Address
+Person *--> Preference
+Person *--> OrderHistory
 @enduml
diff --git a/docs/diagrams/ModelClassDiagram.puml b/docs/diagrams/ModelClassDiagram.puml
index a4e6f845948..489f49a453c 100644
--- a/docs/diagrams/ModelClassDiagram.puml
+++ b/docs/diagrams/ModelClassDiagram.puml
@@ -3,6 +3,8 @@
 skinparam arrowThickness 1.1
 skinparam arrowColor MODEL_COLOR
 skinparam classBackgroundColor MODEL_COLOR
+skinparam classAttributeIconSize 0
+skinparam ClassAttributeFontColor white
 
 Package Model as ModelPackage <<Rectangle>>{
 Class "<<interface>>\nReadOnlyAddressBook" as ReadOnlyAddressBook
@@ -13,7 +15,10 @@ Class ModelManager
 Class UserPrefs
 
 Class UniquePersonList
-Class Person
+Class Person {
+    -orderHistory: Hashmap<String, Integer>
+}
+show Person fields
 Class Name
 Class Phone
 Class Tag
@@ -38,15 +43,13 @@ AddressBook *--> "1" UniquePersonList
 UniquePersonList --> "~* all" Person
 Person *--> Name
 Person *--> Phone
-Person *--> "*" Tag
-Person *--> "*" Preference
+Person *--> "0..1" Tag
+Person *--> Preference
 
 Person -[hidden]up--> I
 UniquePersonList -[hidden]right-> I
 
 Name -[hidden]right-> Phone
-Phone -[hidden]right-> Address
-Address -[hidden]right-> Email
 
 ModelManager --> "~* filtered" Person
 @enduml
diff --git a/docs/diagrams/StorageClassDiagram.puml b/docs/diagrams/StorageClassDiagram.puml
index 27bc1312051..c042861c00c 100644
--- a/docs/diagrams/StorageClassDiagram.puml
+++ b/docs/diagrams/StorageClassDiagram.puml
@@ -19,7 +19,6 @@ Class "<<interface>>\nAddressBookStorage" as AddressBookStorage
 Class JsonAddressBookStorage
 Class JsonSerializableAddressBook
 Class JsonAdaptedPerson
-Class JsonAdaptedTag
 }
 
 }
@@ -38,6 +37,5 @@ JsonUserPrefsStorage .up.|> UserPrefsStorage
 JsonAddressBookStorage .up.|> AddressBookStorage
 JsonAddressBookStorage ..> JsonSerializableAddressBook
 JsonSerializableAddressBook --> "*" JsonAdaptedPerson
-JsonAdaptedPerson --> "*" JsonAdaptedTag
 
 @enduml
diff --git a/src/main/java/seedu/address/storage/JsonAdaptedPerson.java b/src/main/java/seedu/address/storage/JsonAdaptedPerson.java
index 1001c0c3711..f9c0a288ccf 100644
--- a/src/main/java/seedu/address/storage/JsonAdaptedPerson.java
+++ b/src/main/java/seedu/address/storage/JsonAdaptedPerson.java
@@ -43,7 +43,11 @@ public JsonAdaptedPerson(@JsonProperty("name") String name,
         this.phone = phone;
         this.tag = tag;
         this.preference = preference;
-        this.orderHistory = (orderHistory != null) ? new HashMap<>(orderHistory) : new HashMap<>();
+        if (orderHistory == null) {
+            this.orderHistory = new HashMap<>();
+        } else {
+            this.orderHistory = new HashMap<>(orderHistory);
+        }
     }
 
     /**
@@ -88,9 +92,12 @@ public Person toModelType() throws IllegalValueException {
             throw new IllegalValueException(Tag.MESSAGE_CONSTRAINTS);
         }
 
-        final Optional<Tag> modelTag = tag.isEmpty() ? Optional.empty() : Optional.of(new Tag(tag));
+        Optional<Tag> modelTag = Optional.empty();
+        if (!tag.isEmpty()) {
+            modelTag = Optional.of(new Tag(tag));
+        }
 
-        if (preference == null) {
+        if (preference == null || preference.length() < 2) {
             throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, "Preference"));
         }
 
@@ -103,6 +110,10 @@ public Person toModelType() throws IllegalValueException {
 
         Person person = new Person(modelName, modelPhone, modelTag, modelPreference);
 
+        if (orderHistory == null) {
+            throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, "Order History"));
+        }
+
         // Restore the order history into the person object
         for (Map.Entry<String, Integer> entry : orderHistory.entrySet()) {
             for (int i = 0; i < entry.getValue(); i++) {
diff --git a/src/test/java/seedu/address/storage/JsonAdaptedPersonTest.java b/src/test/java/seedu/address/storage/JsonAdaptedPersonTest.java
index 8f694ddb049..37cf2bb1027 100644
--- a/src/test/java/seedu/address/storage/JsonAdaptedPersonTest.java
+++ b/src/test/java/seedu/address/storage/JsonAdaptedPersonTest.java
@@ -5,6 +5,7 @@
 import static seedu.address.testutil.Assert.assertThrows;
 import static seedu.address.testutil.TypicalPersons.BENSON;
 
+import java.util.HashMap;
 import java.util.Map;
 
 import org.junit.jupiter.api.Test;
@@ -17,6 +18,7 @@ public class JsonAdaptedPersonTest {
     private static final String INVALID_NAME = "R@chel";
     private static final String INVALID_PHONE = "+651234";
     private static final String INVALID_TAG = "#friend";
+    private static final String INVALID_PREFERENCE = " ";
 
     private static final String VALID_NAME = BENSON.getName().toString();
     private static final String VALID_PHONE = BENSON.getPhone().toString();
@@ -25,11 +27,18 @@ public class JsonAdaptedPersonTest {
     private static final Map<String, Integer> VALID_ORDER_HISTORY = BENSON.getOrderHistory();
 
     @Test
-    public void toModelType_validPersonDetails_returnsPerson() throws Exception {
+    public void toModelType_validPerson_returnsPerson() throws Exception {
         JsonAdaptedPerson person = new JsonAdaptedPerson(BENSON);
         assertEquals(BENSON, person.toModelType());
     }
 
+    @Test
+    public void toModelType_validPersonDetails_returnsPerson() throws Exception {
+        JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME,
+                VALID_PHONE, VALID_TAG, VALID_PREFERENCE, VALID_ORDER_HISTORY);
+        assertEquals(BENSON, person.toModelType());
+    }
+
     @Test
     public void toModelType_invalidName_throwsIllegalValueException() {
         JsonAdaptedPerson person =
@@ -63,10 +72,42 @@ public void toModelType_nullPhone_throwsIllegalValueException() {
     }
 
     @Test
-    public void toModelType_invalidTags_throwsIllegalValueException() {
+    public void toModelType_invalidTag_throwsIllegalValueException() {
         JsonAdaptedPerson person =
                 new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, INVALID_TAG, VALID_PREFERENCE, VALID_ORDER_HISTORY);
         assertThrows(IllegalValueException.class, person::toModelType);
     }
 
+    @Test
+    public void toModelType_nullTag_throwsIllegalValueException() {
+        JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, null,
+                VALID_PREFERENCE, VALID_ORDER_HISTORY);
+        String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, "Tag");
+        assertThrows(IllegalValueException.class, expectedMessage, person::toModelType);
+    }
+
+    @Test
+    public void toModelType_invalidPreference_throwsIllegalValueException() {
+        JsonAdaptedPerson person =
+                new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_TAG, INVALID_PREFERENCE, VALID_ORDER_HISTORY);
+        assertThrows(IllegalValueException.class, person::toModelType);
+    }
+
+    @Test
+    public void toModelType_nullPreference_throwsIllegalValueException() {
+        JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_TAG,
+                null, VALID_ORDER_HISTORY);
+        String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, "Preference");
+        assertThrows(IllegalValueException.class, expectedMessage, person::toModelType);
+    }
+
+    @Test
+    public void toModelType_nullOrderHistory_success() throws IllegalValueException {
+        JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_TAG,
+                VALID_PREFERENCE, null);
+        JsonAdaptedPerson expectedPerson = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_TAG,
+                VALID_PREFERENCE, new HashMap<>());
+        assertEquals(expectedPerson.toModelType(), person.toModelType());
+    }
+
 }


Reviews:
user: login: Clifong
state: COMMENTED
author_association: NONE
submitted_at: 2025-03-26T09:48:04Z
user: login: Clifong
body: Amazing work!
state: COMMENTED
author_association: NONE
submitted_at: 2025-03-26T09:48:15Z
user: login: Clifong
state: COMMENTED
author_association: NONE
submitted_at: 2025-03-26T09:48:49Z
user: login: Clifong
state: COMMENTED
author_association: NONE
submitted_at: 2025-03-26T09:48:56Z
user: login: Clifong
state: COMMENTED
author_association: NONE
submitted_at: 2025-03-26T09:49:05Z
user: login: sivaramjeychand
state: COMMENTED
author_association: NONE
submitted_at: 2025-03-26T11:08:09Z
user: login: sivaramjeychand
state: COMMENTED
author_association: NONE
submitted_at: 2025-03-26T15:05:45Z

Review comments:
diff_hunk: @@ -4,18 +4,14 @@ skinparam arrowThickness 1.1
 skinparam arrowColor MODEL_COLOR
 skinparam classBackgroundColor MODEL_COLOR
 
-BiteBook *-right-> "1" UniquePersonList
-BiteBook *-right-> "1" UniqueTagList
-UniqueTagList -[hidden]down- UniquePersonList
-UniqueTagList -[hidden]down- UniquePersonList
+BiteBook *-down-> "1" UniquePersonList
path: docs/diagrams/BetterModelClassDiagram.puml
user: login: Clifong
body: Good catch!
created_at: 2025-03-26T09:48:04Z
author_association: NONE
diff_hunk: @@ -13,7 +15,10 @@ Class ModelManager
 Class UserPrefs
 
 Class UniquePersonList
-Class Person
+Class Person {
path: docs/diagrams/ModelClassDiagram.puml
user: login: Clifong
body: Good catch!
created_at: 2025-03-26T09:48:49Z
author_association: NONE
diff_hunk: @@ -19,7 +19,6 @@ Class "<<interface>>\nAddressBookStorage" as AddressBookStorage
 Class JsonAddressBookStorage
 Class JsonSerializableAddressBook
 Class JsonAdaptedPerson
-Class JsonAdaptedTag
path: docs/diagrams/StorageClassDiagram.puml
user: login: Clifong
body: Good catch!
created_at: 2025-03-26T09:48:56Z
author_association: NONE
diff_hunk: @@ -88,7 +92,10 @@ public Person toModelType() throws IllegalValueException {
             throw new IllegalValueException(Tag.MESSAGE_CONSTRAINTS);
         }
 
-        final Optional<Tag> modelTag = tag.isEmpty() ? Optional.empty() : Optional.of(new Tag(tag));
+        Optional<Tag> modelTag = Optional.empty();
path: src/main/java/seedu/address/storage/JsonAdaptedPerson.java
user: login: Clifong
body: Good catch!
created_at: 2025-03-26T09:49:05Z
author_association: NONE
diff_hunk: @@ -4,18 +4,14 @@ skinparam arrowThickness 1.1
 skinparam arrowColor MODEL_COLOR
 skinparam classBackgroundColor MODEL_COLOR
 
-BiteBook *-right-> "1" UniquePersonList
-BiteBook *-right-> "1" UniqueTagList
-UniqueTagList -[hidden]down- UniquePersonList
-UniqueTagList -[hidden]down- UniquePersonList
+BiteBook *-down-> "1" UniquePersonList
 
-UniqueTagList -right-> "*" Tag
 UniquePersonList -right-> Person
 
-Person -up-> "*" Tag
+Person -up-> "0..1" Tag
 
path: docs/diagrams/BetterModelClassDiagram.puml
user: login: sivaramjeychand
body: Good catch here!
created_at: 2025-03-26T11:08:09Z
author_association: NONE
diff_hunk: @@ -38,15 +43,13 @@ AddressBook *--> "1" UniquePersonList
 UniquePersonList --> "~* all" Person
 Person *--> Name
 Person *--> Phone
-Person *--> "*" Tag
-Person *--> "*" Preference
+Person *--> "0..1" Tag
+Person *--> Preference
 
path: docs/diagrams/ModelClassDiagram.puml
user: login: sivaramjeychand
body: Good catch here!
created_at: 2025-03-26T15:05:45Z
author_association: NONE

PR comments:
user: login: codecov[bot]
created_at: 2025-03-25T10:01:40Z
body: ## [Codecov](https://app.codecov.io/gh/AY2425S2-CS2103T-T08-1/tp/pull/93?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AY2425S2-CS2103T-T08-1) Report
Attention: Patch coverage is `77.77778%` with `2 lines` in your changes missing coverage. Please review.

| [Files with missing lines](https://app.codecov.io/gh/AY2425S2-CS2103T-T08-1/tp/pull/93?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AY2425S2-CS2103T-T08-1) | Patch % | Lines |
|---|---|---|
| [.../java/seedu/address/storage/JsonAdaptedPerson.java](https://app.codecov.io/gh/AY2425S2-CS2103T-T08-1/tp/pull/93?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Fseedu%2Faddress%2Fstorage%2FJsonAdaptedPerson.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AY2425S2-CS2103T-T08-1#diff-c3JjL21haW4vamF2YS9zZWVkdS9hZGRyZXNzL3N0b3JhZ2UvSnNvbkFkYXB0ZWRQZXJzb24uamF2YQ==) | 77.77% | [1 Missing and 1 partial :warning: ](https://app.codecov.io/gh/AY2425S2-CS2103T-T08-1/tp/pull/93?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AY2425S2-CS2103T-T08-1) |

| [Files with missing lines](https://app.codecov.io/gh/AY2425S2-CS2103T-T08-1/tp/pull/93?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AY2425S2-CS2103T-T08-1) | Coverage Δ | Complexity Δ | |
|---|---|---|---|
| [.../java/seedu/address/storage/JsonAdaptedPerson.java](https://app.codecov.io/gh/AY2425S2-CS2103T-T08-1/tp/pull/93?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Fseedu%2Faddress%2Fstorage%2FJsonAdaptedPerson.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=AY2425S2-CS2103T-T08-1#diff-c3JjL21haW4vamF2YS9zZWVkdS9hZGRyZXNzL3N0b3JhZ2UvSnNvbkFkYXB0ZWRQZXJzb24uamF2YQ==) | `95.91% <77.77%> (+7.54%)` | `18.00 <0.00> (+4.00)` | |

<details><summary> :rocket: New features to boost your workflow: </summary>

- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
</details>
author_association: NONE
user: login: ziliangstanley
created_at: 2025-03-25T10:30:55Z
body: LGTM
author_association: NONE