diff --git a/src/main/java/seedu/address/commons/core/LogsCenter.java b/src/main/java/seedu/address/commons/core/LogsCenter.java index 8cf8e15a0f0..af77f0c43b1 100644 --- a/src/main/java/seedu/address/commons/core/LogsCenter.java +++ b/src/main/java/seedu/address/commons/core/LogsCenter.java @@ -20,7 +20,7 @@ public class LogsCenter { private static final int MAX_FILE_COUNT = 5; private static final int MAX_FILE_SIZE_IN_BYTES = (int) (Math.pow(2, 20) * 5); // 5MB - private static final String LOG_FILE = "addressbook.log"; + private static final String LOG_FILE = "clinicmate.log"; private static final Logger logger; // logger for this class private static Logger baseLogger; // to be used as the parent of all other loggers created by this class. private static Level currentLogLevel = Level.INFO; diff --git a/src/main/java/seedu/address/logic/Messages.java b/src/main/java/seedu/address/logic/Messages.java index cb316cf95be..3f19dd453cd 100644 --- a/src/main/java/seedu/address/logic/Messages.java +++ b/src/main/java/seedu/address/logic/Messages.java @@ -50,9 +50,7 @@ public static String format(Person person) { .append("; Sex: ") .append(person.getSex()) .append("; Note: ") - .append(person.getNote()) - .append("; Tags: "); - person.getTags().forEach(builder::append); + .append(person.getNote()); return builder.toString(); } diff --git a/src/main/java/seedu/address/model/person/Person.java b/src/main/java/seedu/address/model/person/Person.java index 67166484bba..555005b2c83 100644 --- a/src/main/java/seedu/address/model/person/Person.java +++ b/src/main/java/seedu/address/model/person/Person.java @@ -43,7 +43,6 @@ public Person(Name name, Phone phone, Email email, IdentityCardNumber identityCa this.sex = sex; this.address = address; this.note = note; - this.tags.addAll(tags); } public Name getName() { @@ -123,14 +122,13 @@ public boolean equals(Object other) { && age.equals(otherPerson.age) && sex.equals(otherPerson.sex) && address.equals(otherPerson.address) - && note.equals(otherPerson.note) - && tags.equals(otherPerson.tags); + && note.equals(otherPerson.note); } @Override public int hashCode() { // use this method for custom fields hashing instead of implementing your own - return Objects.hash(name, phone, email, identityCardNumber, age, sex, address, note, tags); + return Objects.hash(name, phone, email, identityCardNumber, age, sex, address, note); } @Override @@ -144,7 +142,6 @@ public String toString() { .add("sex", sex) .add("address", address) .add("note", note) - .add("tags", tags) .toString(); } diff --git a/src/main/java/seedu/address/storage/JsonAdaptedPerson.java b/src/main/java/seedu/address/storage/JsonAdaptedPerson.java index a991705bf8c..ff680e22e4f 100644 --- a/src/main/java/seedu/address/storage/JsonAdaptedPerson.java +++ b/src/main/java/seedu/address/storage/JsonAdaptedPerson.java @@ -1,10 +1,7 @@ package seedu.address.storage; -import java.util.ArrayList; import java.util.HashSet; -import java.util.List; import java.util.Set; -import java.util.stream.Collectors; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; @@ -36,8 +33,6 @@ class JsonAdaptedPerson { private final String sex; private final String address; private final String note; - private final List tags = new ArrayList<>(); - /** * Constructs a {@code JsonAdaptedPerson} with the given person details. */ @@ -48,8 +43,7 @@ public JsonAdaptedPerson(@JsonProperty("name") String name, @JsonProperty("phone @JsonProperty("age") Integer age, @JsonProperty("sex") String sex, @JsonProperty("address") String address, - @JsonProperty("note") String note, - @JsonProperty("tags") List tags) { + @JsonProperty("note") String note) { this.name = name; this.phone = phone; this.email = email; @@ -58,9 +52,6 @@ public JsonAdaptedPerson(@JsonProperty("name") String name, @JsonProperty("phone this.sex = sex; this.address = address; this.note = note; - if (tags != null) { - this.tags.addAll(tags); - } } /** @@ -75,9 +66,6 @@ public JsonAdaptedPerson(Person source) { sex = source.getSex().value; address = source.getAddress().value; note = source.getNote().value; - tags.addAll(source.getTags().stream() - .map(JsonAdaptedTag::new) - .collect(Collectors.toList())); } /** @@ -86,11 +74,6 @@ public JsonAdaptedPerson(Person source) { * @throws IllegalValueException if there were any data constraints violated in the adapted person. */ public Person toModelType() throws IllegalValueException { - final List personTags = new ArrayList<>(); - for (JsonAdaptedTag tag : tags) { - personTags.add(tag.toModelType()); - } - if (name == null) { throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, Name.class.getSimpleName())); } @@ -157,7 +140,7 @@ public Person toModelType() throws IllegalValueException { } final Note modelNote = new Note(note); - final Set modelTags = new HashSet<>(personTags); + final Set modelTags = new HashSet<>(); return new Person(modelName, modelPhone, modelEmail, modelIdentityCardNumber, modelAge, modelSex, modelAddress, modelNote, modelTags); } diff --git a/src/main/java/seedu/address/storage/JsonSerializableAddressBook.java b/src/main/java/seedu/address/storage/JsonSerializableAddressBook.java index 5efd834091d..85c20f9170b 100644 --- a/src/main/java/seedu/address/storage/JsonSerializableAddressBook.java +++ b/src/main/java/seedu/address/storage/JsonSerializableAddressBook.java @@ -16,11 +16,18 @@ /** * An Immutable AddressBook that is serializable to JSON format. */ -@JsonRootName(value = "addressbook") +@JsonRootName(value = "clinicmate") class JsonSerializableAddressBook { public static final String MESSAGE_DUPLICATE_PERSON = "Persons list contains duplicate person(s)."; + public static final String MESSAGE_DUPLICATE_FIELDS = + "Multiple values specified for the following single-valued field(s): "; + + public static final String MESSAGE_MISSING_FIELD = "Person's %s field is missing!"; + + public static final String MESSAGE_EMPTY_FIELD = "Person's %s field is empty!"; + private final List persons = new ArrayList<>(); /** diff --git a/src/main/java/seedu/address/ui/PersonCard.java b/src/main/java/seedu/address/ui/PersonCard.java index e9ecdc38d16..9ad3d57b343 100644 --- a/src/main/java/seedu/address/ui/PersonCard.java +++ b/src/main/java/seedu/address/ui/PersonCard.java @@ -1,7 +1,5 @@ package seedu.address.ui; -import java.util.Comparator; - import javafx.fxml.FXML; import javafx.scene.control.Label; import javafx.scene.layout.FlowPane; @@ -97,11 +95,7 @@ public PersonCard(Person person, int displayedIndex) { ic.setText(person.getIdentityCardNumber().value); age.setText(String.valueOf(person.getAge().value)); sex.setText(person.getSex().value); - StringBuilder truncatedAddress = new StringBuilder(); address.setText(truncatedAddress.append("Address: ").append(person.getAddress().value).toString()); - person.getTags().stream() - .sorted(Comparator.comparing(tag -> tag.tagName)) - .forEach(tag -> tags.getChildren().add(new Label(tag.tagName))); } } diff --git a/src/test/java/seedu/address/model/person/PersonTest.java b/src/test/java/seedu/address/model/person/PersonTest.java index 60b63448cd2..98b6afa9d1e 100644 --- a/src/test/java/seedu/address/model/person/PersonTest.java +++ b/src/test/java/seedu/address/model/person/PersonTest.java @@ -85,10 +85,6 @@ public void equals() { // different address -> returns false editedAlice = new PersonBuilder(ALICE).withAddress(VALID_ADDRESS_BOB).build(); assertFalse(ALICE.equals(editedAlice)); - - // different tags -> returns false - editedAlice = new PersonBuilder(ALICE).withTags(VALID_TAG_HUSBAND).build(); - assertFalse(ALICE.equals(editedAlice)); } @Test @@ -117,10 +113,6 @@ public void hash() { Person editedAlice4 = new PersonBuilder(ALICE).withAddress(VALID_ADDRESS_BOB).build(); assertNotEquals(ALICE.hashCode(), editedAlice4.hashCode()); - // different tags -> returns false - Person editedAlice5 = new PersonBuilder(ALICE).withTags(VALID_TAG_HUSBAND).build(); - assertNotEquals(ALICE.hashCode(), editedAlice5.hashCode()); - // different person -> returns false assertNotEquals(ALICE.hashCode(), BOB.hashCode()); } @@ -130,7 +122,7 @@ public void toStringMethod() { String expected = Person.class.getCanonicalName() + "{name=" + ALICE.getName() + ", phone=" + ALICE.getPhone() + ", email=" + ALICE.getEmail() + ", identityCardNumber=" + ALICE.getIdentityCardNumber() + ", age=" + ALICE.getAge() + ", sex=" + ALICE.getSex() + ", address=" + ALICE.getAddress() - + ", note=" + ALICE.getNote() + ", tags=" + ALICE.getTags() + "}"; + + ", note=" + ALICE.getNote() + "}"; assertEquals(expected, ALICE.toString()); } } diff --git a/src/test/java/seedu/address/storage/JsonAdaptedPersonTest.java b/src/test/java/seedu/address/storage/JsonAdaptedPersonTest.java index b36786c2f90..6bc255ee4f3 100644 --- a/src/test/java/seedu/address/storage/JsonAdaptedPersonTest.java +++ b/src/test/java/seedu/address/storage/JsonAdaptedPersonTest.java @@ -5,10 +5,6 @@ import static seedu.address.testutil.Assert.assertThrows; import static seedu.address.testutil.TypicalPersons.BENSON; -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; - import org.junit.jupiter.api.Test; import seedu.address.commons.exceptions.IllegalValueException; @@ -29,7 +25,6 @@ public class JsonAdaptedPersonTest { private static final Integer INVALID_AGE = -12; private static final String INVALID_SEX = "G"; private static final String INVALID_ADDRESS = " "; - private static final String INVALID_TAG = "#friend"; private static final String VALID_NAME = BENSON.getName().toString(); private static final String VALID_PHONE = BENSON.getPhone().toString(); @@ -39,9 +34,6 @@ public class JsonAdaptedPersonTest { private static final String VALID_SEX = BENSON.getSex().value; private static final String VALID_ADDRESS = BENSON.getAddress().toString(); private static final String VALID_NOTE = BENSON.getNote().toString(); - private static final List VALID_TAGS = BENSON.getTags().stream() - .map(JsonAdaptedTag::new) - .collect(Collectors.toList()); @Test public void toModelType_validPersonDetails_returnsPerson() throws Exception { @@ -53,7 +45,7 @@ public void toModelType_validPersonDetails_returnsPerson() throws Exception { public void toModelType_invalidName_throwsIllegalValueException() { JsonAdaptedPerson person = new JsonAdaptedPerson(INVALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_IDENTITY_CARD_NUMBER, VALID_AGE, - VALID_SEX, VALID_ADDRESS, VALID_NOTE, VALID_TAGS); + VALID_SEX, VALID_ADDRESS, VALID_NOTE); String expectedMessage = Name.MESSAGE_CONSTRAINTS; assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @@ -61,7 +53,7 @@ public void toModelType_invalidName_throwsIllegalValueException() { @Test public void toModelType_nullName_throwsIllegalValueException() { JsonAdaptedPerson person = new JsonAdaptedPerson(null, VALID_PHONE, VALID_EMAIL, VALID_IDENTITY_CARD_NUMBER, - VALID_AGE, VALID_SEX, VALID_ADDRESS, VALID_NOTE, VALID_TAGS); + VALID_AGE, VALID_SEX, VALID_ADDRESS, VALID_NOTE); String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Name.class.getSimpleName()); assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @@ -70,7 +62,7 @@ public void toModelType_nullName_throwsIllegalValueException() { public void toModelType_invalidPhone_throwsIllegalValueException() { JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, INVALID_PHONE, VALID_EMAIL, VALID_IDENTITY_CARD_NUMBER, VALID_AGE, - VALID_SEX, VALID_ADDRESS, VALID_NOTE, VALID_TAGS); + VALID_SEX, VALID_ADDRESS, VALID_NOTE); String expectedMessage = Phone.MESSAGE_CONSTRAINTS; assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @@ -78,7 +70,7 @@ public void toModelType_invalidPhone_throwsIllegalValueException() { @Test public void toModelType_nullPhone_throwsIllegalValueException() { JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, null, VALID_EMAIL, VALID_IDENTITY_CARD_NUMBER, - VALID_AGE, VALID_SEX, VALID_ADDRESS, VALID_NOTE, VALID_TAGS); + VALID_AGE, VALID_SEX, VALID_ADDRESS, VALID_NOTE); String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Phone.class.getSimpleName()); assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @@ -87,7 +79,7 @@ public void toModelType_nullPhone_throwsIllegalValueException() { public void toModelType_invalidEmail_throwsIllegalValueException() { JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, INVALID_EMAIL, VALID_IDENTITY_CARD_NUMBER, VALID_AGE, - VALID_SEX, VALID_ADDRESS, VALID_NOTE, VALID_TAGS); + VALID_SEX, VALID_ADDRESS, VALID_NOTE); String expectedMessage = Email.MESSAGE_CONSTRAINTS; assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @@ -95,7 +87,7 @@ public void toModelType_invalidEmail_throwsIllegalValueException() { @Test public void toModelType_nullEmail_throwsIllegalValueException() { JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, null, - VALID_IDENTITY_CARD_NUMBER, VALID_AGE, VALID_SEX, VALID_ADDRESS, VALID_NOTE, VALID_TAGS); + VALID_IDENTITY_CARD_NUMBER, VALID_AGE, VALID_SEX, VALID_ADDRESS, VALID_NOTE); String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Email.class.getSimpleName()); assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @@ -104,7 +96,7 @@ public void toModelType_nullEmail_throwsIllegalValueException() { public void toModelType_invalidIdentityCardNumber_throwsIllegalValueException() { JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, INVALID_IDENTITY_CARD_NUMBER, VALID_AGE, - VALID_SEX, VALID_ADDRESS, VALID_NOTE, VALID_TAGS); + VALID_SEX, VALID_ADDRESS, VALID_NOTE); String expectedMessage = IdentityCardNumber.MESSAGE_CONSTRAINTS; assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @@ -112,7 +104,7 @@ public void toModelType_invalidIdentityCardNumber_throwsIllegalValueException() @Test public void toModelType_nullIdentityCardNumber_throwsIllegalValueException() { JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, null, - VALID_AGE, VALID_SEX, VALID_ADDRESS, VALID_NOTE, VALID_TAGS); + VALID_AGE, VALID_SEX, VALID_ADDRESS, VALID_NOTE); String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, IdentityCardNumber.class.getSimpleName()); assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @@ -120,7 +112,7 @@ public void toModelType_nullIdentityCardNumber_throwsIllegalValueException() { public void toModelType_invalidAge_throwsIllegalValueException() { JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_IDENTITY_CARD_NUMBER, INVALID_AGE, - VALID_SEX, VALID_ADDRESS, VALID_NOTE, VALID_TAGS); + VALID_SEX, VALID_ADDRESS, VALID_NOTE); String expectedMessage = Age.MESSAGE_CONSTRAINTS; assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @@ -128,7 +120,7 @@ public void toModelType_invalidAge_throwsIllegalValueException() { @Test public void toModelType_nullAge_throwsIllegalValueException() { JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, - VALID_IDENTITY_CARD_NUMBER, null, VALID_SEX, VALID_ADDRESS, VALID_NOTE, VALID_TAGS); + VALID_IDENTITY_CARD_NUMBER, null, VALID_SEX, VALID_ADDRESS, VALID_NOTE); String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Age.class.getSimpleName()); assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @@ -137,7 +129,7 @@ public void toModelType_nullAge_throwsIllegalValueException() { public void toModelType_invalidSex_throwsIllegalValueException() { JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_IDENTITY_CARD_NUMBER, VALID_AGE, - INVALID_SEX, VALID_ADDRESS, VALID_NOTE, VALID_TAGS); + INVALID_SEX, VALID_ADDRESS, VALID_NOTE); String expectedMessage = Sex.MESSAGE_CONSTRAINTS; assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @@ -145,7 +137,7 @@ public void toModelType_invalidSex_throwsIllegalValueException() { @Test public void toModelType_nullSex_throwsIllegalValueException() { JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, - VALID_IDENTITY_CARD_NUMBER, VALID_AGE, null, VALID_ADDRESS, VALID_NOTE, VALID_TAGS); + VALID_IDENTITY_CARD_NUMBER, VALID_AGE, null, VALID_ADDRESS, VALID_NOTE); String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Sex.class.getSimpleName()); assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @@ -154,7 +146,7 @@ public void toModelType_nullSex_throwsIllegalValueException() { public void toModelType_invalidAddress_throwsIllegalValueException() { JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_IDENTITY_CARD_NUMBER, VALID_AGE, - VALID_SEX, INVALID_ADDRESS, VALID_NOTE, VALID_TAGS); + VALID_SEX, INVALID_ADDRESS, VALID_NOTE); String expectedMessage = Address.MESSAGE_CONSTRAINTS; assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @@ -162,7 +154,7 @@ public void toModelType_invalidAddress_throwsIllegalValueException() { @Test public void toModelType_nullAddress_throwsIllegalValueException() { JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, - VALID_IDENTITY_CARD_NUMBER, VALID_AGE, VALID_SEX, null, VALID_NOTE, VALID_TAGS); + VALID_IDENTITY_CARD_NUMBER, VALID_AGE, VALID_SEX, null, VALID_NOTE); String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Address.class.getSimpleName()); assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } @@ -170,19 +162,8 @@ public void toModelType_nullAddress_throwsIllegalValueException() { @Test public void toModelType_nullNote_throwsIllegalValueException() { JsonAdaptedPerson person = new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, - VALID_IDENTITY_CARD_NUMBER, VALID_AGE, VALID_SEX, VALID_ADDRESS, null, VALID_TAGS); + VALID_IDENTITY_CARD_NUMBER, VALID_AGE, VALID_SEX, VALID_ADDRESS, null); String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Note.class.getSimpleName()); assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); } - - @Test - public void toModelType_invalidTags_throwsIllegalValueException() { - List invalidTags = new ArrayList<>(VALID_TAGS); - invalidTags.add(new JsonAdaptedTag(INVALID_TAG)); - JsonAdaptedPerson person = - new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_IDENTITY_CARD_NUMBER, VALID_AGE, - VALID_SEX, VALID_ADDRESS, VALID_NOTE, invalidTags); - assertThrows(IllegalValueException.class, person::toModelType); - } - }