From fbccccfb93b5d81d00f4d26b6669b3f413126a62 Mon Sep 17 00:00:00 2001 From: philos22 Date: Thu, 8 Mar 2018 17:59:45 +0800 Subject: [PATCH 001/244] added prisoner class as child of person --- .../seedu/address/model/person/Prisoner.java | 67 +++++++++++++++++++ .../address/model/person/Release_Date.java | 42 ++++++++++++ 2 files changed, 109 insertions(+) create mode 100644 src/main/java/seedu/address/model/person/Prisoner.java create mode 100644 src/main/java/seedu/address/model/person/Release_Date.java diff --git a/src/main/java/seedu/address/model/person/Prisoner.java b/src/main/java/seedu/address/model/person/Prisoner.java new file mode 100644 index 000000000000..276659d50a80 --- /dev/null +++ b/src/main/java/seedu/address/model/person/Prisoner.java @@ -0,0 +1,67 @@ +package seedu.address.model.person; + +import static seedu.address.commons.util.CollectionUtil.requireAllNonNull; + +import java.util.Objects; +import java.util.Set; + +import seedu.address.model.tag.Tag; +import seedu.address.model.tag.UniqueTagList; +import seedu.address.model.person.Release_Date; + + +//Prisoner class is child class of Person: but each instance has a release date + +public class Prisoner extends Person{ + + private final Release_Date release_date; + + public Prisoner(Name name, Phone phone, Email email, Address address, Set tags, Release_Date release_date) { + super(name, phone, email, address, tags); + requireAllNonNull(name, phone, email, address, tags, release_date); + this.release_date = release_date; + } + + public Release_Date getRelease_date() { + return release_date; + } + + @Override + public boolean equals(Object other) { + if (other == this) { + return true; + } + + if (!(other instanceof Prisoner)) { + return false; + } + + Prisoner otherPerson = (Prisoner) other; + return otherPerson.getName().equals(this.getName()) + && otherPerson.getPhone().equals(this.getPhone()) + && otherPerson.getEmail().equals(this.getEmail()) + && otherPerson.getAddress().equals(this.getAddress()) + && otherPerson.getRelease_date().equals(this.getRelease_date()); + } + + @Override + public int hashCode() { + // use this method for custom fields hashing instead of implementing your own + return Objects.hash(this.getName(), this.getPhone(), this.getEmail(), this.getAddress(), this.getTags(), this.getRelease_date()); + } + + @Override + public String toString() { + final StringBuilder builder = new StringBuilder(); + builder.append(getName()) + .append(" Phone: ") + .append(getPhone()) + .append(" Email: ") + .append(getEmail()) + .append(" Address: ") + .append(getAddress()) + .append(" Tags: "); + getTags().forEach(builder::append); + builder.append(" Release Date: ").append(getRelease_date()); + return builder.toString();} +} diff --git a/src/main/java/seedu/address/model/person/Release_Date.java b/src/main/java/seedu/address/model/person/Release_Date.java new file mode 100644 index 000000000000..0e739ad2acc3 --- /dev/null +++ b/src/main/java/seedu/address/model/person/Release_Date.java @@ -0,0 +1,42 @@ +package seedu.address.model.person; + +//Represents the release date of the prisoner in date time format + +import static java.util.Objects.requireNonNull; +import static seedu.address.commons.util.AppUtil.checkArgument; + +public class Release_Date { + + public static final String MESSAGE_RELEASE_DATE_CONSTRAINTS = "The date format should follow this format: yyyy-MM-dd"; +// credit of the regex goes to - Ofir Luzon - on Stack Overflow + public static final String RELEASE_DATE_VALIDATION_REGEX = "^(?:(?:31(-)(?:0?[13578]|1[02]))\\1|(?:(?:29|30)(-)(?:0?[1,3-9]|1[0-2])\\2))(?:(?:1[6-9]|[2-9]\\d)?\\d{2})$|^(?:29(-)0?2\\3(?:(?:(?:1[6-9]|[2-9]\\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1\\d|2[0-8])(-)(?:(?:0?[1-9])|(?:1[0-2]))\\4(?:(?:1[6-9]|[2-9]\\d)?\\d{2})$"; + public final String value; + + +// Constructs valid release date with valid parameter + public Release_Date(String release_date){ + requireNonNull(release_date); + checkArgument(isValidReleaseDate(release_date), MESSAGE_RELEASE_DATE_CONSTRAINTS); + this.value = release_date; + } + +// Returns true if release date is valid + public static boolean isValidReleaseDate(String test){ return test.matches(RELEASE_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 Release_Date // instanceof handles nulls + && this.value.equals(((Release_Date) other).value)); // state check + } + + @Override + public int hashCode() { + return value.hashCode(); + } +} From 199bff2bd42bff33d4b23b83e37df39af8e522bb Mon Sep 17 00:00:00 2001 From: philos22 Date: Thu, 8 Mar 2018 21:13:38 +0800 Subject: [PATCH 002/244] updated user stories in developer guide --- docs/DeveloperGuide.adoc | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/docs/DeveloperGuide.adoc b/docs/DeveloperGuide.adoc index 1733af113b29..bc63bf9ba9da 100644 --- a/docs/DeveloperGuide.adoc +++ b/docs/DeveloperGuide.adoc @@ -806,9 +806,34 @@ Priorities: High (must have) - `* * \*`, Medium (nice to have) - `* \*`, Low (un |`* * *` |user |find a person by name |locate details of persons without having to go through the entire list +|`* * *` |administrator |Group police officers together |Form teams to carry out various tasks: patrol rotations, perimeter control, cell guards + +|`* * *` |police officer |Have a track record of each prisoner’s past offences + Type 1 – Injuring officer + Type 2 – Infighting with other inmates + Type 3 – Vandalism + |Use the appropriate level of precaution when dealing with unruly individuals + +|`* * *` |police officer |Keep track of each prisoner’s holding cells |Ensure that there are two prisoners per cell and that certain bad prisoner combinations are avoided + +|`* * *` |administrator |Assign ranks to each police officer |Enforce access rights to view/edit prisoner and officer data + |`* *` |user |hide <> by default |minimize chance of someone else seeing them by accident +|`* *` |prisoner |Know my release date |Look forward to the day I can see my family/friends again + +|`* *` |police officer |Assign prisoners to different recess blocks |Separate those that start fights or cause trouble when together + +|`* *` |administrator |Shuffle patrol guards around teams every day |Each team is made up of different members every day, prisoners will acquaint themselves with specific guards + +|`* *` |administrator |Divide cells into sections (A, B, C, D) and name each cell numerically (A1, A2, etc…) |Refer to each cell easily when assigning prisoners to them + |`*` |user with many persons in the address book |sort persons by name |locate a person easily + +|`*` |police officer |See my assigned prisoners’ social networks: friends, enemies, family, etc… |Use this as reference when dealing with inmates + +|`*` |police officer |Assign prisoners to solitary confinement |Punish those that have continuously committed serious offences + |======================================================================= _{More to be added}_ From 2b218539e5caa81160b247897178710052b3c4d9 Mon Sep 17 00:00:00 2001 From: philos22 Date: Thu, 8 Mar 2018 22:41:58 +0800 Subject: [PATCH 003/244] fix travis style 1 --- .../seedu/address/model/person/Prisoner.java | 23 ++++++++----------- .../{Release_Date.java => ReleaseDate.java} | 21 +++++++++-------- 2 files changed, 21 insertions(+), 23 deletions(-) rename src/main/java/seedu/address/model/person/{Release_Date.java => ReleaseDate.java} (69%) diff --git a/src/main/java/seedu/address/model/person/Prisoner.java b/src/main/java/seedu/address/model/person/Prisoner.java index 276659d50a80..b1c354b603f7 100644 --- a/src/main/java/seedu/address/model/person/Prisoner.java +++ b/src/main/java/seedu/address/model/person/Prisoner.java @@ -4,26 +4,22 @@ import java.util.Objects; import java.util.Set; - import seedu.address.model.tag.Tag; -import seedu.address.model.tag.UniqueTagList; -import seedu.address.model.person.Release_Date; - -//Prisoner class is child class of Person: but each instance has a release date -public class Prisoner extends Person{ +/*Prisoner class is child class of Person: but each instance has a release date*/ +public class Prisoner extends Person { - private final Release_Date release_date; + private final ReleaseDate ReleaseDate; - public Prisoner(Name name, Phone phone, Email email, Address address, Set tags, Release_Date release_date) { + public Prisoner(Name name, Phone phone, Email email, Address address, Set tags, ReleaseDate ReleaseDate) { super(name, phone, email, address, tags); - requireAllNonNull(name, phone, email, address, tags, release_date); - this.release_date = release_date; + requireAllNonNull(name, phone, email, address, tags, ReleaseDate); + this.ReleaseDate = ReleaseDate; } - public Release_Date getRelease_date() { - return release_date; + public ReleaseDate getRelease_date() { + return ReleaseDate; } @Override @@ -63,5 +59,6 @@ public String toString() { .append(" Tags: "); getTags().forEach(builder::append); builder.append(" Release Date: ").append(getRelease_date()); - return builder.toString();} + return builder.toString(); + } } diff --git a/src/main/java/seedu/address/model/person/Release_Date.java b/src/main/java/seedu/address/model/person/ReleaseDate.java similarity index 69% rename from src/main/java/seedu/address/model/person/Release_Date.java rename to src/main/java/seedu/address/model/person/ReleaseDate.java index 0e739ad2acc3..730c56ecedcd 100644 --- a/src/main/java/seedu/address/model/person/Release_Date.java +++ b/src/main/java/seedu/address/model/person/ReleaseDate.java @@ -1,27 +1,28 @@ package seedu.address.model.person; -//Represents the release date of the prisoner in date time format - import static java.util.Objects.requireNonNull; import static seedu.address.commons.util.AppUtil.checkArgument; -public class Release_Date { +//Represents the release date of the prisoner in date time format +public class ReleaseDate { public static final String MESSAGE_RELEASE_DATE_CONSTRAINTS = "The date format should follow this format: yyyy-MM-dd"; -// credit of the regex goes to - Ofir Luzon - on Stack Overflow + // credit of the regex goes to - Ofir Luzon - on Stack Overflow public static final String RELEASE_DATE_VALIDATION_REGEX = "^(?:(?:31(-)(?:0?[13578]|1[02]))\\1|(?:(?:29|30)(-)(?:0?[1,3-9]|1[0-2])\\2))(?:(?:1[6-9]|[2-9]\\d)?\\d{2})$|^(?:29(-)0?2\\3(?:(?:(?:1[6-9]|[2-9]\\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1\\d|2[0-8])(-)(?:(?:0?[1-9])|(?:1[0-2]))\\4(?:(?:1[6-9]|[2-9]\\d)?\\d{2})$"; public final String value; -// Constructs valid release date with valid parameter - public Release_Date(String release_date){ + // Constructs valid release date with valid parameter + public ReleaseDate(String release_date) { requireNonNull(release_date); checkArgument(isValidReleaseDate(release_date), MESSAGE_RELEASE_DATE_CONSTRAINTS); this.value = release_date; } -// Returns true if release date is valid - public static boolean isValidReleaseDate(String test){ return test.matches(RELEASE_DATE_VALIDATION_REGEX); } + // Returns true if release date is valid + public static boolean isValidReleaseDate(String test) { + return test.matches(RELEASE_DATE_VALIDATION_REGEX); + } @Override public String toString() { @@ -31,8 +32,8 @@ public String toString() { @Override public boolean equals(Object other) { return other == this // short circuit if same object - || (other instanceof Release_Date // instanceof handles nulls - && this.value.equals(((Release_Date) other).value)); // state check + || (other instanceof ReleaseDate // instanceof handles nulls + && this.value.equals(((ReleaseDate) other).value)); // state check } @Override From 4ee659bf3177b3d4c529d9cf6b406b9958830a48 Mon Sep 17 00:00:00 2001 From: philos22 Date: Thu, 8 Mar 2018 23:01:38 +0800 Subject: [PATCH 004/244] fix travis style 2 --- .../seedu/address/model/person/Prisoner.java | 14 +++++++++----- .../address/model/person/ReleaseDate.java | 19 ++++++++++++------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/main/java/seedu/address/model/person/Prisoner.java b/src/main/java/seedu/address/model/person/Prisoner.java index b1c354b603f7..d04208561b52 100644 --- a/src/main/java/seedu/address/model/person/Prisoner.java +++ b/src/main/java/seedu/address/model/person/Prisoner.java @@ -4,18 +4,21 @@ import java.util.Objects; import java.util.Set; + import seedu.address.model.tag.Tag; -/*Prisoner class is child class of Person: but each instance has a release date*/ +/** + * Prisoner class is child class of Person: but each instance has a release date + */ public class Prisoner extends Person { private final ReleaseDate ReleaseDate; - public Prisoner(Name name, Phone phone, Email email, Address address, Set tags, ReleaseDate ReleaseDate) { + public Prisoner(Name name, Phone phone, Email email, Address address, Set tags, ReleaseDate releaseDate) { super(name, phone, email, address, tags); - requireAllNonNull(name, phone, email, address, tags, ReleaseDate); - this.ReleaseDate = ReleaseDate; + requireAllNonNull(name, phone, email, address, tags, releaseDate); + this.ReleaseDate = releaseDate; } public ReleaseDate getRelease_date() { @@ -43,7 +46,8 @@ public boolean equals(Object other) { @Override public int hashCode() { // use this method for custom fields hashing instead of implementing your own - return Objects.hash(this.getName(), this.getPhone(), this.getEmail(), this.getAddress(), this.getTags(), this.getRelease_date()); + return Objects.hash(this.getName(), this.getPhone(), this.getEmail(), this.getAddress(), this.getTags(), + this.getRelease_date()); } @Override diff --git a/src/main/java/seedu/address/model/person/ReleaseDate.java b/src/main/java/seedu/address/model/person/ReleaseDate.java index 730c56ecedcd..87d08534ab94 100644 --- a/src/main/java/seedu/address/model/person/ReleaseDate.java +++ b/src/main/java/seedu/address/model/person/ReleaseDate.java @@ -3,20 +3,25 @@ import static java.util.Objects.requireNonNull; import static seedu.address.commons.util.AppUtil.checkArgument; -//Represents the release date of the prisoner in date time format +/** + * Represents the release date of the prisoner in date time format + */ public class ReleaseDate { - public static final String MESSAGE_RELEASE_DATE_CONSTRAINTS = "The date format should follow this format: yyyy-MM-dd"; + public static final String MESSAGE_RELEASE_DATE_CONSTRAINTS = "The date format: yyyy-MM-dd"; // credit of the regex goes to - Ofir Luzon - on Stack Overflow - public static final String RELEASE_DATE_VALIDATION_REGEX = "^(?:(?:31(-)(?:0?[13578]|1[02]))\\1|(?:(?:29|30)(-)(?:0?[1,3-9]|1[0-2])\\2))(?:(?:1[6-9]|[2-9]\\d)?\\d{2})$|^(?:29(-)0?2\\3(?:(?:(?:1[6-9]|[2-9]\\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1\\d|2[0-8])(-)(?:(?:0?[1-9])|(?:1[0-2]))\\4(?:(?:1[6-9]|[2-9]\\d)?\\d{2})$"; + public static final String RELEASE_DATE_VALIDATION_REGEX = "^(?:(?:31(-)(?:0?[13578]|1[02]))\\1|" + + "(?:(?:29|30)(-)(?:0?[1,3-9]|1[0-2])\\2))(?:(?:1[6-9]|[2-9]\\d)?\\d{2})$|^(?:29(-)0?2\\3" + + "(?:(?:(?:1[6-9]|[2-9]\\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))" + + "$|^(?:0?[1-9]|1\\d|2[0-8])(-)(?:(?:0?[1-9])|(?:1[0-2]))\\4(?:(?:1[6-9]|[2-9]\\d)?\\d{2})$"; public final String value; // Constructs valid release date with valid parameter - public ReleaseDate(String release_date) { - requireNonNull(release_date); - checkArgument(isValidReleaseDate(release_date), MESSAGE_RELEASE_DATE_CONSTRAINTS); - this.value = release_date; + public ReleaseDate(String ReleaseDate) { + requireNonNull(ReleaseDate); + checkArgument(isValidReleaseDate(ReleaseDate), MESSAGE_RELEASE_DATE_CONSTRAINTS); + this.value = ReleaseDate; } // Returns true if release date is valid From 55bf1805e95d8d9d6ad34ce9fc87bc0187c2d467 Mon Sep 17 00:00:00 2001 From: philos22 Date: Thu, 8 Mar 2018 23:08:08 +0800 Subject: [PATCH 005/244] fix travis style 3 --- .../seedu/address/model/person/Prisoner.java | 6 +++--- .../seedu/address/model/person/ReleaseDate.java | 17 ++++++++++------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/main/java/seedu/address/model/person/Prisoner.java b/src/main/java/seedu/address/model/person/Prisoner.java index d04208561b52..c44961978adc 100644 --- a/src/main/java/seedu/address/model/person/Prisoner.java +++ b/src/main/java/seedu/address/model/person/Prisoner.java @@ -13,16 +13,16 @@ */ public class Prisoner extends Person { - private final ReleaseDate ReleaseDate; + private final ReleaseDate releaseDate; public Prisoner(Name name, Phone phone, Email email, Address address, Set tags, ReleaseDate releaseDate) { super(name, phone, email, address, tags); requireAllNonNull(name, phone, email, address, tags, releaseDate); - this.ReleaseDate = releaseDate; + this.releaseDate = releaseDate; } public ReleaseDate getRelease_date() { - return ReleaseDate; + return releaseDate; } @Override diff --git a/src/main/java/seedu/address/model/person/ReleaseDate.java b/src/main/java/seedu/address/model/person/ReleaseDate.java index 87d08534ab94..8a627220a8b9 100644 --- a/src/main/java/seedu/address/model/person/ReleaseDate.java +++ b/src/main/java/seedu/address/model/person/ReleaseDate.java @@ -10,18 +10,21 @@ public class ReleaseDate { public static final String MESSAGE_RELEASE_DATE_CONSTRAINTS = "The date format: yyyy-MM-dd"; // credit of the regex goes to - Ofir Luzon - on Stack Overflow - public static final String RELEASE_DATE_VALIDATION_REGEX = "^(?:(?:31(-)(?:0?[13578]|1[02]))\\1|" + - "(?:(?:29|30)(-)(?:0?[1,3-9]|1[0-2])\\2))(?:(?:1[6-9]|[2-9]\\d)?\\d{2})$|^(?:29(-)0?2\\3" + - "(?:(?:(?:1[6-9]|[2-9]\\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))" + + public static final String RELEASE_DATE_VALIDATION_REGEX = "^(?:(?:31(-)(?:0?[13578]|1[02]))\\1|" + + + "(?:(?:29|30)(-)(?:0?[1,3-9]|1[0-2])\\2))(?:(?:1[6-9]|[2-9]\\d)?\\d{2})$|^(?:29(-)0?2\\3" + + + "(?:(?:(?:1[6-9]|[2-9]\\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))" + + "$|^(?:0?[1-9]|1\\d|2[0-8])(-)(?:(?:0?[1-9])|(?:1[0-2]))\\4(?:(?:1[6-9]|[2-9]\\d)?\\d{2})$"; public final String value; // Constructs valid release date with valid parameter - public ReleaseDate(String ReleaseDate) { - requireNonNull(ReleaseDate); - checkArgument(isValidReleaseDate(ReleaseDate), MESSAGE_RELEASE_DATE_CONSTRAINTS); - this.value = ReleaseDate; + public ReleaseDate(String releaseDate) { + requireNonNull(releaseDate); + checkArgument(isValidReleaseDate(releaseDate), MESSAGE_RELEASE_DATE_CONSTRAINTS); + this.value = releaseDate; } // Returns true if release date is valid From 46aba93a991fbf5463e062d5f812d1351e5f8f88 Mon Sep 17 00:00:00 2001 From: sarahgoh97 Date: Thu, 8 Mar 2018 23:21:47 +0800 Subject: [PATCH 006/244] Update user stories in DeveloperGuide --- docs/DeveloperGuide.adoc | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/docs/DeveloperGuide.adoc b/docs/DeveloperGuide.adoc index 1733af113b29..7f1adfeff231 100644 --- a/docs/DeveloperGuide.adoc +++ b/docs/DeveloperGuide.adoc @@ -12,7 +12,7 @@ ifdef::env-github[] endif::[] :repoURL: https://github.com/se-edu/addressbook-level4/tree/master -By: `Team SE-EDU`      Since: `Jun 2016`      Licence: `MIT` +By: `CS2103-T11-B2`      Since: `Jan 2018`      Licence: `MIT` == Setting up @@ -798,17 +798,31 @@ Priorities: High (must have) - `* * \*`, Medium (nice to have) - `* \*`, Low (un [width="59%",cols="22%,<23%,<25%,<30%",options="header",] |======================================================================= |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 +|`* * *` |police officer |check the length of imprisonment of prisoners I am in charge of |know when they are leaving -|`* * *` |user |add a new person | +|`* * *` |police officer |add prisoners to prison cells |the prisoners have a prison cell to stay in -|`* * *` |user |delete a person |remove entries that I no longer need +|`* * *` |police officer |check number of prison cells available |decide whether to take more prisoners in -|`* * *` |user |find a person by name |locate details of persons without having to go through the entire list +|`* * *` |police officer |delete a prisoner |add more prisoners to prison -|`* *` |user |hide <> by default |minimize chance of someone else seeing them by accident +|`* * *` |police officer |check when I am on duty |see when I have to come to work -|`*` |user with many persons in the address book |sort persons by name |locate a person easily +|`* * *` |police officer |check who are in my team |coordinate with my team + +|`* * *` |administrator |add police officers |give access to new police officers + +|`* *` |police officer |check whether there are visitor appointments |inform prisoners and bring them to see their visitors + +|`* *` |police officer |edit details of prisoners |update information of prisoners + +|`* *` |police officer |transfer people to other prisons |have more empty cells for more prisoners + +|`*` |criminal |check when I am released from prison |look forward to life after prison + +|`*` |cook |check dietary requirements of all people in prison |cook sufficient food + +|`*` |counselor |check what prisoners' crimes |understand my patients better |======================================================================= _{More to be added}_ From 9e4ef5f23b1c6ea37f80f62305a987ab2d1b1a35 Mon Sep 17 00:00:00 2001 From: sarahgoh97 Date: Thu, 8 Mar 2018 23:39:11 +0800 Subject: [PATCH 007/244] Minor Edits to DeveloperGuide user stories --- docs/DeveloperGuide.adoc | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/docs/DeveloperGuide.adoc b/docs/DeveloperGuide.adoc index 2ed36a00e2f8..2adceff962a6 100644 --- a/docs/DeveloperGuide.adoc +++ b/docs/DeveloperGuide.adoc @@ -798,17 +798,17 @@ Priorities: High (must have) - `* * \*`, Medium (nice to have) - `* \*`, Low (un [width="59%",cols="22%,<23%,<25%,<30%",options="header",] |======================================================================= |Priority |As a ... |I want to ... |So that I can... -|`* * *` |administrator |Group police officers together |Form teams to carry out various tasks: patrol rotations, perimeter control, cell guards +|`* * *` |administrator |group police officers together |form teams to carry out various tasks: patrol rotations, perimeter control, cell guards -|`* * *` |police officer |Have a track record of each prisoner’s past offences +|`* * *` |police officer |have a track record of each prisoner’s past offences Type 1 – Injuring officer Type 2 – Infighting with other inmates Type 3 – Vandalism - |Use the appropriate level of precaution when dealing with unruly individuals + |use the appropriate level of precaution when dealing with unruly individuals -|`* * *` |police officer |Keep track of each prisoner’s holding cells |Ensure that there are two prisoners per cell and that certain bad prisoner combinations are avoided +|`* * *` |police officer |keep track of each prisoner’s holding cells |ensure that there are two prisoners per cell and that certain bad prisoner combinations are avoided -|`* * *` |administrator |Assign ranks to each police officer |Enforce access rights to view/edit prisoner and officer data +|`* * *` |administrator |assign ranks to each police officer |enforce access rights to view/edit prisoner and officer data |`* * *` |police officer |check the length of imprisonment of prisoners I am in charge of |know when they are leaving @@ -824,11 +824,11 @@ Priorities: High (must have) - `* * \*`, Medium (nice to have) - `* \*`, Low (un |`* * *` |administrator |add police officers |give access to new police officers -|`* *` |police officer |Assign prisoners to different recess blocks |Separate those that start fights or cause trouble when together +|`* *` |police officer |assign prisoners to different recess blocks |separate those that start fights or cause trouble when together -|`* *` |administrator |Shuffle patrol guards around teams every day |Each team is made up of different members every day, prisoners will acquaint themselves with specific guards +|`* *` |administrator |shuffle patrol guards around teams every day |each team is made up of different members every day, prisoners will acquaint themselves with specific guards -|`* *` |administrator |Divide cells into sections (A, B, C, D) and name each cell numerically (A1, A2, etc…) |Refer to each cell easily when assigning prisoners to them +|`* *` |administrator |divide cells into sections (A, B, C, D) and name each cell numerically (A1, A2, etc…) |refer to each cell easily when assigning prisoners to them |`* *` |police officer |check whether there are visitor appointments |inform prisoners and bring them to see their visitors @@ -836,13 +836,11 @@ Priorities: High (must have) - `* * \*`, Medium (nice to have) - `* \*`, Low (un |`* *` |police officer |transfer people to other prisons |have more empty cells for more prisoners -|`* *` |prisoner |Know my release date |Look forward to the day I can see my family/friends again +|`*` |prisoner |know my release date |look forward to the day I can see my family/friends again -|`*` |user with many persons in the address book |sort persons by name |locate a person easily +|`*` |police officer |see my assigned prisoners’ social networks: friends, enemies, family, etc… |use this as reference when dealing with inmates -|`*` |police officer |See my assigned prisoners’ social networks: friends, enemies, family, etc… |Use this as reference when dealing with inmates - -|`*` |police officer |Assign prisoners to solitary confinement |Punish those that have continuously committed serious offences +|`*` |police officer |assign prisoners to solitary confinement |punish those that have continuously committed serious offences |`*` |cook |check dietary requirements of all people in prison |cook sufficient food From 860ab94a3bff2f5336691dddac245fbad9ecdccf Mon Sep 17 00:00:00 2001 From: sarahgoh97 Date: Thu, 8 Mar 2018 23:41:49 +0800 Subject: [PATCH 008/244] Update details regarding team repo --- docs/DeveloperGuide.adoc | 2 +- docs/UserGuide.adoc | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/DeveloperGuide.adoc b/docs/DeveloperGuide.adoc index 2adceff962a6..1f15898800f0 100644 --- a/docs/DeveloperGuide.adoc +++ b/docs/DeveloperGuide.adoc @@ -10,7 +10,7 @@ ifdef::env-github[] :tip-caption: :bulb: :note-caption: :information_source: endif::[] -:repoURL: https://github.com/se-edu/addressbook-level4/tree/master +:repoURL: https://github.com/CS2103JAN2018-T11-B2/main/ By: `CS2103-T11-B2`      Since: `Jan 2018`      Licence: `MIT` diff --git a/docs/UserGuide.adoc b/docs/UserGuide.adoc index 74248917e438..1e2d9f03372e 100644 --- a/docs/UserGuide.adoc +++ b/docs/UserGuide.adoc @@ -11,9 +11,9 @@ ifdef::env-github[] :tip-caption: :bulb: :note-caption: :information_source: endif::[] -:repoURL: https://github.com/se-edu/addressbook-level4 +:repoURL: https://github.com/CS2103JAN2018-T11-B2/main/ -By: `Team SE-EDU` Since: `Jun 2016` Licence: `MIT` +By: `CS2103-B2` Since: `Jan 2018` Licence: `MIT` == Introduction From 110525e4e275e227456519b1a1c0afb1be953cc5 Mon Sep 17 00:00:00 2001 From: sarahgoh97 Date: Thu, 8 Mar 2018 23:50:18 +0800 Subject: [PATCH 009/244] Add use case to developerGuide --- docs/DeveloperGuide.adoc | 41 ++++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/docs/DeveloperGuide.adoc b/docs/DeveloperGuide.adoc index 1f15898800f0..5434970eb9b4 100644 --- a/docs/DeveloperGuide.adoc +++ b/docs/DeveloperGuide.adoc @@ -854,30 +854,51 @@ _{More to be added}_ (For all use cases below, the *System* is the `AddressBook` and the *Actor* is the `user`, unless specified otherwise) [discrete] -=== Use case: Delete person - +=== Use case: Add a prisoner +(User is the "Police Officer".) *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. PO requests to add prisoner +2. AB adds prisoner +3. PO requests to list cells that are empty/not filled +4. AB shows a list of empty/not filled cells +5. PO requests to view a specific cell’s prisoner’s details +6. AB shows details of prisoner in cell +7. PO requests to add a prisoner to a specific cell +8. AB adds prisoner to cell + Use case ends. *Extensions* [none] -* 2a. The list is empty. +* 2a. There are no cells available for new prisoner. ++ +[none] +** 2a1. AB shows an error message. + Use case ends. -* 3a. The given index is invalid. +* 5a. The given index is invalid, outside range. ++ +[none] +** 5a1. AddressBook shows an error message. ++ +Use case resumes at step 4. + +* 5b. The given index of cell has no prisoners. ++ +[none] +** 5b1. AddressBook shows an error message. ++ +Use case resumes at step 4. + +* 7a. The given index is invalid. + [none] -** 3a1. AddressBook shows an error message. +** 7a1. AddressBook shows an error message. + -Use case resumes at step 2. +Use case resumes at step 6. _{More to be added}_ From b1d88a60d6e2c42f3f10e62ba6cf65d6c437002b Mon Sep 17 00:00:00 2001 From: philos22 Date: Thu, 8 Mar 2018 23:56:03 +0800 Subject: [PATCH 010/244] added use case - assign prisoner to cell --- docs/DeveloperGuide.adoc | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/docs/DeveloperGuide.adoc b/docs/DeveloperGuide.adoc index 1733af113b29..eb5bbb1ebd90 100644 --- a/docs/DeveloperGuide.adoc +++ b/docs/DeveloperGuide.adoc @@ -816,10 +816,11 @@ _{More to be added}_ [appendix] == 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 `AddressBook` unless specified otherwise) [discrete] === Use case: Delete person +Actor: user *MSS* @@ -844,6 +845,34 @@ Use case ends. + Use case resumes at step 2. +[discrete] +=== Use case: Assign prisoner to a cell +Actor: police officer + +*MSS* + +1. Police officer selects a prisoner +2. Police officer requests a list of available cells with room available +3. AddressBook shows a list of available cells +4. Police officer requests to add prisoner to vacant cell +5. AddressBook updates prisoner status and cell status ++ +Use case ends. + +*Extensions* + +[none] +* 2a. The cell list is empty. ++ +Use case ends. + +* 3a. Prisoner is already assigned to a cell. ++ +[none] +** 3a1. AddressBook removes cell tag from prisoner status and removes prisoner from cell status ++ +Use case resumes at step 2. + _{More to be added}_ [appendix] From fe949381ef98df117fc7036974d5f9f1f6b6eebc Mon Sep 17 00:00:00 2001 From: sarahgoh97 Date: Thu, 8 Mar 2018 23:57:04 +0800 Subject: [PATCH 011/244] Add NFRs to developerGuide --- docs/DeveloperGuide.adoc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/DeveloperGuide.adoc b/docs/DeveloperGuide.adoc index 5434970eb9b4..bd0fa2985315 100644 --- a/docs/DeveloperGuide.adoc +++ b/docs/DeveloperGuide.adoc @@ -908,6 +908,8 @@ _{More to be added}_ . Should work on any <> as long as it has Java `1.8.0_60` or higher installed. . Should be able to hold up to 1000 persons without a noticeable sluggishness in performance for typical usage. . A user with above average typing speed for regular English text (i.e. not code, not system admin commands) should be able to accomplish most of the tasks faster using commands than using the mouse. +. Should have different levels of access for users of different ranks. +. Should have a backup copy at all times in case a user accidentally deletes any information. _{More to be added}_ From 9899a07624727f165acec0a29c77e5628f481060 Mon Sep 17 00:00:00 2001 From: sarahgoh97 Date: Thu, 8 Mar 2018 23:58:05 +0800 Subject: [PATCH 012/244] Update Glossary --- docs/DeveloperGuide.adoc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/DeveloperGuide.adoc b/docs/DeveloperGuide.adoc index bd0fa2985315..0bb9ad9fe50a 100644 --- a/docs/DeveloperGuide.adoc +++ b/docs/DeveloperGuide.adoc @@ -922,6 +922,9 @@ Windows, Linux, Unix, OS-X [[private-contact-detail]] Private contact detail:: A contact detail that is not meant to be shared with others +[[prisoner]] Prisoner:: +A person has been imprisoned for a crime. + [appendix] == Product Survey From fd2a53c7e12e3f5116b19dcab98ea4868c00fb81 Mon Sep 17 00:00:00 2001 From: philos22 Date: Fri, 9 Mar 2018 00:00:22 +0800 Subject: [PATCH 013/244] added 2 NFRs --- docs/DeveloperGuide.adoc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/DeveloperGuide.adoc b/docs/DeveloperGuide.adoc index eb5bbb1ebd90..0da3bdc823a9 100644 --- a/docs/DeveloperGuide.adoc +++ b/docs/DeveloperGuide.adoc @@ -881,6 +881,8 @@ _{More to be added}_ . Should work on any <> as long as it has Java `1.8.0_60` or higher installed. . Should be able to hold up to 1000 persons without a noticeable sluggishness in performance for typical usage. . A user with above average typing speed for regular English text (i.e. not code, not system admin commands) should be able to accomplish most of the tasks faster using commands than using the mouse. +. Should work for 32-bit and 64-bit environments +. System should respond within 2 seconds _{More to be added}_ From 74ea5af5332a9dba5dbe2e5a84f34bf8a9239118 Mon Sep 17 00:00:00 2001 From: sarahgoh97 Date: Fri, 9 Mar 2018 00:14:52 +0800 Subject: [PATCH 014/244] Add column for statusBar for number of people listed --- src/main/resources/view/StatusBarFooter.fxml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/resources/view/StatusBarFooter.fxml b/src/main/resources/view/StatusBarFooter.fxml index 5a9c5a65e43f..8b97b9936013 100644 --- a/src/main/resources/view/StatusBarFooter.fxml +++ b/src/main/resources/view/StatusBarFooter.fxml @@ -8,7 +8,9 @@ + - + + From cc05eb8be9d9f8df668a17b186876cc2b6ae76fc Mon Sep 17 00:00:00 2001 From: sarahgoh97 Date: Fri, 9 Mar 2018 00:22:09 +0800 Subject: [PATCH 015/244] Add dummy numberOfPeople message to show in status bar --- src/main/java/seedu/address/ui/StatusBarFooter.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/seedu/address/ui/StatusBarFooter.java b/src/main/java/seedu/address/ui/StatusBarFooter.java index 06fb7e50c935..8f91cc8d01ac 100644 --- a/src/main/java/seedu/address/ui/StatusBarFooter.java +++ b/src/main/java/seedu/address/ui/StatusBarFooter.java @@ -39,6 +39,8 @@ public class StatusBarFooter extends UiPart { @FXML private StatusBar syncStatus; @FXML + private StatusBar numberOfPeopleStatus; + @FXML private StatusBar saveLocationStatus; @@ -47,6 +49,7 @@ public StatusBarFooter(String saveLocation) { setSyncStatus(SYNC_STATUS_INITIAL); setSaveLocation("./" + saveLocation); registerAsAnEventHandler(this); + setNumberOfPeopleStatus(1); } /** @@ -71,11 +74,16 @@ private void setSyncStatus(String status) { Platform.runLater(() -> this.syncStatus.setText(status)); } + private void setNumberOfPeopleStatus(int numberOfPeople) { + Platform.runLater(() -> this.numberOfPeopleStatus.setText(numberOfPeople + " person(s) listed.")); + } + @Subscribe public void handleAddressBookChangedEvent(AddressBookChangedEvent abce) { long now = clock.millis(); String lastUpdated = new Date(now).toString(); logger.info(LogsCenter.getEventHandlingLogMessage(abce, "Setting last updated status to " + lastUpdated)); setSyncStatus(String.format(SYNC_STATUS_UPDATED, lastUpdated)); + setNumberOfPeopleStatus(1); } } From e7a69293ae1becbd5ade23e2a4b75737ed38f49e Mon Sep 17 00:00:00 2001 From: sarahgoh97 Date: Fri, 9 Mar 2018 00:46:11 +0800 Subject: [PATCH 016/244] Number of peoplie listed changes when the actual addressbook changes --- src/main/java/seedu/address/ui/MainWindow.java | 2 +- .../java/seedu/address/ui/StatusBarFooter.java | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/main/java/seedu/address/ui/MainWindow.java b/src/main/java/seedu/address/ui/MainWindow.java index 20ad5fee906a..f16a9203925d 100644 --- a/src/main/java/seedu/address/ui/MainWindow.java +++ b/src/main/java/seedu/address/ui/MainWindow.java @@ -125,7 +125,7 @@ void fillInnerParts() { ResultDisplay resultDisplay = new ResultDisplay(); resultDisplayPlaceholder.getChildren().add(resultDisplay.getRoot()); - StatusBarFooter statusBarFooter = new StatusBarFooter(prefs.getAddressBookFilePath()); + StatusBarFooter statusBarFooter = new StatusBarFooter(prefs.getAddressBookFilePath(), logic.getFilteredPersonList()); statusbarPlaceholder.getChildren().add(statusBarFooter.getRoot()); CommandBox commandBox = new CommandBox(logic); diff --git a/src/main/java/seedu/address/ui/StatusBarFooter.java b/src/main/java/seedu/address/ui/StatusBarFooter.java index 8f91cc8d01ac..8ce0063bc9ec 100644 --- a/src/main/java/seedu/address/ui/StatusBarFooter.java +++ b/src/main/java/seedu/address/ui/StatusBarFooter.java @@ -4,6 +4,7 @@ import java.util.Date; import java.util.logging.Logger; +import javafx.collections.ObservableList; import org.controlsfx.control.StatusBar; import com.google.common.eventbus.Subscribe; @@ -11,8 +12,10 @@ import javafx.application.Platform; import javafx.fxml.FXML; import javafx.scene.layout.Region; +import org.fxmisc.easybind.EasyBind; import seedu.address.commons.core.LogsCenter; import seedu.address.commons.events.model.AddressBookChangedEvent; +import seedu.address.model.person.Person; /** * A ui for the status bar that is displayed at the footer of the application. @@ -44,12 +47,19 @@ public class StatusBarFooter extends UiPart { private StatusBar saveLocationStatus; - public StatusBarFooter(String saveLocation) { + public StatusBarFooter(String saveLocation, ObservableList personList) { super(FXML); setSyncStatus(SYNC_STATUS_INITIAL); setSaveLocation("./" + saveLocation); + setNumberOfPeopleStatus(personList.size()); + setConnections(personList); registerAsAnEventHandler(this); - setNumberOfPeopleStatus(1); + } + + private void setConnections(ObservableList personList) { + ObservableList mappedList = EasyBind.map( + personList, (person) -> new PersonCard(person, personList.indexOf(person) + 1)); + setNumberOfPeopleStatus(mappedList.size()); } /** @@ -84,6 +94,6 @@ public void handleAddressBookChangedEvent(AddressBookChangedEvent abce) { String lastUpdated = new Date(now).toString(); logger.info(LogsCenter.getEventHandlingLogMessage(abce, "Setting last updated status to " + lastUpdated)); setSyncStatus(String.format(SYNC_STATUS_UPDATED, lastUpdated)); - setNumberOfPeopleStatus(1); + setNumberOfPeopleStatus(abce.data.getPersonList().size()); } } From feb7c7293381c5354c073326ef8065b20aadfb9f Mon Sep 17 00:00:00 2001 From: sarahgoh97 Date: Fri, 9 Mar 2018 00:47:31 +0800 Subject: [PATCH 017/244] Update test for status bar --- src/test/java/seedu/address/ui/StatusBarFooterTest.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/test/java/seedu/address/ui/StatusBarFooterTest.java b/src/test/java/seedu/address/ui/StatusBarFooterTest.java index 0c75a73b1864..132da0d00db1 100644 --- a/src/test/java/seedu/address/ui/StatusBarFooterTest.java +++ b/src/test/java/seedu/address/ui/StatusBarFooterTest.java @@ -10,6 +10,7 @@ import java.time.ZoneId; import java.util.Date; +import javafx.collections.ObservableList; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; @@ -17,7 +18,9 @@ import guitests.guihandles.StatusBarFooterHandle; import seedu.address.commons.events.model.AddressBookChangedEvent; +import seedu.address.logic.Logic; import seedu.address.model.AddressBook; +import seedu.address.model.person.Person; public class StatusBarFooterTest extends GuiUnitTest { @@ -45,7 +48,7 @@ public static void tearDownAfterClass() { @Before public void setUp() { - StatusBarFooter statusBarFooter = new StatusBarFooter(STUB_SAVE_LOCATION); + StatusBarFooter statusBarFooter = new StatusBarFooter(STUB_SAVE_LOCATION, EVENT_STUB.data.getPersonList()); uiPartRule.setUiPart(statusBarFooter); statusBarFooterHandle = new StatusBarFooterHandle(statusBarFooter.getRoot()); From 397fd7bde831e59d5b334ff7c159287c444fe2dd Mon Sep 17 00:00:00 2001 From: sarahgoh97 Date: Fri, 9 Mar 2018 12:32:57 +0800 Subject: [PATCH 018/244] Remove redundant and unused code --- src/main/java/seedu/address/ui/StatusBarFooter.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/main/java/seedu/address/ui/StatusBarFooter.java b/src/main/java/seedu/address/ui/StatusBarFooter.java index 8ce0063bc9ec..0d01c648802d 100644 --- a/src/main/java/seedu/address/ui/StatusBarFooter.java +++ b/src/main/java/seedu/address/ui/StatusBarFooter.java @@ -12,7 +12,6 @@ import javafx.application.Platform; import javafx.fxml.FXML; import javafx.scene.layout.Region; -import org.fxmisc.easybind.EasyBind; import seedu.address.commons.core.LogsCenter; import seedu.address.commons.events.model.AddressBookChangedEvent; import seedu.address.model.person.Person; @@ -52,15 +51,9 @@ public StatusBarFooter(String saveLocation, ObservableList personList) { setSyncStatus(SYNC_STATUS_INITIAL); setSaveLocation("./" + saveLocation); setNumberOfPeopleStatus(personList.size()); - setConnections(personList); registerAsAnEventHandler(this); } - private void setConnections(ObservableList personList) { - ObservableList mappedList = EasyBind.map( - personList, (person) -> new PersonCard(person, personList.indexOf(person) + 1)); - setNumberOfPeopleStatus(mappedList.size()); - } /** * Sets the clock used to determine the current time. From 033095ab51309d2a5d99cd041fa6f67a2ffbca55 Mon Sep 17 00:00:00 2001 From: sarahgoh97 Date: Fri, 9 Mar 2018 12:45:04 +0800 Subject: [PATCH 019/244] Update status bar handle to store number of people --- .../seedu/address/ui/StatusBarFooter.java | 2 +- .../guihandles/StatusBarFooterHandle.java | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/main/java/seedu/address/ui/StatusBarFooter.java b/src/main/java/seedu/address/ui/StatusBarFooter.java index 0d01c648802d..637f57b12d17 100644 --- a/src/main/java/seedu/address/ui/StatusBarFooter.java +++ b/src/main/java/seedu/address/ui/StatusBarFooter.java @@ -69,7 +69,7 @@ public static Clock getClock() { return clock; } - private void setSaveLocation(String location) { + void setSaveLocation(String location) { Platform.runLater(() -> this.saveLocationStatus.setText(location)); } diff --git a/src/test/java/guitests/guihandles/StatusBarFooterHandle.java b/src/test/java/guitests/guihandles/StatusBarFooterHandle.java index 5111fba42b33..18d5081e324a 100644 --- a/src/test/java/guitests/guihandles/StatusBarFooterHandle.java +++ b/src/test/java/guitests/guihandles/StatusBarFooterHandle.java @@ -11,18 +11,22 @@ public class StatusBarFooterHandle extends NodeHandle { public static final String STATUS_BAR_PLACEHOLDER = "#statusbarPlaceholder"; private static final String SYNC_STATUS_ID = "#syncStatus"; + private static final String NUMBER_OF_PEOPLE_STATUS_ID = "#numberOfPeopleStatus"; private static final String SAVE_LOCATION_STATUS_ID = "#saveLocationStatus"; private final StatusBar syncStatusNode; + private final StatusBar numberOfPeopleNode; private final StatusBar saveLocationNode; private String lastRememberedSyncStatus; + private String lastRememberedNumberOfPeople; private String lastRememberedSaveLocation; public StatusBarFooterHandle(Node statusBarFooterNode) { super(statusBarFooterNode); this.syncStatusNode = getChildNode(SYNC_STATUS_ID); + this.numberOfPeopleNode = getChildNode(NUMBER_OF_PEOPLE_STATUS_ID); this.saveLocationNode = getChildNode(SAVE_LOCATION_STATUS_ID); } @@ -33,6 +37,13 @@ public String getSyncStatus() { return syncStatusNode.getText(); } + /** + * Returns the text of the 'number of people' portion of the status bar. + */ + public String getNumberOfPeopleStatus() { + return numberOfPeopleNode.getText(); + } + /** * Returns the text of the 'save location' portion of the status bar. */ @@ -55,6 +66,21 @@ public boolean isSyncStatusChanged() { return !lastRememberedSyncStatus.equals(getSyncStatus()); } + /** + * Remembers the 'number of people' portion of the status bar. + */ + public void rememberNumberOfPeople() { + lastRememberedNumberOfPeople = getNumberOfPeopleStatus(); + } + + /** + * Returns true if the number of people is different from the value remembered by the most + * recent {@code rememberSaveLocation()} call. + */ + public boolean isNumberOfPeopleChanged() { + return !lastRememberedNumberOfPeople.equals(getNumberOfPeopleStatus()); + } + /** * Remembers the content of the 'save location' portion of the status bar. */ From e819b1107e2088c29ffc39064574582e4008d582 Mon Sep 17 00:00:00 2001 From: sarahgoh97 Date: Fri, 9 Mar 2018 12:45:38 +0800 Subject: [PATCH 020/244] Update message in status bar for number of people --- src/main/java/seedu/address/ui/StatusBarFooter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/seedu/address/ui/StatusBarFooter.java b/src/main/java/seedu/address/ui/StatusBarFooter.java index 637f57b12d17..9a89e38354e6 100644 --- a/src/main/java/seedu/address/ui/StatusBarFooter.java +++ b/src/main/java/seedu/address/ui/StatusBarFooter.java @@ -78,7 +78,7 @@ private void setSyncStatus(String status) { } private void setNumberOfPeopleStatus(int numberOfPeople) { - Platform.runLater(() -> this.numberOfPeopleStatus.setText(numberOfPeople + " person(s) listed.")); + Platform.runLater(() -> this.numberOfPeopleStatus.setText(numberOfPeople + " person(s) total.")); } @Subscribe From 436b891f98fc9f72738f4a44bfce714e809156fb Mon Sep 17 00:00:00 2001 From: zacci Date: Fri, 9 Mar 2018 13:19:05 +0800 Subject: [PATCH 021/244] Added Command Aliases and Updated Documentation --- docs/UserGuide.adoc | 20 +++++++++---------- .../address/logic/commands/AddCommand.java | 1 + .../address/logic/commands/ClearCommand.java | 1 + .../address/logic/commands/DeleteCommand.java | 1 + .../address/logic/commands/EditCommand.java | 1 + .../address/logic/commands/FindCommand.java | 1 + .../logic/commands/HistoryCommand.java | 1 + .../address/logic/commands/ListCommand.java | 1 + .../address/logic/commands/RedoCommand.java | 1 + .../address/logic/commands/SelectCommand.java | 1 + .../address/logic/commands/UndoCommand.java | 1 + .../logic/parser/AddressBookParser.java | 10 ++++++++++ 12 files changed, 30 insertions(+), 10 deletions(-) diff --git a/docs/UserGuide.adoc b/docs/UserGuide.adoc index 1e2d9f03372e..dcbc2688a408 100644 --- a/docs/UserGuide.adoc +++ b/docs/UserGuide.adoc @@ -60,7 +60,7 @@ e.g. typing *`help`* and pressing kbd:[Enter] will open the help window. Format: `help` -=== Adding a person: `add` +=== Adding a person: `add or a` Adds a person to the address book + Format: `add n/NAME p/PHONE_NUMBER e/EMAIL a/ADDRESS [t/TAG]...` @@ -73,12 +73,12 @@ Examples: * `add n/John Doe p/98765432 e/johnd@example.com a/John street, block 123, #01-01` * `add n/Betsy Crowe t/friend e/betsycrowe@example.com a/Newgate Prison p/1234567 t/criminal` -=== Listing all persons : `list` +=== Listing all persons : `list or l` Shows a list of all persons in the address book. + Format: `list` -=== Editing a person : `edit` +=== Editing a person : `edit or e` Edits an existing person in the address book. + Format: `edit INDEX [n/NAME] [p/PHONE] [e/EMAIL] [a/ADDRESS] [t/TAG]...` @@ -98,7 +98,7 @@ Edits the phone number and email address of the 1st person to be `91234567` and * `edit 2 n/Betsy Crower t/` + Edits the name of the 2nd person to be `Betsy Crower` and clears all existing tags. -=== Locating persons by name: `find` +=== Locating persons by name: `find or f` Finds persons whose names contain any of the given keywords. + Format: `find KEYWORD [MORE_KEYWORDS]` @@ -118,7 +118,7 @@ Returns `john` and `John Doe` * `find Betsy Tim John` + Returns any person having names `Betsy`, `Tim`, or `John` -=== Deleting a person : `delete` +=== Deleting a person : `delete or d` Deletes the specified person from the address book. + Format: `delete INDEX` @@ -138,7 +138,7 @@ Deletes the 2nd person in the address book. `delete 1` + Deletes the 1st person in the results of the `find` command. -=== Selecting a person : `select` +=== Selecting a person : `select or s` Selects the person identified by the index number used in the last person listing. + Format: `select INDEX` @@ -158,7 +158,7 @@ Selects the 2nd person in the address book. `select 1` + Selects the 1st person in the results of the `find` command. -=== Listing entered commands : `history` +=== Listing entered commands : `history or h` Lists all the commands that you have entered in reverse chronological order. + Format: `history` @@ -169,7 +169,7 @@ Pressing the kbd:[↑] and kbd:[↓] arrows will display the previous and ==== // tag::undoredo[] -=== Undoing previous command : `undo` +=== Undoing previous command : `undo or u` Restores the address book to the state before the previous _undoable_ command was executed. + Format: `undo` @@ -195,7 +195,7 @@ The `undo` command fails as there are no undoable commands executed previously. `undo` (reverses the `clear` command) + `undo` (reverses the `delete 1` command) + -=== Redoing the previously undone command : `redo` +=== Redoing the previously undone command : `redo or r` Reverses the most recent `undo` command. + Format: `redo` @@ -218,7 +218,7 @@ The `redo` command fails as there are no `undo` commands executed previously. `redo` (reapplies the `clear` command) + // end::undoredo[] -=== Clearing all entries : `clear` +=== Clearing all entries : `clear or c` Clears all entries from the address book. + Format: `clear` diff --git a/src/main/java/seedu/address/logic/commands/AddCommand.java b/src/main/java/seedu/address/logic/commands/AddCommand.java index c334710c0ea3..d5de4a572715 100644 --- a/src/main/java/seedu/address/logic/commands/AddCommand.java +++ b/src/main/java/seedu/address/logic/commands/AddCommand.java @@ -17,6 +17,7 @@ public class AddCommand extends UndoableCommand { public static final String COMMAND_WORD = "add"; + public static final String COMMAND_ALIAS = "a"; public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a person to the address book. " + "Parameters: " diff --git a/src/main/java/seedu/address/logic/commands/ClearCommand.java b/src/main/java/seedu/address/logic/commands/ClearCommand.java index ceeb7ba913c6..6d04efaf3295 100644 --- a/src/main/java/seedu/address/logic/commands/ClearCommand.java +++ b/src/main/java/seedu/address/logic/commands/ClearCommand.java @@ -10,6 +10,7 @@ public class ClearCommand extends UndoableCommand { public static final String COMMAND_WORD = "clear"; + public static final String COMMAND_ALIAS = "c"; public static final String MESSAGE_SUCCESS = "Address book has been cleared!"; diff --git a/src/main/java/seedu/address/logic/commands/DeleteCommand.java b/src/main/java/seedu/address/logic/commands/DeleteCommand.java index b539d240001a..0cd0fbd860ad 100644 --- a/src/main/java/seedu/address/logic/commands/DeleteCommand.java +++ b/src/main/java/seedu/address/logic/commands/DeleteCommand.java @@ -17,6 +17,7 @@ public class DeleteCommand extends UndoableCommand { public static final String COMMAND_WORD = "delete"; + public static final String COMMAND_ALIAS = "d"; public static final String MESSAGE_USAGE = COMMAND_WORD + ": Deletes the person identified by the index number used in the last person listing.\n" diff --git a/src/main/java/seedu/address/logic/commands/EditCommand.java b/src/main/java/seedu/address/logic/commands/EditCommand.java index e6c3a3e034bc..3021c951a5b1 100644 --- a/src/main/java/seedu/address/logic/commands/EditCommand.java +++ b/src/main/java/seedu/address/logic/commands/EditCommand.java @@ -34,6 +34,7 @@ public class EditCommand extends UndoableCommand { public static final String COMMAND_WORD = "edit"; + public static final String COMMAND_ALIAS = "e"; public static final String MESSAGE_USAGE = COMMAND_WORD + ": Edits the details of the person identified " + "by the index number used in the last person listing. " diff --git a/src/main/java/seedu/address/logic/commands/FindCommand.java b/src/main/java/seedu/address/logic/commands/FindCommand.java index b1e671f633d2..a73078ed6ea3 100644 --- a/src/main/java/seedu/address/logic/commands/FindCommand.java +++ b/src/main/java/seedu/address/logic/commands/FindCommand.java @@ -9,6 +9,7 @@ public class FindCommand extends Command { public static final String COMMAND_WORD = "find"; + public static final String COMMAND_ALIAS = "f"; public static final String MESSAGE_USAGE = COMMAND_WORD + ": Finds all persons whose names contain any of " + "the specified keywords (case-sensitive) and displays them as a list with index numbers.\n" diff --git a/src/main/java/seedu/address/logic/commands/HistoryCommand.java b/src/main/java/seedu/address/logic/commands/HistoryCommand.java index f87abee5511d..a3a8f11563d0 100644 --- a/src/main/java/seedu/address/logic/commands/HistoryCommand.java +++ b/src/main/java/seedu/address/logic/commands/HistoryCommand.java @@ -15,6 +15,7 @@ public class HistoryCommand extends Command { public static final String COMMAND_WORD = "history"; + public static final String COMMAND_ALIAS = "h"; public static final String MESSAGE_SUCCESS = "Entered commands (from most recent to earliest):\n%1$s"; public static final String MESSAGE_NO_HISTORY = "You have not yet entered any commands."; diff --git a/src/main/java/seedu/address/logic/commands/ListCommand.java b/src/main/java/seedu/address/logic/commands/ListCommand.java index 7b6463780824..2631e4dda649 100644 --- a/src/main/java/seedu/address/logic/commands/ListCommand.java +++ b/src/main/java/seedu/address/logic/commands/ListCommand.java @@ -8,6 +8,7 @@ public class ListCommand extends Command { public static final String COMMAND_WORD = "list"; + public static final String COMMAND_ALIAS = "l"; public static final String MESSAGE_SUCCESS = "Listed all persons"; diff --git a/src/main/java/seedu/address/logic/commands/RedoCommand.java b/src/main/java/seedu/address/logic/commands/RedoCommand.java index 7b99d0f372fc..311c95c1a1f2 100644 --- a/src/main/java/seedu/address/logic/commands/RedoCommand.java +++ b/src/main/java/seedu/address/logic/commands/RedoCommand.java @@ -13,6 +13,7 @@ public class RedoCommand extends Command { public static final String COMMAND_WORD = "redo"; + public static final String COMMAND_ALIAS = "r"; public static final String MESSAGE_SUCCESS = "Redo success!"; public static final String MESSAGE_FAILURE = "No more commands to redo!"; diff --git a/src/main/java/seedu/address/logic/commands/SelectCommand.java b/src/main/java/seedu/address/logic/commands/SelectCommand.java index 9e3840a9dde6..0bc2e3e21485 100644 --- a/src/main/java/seedu/address/logic/commands/SelectCommand.java +++ b/src/main/java/seedu/address/logic/commands/SelectCommand.java @@ -15,6 +15,7 @@ public class SelectCommand extends Command { public static final String COMMAND_WORD = "select"; + public static final String COMMAND_ALIAS = "s"; public static final String MESSAGE_USAGE = COMMAND_WORD + ": Selects the person identified by the index number used in the last person listing.\n" diff --git a/src/main/java/seedu/address/logic/commands/UndoCommand.java b/src/main/java/seedu/address/logic/commands/UndoCommand.java index 1f3dcea8bbaa..7d62dcc53d38 100644 --- a/src/main/java/seedu/address/logic/commands/UndoCommand.java +++ b/src/main/java/seedu/address/logic/commands/UndoCommand.java @@ -13,6 +13,7 @@ public class UndoCommand extends Command { public static final String COMMAND_WORD = "undo"; + public static final String COMMAND_ALIAS = "u"; public static final String MESSAGE_SUCCESS = "Undo success!"; public static final String MESSAGE_FAILURE = "No more commands to undo!"; diff --git a/src/main/java/seedu/address/logic/parser/AddressBookParser.java b/src/main/java/seedu/address/logic/parser/AddressBookParser.java index b7d57f5db86a..e35710f7e489 100644 --- a/src/main/java/seedu/address/logic/parser/AddressBookParser.java +++ b/src/main/java/seedu/address/logic/parser/AddressBookParser.java @@ -49,27 +49,35 @@ public Command parseCommand(String userInput) throws ParseException { switch (commandWord) { case AddCommand.COMMAND_WORD: + case AddCommand.COMMAND_ALIAS: return new AddCommandParser().parse(arguments); case EditCommand.COMMAND_WORD: + case EditCommand.COMMAND_ALIAS: return new EditCommandParser().parse(arguments); case SelectCommand.COMMAND_WORD: + case SelectCommand.COMMAND_ALIAS: return new SelectCommandParser().parse(arguments); case DeleteCommand.COMMAND_WORD: + case DeleteCommand.COMMAND_ALIAS: return new DeleteCommandParser().parse(arguments); case ClearCommand.COMMAND_WORD: + case ClearCommand.COMMAND_ALIAS: return new ClearCommand(); case FindCommand.COMMAND_WORD: + case FindCommand.COMMAND_ALIAS: return new FindCommandParser().parse(arguments); case ListCommand.COMMAND_WORD: + case ListCommand.COMMAND_ALIAS: return new ListCommand(); case HistoryCommand.COMMAND_WORD: + case HistoryCommand.COMMAND_ALIAS: return new HistoryCommand(); case ExitCommand.COMMAND_WORD: @@ -79,9 +87,11 @@ public Command parseCommand(String userInput) throws ParseException { return new HelpCommand(); case UndoCommand.COMMAND_WORD: + case UndoCommand.COMMAND_ALIAS: return new UndoCommand(); case RedoCommand.COMMAND_WORD: + case RedoCommand.COMMAND_ALIAS: return new RedoCommand(); default: From 12eeadfd7b4418ba62beccea096c7f5439d1d576 Mon Sep 17 00:00:00 2001 From: zacci Date: Fri, 9 Mar 2018 13:45:14 +0800 Subject: [PATCH 022/244] Added Use Case for Police Officer --- docs/DeveloperGuide.adoc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/docs/DeveloperGuide.adoc b/docs/DeveloperGuide.adoc index 33e7223e16e0..2ac10cfa0167 100644 --- a/docs/DeveloperGuide.adoc +++ b/docs/DeveloperGuide.adoc @@ -930,6 +930,26 @@ Use case ends. ** 3a1. AB removes cell tag from prisoner status and removes prisoner from cell status + Use case resumes at step 2. +[discrete] +=== Use case: Get the list of prisoners in a certain cell +Actor: police officer (PO) + +*MSS* + +1. PO requests a list of cells +2. AB shows the list of cells +3. PO requests to view the list of prisoners assigned to a specific cell +4. AB shows a list of of prisoners assigned to the cell ++ +Use case ends. + +*Extensions* + +[none] +* 3a. PO does not have access rights to view the details of the requested cell ++ +Use case ends. + _{More to be added}_ From c857853b152972bc6d896a46dbb0e7292a46af76 Mon Sep 17 00:00:00 2001 From: sarahgoh97 Date: Fri, 9 Mar 2018 16:02:01 +0800 Subject: [PATCH 023/244] Update tests to handle change in addressBook --- .../java/systemtests/AddCommandSystemTest.java | 2 +- .../java/systemtests/AddressBookSystemTest.java | 17 +++++++++++++++++ .../systemtests/ClearCommandSystemTest.java | 2 +- .../systemtests/DeleteCommandSystemTest.java | 2 +- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/test/java/systemtests/AddCommandSystemTest.java b/src/test/java/systemtests/AddCommandSystemTest.java index 3254b60154c4..970aac44ccc5 100644 --- a/src/test/java/systemtests/AddCommandSystemTest.java +++ b/src/test/java/systemtests/AddCommandSystemTest.java @@ -235,7 +235,7 @@ private void assertCommandSuccess(String command, Model expectedModel, String ex assertApplicationDisplaysExpected("", expectedResultMessage, expectedModel); assertSelectedCardUnchanged(); assertCommandBoxShowsDefaultStyle(); - assertStatusBarUnchangedExceptSyncStatus(); + assertStatusBarChangedExceptSaveLocation(expectedModel.getAddressBook().getPersonList().size()); } /** diff --git a/src/test/java/systemtests/AddressBookSystemTest.java b/src/test/java/systemtests/AddressBookSystemTest.java index 97cdf96d65b8..e52c157195a0 100644 --- a/src/test/java/systemtests/AddressBookSystemTest.java +++ b/src/test/java/systemtests/AddressBookSystemTest.java @@ -190,6 +190,7 @@ private void rememberStates() { StatusBarFooterHandle statusBarFooterHandle = getStatusBarFooter(); getBrowserPanel().rememberUrl(); statusBarFooterHandle.rememberSaveLocation(); + statusBarFooterHandle.rememberNumberOfPeople(); statusBarFooterHandle.rememberSyncStatus(); getPersonListPanel().rememberSelectedPersonCard(); } @@ -253,6 +254,7 @@ protected void assertCommandBoxShowsErrorStyle() { protected void assertStatusBarUnchanged() { StatusBarFooterHandle handle = getStatusBarFooter(); assertFalse(handle.isSaveLocationChanged()); + assertFalse(handle.isNumberOfPeopleChanged()); assertFalse(handle.isSyncStatusChanged()); } @@ -265,6 +267,21 @@ protected void assertStatusBarUnchangedExceptSyncStatus() { String timestamp = new Date(clockRule.getInjectedClock().millis()).toString(); String expectedSyncStatus = String.format(SYNC_STATUS_UPDATED, timestamp); assertEquals(expectedSyncStatus, handle.getSyncStatus()); + assertFalse(handle.isNumberOfPeopleChanged()); + assertFalse(handle.isSaveLocationChanged()); + } + + /** + * Asserts that the total number of people and sync status in the status bar was changed to the timing of + * {@code ClockRule#getInjectedClock()}, while the save location remains the same. + */ + protected void assertStatusBarChangedExceptSaveLocation(int expectedNumberOfPeople) { + StatusBarFooterHandle handle = getStatusBarFooter(); + String timestamp = new Date(clockRule.getInjectedClock().millis()).toString(); + String expectedSyncStatus = String.format(SYNC_STATUS_UPDATED, timestamp); + String expectedNumberOfPeopleStatus = expectedNumberOfPeople + " person(s) total."; + assertEquals(expectedSyncStatus, handle.getSyncStatus()); + assertEquals(expectedNumberOfPeopleStatus, handle.getNumberOfPeopleStatus()); assertFalse(handle.isSaveLocationChanged()); } diff --git a/src/test/java/systemtests/ClearCommandSystemTest.java b/src/test/java/systemtests/ClearCommandSystemTest.java index 805a59784e29..9ad1c42f7a9d 100644 --- a/src/test/java/systemtests/ClearCommandSystemTest.java +++ b/src/test/java/systemtests/ClearCommandSystemTest.java @@ -77,7 +77,7 @@ private void assertCommandSuccess(String command, String expectedResultMessage, executeCommand(command); assertApplicationDisplaysExpected("", expectedResultMessage, expectedModel); assertCommandBoxShowsDefaultStyle(); - assertStatusBarUnchangedExceptSyncStatus(); + assertStatusBarChangedExceptSaveLocation(expectedModel.getAddressBook().getPersonList().size()); } /** diff --git a/src/test/java/systemtests/DeleteCommandSystemTest.java b/src/test/java/systemtests/DeleteCommandSystemTest.java index c0de78e4aba6..cab390f74064 100644 --- a/src/test/java/systemtests/DeleteCommandSystemTest.java +++ b/src/test/java/systemtests/DeleteCommandSystemTest.java @@ -174,7 +174,7 @@ private void assertCommandSuccess(String command, Model expectedModel, String ex } assertCommandBoxShowsDefaultStyle(); - assertStatusBarUnchangedExceptSyncStatus(); + assertStatusBarChangedExceptSaveLocation(expectedModel.getAddressBook().getPersonList().size()); } /** From 0fcb77dbd723e783a8518fab85780d047b9acebc Mon Sep 17 00:00:00 2001 From: sarahgoh97 Date: Fri, 9 Mar 2018 16:05:47 +0800 Subject: [PATCH 024/244] Update test for starting state --- src/test/java/systemtests/AddressBookSystemTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/java/systemtests/AddressBookSystemTest.java b/src/test/java/systemtests/AddressBookSystemTest.java index e52c157195a0..dd71155cd1bf 100644 --- a/src/test/java/systemtests/AddressBookSystemTest.java +++ b/src/test/java/systemtests/AddressBookSystemTest.java @@ -296,6 +296,7 @@ private void assertApplicationStartingStateIsCorrect() { assertEquals(MainApp.class.getResource(FXML_FILE_FOLDER + DEFAULT_PAGE), getBrowserPanel().getLoadedUrl()); assertEquals("./" + testApp.getStorageSaveLocation(), getStatusBarFooter().getSaveLocation()); assertEquals(SYNC_STATUS_INITIAL, getStatusBarFooter().getSyncStatus()); + assertEquals(testApp.getModel().getAddressBook().getPersonList().size() + " person(s) total.",getStatusBarFooter().getNumberOfPeopleStatus()); } catch (Exception e) { throw new AssertionError("Starting state is wrong.", e); } From bf01e928699dc076de022f9468031ee6ed19d410 Mon Sep 17 00:00:00 2001 From: sarahgoh97 Date: Fri, 9 Mar 2018 16:29:15 +0800 Subject: [PATCH 025/244] Correct coding standard violations --- src/main/java/seedu/address/ui/MainWindow.java | 3 ++- src/main/java/seedu/address/ui/StatusBarFooter.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/seedu/address/ui/MainWindow.java b/src/main/java/seedu/address/ui/MainWindow.java index f16a9203925d..c47dbbb0ab21 100644 --- a/src/main/java/seedu/address/ui/MainWindow.java +++ b/src/main/java/seedu/address/ui/MainWindow.java @@ -125,7 +125,8 @@ void fillInnerParts() { ResultDisplay resultDisplay = new ResultDisplay(); resultDisplayPlaceholder.getChildren().add(resultDisplay.getRoot()); - StatusBarFooter statusBarFooter = new StatusBarFooter(prefs.getAddressBookFilePath(), logic.getFilteredPersonList()); + StatusBarFooter statusBarFooter = new StatusBarFooter(prefs.getAddressBookFilePath(), + logic.getFilteredPersonList()); statusbarPlaceholder.getChildren().add(statusBarFooter.getRoot()); CommandBox commandBox = new CommandBox(logic); diff --git a/src/main/java/seedu/address/ui/StatusBarFooter.java b/src/main/java/seedu/address/ui/StatusBarFooter.java index 9a89e38354e6..d027fd842e8f 100644 --- a/src/main/java/seedu/address/ui/StatusBarFooter.java +++ b/src/main/java/seedu/address/ui/StatusBarFooter.java @@ -4,12 +4,12 @@ import java.util.Date; import java.util.logging.Logger; -import javafx.collections.ObservableList; import org.controlsfx.control.StatusBar; import com.google.common.eventbus.Subscribe; import javafx.application.Platform; +import javafx.collections.ObservableList; import javafx.fxml.FXML; import javafx.scene.layout.Region; import seedu.address.commons.core.LogsCenter; From cd2575ca4bd1404d9d823d49d4d7e1e32155c705 Mon Sep 17 00:00:00 2001 From: sarahgoh97 Date: Fri, 9 Mar 2018 16:43:56 +0800 Subject: [PATCH 026/244] Update StatusBarFooterTest to check number of people displayed --- src/test/java/seedu/address/ui/StatusBarFooterTest.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/test/java/seedu/address/ui/StatusBarFooterTest.java b/src/test/java/seedu/address/ui/StatusBarFooterTest.java index 132da0d00db1..5351c02e3bc8 100644 --- a/src/test/java/seedu/address/ui/StatusBarFooterTest.java +++ b/src/test/java/seedu/address/ui/StatusBarFooterTest.java @@ -26,6 +26,7 @@ public class StatusBarFooterTest extends GuiUnitTest { private static final String STUB_SAVE_LOCATION = "Stub"; private static final String RELATIVE_PATH = "./"; + private static final String NUMBER_OF_PEOPLE_POSTFIX = " person(s) total."; private static final AddressBookChangedEvent EVENT_STUB = new AddressBookChangedEvent(new AddressBook()); @@ -57,11 +58,14 @@ public void setUp() { @Test public void display() { // initial state - assertStatusBarContent(RELATIVE_PATH + STUB_SAVE_LOCATION, SYNC_STATUS_INITIAL); + assertStatusBarContent(RELATIVE_PATH + STUB_SAVE_LOCATION, + EVENT_STUB.data.getPersonList().size() + NUMBER_OF_PEOPLE_POSTFIX, + SYNC_STATUS_INITIAL); // after address book is updated postNow(EVENT_STUB); assertStatusBarContent(RELATIVE_PATH + STUB_SAVE_LOCATION, + EVENT_STUB.data.getPersonList().size() + NUMBER_OF_PEOPLE_POSTFIX, String.format(SYNC_STATUS_UPDATED, new Date(injectedClock.millis()).toString())); } @@ -69,8 +73,9 @@ public void display() { * Asserts that the save location matches that of {@code expectedSaveLocation}, and the * sync status matches that of {@code expectedSyncStatus}. */ - private void assertStatusBarContent(String expectedSaveLocation, String expectedSyncStatus) { + private void assertStatusBarContent(String expectedSaveLocation, String expectedNumberOfPeopleStatus, String expectedSyncStatus) { assertEquals(expectedSaveLocation, statusBarFooterHandle.getSaveLocation()); + assertEquals(expectedNumberOfPeopleStatus, statusBarFooterHandle.getNumberOfPeopleStatus()); assertEquals(expectedSyncStatus, statusBarFooterHandle.getSyncStatus()); guiRobot.pauseForHuman(); } From e0ccd7cd03325053e6d622efc0e2c743647fd79b Mon Sep 17 00:00:00 2001 From: sarahgoh97 Date: Fri, 9 Mar 2018 16:46:44 +0800 Subject: [PATCH 027/244] Correcting more coding standard violations --- src/test/java/seedu/address/ui/StatusBarFooterTest.java | 3 --- src/test/java/systemtests/AddressBookSystemTest.java | 3 ++- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/test/java/seedu/address/ui/StatusBarFooterTest.java b/src/test/java/seedu/address/ui/StatusBarFooterTest.java index 5351c02e3bc8..17601223652e 100644 --- a/src/test/java/seedu/address/ui/StatusBarFooterTest.java +++ b/src/test/java/seedu/address/ui/StatusBarFooterTest.java @@ -10,7 +10,6 @@ import java.time.ZoneId; import java.util.Date; -import javafx.collections.ObservableList; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; @@ -18,9 +17,7 @@ import guitests.guihandles.StatusBarFooterHandle; import seedu.address.commons.events.model.AddressBookChangedEvent; -import seedu.address.logic.Logic; import seedu.address.model.AddressBook; -import seedu.address.model.person.Person; public class StatusBarFooterTest extends GuiUnitTest { diff --git a/src/test/java/systemtests/AddressBookSystemTest.java b/src/test/java/systemtests/AddressBookSystemTest.java index dd71155cd1bf..3a5c7bfa2d77 100644 --- a/src/test/java/systemtests/AddressBookSystemTest.java +++ b/src/test/java/systemtests/AddressBookSystemTest.java @@ -296,7 +296,8 @@ private void assertApplicationStartingStateIsCorrect() { assertEquals(MainApp.class.getResource(FXML_FILE_FOLDER + DEFAULT_PAGE), getBrowserPanel().getLoadedUrl()); assertEquals("./" + testApp.getStorageSaveLocation(), getStatusBarFooter().getSaveLocation()); assertEquals(SYNC_STATUS_INITIAL, getStatusBarFooter().getSyncStatus()); - assertEquals(testApp.getModel().getAddressBook().getPersonList().size() + " person(s) total.",getStatusBarFooter().getNumberOfPeopleStatus()); + assertEquals(testApp.getModel().getAddressBook().getPersonList().size() + " person(s) total.", + getStatusBarFooter().getNumberOfPeopleStatus()); } catch (Exception e) { throw new AssertionError("Starting state is wrong.", e); } From 31a3dc3cd9f5e0efbc722c573936a50c9a136827 Mon Sep 17 00:00:00 2001 From: sarahgoh97 Date: Fri, 9 Mar 2018 16:51:56 +0800 Subject: [PATCH 028/244] Correcting more coding standard violations again --- src/test/java/seedu/address/ui/StatusBarFooterTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/java/seedu/address/ui/StatusBarFooterTest.java b/src/test/java/seedu/address/ui/StatusBarFooterTest.java index 17601223652e..bb8e8c2e512c 100644 --- a/src/test/java/seedu/address/ui/StatusBarFooterTest.java +++ b/src/test/java/seedu/address/ui/StatusBarFooterTest.java @@ -70,7 +70,8 @@ public void display() { * Asserts that the save location matches that of {@code expectedSaveLocation}, and the * sync status matches that of {@code expectedSyncStatus}. */ - private void assertStatusBarContent(String expectedSaveLocation, String expectedNumberOfPeopleStatus, String expectedSyncStatus) { + private void assertStatusBarContent(String expectedSaveLocation, + String expectedNumberOfPeopleStatus, String expectedSyncStatus) { assertEquals(expectedSaveLocation, statusBarFooterHandle.getSaveLocation()); assertEquals(expectedNumberOfPeopleStatus, statusBarFooterHandle.getNumberOfPeopleStatus()); assertEquals(expectedSyncStatus, statusBarFooterHandle.getSyncStatus()); From ec30908fbdcf3de248765a9f3b13c325976d0885 Mon Sep 17 00:00:00 2001 From: sarahgoh97 Date: Sat, 10 Mar 2018 11:44:05 +0800 Subject: [PATCH 029/244] Remove codacy badge --- README.adoc | 1 - 1 file changed, 1 deletion(-) diff --git a/README.adoc b/README.adoc index 03eff3a4d191..19a41765efb0 100644 --- a/README.adoc +++ b/README.adoc @@ -4,7 +4,6 @@ ifdef::env-github,env-browser[:relfileprefix: docs/] https://travis-ci.org/se-edu/addressbook-level4[image:https://travis-ci.org/se-edu/addressbook-level4.svg?branch=master[Build Status]] https://ci.appveyor.com/project/damithc/addressbook-level4[image:https://ci.appveyor.com/api/projects/status/3boko2x2vr5cc3w2?svg=true[Build status]] https://coveralls.io/github/se-edu/addressbook-level4?branch=master[image:https://coveralls.io/repos/github/se-edu/addressbook-level4/badge.svg?branch=master[Coverage Status]] -https://www.codacy.com/app/damith/addressbook-level4?utm_source=github.com&utm_medium=referral&utm_content=se-edu/addressbook-level4&utm_campaign=Badge_Grade[image:https://api.codacy.com/project/badge/Grade/fc0b7775cf7f4fdeaf08776f3d8e364a[Codacy Badge]] https://gitter.im/se-edu/Lobby[image:https://badges.gitter.im/se-edu/Lobby.svg[Gitter chat]] ifdef::env-github[] From 87eab9189d3ebb1affccbfdeca1d32359d2263e0 Mon Sep 17 00:00:00 2001 From: sarahgoh97 Date: Wed, 14 Mar 2018 15:03:12 +0800 Subject: [PATCH 030/244] Update DeveloperGuide from given comments --- docs/DeveloperGuide.adoc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/DeveloperGuide.adoc b/docs/DeveloperGuide.adoc index 2ac10cfa0167..92b532b07726 100644 --- a/docs/DeveloperGuide.adoc +++ b/docs/DeveloperGuide.adoc @@ -930,6 +930,7 @@ Use case ends. ** 3a1. AB removes cell tag from prisoner status and removes prisoner from cell status + Use case resumes at step 2. + [discrete] === Use case: Get the list of prisoners in a certain cell Actor: police officer (PO) @@ -964,8 +965,6 @@ _{More to be added}_ . Should have different levels of access for users of different ranks. . Should have a backup copy at all times in case a user accidentally deletes any information. -_{More to be added}_ - [appendix] == Glossary From 213970c9aed9821e08b62fdcbebba168adddab4f Mon Sep 17 00:00:00 2001 From: zacci Date: Wed, 14 Mar 2018 15:03:24 +0800 Subject: [PATCH 031/244] Adding Role Field v0.1 Teach application to parse 'r/' token for Role attribute, which will do nothing. --- .../seedu/address/logic/parser/AddCommandParser.java | 9 +++------ src/main/java/seedu/address/logic/parser/CliSyntax.java | 1 + 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main/java/seedu/address/logic/parser/AddCommandParser.java b/src/main/java/seedu/address/logic/parser/AddCommandParser.java index 3c729b388554..1e67e0bfded0 100644 --- a/src/main/java/seedu/address/logic/parser/AddCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/AddCommandParser.java @@ -1,11 +1,8 @@ package seedu.address.logic.parser; import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT; -import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS; -import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL; -import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; -import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; -import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; +import static seedu.address.logic.parser.CliSyntax.*; + import java.util.Set; import java.util.stream.Stream; @@ -32,7 +29,7 @@ public class AddCommandParser implements Parser { */ public AddCommand parse(String args) throws ParseException { ArgumentMultimap argMultimap = - ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS, PREFIX_TAG); + ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS, PREFIX_TAG, PREFIX_ROLE); if (!arePrefixesPresent(argMultimap, PREFIX_NAME, PREFIX_ADDRESS, PREFIX_PHONE, PREFIX_EMAIL) || !argMultimap.getPreamble().isEmpty()) { diff --git a/src/main/java/seedu/address/logic/parser/CliSyntax.java b/src/main/java/seedu/address/logic/parser/CliSyntax.java index 75b1a9bf1190..0342aa1c3f5d 100644 --- a/src/main/java/seedu/address/logic/parser/CliSyntax.java +++ b/src/main/java/seedu/address/logic/parser/CliSyntax.java @@ -11,5 +11,6 @@ public class CliSyntax { public static final Prefix PREFIX_EMAIL = new Prefix("e/"); public static final Prefix PREFIX_ADDRESS = new Prefix("a/"); public static final Prefix PREFIX_TAG = new Prefix("t/"); + public static final Prefix PREFIX_ROLE = new Prefix("r/"); } From fe81dbfcd2456a73d4a3b5373440b9d7b3678694 Mon Sep 17 00:00:00 2001 From: sarahgoh97 Date: Wed, 14 Mar 2018 15:03:42 +0800 Subject: [PATCH 032/244] Update README, AboutUs and UserGuide related to my enhancement and myself --- README.adoc | 23 ++++++++++------------ docs/AboutUs.adoc | 30 ++++++----------------------- docs/UserGuide.adoc | 47 +++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 61 insertions(+), 39 deletions(-) diff --git a/README.adoc b/README.adoc index 19a41765efb0..2ec818a4f683 100644 --- a/README.adoc +++ b/README.adoc @@ -1,10 +1,9 @@ -= Address Book (Level 4) += PrisonBook ifdef::env-github,env-browser[:relfileprefix: docs/] -https://travis-ci.org/se-edu/addressbook-level4[image:https://travis-ci.org/se-edu/addressbook-level4.svg?branch=master[Build Status]] -https://ci.appveyor.com/project/damithc/addressbook-level4[image:https://ci.appveyor.com/api/projects/status/3boko2x2vr5cc3w2?svg=true[Build status]] +https://travis-ci.org/CS2103Jan2018-T11-B2[image:https://travis-ci.org/se-edu/addressbook-level4.svg?branch=master[Build Status]] +https://ci.appveyor.com/project/sarahgoh97/main[image:https://ci.appveyor.com/api/projects/status/3boko2x2vr5cc3w2?svg=true[Build status]] https://coveralls.io/github/se-edu/addressbook-level4?branch=master[image:https://coveralls.io/repos/github/se-edu/addressbook-level4/badge.svg?branch=master[Coverage Status]] -https://gitter.im/se-edu/Lobby[image:https://badges.gitter.im/se-edu/Lobby.svg[Gitter chat]] ifdef::env-github[] image::docs/images/Ui.png[width="600"] @@ -14,24 +13,22 @@ ifndef::env-github[] image::images/Ui.png[width="600"] endif::[] -* This is a desktop Address Book 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. -* 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 https://github.com/se-edu/addressbook-level3[level 3]: -** 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. +* This is a desktop Prison Book application. It has a GUI but most of the user interactions happen using a CLI (Command Line Interface). + +== Target Users + +* Private prison owners or wardens have to keep track of what is happening in their own prisons. +* Guards who want to check when they are on duty == Site Map * <> * <> -* <> * <> -* <> == Acknowledgements +* The original source code of this application is from the AddressBook-Level4 project created by SE-EDU initiative. * Some parts of this sample application were inspired by the excellent http://code.makery.ch/library/javafx-8-tutorial/[Java FX tutorial] by _Marco Jakob_. * Libraries used: https://github.com/TomasMikula/EasyBind[EasyBind], https://github.com/TestFX/TestFX[TextFX], https://bitbucket.org/controlsfx/controlsfx/[ControlsFX], https://github.com/FasterXML/jackson[Jackson], https://github.com/google/guava[Guava], https://github.com/junit-team/junit4[JUnit4] diff --git a/docs/AboutUs.adoc b/docs/AboutUs.adoc index 0f0a8e7ab51e..55c95b547efb 100644 --- a/docs/AboutUs.adoc +++ b/docs/AboutUs.adoc @@ -3,8 +3,7 @@ :imagesDir: images :stylesDir: stylesheets -AddressBook - Level 4 was developed by the https://se-edu.github.io/docs/Team.html[se-edu] team. + -_{The dummy content given below serves as a placeholder to be used by future forks of the project.}_ + +PrisonBook was developed by the https://cs2103jan2018-t11-b2.github.io/docs/Team.html team. + {empty} + We are a team based in the http://www.comp.nus.edu.sg[School of Computing, National University of Singapore]. @@ -27,29 +26,12 @@ Responsibilities: UI ''' -=== Johnny Doe -image::yijinl.jpg[width="150", align="left"] -{empty}[http://github.com/yijinl[github]] [<>] +=== Sarah Goh Shi Ning +image::sarahgoh97.jpg[width="150", align="left"] +{empty}[http://github.com/sarahgoh97[github]] [<>] -Role: Developer + -Responsibilities: Data +Role: Documentation IC + +Responsibilities: Assigning tasks regarding documentation and checking pull requests regarding documenation -''' - -=== Johnny Roe -image::m133225.jpg[width="150", align="left"] -{empty}[http://github.com/m133225[github]] [<>] - -Role: Developer + -Responsibilities: Dev Ops + Threading - -''' - -=== Benson Meier -image::yl_coder.jpg[width="150", align="left"] -{empty}[http://github.com/yl-coder[github]] [<>] - -Role: Developer + -Responsibilities: UI ''' diff --git a/docs/UserGuide.adoc b/docs/UserGuide.adoc index dcbc2688a408..80cd6fe09ae2 100644 --- a/docs/UserGuide.adoc +++ b/docs/UserGuide.adoc @@ -17,7 +17,7 @@ By: `CS2103-B2` Since: `Jan 2018` Licence: `MIT` == Introduction -AddressBook Level 4 (AB4) is for those who *prefer to use a desktop app for managing contacts*. More importantly, AB4 is *optimized for those who prefer to work with a Command Line Interface* (CLI) while still having the benefits of a Graphical User Interface (GUI). If you can type fast, AB4 can get your contact management tasks done faster than traditional GUI apps. Interested? Jump to the <> to get started. Enjoy! +PrisonBook is for those who *prefer to use a desktop app for managing their prison and accessing the database of prisoners*. More importantly, PrisonBook is *optimized for those who prefer to work with a Command Line Interface* (CLI) while still having the benefits of a Graphical User Interface (GUI). If you can type fast, PrisonBook can help you manage your prison faster than traditional GUI apps. Interested? Jump to the <> to get started. Enjoy! == Quick Start @@ -73,11 +73,34 @@ Examples: * `add n/John Doe p/98765432 e/johnd@example.com a/John street, block 123, #01-01` * `add n/Betsy Crowe t/friend e/betsycrowe@example.com a/Newgate Prison p/1234567 t/criminal` +=== Adding a prisoner to a cell: `addcell or ac` (incomplete) + +Adds a person to one of the cells in the prison + +Format: `add n/NAME p/PHONE_NUMBER e/EMAIL a/ADDRESS [t/TAG]...` + +[TIP] +A person must have at least a prisoner tag + +Examples: + +* `addcell n/John Doe p/98765432 e/johnd@example.com a/John street, block 123, #01-01 t/prisoner` +* `ac n/Betsy Crowe t/friend e/betsycrowe@example.com a/Newgate Prison p/1234567 t/prisoner` + + === Listing all persons : `list or l` Shows a list of all persons in the address book. + Format: `list` +=== Listing prisoners in a cell : `listcell or lc` (incomplete) + +Shows a list of all persons in a prison cell in the address book. + +Format: `list CELL` + +Examples: +* `listcell a1` +* `lc c13` + === Editing a person : `edit or e` Edits an existing person in the address book. + @@ -138,6 +161,26 @@ Deletes the 2nd person in the address book. `delete 1` + Deletes the 1st person in the results of the `find` command. +=== Deleting a person from a cell : `deletecell or dc` (incomplete) + +Deletes the specified person from the cell in the PrisonBook. + +Format: `deletecell 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, ... +**** + +Examples: + +* `lc a2` + +`deletecell 2` + +Deletes the 2nd person in the cell in the PrisonBook. +* `listcell b4` + +`dc 1` +Deletes the 1st person in the cell in the PrisonBook. + === Selecting a person : `select or s` Selects the person identified by the index number used in the last person listing. + @@ -220,7 +263,7 @@ The `redo` command fails as there are no `undo` commands executed previously. === Clearing all entries : `clear or c` -Clears all entries from the address book. + +Clears all entries from the address book. Clears all prison cells. + Format: `clear` === Exiting the program : `exit` From e819bb49db7f8bef99c0205514018345621316ed Mon Sep 17 00:00:00 2001 From: zacci Date: Wed, 14 Mar 2018 16:08:06 +0800 Subject: [PATCH 033/244] Adding Role Field v0.2 Added Role Class to store state of person Updated Person Class to store additional Role Variable. Updated Person Class to include additional constructor to accept Role argument Updated original Person class constructor to assign default role as guard --- .../seedu/address/model/person/Person.java | 21 ++++++++ .../java/seedu/address/model/person/Role.java | 52 +++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 src/main/java/seedu/address/model/person/Role.java diff --git a/src/main/java/seedu/address/model/person/Person.java b/src/main/java/seedu/address/model/person/Person.java index ec9f2aa5e919..2576189b4d21 100644 --- a/src/main/java/seedu/address/model/person/Person.java +++ b/src/main/java/seedu/address/model/person/Person.java @@ -19,6 +19,7 @@ public class Person { private final Phone phone; private final Email email; private final Address address; + private final Role role; private final UniqueTagList tags; @@ -31,6 +32,22 @@ public Person(Name name, Phone phone, Email email, Address address, Set tag this.phone = phone; this.email = email; this.address = address; + this.role = new Role("g"); + // protect internal tags from changes in the arg list + this.tags = new UniqueTagList(tags); + } + + /** + * New Constructor for working + * Every field must be present and not null. + */ + public Person(Name name, Phone phone, Email email, Address address, Role role, Set tags) { + requireAllNonNull(name, phone, email, address, tags); + this.name = name; + this.phone = phone; + this.email = email; + this.address = address; + this.role = role; // protect internal tags from changes in the arg list this.tags = new UniqueTagList(tags); } @@ -51,6 +68,8 @@ public Address getAddress() { return address; } + public Role getRole() {return role;} + /** * Returns an immutable tag set, which throws {@code UnsupportedOperationException} * if modification is attempted. @@ -92,6 +111,8 @@ public String toString() { .append(getEmail()) .append(" Address: ") .append(getAddress()) + .append(" Role: ") + .append(getRole()) .append(" Tags: "); getTags().forEach(builder::append); return builder.toString(); diff --git a/src/main/java/seedu/address/model/person/Role.java b/src/main/java/seedu/address/model/person/Role.java new file mode 100644 index 000000000000..f3a1b72523a3 --- /dev/null +++ b/src/main/java/seedu/address/model/person/Role.java @@ -0,0 +1,52 @@ +package seedu.address.model.person; + +import static java.util.Objects.requireNonNull; +import static seedu.address.commons.util.AppUtil.checkArgument; + +/** + * Represents a Person's role in the address book. + * Guarantees: immutable; is valid as declared in {@link #isValidRole(String)} + */ +public class Role { + + + public static final String MESSAGE_ROLE_CONSTRAINTS = + "Enter 'g' or 'p' to assign the role as Guard or Prisoner respectively"; + public final String value; + + /** + * Constructs a {@code Role}. + * + * @param role 'g' or 'p' to represent Guard or Prisoner respectively. + */ + public Role(String role) { + requireNonNull(role); + checkArgument(isValidRole(role), MESSAGE_ROLE_CONSTRAINTS); + this.value = role; + } + + /** + * Returns true if a given string is a valid person phone number. + */ + public static boolean isValidRole(String test) { + return test.equals("g") || test.equals("p"); + } + + @Override + public String toString() { + return value; + } + + @Override + public boolean equals(Object other) { + return other == this // short circuit if same object + || (other instanceof Role // instanceof handles nulls + && this.value.equals(((Role) other).value)); // state check + } + + @Override + public int hashCode() { + return value.hashCode(); + } + +} From be47bf05a40227f86c615eb778cdef91d14f2f36 Mon Sep 17 00:00:00 2001 From: zacci Date: Wed, 14 Mar 2018 22:14:51 +0800 Subject: [PATCH 034/244] Adding Role Field v0.3 Added for roles for Model, UI and Storage --- .../address/logic/commands/AddCommand.java | 9 +++---- .../address/logic/commands/EditCommand.java | 13 +++++++++- .../logic/parser/AddCommandParser.java | 4 ++- .../address/logic/parser/ParserUtil.java | 25 +++++++++++++++++++ .../java/seedu/address/model/AddressBook.java | 2 +- .../seedu/address/model/person/Person.java | 7 ++++-- .../seedu/address/model/person/Prisoner.java | 4 +-- .../java/seedu/address/model/person/Role.java | 2 +- .../address/model/util/SampleDataUtil.java | 13 +++++----- .../address/storage/XmlAdaptedPerson.java | 18 +++++++++++-- .../java/seedu/address/ui/PersonCard.java | 3 +++ src/main/resources/view/PersonListCard.fxml | 1 + .../guitests/guihandles/PersonCardHandle.java | 7 ++++++ 13 files changed, 87 insertions(+), 21 deletions(-) diff --git a/src/main/java/seedu/address/logic/commands/AddCommand.java b/src/main/java/seedu/address/logic/commands/AddCommand.java index d5de4a572715..1778e70d9801 100644 --- a/src/main/java/seedu/address/logic/commands/AddCommand.java +++ b/src/main/java/seedu/address/logic/commands/AddCommand.java @@ -1,11 +1,8 @@ package seedu.address.logic.commands; import static java.util.Objects.requireNonNull; -import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS; -import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL; -import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; -import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; -import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; +import static seedu.address.logic.parser.CliSyntax.*; + import seedu.address.logic.commands.exceptions.CommandException; import seedu.address.model.person.Person; @@ -25,12 +22,14 @@ public class AddCommand extends UndoableCommand { + PREFIX_PHONE + "PHONE " + PREFIX_EMAIL + "EMAIL " + PREFIX_ADDRESS + "ADDRESS " + + PREFIX_ROLE + "ROLE " + "[" + PREFIX_TAG + "TAG]...\n" + "Example: " + COMMAND_WORD + " " + PREFIX_NAME + "John Doe " + PREFIX_PHONE + "98765432 " + PREFIX_EMAIL + "johnd@example.com " + PREFIX_ADDRESS + "311, Clementi Ave 2, #02-25 " + + PREFIX_ROLE + "g" + PREFIX_TAG + "friends " + PREFIX_TAG + "owesMoney"; diff --git a/src/main/java/seedu/address/logic/commands/EditCommand.java b/src/main/java/seedu/address/logic/commands/EditCommand.java index 3021c951a5b1..19519002dc38 100644 --- a/src/main/java/seedu/address/logic/commands/EditCommand.java +++ b/src/main/java/seedu/address/logic/commands/EditCommand.java @@ -24,6 +24,7 @@ import seedu.address.model.person.Name; import seedu.address.model.person.Person; import seedu.address.model.person.Phone; +import seedu.address.model.person.Role; import seedu.address.model.person.exceptions.DuplicatePersonException; import seedu.address.model.person.exceptions.PersonNotFoundException; import seedu.address.model.tag.Tag; @@ -107,9 +108,10 @@ private static Person createEditedPerson(Person personToEdit, EditPersonDescript Phone updatedPhone = editPersonDescriptor.getPhone().orElse(personToEdit.getPhone()); Email updatedEmail = editPersonDescriptor.getEmail().orElse(personToEdit.getEmail()); Address updatedAddress = editPersonDescriptor.getAddress().orElse(personToEdit.getAddress()); + Role updatedRole = editPersonDescriptor.getRole().orElse(personToEdit.getRole()); Set updatedTags = editPersonDescriptor.getTags().orElse(personToEdit.getTags()); - return new Person(updatedName, updatedPhone, updatedEmail, updatedAddress, updatedTags); + return new Person(updatedName, updatedPhone, updatedEmail, updatedAddress, updatedRole, updatedTags); } @Override @@ -140,6 +142,7 @@ public static class EditPersonDescriptor { private Phone phone; private Email email; private Address address; + private Role role; private Set tags; public EditPersonDescriptor() {} @@ -195,6 +198,14 @@ public Optional
getAddress() { return Optional.ofNullable(address); } + public void setRole(Role role) { + this.role = role; + } + + public Optional getRole() { + return Optional.ofNullable(role); + } + /** * Sets {@code tags} to this object's {@code tags}. * A defensive copy of {@code tags} is used internally. diff --git a/src/main/java/seedu/address/logic/parser/AddCommandParser.java b/src/main/java/seedu/address/logic/parser/AddCommandParser.java index 1e67e0bfded0..9b1faa4310c4 100644 --- a/src/main/java/seedu/address/logic/parser/AddCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/AddCommandParser.java @@ -15,6 +15,7 @@ import seedu.address.model.person.Name; import seedu.address.model.person.Person; import seedu.address.model.person.Phone; +import seedu.address.model.person.Role; import seedu.address.model.tag.Tag; /** @@ -41,9 +42,10 @@ public AddCommand parse(String args) throws ParseException { Phone phone = ParserUtil.parsePhone(argMultimap.getValue(PREFIX_PHONE)).get(); Email email = ParserUtil.parseEmail(argMultimap.getValue(PREFIX_EMAIL)).get(); Address address = ParserUtil.parseAddress(argMultimap.getValue(PREFIX_ADDRESS)).get(); + Role role = ParserUtil.parseRole(argMultimap.getValue(PREFIX_ROLE)).get(); Set tagList = ParserUtil.parseTags(argMultimap.getAllValues(PREFIX_TAG)); - Person person = new Person(name, phone, email, address, tagList); + Person person = new Person(name, phone, email, address, role, tagList); return new AddCommand(person); } catch (IllegalValueException ive) { diff --git a/src/main/java/seedu/address/logic/parser/ParserUtil.java b/src/main/java/seedu/address/logic/parser/ParserUtil.java index 5d6d4ae3f7b1..26b2e417d3ae 100644 --- a/src/main/java/seedu/address/logic/parser/ParserUtil.java +++ b/src/main/java/seedu/address/logic/parser/ParserUtil.java @@ -14,6 +14,7 @@ import seedu.address.model.person.Email; import seedu.address.model.person.Name; import seedu.address.model.person.Phone; +import seedu.address.model.person.Role; import seedu.address.model.tag.Tag; /** @@ -139,6 +140,30 @@ public static Optional parseEmail(Optional email) throws IllegalV return email.isPresent() ? Optional.of(parseEmail(email.get())) : Optional.empty(); } + /** + * Parses a {@code String role} into an {@code role}. + * Leading and trailing whitespaces will be trimmed. + * + * @throws IllegalValueException if the given {@code role} is invalid. + */ + public static Role parseRole(String role) throws IllegalValueException { + //requireNonNull(role); null accepted for now + String trimmedRole = role.trim(); + if (!Role.isValidRole(trimmedRole)) { + throw new IllegalValueException(Role.MESSAGE_ROLE_CONSTRAINTS); + } + return new Role(trimmedRole); + } + + /** + * Parses a {@code Optional email} into an {@code Optional} if {@code email} is present. + * See header comment of this class regarding the use of {@code Optional} parameters. + */ + public static Optional parseRole(Optional role) throws IllegalValueException { + //requireNonNull(role); null accepted for now + return role.isPresent() ? Optional.of(parseRole(role.get())) : Optional.empty(); + } + /** * Parses a {@code String tag} into a {@code Tag}. * Leading and trailing whitespaces will be trimmed. diff --git a/src/main/java/seedu/address/model/AddressBook.java b/src/main/java/seedu/address/model/AddressBook.java index f8d0260de159..e1a8f8e7c4a5 100644 --- a/src/main/java/seedu/address/model/AddressBook.java +++ b/src/main/java/seedu/address/model/AddressBook.java @@ -132,7 +132,7 @@ private Person syncWithMasterTagList(Person person) { final Set correctTagReferences = new HashSet<>(); personTags.forEach(tag -> correctTagReferences.add(masterTagObjects.get(tag))); return new Person( - person.getName(), person.getPhone(), person.getEmail(), person.getAddress(), correctTagReferences); + person.getName(), person.getPhone(), person.getEmail(), person.getAddress(), person.getRole(), correctTagReferences); } /** diff --git a/src/main/java/seedu/address/model/person/Person.java b/src/main/java/seedu/address/model/person/Person.java index 2576189b4d21..755ce1a04a31 100644 --- a/src/main/java/seedu/address/model/person/Person.java +++ b/src/main/java/seedu/address/model/person/Person.java @@ -26,16 +26,18 @@ public class Person { /** * Every field must be present and not null. */ + /* public Person(Name name, Phone phone, Email email, Address address, Set tags) { requireAllNonNull(name, phone, email, address, tags); this.name = name; this.phone = phone; this.email = email; this.address = address; - this.role = new Role("g"); + this.role = new Role("p"); // protect internal tags from changes in the arg list this.tags = new UniqueTagList(tags); } + */ /** * New Constructor for working @@ -92,7 +94,8 @@ public boolean equals(Object other) { return otherPerson.getName().equals(this.getName()) && otherPerson.getPhone().equals(this.getPhone()) && otherPerson.getEmail().equals(this.getEmail()) - && otherPerson.getAddress().equals(this.getAddress()); + && otherPerson.getAddress().equals(this.getAddress()) + && otherPerson.getRole().equals(this.getRole()); } @Override diff --git a/src/main/java/seedu/address/model/person/Prisoner.java b/src/main/java/seedu/address/model/person/Prisoner.java index c44961978adc..1d5b5aa7c346 100644 --- a/src/main/java/seedu/address/model/person/Prisoner.java +++ b/src/main/java/seedu/address/model/person/Prisoner.java @@ -15,8 +15,8 @@ public class Prisoner extends Person { private final ReleaseDate releaseDate; - public Prisoner(Name name, Phone phone, Email email, Address address, Set tags, ReleaseDate releaseDate) { - super(name, phone, email, address, tags); + public Prisoner(Name name, Phone phone, Email email, Address address, Role role, Set tags, ReleaseDate releaseDate) { + super(name, phone, email, address, role, tags); requireAllNonNull(name, phone, email, address, tags, releaseDate); this.releaseDate = releaseDate; } diff --git a/src/main/java/seedu/address/model/person/Role.java b/src/main/java/seedu/address/model/person/Role.java index f3a1b72523a3..8fc125fd5b71 100644 --- a/src/main/java/seedu/address/model/person/Role.java +++ b/src/main/java/seedu/address/model/person/Role.java @@ -11,7 +11,7 @@ public class Role { public static final String MESSAGE_ROLE_CONSTRAINTS = - "Enter 'g' or 'p' to assign the role as Guard or Prisoner respectively"; + "Role can only take on the values 'g' or 'p', which represents Guard or Prisoner respectively"; public final String value; /** diff --git a/src/main/java/seedu/address/model/util/SampleDataUtil.java b/src/main/java/seedu/address/model/util/SampleDataUtil.java index aea96bfb31f3..aefe9f59e397 100644 --- a/src/main/java/seedu/address/model/util/SampleDataUtil.java +++ b/src/main/java/seedu/address/model/util/SampleDataUtil.java @@ -10,6 +10,7 @@ import seedu.address.model.person.Name; import seedu.address.model.person.Person; import seedu.address.model.person.Phone; +import seedu.address.model.person.Role; import seedu.address.model.person.exceptions.DuplicatePersonException; import seedu.address.model.tag.Tag; @@ -20,22 +21,22 @@ public class SampleDataUtil { public static Person[] getSamplePersons() { return new Person[] { new Person(new Name("Alex Yeoh"), new Phone("87438807"), new Email("alexyeoh@example.com"), - new Address("Blk 30 Geylang Street 29, #06-40"), + new Address("Blk 30 Geylang Street 29, #06-40"), new Role("p"), getTagSet("friends")), new Person(new Name("Bernice Yu"), new Phone("99272758"), new Email("berniceyu@example.com"), - new Address("Blk 30 Lorong 3 Serangoon Gardens, #07-18"), + new Address("Blk 30 Lorong 3 Serangoon Gardens, #07-18"), new Role("g"), getTagSet("colleagues", "friends")), new Person(new Name("Charlotte Oliveiro"), new Phone("93210283"), new Email("charlotte@example.com"), - new Address("Blk 11 Ang Mo Kio Street 74, #11-04"), + new Address("Blk 11 Ang Mo Kio Street 74, #11-04"), new Role("p"), getTagSet("neighbours")), new Person(new Name("David Li"), new Phone("91031282"), new Email("lidavid@example.com"), - new Address("Blk 436 Serangoon Gardens Street 26, #16-43"), + new Address("Blk 436 Serangoon Gardens Street 26, #16-43"), new Role("g"), getTagSet("family")), new Person(new Name("Irfan Ibrahim"), new Phone("92492021"), new Email("irfan@example.com"), - new Address("Blk 47 Tampines Street 20, #17-35"), + new Address("Blk 47 Tampines Street 20, #17-35"), new Role("p"), getTagSet("classmates")), new Person(new Name("Roy Balakrishnan"), new Phone("92624417"), new Email("royb@example.com"), - new Address("Blk 45 Aljunied Street 85, #11-31"), + new Address("Blk 45 Aljunied Street 85, #11-31"), new Role("g"), getTagSet("colleagues")) }; } diff --git a/src/main/java/seedu/address/storage/XmlAdaptedPerson.java b/src/main/java/seedu/address/storage/XmlAdaptedPerson.java index 2cd92dc4fd20..eff2dfcbf7c2 100644 --- a/src/main/java/seedu/address/storage/XmlAdaptedPerson.java +++ b/src/main/java/seedu/address/storage/XmlAdaptedPerson.java @@ -14,6 +14,7 @@ import seedu.address.model.person.Name; import seedu.address.model.person.Person; import seedu.address.model.person.Phone; +import seedu.address.model.person.Role; import seedu.address.model.tag.Tag; /** @@ -31,6 +32,8 @@ public class XmlAdaptedPerson { private String email; @XmlElement(required = true) private String address; + @XmlElement(required = true) + private String role; @XmlElement private List tagged = new ArrayList<>(); @@ -44,11 +47,12 @@ public XmlAdaptedPerson() {} /** * Constructs an {@code XmlAdaptedPerson} with the given person details. */ - public XmlAdaptedPerson(String name, String phone, String email, String address, List tagged) { + public XmlAdaptedPerson(String name, String phone, String email, String address, String role, List tagged) { this.name = name; this.phone = phone; this.email = email; this.address = address; + this.role = role; if (tagged != null) { this.tagged = new ArrayList<>(tagged); } @@ -64,6 +68,7 @@ public XmlAdaptedPerson(Person source) { phone = source.getPhone().value; email = source.getEmail().value; address = source.getAddress().value; + role = source.getRole().value; tagged = new ArrayList<>(); for (Tag tag : source.getTags()) { tagged.add(new XmlAdaptedTag(tag)); @@ -113,8 +118,16 @@ public Person toModelType() throws IllegalValueException { } final Address address = new Address(this.address); + if (this.role == null) { + throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, Address.class.getSimpleName())); + } + if (!Role.isValidRole(this.role)) { + throw new IllegalValueException(Role.MESSAGE_ROLE_CONSTRAINTS); + } + final Role role = new Role(this.role); + final Set tags = new HashSet<>(personTags); - return new Person(name, phone, email, address, tags); + return new Person(name, phone, email, address, role, tags); } @Override @@ -132,6 +145,7 @@ public boolean equals(Object other) { && Objects.equals(phone, otherPerson.phone) && Objects.equals(email, otherPerson.email) && Objects.equals(address, otherPerson.address) + && Objects.equals(role, otherPerson.role) && tagged.equals(otherPerson.tagged); } } diff --git a/src/main/java/seedu/address/ui/PersonCard.java b/src/main/java/seedu/address/ui/PersonCard.java index f6727ea83abd..c7e774eb8dbd 100644 --- a/src/main/java/seedu/address/ui/PersonCard.java +++ b/src/main/java/seedu/address/ui/PersonCard.java @@ -37,6 +37,8 @@ public class PersonCard extends UiPart { @FXML private Label email; @FXML + private Label role; + @FXML private FlowPane tags; public PersonCard(Person person, int displayedIndex) { @@ -47,6 +49,7 @@ public PersonCard(Person person, int displayedIndex) { phone.setText(person.getPhone().value); address.setText(person.getAddress().value); email.setText(person.getEmail().value); + role.setText(person.getRole().value); person.getTags().forEach(tag -> tags.getChildren().add(new Label(tag.tagName))); } diff --git a/src/main/resources/view/PersonListCard.fxml b/src/main/resources/view/PersonListCard.fxml index f08ea32ad558..56855069f876 100644 --- a/src/main/resources/view/PersonListCard.fxml +++ b/src/main/resources/view/PersonListCard.fxml @@ -31,6 +31,7 @@