Skip to content

Commit

Permalink
Merge pull request #249 from ShreyasKp/master
Browse files Browse the repository at this point in the history
Update DG and PPP
  • Loading branch information
ongweekeong authored Nov 12, 2018
2 parents 43428d5 + 95c9a7d commit 61eef51
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 11 deletions.
7 changes: 5 additions & 2 deletions docs/DeveloperGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -943,9 +943,10 @@ To run tests for the project, complete the step below.

// tag::stories[]

[[stories]]

[appendix]

[[stories]]
== User Stories

Priorities: High (must have) - `* * \*`, Medium (nice to have) - `* \*`, Low (unlikely to have) - `*`
Expand All @@ -966,8 +967,10 @@ HQP- Headquarters Personnel
|`*` |PO |know the serial number and battery level |to return it to HQ and charge it when necessary
|===========================================================================================================================================

// end::stories[]
[appendix]

// end::stories[]

== Use Cases

(For all use cases below, the *System* is the `Police Records` and the *User* is either the `Police Officer (PO)' or 'Headquarters Personnel (HQP)', unless specified otherwise)
Expand Down
24 changes: 16 additions & 8 deletions docs/team/shreyaskp.adoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
= Shreyas Kuthanoor Prakash - Project Portfolio

== PROJECT: Police Records and Intelligence System (PRISM)
:site-section: ProjectPortfolio
:toc:
:toc-title:
:sectnums:
:imagesDir: ../images
:stylesDir: ../stylesheets
:xrefstyle: full

:tip-caption: :bulb:
:note-caption: :information_source:
:warning-caption: :warning:
:experimental:
= PROJECT: Police Records and Intelligence System (PRISM)

---

Expand All @@ -10,11 +21,7 @@ This document serves to showcase my contributions towards the CS2113T Software E
My team and I have built PRISM using AddressBook - Level 3, provided by the se-edu team as a base.

The Police Records and Intelligence System (PRISM) is a desktop application catered towards the needs of the Police. The System
has two types of users- Police Officers and Headquarters Personnel, each with different levels of access. As a Police
Officer on patrol, you can screen someone using the system. You can then choose a course of action based on the status
and criminal history of the subject screened. On the other hand, as a Headquarters Personnel, you can not only perform all
actions that can be performed by a Police Officer, but also perform additional functionalities such as adding, removing and
editing subjects currently present in the database, and dispatching other Police Officers, when need be. Both types of users
has two types of users- Police Officers and Headquarters Personnel, each with different levels of access. Both types of users
interact with the System using a CLI (Command-Line Interface). The application is written in Java, and it has a minimalistic
GUI (Graphical User Interface) created with JavaFX.

Expand All @@ -35,12 +42,13 @@ Thus, the AutoCorrect feature is extremely useful in cases where minute errors a

* *Minor enhancement*: The user can view the current local time and date using the time command. This is useful especially for providing backup as well as meeting deadlines.

* *Code contributed*: [https://github.com/CS2113-AY1819S1-F10-3/main/blob/master/collated/functional/ShreyasKp.md[Functional code]] https://github.com/CS2113-AY1819S1-F10-3/main/blob/master/collated/test/ShreyasKp.md[Test code]]
* *Code contributed*: https://nuscs2113-ay1819s1.github.io/dashboard/#=undefined&search=shreyaskp&sort=displayName&since=2018-09-12&until=2018-10-30&timeframe=day&reverse=false&repoSort=true[Functional & Test code]

* *Other contributions*:

** Project management:
*** Ensured team maintains code quality, according to the https://oss-generic.github.io/process/codingStandards/CodingStandard-Java.html[Java Coding Standard]
*** Added implementation of CheckStyle plugin to fix code quality bugs: https://github.com/CS2113-AY1819S1-F10-3/main/pull/235[#235], https://github.com/CS2113-AY1819S1-F10-3/main/pull/242[#242]
** Documentation:
*** Added user stories relevant to our project in the Developer Guide: https://github.com/CS2113-AY1819S1-F10-3/main/pull/4[#4]
*** Added use cases for features implemented in the Developer Guide: https://github.com/CS2113-AY1819S1-F10-3/main/pull/111[#111]
Expand Down
11 changes: 11 additions & 0 deletions src/seedu/addressbook/autocorrect/AutoCorrect.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

import static seedu.addressbook.common.Messages.MESSAGE_INVALID_COMMAND_FORMAT;

import java.util.logging.Logger;

import seedu.addressbook.commands.AddCommand;
import seedu.addressbook.commands.CheckCommand;
import seedu.addressbook.commands.CheckPoStatusCommand;
Expand All @@ -25,12 +27,15 @@
import seedu.addressbook.commands.ShutdownCommand;
import seedu.addressbook.commands.UpdateStatusCommand;
import seedu.addressbook.commands.ViewAllCommand;
import seedu.addressbook.parser.Parser;
import seedu.addressbook.password.Password;


/**
* Checks if the invalid command has a prediction and returns the valid format for using the command
*/
public class AutoCorrect {
private static final Logger logger = Logger.getLogger(AutoCorrect.class.getName());

private CheckDistance checker = new CheckDistance();

Expand All @@ -42,6 +47,7 @@ public class AutoCorrect {
* @return The command
*/
public static String getCommand(String userInput) {
setupLogger();
String[] arr = userInput.split(" ", 2);
return arr[0];
}
Expand All @@ -56,7 +62,12 @@ public static String getInvalidCommandMessage(boolean isHqpFlag) {
}
}

private static void setupLogger() {
Parser.setupLoggerForAll(logger);
}

public String getResultOfInvalidCommand(String userInput) {
setupLogger();
boolean isHqpFlag = Password.isHqpUser();
String command = checkCommand(userInput, isHqpFlag);
String output = checker.checkDistance(userInput);
Expand Down
14 changes: 14 additions & 0 deletions src/seedu/addressbook/autocorrect/CheckDistance.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@
package seedu.addressbook.autocorrect;

import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;

import seedu.addressbook.commands.Dictionary;
import seedu.addressbook.parser.Parser;

/**
* Checks the number of single character changes required to convert one string to another.
*/
public class CheckDistance {

private static final Logger logger = Logger.getLogger(CheckDistance.class.getName());

private Dictionary dictionary = new Dictionary();

private ArrayList<String> commandsList = Dictionary.getCommands();
Expand All @@ -18,12 +23,19 @@ public class CheckDistance {

private String prediction = "none";

private static void setupLogger() {
Parser.setupLoggerForAll(logger);
}

/**
* Checks distance for invalid commands
* @param commandInput The invalid input command
* @return The prediction if found
*/
public String checkDistance(String commandInput) {
setupLogger();
logger.log(Level.INFO, "Checking distance of input command from valid inputs");

int distance;
for (String command : commandsList) {
distance = EditDistance.computeDistance(commandInput, command);
Expand All @@ -42,6 +54,8 @@ public String checkDistance(String commandInput) {
* @return The prediction if found
*/
public String checkInputDistance(String input) {
logger.log(Level.INFO, "Checking distance of inputted NRIC from existing NRICs");

int distance;
for (String nric : detailsList) {
distance = EditDistance.computeDistance(input, nric);
Expand Down
13 changes: 12 additions & 1 deletion src/seedu/addressbook/commands/Dictionary.java
Original file line number Diff line number Diff line change
@@ -1,30 +1,37 @@
//@@author ShreyasKp
package seedu.addressbook.commands;
import static seedu.addressbook.parser.Parser.setupLoggerForAll;

import java.util.ArrayList;
import java.util.Collections;
import java.util.logging.Level;
import java.util.logging.Logger;

import seedu.addressbook.data.AddressBook;
import seedu.addressbook.data.person.ReadOnlyPerson;
import seedu.addressbook.storage.StorageFile;



/**
* Stores all the COMMANDS to be compared with for autocorrect function.
*/
public class Dictionary extends Command {
private static final ArrayList<String> COMMANDS = new ArrayList<>();

private static final Logger logger = Logger.getLogger(Dictionary.class.getName());

private ArrayList<String> details = new ArrayList<>();
private AddressBook addressBook;

public Dictionary() {
setupLogger();
try {
StorageFile storage = new StorageFile();
this.addressBook = storage.load();
logger.log(Level.INFO, "Accessed addressbook succesfully");
} catch (Exception e) {
//This constructor is only used to access the addressbook, and thus will never throw an exception
logger.severe("Couldn't load addressbook");
} finally {
COMMANDS.add(AddCommand.COMMAND_WORD);
COMMANDS.add(CheckCommand.COMMAND_WORD);
Expand All @@ -49,6 +56,10 @@ public Dictionary() {
}
}

private void setupLogger() {
setupLoggerForAll(logger);
}

String getErrorMessage() {
return "Did you mean to use %s?"
+ "\n" + "Please try using the correct implementation of the input as shown below-";
Expand Down

0 comments on commit 61eef51

Please sign in to comment.