Skip to content

Commit

Permalink
Merge pull request #108 from muhdharun/Screening_History_Feature
Browse files Browse the repository at this point in the history
Add screening history feature and add codecov
  • Loading branch information
iamputradanish committed Oct 16, 2018
2 parents 7bab73b + 224c9dc commit 78be6b0
Show file tree
Hide file tree
Showing 23 changed files with 524 additions and 181 deletions.
6 changes: 4 additions & 2 deletions .travis.yml
Expand Up @@ -4,8 +4,7 @@ matrix:
- jdk: oraclejdk9

script: >-
./gradlew test asciidoctor
./gradlew test asciidoctor
deploy:
skip_cleanup: true
provider: script
Expand All @@ -17,3 +16,6 @@ addons:
apt:
packages:
- oracle-java9-installer
after_success:
- if [ -e ./gradlew ]; then ./gradlew jacocoTestReport;else gradle jacocoTestReport;fi
- bash <(curl -s https://codecov.io/bash)
19 changes: 19 additions & 0 deletions ScreeningHistory.txt
@@ -0,0 +1,19 @@
s1234567a 15/10/2018-17:55:01
s1234567a 15/10/2018-17:55:07
f1234567a 15/10/2018-17:55:45
f1234567a 15/10/2018-17:55:55
s1234567a 15/10/2018-20:03:07
s1234567a 16/10/2018-11:19:30
s1234567a 16/10/2018-11:54:56
s1234567b 16/10/2018-11:58:30
s1234567b 16/10/2018-11:58:51
s1234567b 16/10/2018-12:02:34
s1234567b 16/10/2018-12:04:40
s1234567b 16/10/2018-12:05:43
s1234567b 16/10/2018-12:06:18
s1234567b 16/10/2018-12:07:06
s1234567b 16/10/2018-12:13:10
s1234567b 16/10/2018-12:14:24
s1234567b 16/10/2018-12:16:18
s1234567b 16/10/2018-12:16:43
s1234567b 16/10/2018-12:18:34
10 changes: 10 additions & 0 deletions build.gradle
Expand Up @@ -7,6 +7,7 @@ import org.gradle.api.tasks.testing.logging.TestLogEvent
plugins {
id 'java'
id 'org.asciidoctor.convert' version '1.5.6'
id 'jacoco'
}

sourceCompatibility = JavaVersion.VERSION_1_9
Expand Down Expand Up @@ -92,6 +93,13 @@ asciidoctor {
}
}

jacocoTestReport {
reports {
xml.enabled true
html.enabled false
}
}

// Copies stylesheets into the directory containing generated HTML files as
// Asciidoctor does not copy linked CSS files to the output directory when rendering.
// This is needed for linked stylesheets and embedded stylesheets which import other files.
Expand All @@ -101,4 +109,6 @@ task copyStylesheets(type: Copy) {
}
asciidoctor.dependsOn copyStylesheets

check.dependsOn jacocoTestReport

defaultTasks 'clean', 'test', 'asciidoctor'
94 changes: 91 additions & 3 deletions docs/DeveloperGuide.adoc
Expand Up @@ -181,22 +181,40 @@ Use case ends.

*MSS*

. System prompts user to enter his password
. User enters password
. User keys in NRIC of person to delete
. System deletes the person.

. User requests to list persons.
. System shows a list of persons.
. User requests to delete a specific person in the list.
. System deletes the person.

+
Use case ends.

*Extensions*

* 2a. The list is empty.
* 2a. The entered password is invalid.
** 2a1. System shows an error message.
+
Use case resumes at step 1.

* 3a. The list is empty.
** 3a1. System shows an error message
+

Use case ends.

* 3a. The given index is invalid.
** 3a1. System shows an error message.
* 3b. The given NRIC is invalid.
** 3b1. System shows an error message.
+
Use case ends.

* 3c. The person with given NRIC does not exists.
** 3c1. System shows an error message.

Use case resumes at step 3.

* *a. At any time, User chooses to cancel the delete action.
Expand Down Expand Up @@ -242,6 +260,13 @@ Use case ends.

*MSS*


. User requests to find person
. System prompts User to enter his password
. User enters his password
. System prompts User to key in NRIC to find
. User enters NRIC of person

. User requests to find person.
. System prompts User to key in NRIC of person.
. User enters NRIC of person.
Expand All @@ -251,16 +276,65 @@ Use case ends.

*Extensions*


