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 3b7ca27a51bf..cf14dcec73a5 100644 --- a/src/main/java/seedu/address/commons/events/model/AddressBookChangedEvent.java +++ b/src/main/java/seedu/address/commons/events/model/AddressBookChangedEvent.java @@ -17,7 +17,6 @@ public String toString() { return "number of persons " + data.getPersonList().size() + ", number of tags " + data.getTagList().size() + ", number of appointments " + data.getAppointmentList().size() - + ", number of pet patients " + data.getPetPatientList().size() - + ", number of pet patient tags " + data.getPetPatientTagList().size(); + + ", number of pet patients " + data.getPetPatientList().size(); } } diff --git a/src/main/java/seedu/address/logic/parser/AddCommandParser.java b/src/main/java/seedu/address/logic/parser/AddCommandParser.java index b82316c423bb..ba311bb9208b 100644 --- a/src/main/java/seedu/address/logic/parser/AddCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/AddCommandParser.java @@ -176,7 +176,7 @@ public AddCommand createNewOwnerPetAppt(String ownerInfo, String petInfo, String public AddCommand createNewApptforExistingOwnerAndPet(String apptInfo, String ownerNric, String petName) throws ParseException { Appointment appt = parseAppointment(apptInfo); - return new AddCommand(appt, new Nric(ownerNric), new PetPatientName(petName)); + return new AddCommand(appt, new Nric(ownerNric.trim()), new PetPatientName(petName.trim())); } /** diff --git a/src/main/java/seedu/address/model/AddressBook.java b/src/main/java/seedu/address/model/AddressBook.java index fc56994464e5..30b0b118d48e 100644 --- a/src/main/java/seedu/address/model/AddressBook.java +++ b/src/main/java/seedu/address/model/AddressBook.java @@ -33,9 +33,7 @@ public class AddressBook implements ReadOnlyAddressBook { private final UniquePersonList persons; private final UniqueTagList tags; private final UniqueAppointmentList appointments; - private final UniqueTagList appointmentTags; private final UniquePetPatientList petPatients; - private final UniqueTagList petPatientTags; /* * The 'unusual' code block below is an non-static initialization block, sometimes used to avoid duplication @@ -47,9 +45,7 @@ public class AddressBook implements ReadOnlyAddressBook { persons = new UniquePersonList(); tags = new UniqueTagList(); appointments = new UniqueAppointmentList(); - appointmentTags = new UniqueTagList(); petPatients = new UniquePetPatientList(); - petPatientTags = new UniqueTagList(); } public AddressBook() { @@ -77,18 +73,10 @@ public void setAppointments(List appointments) throws DuplicateAppo this.appointments.setAppointments(appointments); } - public void setAppointmentTags(Set appointmentTags) { - this.appointmentTags.setTags(appointmentTags); - } - public void setPetPatients(List petPatients) throws DuplicatePetPatientException { this.petPatients.setPetPatients(petPatients); } - public void setPetPatientTags(Set petPatientTags) { - this.petPatientTags.setTags(petPatientTags); - } - /** * Resets the existing data of this {@code AddressBook} with {@code newData}. */ @@ -105,7 +93,7 @@ public void resetData(ReadOnlyAddressBook newData) { throw new AssertionError("AddressBooks should not have duplicate persons"); } - setAppointmentTags(new HashSet<>(newData.getAppointmentTagList())); + setTags(new HashSet<>(newData.getTagList())); List syncedAppointmentList = newData.getAppointmentList().stream() .map(this::syncWithAppointmentMasterTagList) .collect(Collectors.toList()); @@ -115,7 +103,7 @@ public void resetData(ReadOnlyAddressBook newData) { throw new AssertionError("AddressBook should not have appointments on the same slot"); } - setPetPatientTags(new HashSet<>(newData.getPetPatientTagList())); + setTags(new HashSet<>(newData.getTagList())); List syncedPetPatientList = newData.getPetPatientList().stream() .map(this::syncWithMasterTagList) .collect(Collectors.toList()); @@ -225,7 +213,7 @@ private Person syncWithMasterTagList(Person person) { */ private PetPatient syncWithMasterTagList (PetPatient petPatient) { final UniqueTagList currentPetPatientTags = new UniqueTagList(petPatient.getTags()); - petPatientTags.mergeFrom(currentPetPatientTags); + tags.mergeFrom(currentPetPatientTags); // Create map with values = tag object references in the master list // used for checking person tag references @@ -287,8 +275,8 @@ public boolean removePerson(Person key) throws PersonNotFoundException { /** * Adds a pet patient to the address book. - * Also checks the new pet patient's tags and updates {@link #petPatientTags} with any new tags found, - * and updates the Tag objects in the pet patient to point to those in {@link #petPatientTags}. + * Also checks the new pet patient's tags and updates {@link #tags} with any new tags found, + * and updates the Tag objects in the pet patient to point to those in {@link #tags}. * * @throws DuplicatePetPatientException if an equivalent person already exists. */ @@ -303,14 +291,6 @@ public void addTag(Tag t) throws UniqueTagList.DuplicateTagException { tags.add(t); } - public void addPetPatientTag(Tag t) throws UniqueTagList.DuplicateTagException { - petPatientTags.add(t); - } - - public void addAppointmentTag(Tag t) throws UniqueTagList.DuplicateTagException { - appointmentTags.add(t); - } - /** * Removes {@code tag} from {@code person} with that tag this {@code AddressBook}. * @@ -355,11 +335,9 @@ public void removeTag(Tag tag) { @Override public String toString() { return persons.asObservableList().size() + " persons, " - + tags.asObservableList().size() + " tags, " - + appointments.asObservableList().size() + " appointments, " - + appointmentTags.asObservableList().size() + " appointment tags, " + petPatients.asObservableList().size() + " pet patients, " - + petPatientTags.asObservableList().size() + " pet patient tags"; + + appointments.asObservableList().size() + " appointments, " + + tags.asObservableList().size() + " tags"; // TODO: refine later } @@ -378,36 +356,24 @@ public ObservableList getAppointmentList() { return appointments.asObservableList(); } - @Override - public ObservableList getAppointmentTagList() { - return appointmentTags.asObservableList(); - } - @Override public ObservableList getPetPatientList() { return petPatients.asObservableList(); } - @Override - public ObservableList getPetPatientTagList() { - return petPatientTags.asObservableList(); - } - @Override 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.tags.equalsOrderInsensitive(((AddressBook) other).tags)) && this.appointments.equals(((AddressBook) other).appointments) - && this.appointmentTags.equals(((AddressBook) other).appointmentTags) && this.petPatients.equals(((AddressBook) other).petPatients) - && this.petPatientTags.equalsOrderInsensitive(((AddressBook) other).petPatientTags); + && this.tags.equalsOrderInsensitive(((AddressBook) other).tags)); } @Override public int hashCode() { // use this method for custom fields hashing instead of implementing your own - return Objects.hash(persons, tags, appointments, appointmentTags, petPatients, petPatientTags); + return Objects.hash(persons, appointments, petPatients, tags); } } diff --git a/src/main/java/seedu/address/model/ReadOnlyAddressBook.java b/src/main/java/seedu/address/model/ReadOnlyAddressBook.java index d1f7f6a23700..039df01c25b2 100644 --- a/src/main/java/seedu/address/model/ReadOnlyAddressBook.java +++ b/src/main/java/seedu/address/model/ReadOnlyAddressBook.java @@ -30,24 +30,10 @@ public interface ReadOnlyAddressBook { */ ObservableList getAppointmentList(); - /** - - * Returns an unmodifiable view of the appointment tag list. - * This list will not contain any duplicate appointment tags. - */ - ObservableList getAppointmentTagList(); - /** * Returns an unmodifiable view of the pet patient list. * This list will not contain any duplicate pet patients. */ ObservableList getPetPatientList(); - - /** - - * Returns an unmodifiable view of the pet patient tags list. - * This list will not contain any duplicate pet patient tags. - */ - ObservableList getPetPatientTagList(); } diff --git a/src/main/java/seedu/address/storage/XmlSerializableAddressBook.java b/src/main/java/seedu/address/storage/XmlSerializableAddressBook.java index 170a35629a27..ff9a5c9961e9 100644 --- a/src/main/java/seedu/address/storage/XmlSerializableAddressBook.java +++ b/src/main/java/seedu/address/storage/XmlSerializableAddressBook.java @@ -25,8 +25,6 @@ public class XmlSerializableAddressBook { private List appointments; @XmlElement private List petPatients; - @XmlElement - private List petPatientTags; /** * Creates an empty XmlSerializableAddressBook. @@ -37,7 +35,6 @@ public XmlSerializableAddressBook() { tags = new ArrayList<>(); appointments = new ArrayList<>(); petPatients = new ArrayList<>(); - petPatientTags = new ArrayList<>(); } /** @@ -53,8 +50,6 @@ public XmlSerializableAddressBook(ReadOnlyAddressBook src) { .collect(Collectors.toList())); petPatients.addAll(src.getPetPatientList().stream().map(XmlAdaptedPetPatient::new) .collect(Collectors.toList())); - petPatientTags.addAll(src.getPetPatientTagList().stream().map(XmlAdaptedTag::new) - .collect(Collectors.toList())); } /** @@ -77,9 +72,6 @@ public AddressBook toModelType() throws IllegalValueException { for (XmlAdaptedPetPatient pp : petPatients) { addressBook.addPetPatient(pp.toModelType()); } - for (XmlAdaptedTag pt : petPatientTags) { - addressBook.addPetPatientTag(pt.toModelType()); - } return addressBook; } @@ -97,7 +89,6 @@ public boolean equals(Object other) { return persons.equals(otherAb.persons) && tags.equals(otherAb.tags) && appointments.equals(otherAb.appointments) - && petPatients.equals(otherAb.petPatients) - && petPatientTags.equals(otherAb.petPatientTags); + && petPatients.equals(otherAb.petPatients); } } diff --git a/src/test/java/seedu/address/model/AddressBookTest.java b/src/test/java/seedu/address/model/AddressBookTest.java index 4dbc04c99eb6..d1e72adb8429 100644 --- a/src/test/java/seedu/address/model/AddressBookTest.java +++ b/src/test/java/seedu/address/model/AddressBookTest.java @@ -41,7 +41,6 @@ public void constructor() { assertEquals(Collections.emptyList(), addressBook.getPersonList()); assertEquals(Collections.emptyList(), addressBook.getTagList()); assertEquals(Collections.emptyList(), addressBook.getAppointmentList()); - assertEquals(Collections.emptyList(), addressBook.getAppointmentTagList()); } @Test @@ -142,20 +141,10 @@ public ObservableList getAppointmentList() { return appointments; } - @Override - public ObservableList getAppointmentTagList() { - return appointmentTags; - } - @Override public ObservableList getPetPatientList() { return petPatients; } - - @Override - public ObservableList getPetPatientTagList() { - return petPatientTags; - } } } diff --git a/src/test/java/seedu/address/testutil/TypicalPetPatients.java b/src/test/java/seedu/address/testutil/TypicalPetPatients.java index 983a62b2b388..3fa141eba19f 100644 --- a/src/test/java/seedu/address/testutil/TypicalPetPatients.java +++ b/src/test/java/seedu/address/testutil/TypicalPetPatients.java @@ -14,7 +14,7 @@ public class TypicalPetPatients { .withColour("Brown and White") .withBloodType("O") .withOwnerNric(TypicalPersons.BOB.getNric().toString()) - .withTags("Injured").build(); + .withTags(new String[]{}).build(); public static final PetPatient JEWEL = new PetPatientBuilder() .withName("Jewel") @@ -23,7 +23,7 @@ public class TypicalPetPatients { .withColour("Calico") .withBloodType("AB") .withOwnerNric(TypicalPersons.ALICE.getNric().toString()) - .withTags(new String[]{}).build(); + .withTags("Depression", "Test").build(); private TypicalPetPatients() {} }