Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/AY2122S1-CS2103T-T17-3/tp
Browse files Browse the repository at this point in the history
…into update-PC
  • Loading branch information
CrownKira committed Oct 13, 2021
2 parents b3b0af4 + 2c7bcd8 commit 4ccb615
Show file tree
Hide file tree
Showing 20 changed files with 100 additions and 114 deletions.
89 changes: 37 additions & 52 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,16 @@ Finding your next lead has never been easier.
* [Features](#features)
* [Create new contact: create](#create-new-contact--create)
* [Retrieve particular contact: view](#retrieve-particular-contact--view)
* [Update existing contact: update](#update-existing-contact--update)
* [Update existing contact: edit](#update-existing-contact--edit)
* [Delete particular contact: delete](#delete-particular-contact--delete)
* [List all contacts](#list-all-contacts--list)
* [List all contacts: list](#list-all-contacts--list)
* [Clearing all entries: clear](#clearing-all-entries--clear)
* [Sort Contacts: sort](#sort-contacts--sort)
* [Locating person by name: find](#locating-clients-by-keywords--find)
* [Locating clients by keywords](#locating-clients-by-keywords--search)
* [Filter current list](#filter-current-list-by-keywords--filter)
* [Locating clients by keywords: search](#locating-clients-by-keywords--search)
* [Filter current list: filter](#filter-current-list-by-keywords--filter)
* [Exiting the program: exit](#exiting-the-program--exit)
* [Saving data](#saving-the-data)
* [Edit data file](#editing-data-file)
* [Edit data file](#edit-data-file)
* [FAQ](#faq)
* [Command Summary](#command-summary)

Expand All @@ -46,7 +45,7 @@ Finding your next lead has never been easier.

* **`list`** : Lists all contacts.

* **`add`**`n/John Doe p/98765432 e/johnd@example.com a/John street, block 123, #01-01` : Adds a contact named `John Doe` to the Address Book.
* **`create`**`n/John Doe p/98765432 e/johnd@example.com a/John street, block 123, #01-01` : Creates a contact named `John Doe` to the Address Book.

* **`delete`**`3` : Deletes the 3rd contact shown in the current list.

Expand All @@ -64,14 +63,15 @@ Every client that is registered in LeadsForce have the following attributes that

Client Attribute | Type of Attribute | Argument Tag
-----------------|-----------------|-----------------
Client ID (**unique**) | integer | None. Assigned on creation of new contact
Name (**Compulsory**) | String | name/
Email (**Compulsory**)| String (email address)| email/
Contact number | Integer (8 digits long)| contact/
Risk appetite | Integer from 1-5, <br>where 1 is very low risk tolerance and 5 is very high risk tolerance| risk-appetite/
Last met/contacted | Date | last-met/
Current financial plans | List of Strings | current-plans-add/<br>current-plans-remove/
Disposable Income | Integer | disposable-income/
Client ID (**unique**) | integer | i/. Assigned on creation of new contact
Name (**Compulsory**) | String | n/
Email (**Compulsory**)| String (email address)| e/
Contact number | Integer (8 digits long)| p/
Risk appetite | Integer from 1-5, <br>where 1 is very low risk tolerance and 5 is very high risk tolerance| r/
Last met/contacted | Date | l/
Current financial plans | List of Strings | c/
Disposable Income | Integer | d/
Address | String | a/



Expand All @@ -90,7 +90,7 @@ Disposable Income | Integer | disposable-income/

* Inputs with ``​ at the end refers to inputs that can be used multiple times in that command
.<br>
e.g. `[/tag ATTRIBUTE]…​` can be in the form of `/email @gmail.com` or `/email @gmail.com /risk-appetite 5`
e.g. `[tag/ATTRIBUTE]…​` can be in the form of `e/@gmail.com` or `e/@gmail.com r/5`
</div>


Expand All @@ -105,8 +105,8 @@ Format: `create {client’s name} <email>/{email} <phone-no>/{phone number} <ris
* Tags that can be added are as seen in the client information in the Client Info Section

Examples:
* `create Benedict Chua email/benchua@hotmail.com`
* `create Keith email/keithtan@ymail.com phone-no/12345678 risk-appetite/4`
* `create Benedict Chua e/benchua@hotmail.com`
* `create Keith e/keithtan@ymail.com p/12345678 r/4`


### Retrieve Particular Contact : `view`
Expand All @@ -117,9 +117,9 @@ Format: `view {client’s id number}`

Example: `view 2` would be used to view client 2's information

### Update Existing Contact : `update`
### Update Existing Contact : `edit`

Update the information of existing users by using the “update” command. This can be used to change the
Update the information of existing users by using the “edit” command. This can be used to change the
attributes of a client, using the tag of the client’s attribute.

* Multiple attributes could be changed with one command.
Expand All @@ -128,8 +128,8 @@ Format: `update {Client’s id number} <attribute>/{changed value of attribute}

Examples:

* `update 15 name/Dominic` command changes the name of client 15 to “Dominic”.
* `update 3 contact-number/12345678 risk-appetite/5` command changes the contact number to “12345678” and
* `update 15 n/Dominic` command changes the name of client 15 to “Dominic”.
* `update 3 p/12345678 r/5` command changes the contact number to “12345678” and
the risk appetite to 5 for the client who’s id number is 3.

### Delete particular contact : `delete`
Expand All @@ -138,12 +138,12 @@ Deletes an existing client from the address book using any specified attribute t

Format: `delete <attribute>/{value}`

* Attributes would be limited to client id, email or contact number.
* It is possible to bulk delete multiple clients by inputting multiple keys separated by ‘,’.
* Attributes would be limited to client id, email or both.

Examples:
* `delete id/4,6,7`(deletes clients with client id 4, client id 6 and client 7)
* `delete email/keithtan@gmail.com`(deletes a client whose email address is keithtan@gmail.com)
* `delete i/7`(deletes client with client id 7)
* `delete e/keithtan@gmail.com`(deletes the client whose email address is keithtan@gmail.com)
* `delete i/4 e/johndoe@gmail.com`(deletes the client whose client id is 4 and email address is johndoe@gmail.com)

### List all contacts : `list`

Expand All @@ -156,29 +156,14 @@ Format: `list`

Sorts clients in order based off the inputted attribute

Format: `sort <attribute>/{ASC/DESC}`
Format: `sort <attribute>/{ASC/DSC}`

* The asc and desc tag dictates whether filtered client list is sorted in ascending or descending order
* The asc and dsc tag dictates whether filtered client list is sorted in ascending or descending order.
* The tags are case-insensitive. (ASC are asc both okay.)

Examples:
* `sort risk-appetite/ASC`

### Locating persons by name: `find`

Finds persons whose names contain any of the given keywords.

Format: `find KEYWORD [MORE_KEYWORDS]...`

* The search is case-insensitive. e.g `hans` will match `Hans`
* The order of the keywords does not matter. e.g. `Hans Bo` will match `Bo Hans`
* Only the name is searched.
* Only full words will be matched e.g. `Han` will not match `Hans`
* Persons matching at least one keyword will be returned (i.e. `OR` search).
e.g. `Hans Bo` will return `Hans Gruber`, `Bo Yang`

Examples:
* `find John` returns `john` and `John Doe`
* `find alex david` returns `Alex Yeoh`, `David Li`
* `sort r/ASC` will sort the list by ascending risk-appetite
* `sort i/dsc` will sort the list by descending client id

### Locating clients by keywords : `search`

Expand Down Expand Up @@ -260,13 +245,13 @@ If your changes to the data file makes its format invalid, AddressBook will disc

Action | Format | Examples
--------|---------|---------
**Create** | `create {client’s name} <email>/{email} <phone-no>/{phone number} <risk-appetite>/{risk appetite}`| create benedict email/benedict@gmail.com phone-no/90909898 risk-appetite/3 |
**Create** | `create {client’s name} <email>/{email} <phone-no>/{phone number} <risk-appetite>/{risk appetite}`| create benedict e/benedict@gmail.com p/90909898 r/3 |
**View** | `view {client’s id number}` | view 123 |
**Delete** | `delete <attribute>/{value}` | delete id/4,6,7 |
**Update** | `update {Client’s id number} <attribute>/{change value of attribute}` | update 1234 name/Dominic phone-number/12345678 |
**Delete** | `delete <attribute>/{value}` | delete i/4 |
**Edit** | `update {Client’s id number} <attribute>/{change value of attribute}` | update 1234 n/Dominic p/12345678 |
**List** | `list` | - |
**Find** | `find KEYWORD [OTHER_KEYWORD]` | find alex tom |
**Search** | `search [KEYWORD]... [ATTRIBUTE/ATTRIBUTE_KEYWORD]...` | search * email/doe@gmail.com risk-appetite/5 |
**Filter** | `filter KEYWORD [OTHER_KEYWORD] [ATTRIBUTE/ATTRIBUTE_KEYWORD]...` | search * email/doe@gmail.com p/9 |
**Sort** | `sort <attribute>/{ASC/DESC}` | sort risk-appetite/asc |
**Search** | `search [KEYWORD]... [ATTRIBUTE/ATTRIBUTE_KEYWORD]...` | search * e/doe@gmail.com r/5 |
**Filter** | `filter KEYWORD [OTHER_KEYWORD] [ATTRIBUTE/ATTRIBUTE_KEYWORD]...` | search * e/doe@gmail.com p/9 |
**Sort** | `sort <attribute>/{ASC/DESC}` | sort r/asc |
**Exit** | `exit` | - |
6 changes: 3 additions & 3 deletions src/main/java/seedu/address/logic/commands/DeleteCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import static seedu.address.logic.parser.CliSyntax.PREFIX_CLIENTID;
import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Predicate;

import seedu.address.logic.commands.exceptions.CommandException;
Expand All @@ -31,9 +31,9 @@ public class DeleteCommand extends Command {
public static final String MESSAGE_DELETE_PERSON_SUCCESS = "Deleted Person: %1$s";
public static final String MESSAGE_DELETE_PERSON_FAILURE = "Person not found in list";

private final ArrayList<Predicate> predicates;
private final List<Predicate<Person>> predicates;

public DeleteCommand(ArrayList<Predicate> predicates) {
public DeleteCommand(List<Predicate<Person>> predicates) {
this.predicates = predicates;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import static java.util.Objects.requireNonNull;
import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS;
import static seedu.address.logic.parser.CliSyntax.PREFIX_CLIENTID;
import static seedu.address.logic.parser.CliSyntax.PREFIX_CURRENTPLAN;
import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL;
import static seedu.address.logic.parser.CliSyntax.PREFIX_LASTMET;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.person.ClientId;
import seedu.address.model.person.Email;
import seedu.address.model.person.Person;
import seedu.address.model.person.PersonHasEmail;
import seedu.address.model.person.PersonHasId;

Expand Down Expand Up @@ -52,7 +53,7 @@ public DeleteCommand parse(String args) throws ParseException {
throw new ParseException(String.format(Messages.MESSAGE_TOO_MANY_FIELDS, DeleteCommand.MESSAGE_USAGE));
}

ArrayList<Predicate> predicatesToDelete = new ArrayList<>();
ArrayList<Predicate<Person>> predicatesToDelete = new ArrayList<>();
String clientIdString = argMultimap.getValue(PREFIX_CLIENTID).orElse("");
if (!clientIdString.isEmpty()) {
ClientId clientId = ParserUtil.parseClientId(clientIdString);
Expand All @@ -69,14 +70,6 @@ public DeleteCommand parse(String args) throws ParseException {

}

/**
* Returns true if none of the prefixes contains empty {@code Optional} values in the given
* {@code ArgumentMultimap}.
*/
private static boolean arePrefixesPresent(ArgumentMultimap argumentMultimap, Prefix... prefixes) {
return Stream.of(prefixes).allMatch(prefix -> argumentMultimap.getValue(prefix).isPresent());
}

/**
* Returns true if any of the prefixes contains empty {@code Optional} values in the given
* {@code ArgumentMultimap}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import java.util.Optional;
import java.util.Set;

import seedu.address.commons.core.index.Index;
import seedu.address.logic.commands.EditCommand;
import seedu.address.logic.commands.EditCommand.EditPersonDescriptor;
import seedu.address.logic.parser.exceptions.ParseException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
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_CURRENTPLAN;
import static seedu.address.logic.parser.CliSyntax.PREFIX_DISPOSABLEINCOME;
import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL;
import static seedu.address.logic.parser.CliSyntax.PREFIX_LASTMET;
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_RISKAPPETITE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG;

import seedu.address.logic.commands.FilterCommand;
Expand All @@ -30,8 +32,8 @@ public FilterCommand parse(String args) throws ParseException {
// appends " " in front as Filter Command can accept arguments without a preamble
String preparedArgs = " ".concat(trimmedArgs);
ArgumentMultimap argMultimap = ArgumentTokenizer
.tokenize(preparedArgs, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS,
PREFIX_LASTMET, PREFIX_CURRENTPLAN, PREFIX_TAG);
.tokenize(preparedArgs, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS, PREFIX_RISKAPPETITE,
PREFIX_DISPOSABLEINCOME, PREFIX_LASTMET, PREFIX_CURRENTPLAN, PREFIX_TAG);
return new FilterCommand(new PersonContainsKeywordsPredicate(argMultimap));
}
}
13 changes: 0 additions & 13 deletions src/main/java/seedu/address/logic/parser/ParserUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,6 @@ public static ClientId parseClientId(String clientId) throws ParseException {
}
return new ClientId(trimmedId);
}
/**
* Parses {@code clientId} into an {@code Index} and returns it. Leading and trailing whitespaces will be
* trimmed.
*
* @throws ParseException if the specified index is invalid (not non-zero unsigned integer).
*/
public static Index parseClientIndex(String clientId) throws ParseException {
String trimmedIndex = clientId.trim();
if (!StringUtil.isNonZeroUnsignedInteger(trimmedIndex)) {
throw new ParseException(MESSAGE_INVALID_INDEX);
}
return Index.fromZeroBased(Integer.parseInt(trimmedIndex));
}

/**
* Parses a {@code String name} into a {@code Name}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@

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_CURRENTPLAN;
import static seedu.address.logic.parser.CliSyntax.PREFIX_DISPOSABLEINCOME;
import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL;
import static seedu.address.logic.parser.CliSyntax.PREFIX_LASTMET;
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_RISKAPPETITE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG;

import seedu.address.logic.commands.SearchCommand;
Expand All @@ -31,7 +35,8 @@ public SearchCommand parse(String args) throws ParseException {
// appends " " in front as Search Command can accept arguments without a preamble
String preparedArgs = " ".concat(trimmedArgs);
ArgumentMultimap argMultimap = ArgumentTokenizer
.tokenize(preparedArgs, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS, PREFIX_TAG);
.tokenize(preparedArgs, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS, PREFIX_RISKAPPETITE,
PREFIX_DISPOSABLEINCOME, PREFIX_LASTMET, PREFIX_CURRENTPLAN, PREFIX_TAG);
return new SearchCommand(new PersonContainsKeywordsPredicate(argMultimap));
}

Expand Down
3 changes: 1 addition & 2 deletions src/main/java/seedu/address/model/AddressBook.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import static java.util.Objects.requireNonNull;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Predicate;

Expand Down Expand Up @@ -152,7 +151,7 @@ public void removePerson(Person key) {
* Removes person with matching {@code clientId} and {@code email} from this {@code AddressBook}.
* Person with {@code clientId} and {@code email} must exist in the address book.
*/
public Person removePersonByFields(ArrayList<Predicate> predicates) {
public Person removePersonByFields(List<Predicate<Person>> predicates) {
return persons.removeByFields(predicates);
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/seedu/address/model/Model.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package seedu.address.model;

import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Predicate;

import javafx.collections.ObservableList;
Expand Down Expand Up @@ -73,7 +73,7 @@ public interface Model {
/**
* Deletes the person with the matching Client ID and Email and returns the deleted person
*/
Person deletePersonByFields(ArrayList<Predicate> predicates);
Person deletePersonByFields(List<Predicate<Person>> predicates);

/**
* Adds the given person.
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/seedu/address/model/ModelManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import static seedu.address.commons.util.CollectionUtil.requireAllNonNull;

import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Predicate;
import java.util.logging.Logger;

Expand Down Expand Up @@ -110,7 +110,7 @@ public void deletePerson(Person target) {
}

@Override
public Person deletePersonByFields(ArrayList<Predicate> predicates) {
public Person deletePersonByFields(List<Predicate<Person>> predicates) {
return addressBook.removePersonByFields(predicates);
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/model/ReadOnlyAddressBook.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public interface ReadOnlyAddressBook {
* Sets the target {@code target} in the addressBook to {@code editperson}.
*/
void setPerson(Person target, Person editedPerson);

/**
* Returns the person with {@code clientId}
*/
Expand Down
Loading

0 comments on commit 4ccb615

Please sign in to comment.