* 3a. The entered password is invalid
** 3a1. System shows an error message
+
Use case resumes in step 2.

* 5a. The person’s NRIC are entered with invalid format.
** 5a1. System shows an error message.
+
Use case resumes at step 4.

* 5b. The list of persons is empty.
** 5b1. System shows an error essage
+
Use case ends.

* 6a. Person does not exist in the list
** 6a1. System informs User that person is not in the list
+
Use case ends.

* *a. At any time, User chooses to cancel the delete action.
** *a1. System requests confirmation to cancel
** *a2. User confirms the cancellation.
+
Use case ends

=== Use case: Check

*MSS*

. User requests to check person's screening history
. System prompts User to enter his password
. User enters his password
. System prompts User to key in NRIC to check
. User enters NRIC of person
. System displays past screening timestamps of person, if found on the list.
+
Use case ends.

*Extensions*

* 3a. The entered password is invalid
** 3a1. System shows an error message

* 1a. The list is empty.
** 1a1. System shows an error message.
+
Use case ends.

* 3a. The person’s details are entered with invalid format.
** 3a1. System shows an error message.

+
Use case resumes at step 3.

* 5a. The person’s NRIC are entered with invalid format.
** 5a1. System shows an error message.

* 4a. Person does not exist in the list.
** 4a1. System informs User that person is not in the list.
+
Expand All @@ -279,6 +353,14 @@ Use case ends.
*MSS*


* 5b. The list of persons is empty.
** 5b1. System shows an error essage
+
Use case ends.

* 6a. Person does not exist in the list
** 6a1. System informs User that person is not in the list

. User enters invalid input
. System tries to predict what the user would have wanted to type
. System displays the valid use of input, if found
Expand All @@ -289,6 +371,7 @@ Use case ends.

* 3a. The invalid input is an invalid command.
** 3a1. System also displays the valid usage of the command.

+
Use case ends.

Expand All @@ -298,8 +381,13 @@ Use case ends.
+
Use case ends.



=== Use case: Undo

=== Use case: Load messages


*MSS*

. User requests to display messages in inbox
Expand Down
14 changes: 7 additions & 7 deletions docs/UserGuide.adoc
Expand Up @@ -26,12 +26,12 @@ Format: help

3.2. Adding a new person: add
Adds a criminal to the database- only by Admin.
Format: add i/NRIC n/NAME p/PHONE_NUMBER d/DATE_OF_BIRTH s/STATUS a/ADDRESS
Format: add NAME n/NRIC d/DATEOFBIRTH p/POSTALCODE s/STATUS w/WANTEDFOR [o/PASTOFFENSES]
Examples:
● add i/G1978411Q n/John Doe p/98765432 d/03-April-1972 s/Wanted a/John street, block 123, #01-01
● add John Doe n/s1234567a d/1996 p/510246 s/xc w/none o/theft o/drugs"
3.3. Editing a person : edit
Edits an existing person in the address book.
Format: edit NRIC [n/NAME] [p/PHONE] [d/DATE_OF_BIRTH] [s/STATUS] [a/ADDRESS]
Format: edit n/[NAME] p/[POSTAL_CODE] s/[STATUS] w/WANTED_FOR o/PAST_OFFENCES
● Edits the person with the specified NRIC.
● At least one of the optional fields must be provided.
● Existing values will be updated to the input values.
Expand Down Expand Up @@ -172,14 +172,14 @@ Output: Dispatch message sent to PO2
Format - help

● Add
Format - add i/[NRIC] n/[NAME] p/[PHONE_NUMBER] d/[DATE_OF_BIRTH] s/[STATUS] a/[ADDRESS]
Format - add n/[NAME] n/[NRIC] d/[DATE_OF_BIRTH] p/[POSTAL_CODE] s/[STATUS] w/WANTED_FOR o/PAST_OFFENCES

E.g. add i/G1978411Q n/John Doe p/98765432 d/03-April-1972 s/Wanted a/John street, block 123, #01-01
E.g. add John Doe n/s1234567a d/1996 p/510246 s/xc w/none o/theft o/drugs"

● Edit
Format- edit NRIC [n/NAME] [p/PHONE] [d/DATE_OF_BIRTH] [s/STATUS] [a/ADDRESS]
Format- edit n/[NAME] p/[POSTAL_CODE] s/[STATUS] w/WANTED_FOR o/PAST_OFFENCES

E.g. edit G1952866Q p/91234567
E.g. edit G1952866Q p/510246

● Delete
Format- delete NRIC
Expand Down
16 changes: 16 additions & 0 deletions parserLog.log.1
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE log SYSTEM "logger.dtd">
<log>
<record>
<date>2018-10-14T13:51:33.815695600Z</date>
<millis>1539525093815</millis>
<nanos>695600</nanos>
<sequence>0</sequence>
<logger>seedu.addressbook.parser.Parser</logger>
<level>INFO</level>
<class>seedu.addressbook.parser.Parser</class>
<method>parseCommand</method>
<thread>17</thread>
<message>Parsed the user input and matching commands.</message>
</record>
</log>
52 changes: 52 additions & 0 deletions src/seedu/addressbook/commands/CheckCommand.java
@@ -0,0 +1,52 @@
package seedu.addressbook.commands;


import seedu.addressbook.data.exception.IllegalValueException;
import seedu.addressbook.data.person.Person;
import seedu.addressbook.data.person.ReadOnlyPerson;
import seedu.addressbook.storage.jaxb.AdaptedAddressBook;
import seedu.addressbook.storage.jaxb.AdaptedPerson;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class CheckCommand extends Command {


public static final String COMMAND_WORD = "check";
public static final String MESSAGE_USAGE = COMMAND_WORD + ":\n" + "Gets screening history of person with specified NRIC \n\t"
+ "Parameters: NRIC ...\n\t"
+ "Example: " + COMMAND_WORD + " s1234567a";
private String nricKeyword;
private ReadOnlyPerson matchedPerson;


public CheckCommand(String nricToFind)
{
this.nricKeyword = nricToFind;
}

public String getNricKeyword(){
return nricKeyword;
}



@Override
public CommandResult execute() {
final List<String> screeningHistory = getPersonWithNric(nricKeyword);
return new CommandResult(getMessageForScreeningHistoryShownSummary(screeningHistory));
}

private List<String> getPersonWithNric(String nric){
List<String> screeningHistory = new ArrayList<>();
try {
screeningHistory = addressBook.readDatabase(nric);
} catch (IOException e) {
e.printStackTrace();
}
return screeningHistory;
}

}
30 changes: 30 additions & 0 deletions src/seedu/addressbook/commands/Command.java
@@ -1,5 +1,6 @@
package seedu.addressbook.commands;

import seedu.addressbook.Main;
import seedu.addressbook.common.Messages;
import seedu.addressbook.data.AddressBook;
import seedu.addressbook.data.person.*;
Expand All @@ -9,6 +10,9 @@
import java.util.NoSuchElementException;
import java.util.Set;

import seedu.addressbook.ui.Formatter;
import seedu.addressbook.ui.MainWindow;

import static seedu.addressbook.ui.Gui.DISPLAYED_INDEX_OFFSET;

/**
Expand Down Expand Up @@ -39,6 +43,22 @@ public static String getMessageForPersonListShownSummary(List<? extends ReadOnly
return String.format(Messages.MESSAGE_PERSONS_LISTED_OVERVIEW, personsDisplayed.size());
}

/**
* Constructs a feedback message to summarise an operation that displayed a listing of persons.
*
* @param timestampsDisplayed used to generate summary
* @return summary message for timestamps displayed
*/

public static String getMessageForScreeningHistoryShownSummary(List<String> timestampsDisplayed) {

//TODO: Try format or mainwindow methods
Formatter formatter = new Formatter();
String result = formatter.formatForTstamps(timestampsDisplayed);
String finalResult = result + String.format(Messages.MESSAGE_TIMESTAMPS_LISTED_OVERVIEW, timestampsDisplayed.size());
return finalResult;
}

/**
* Executes the command and returns the result.
*/
Expand Down Expand Up @@ -75,6 +95,16 @@ protected ReadOnlyPerson getTargetPerson(Name name) throws UniquePersonList.Pers
throw new UniquePersonList.PersonNotFoundException();
}

protected ReadOnlyPerson getTargetPersonWithNric(NRIC nric) throws UniquePersonList.PersonNotFoundException {
for (ReadOnlyPerson person: relevantPersons) {
if (person.getNRIC().getIdentificationNumber().equals(nric.getIdentificationNumber())) {
return person;
}
}
throw new UniquePersonList.PersonNotFoundException();
}


public int getTargetIndex() {
return targetIndex;
}
Expand Down

0 comments on commit 78be6b0

Please sign in to comment.