Skip to content

Commit

Permalink
Merge branch 'master' into user-guide
Browse files Browse the repository at this point in the history
  • Loading branch information
pjanthony2001 authored Apr 15, 2024
2 parents 732793e + e49a653 commit d27c9d0
Show file tree
Hide file tree
Showing 18 changed files with 169 additions and 317 deletions.
24 changes: 14 additions & 10 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,16 +290,20 @@ _{Explain here how the data archiving feature will be implemented}_

Priorities: High (must have) - `* * *`, Medium (nice to have) - `* *`, Low (unlikely to have) - `*`

| Priority | As a …​ | I want to …​ | So that I can…​ |
|----------|---------------------------------|------------------------------|------------------------------------------------------------------------|
| `* * *` | social worker | see usage instructions | refer to instructions when I forget how to use the App |
| `* * *` | social worker | create a new client | keep track of their information efficiently |
| `* * *` | social worker | delete a client | remove client entries that I no longer need |
| `* * *` | social worker | find a client by name | locate details of clients without having to go through the entire list |
| `* *` | social worker | hide private contact details | minimize chance of someone else seeing them by accident |
| `*` | social worker with many clients | sort persons by name | locate a person easily |
| `*` | social worker with colleagues | switch between profiles | manage my own set of clients on the same machine |
| `*` | social worker | undo and redo my commands | easily rectify a mistaken command |
| Priority | As a …​ | I want to …​ | So that I can…​ |
|----------|---------------------------------|------------------------------|------------------------------------------------------------------------------|
| `* * *` | social worker | see usage instructions | refer to instructions when I forget how to use the App |
| `* * *` | social worker | create a new client | keep track of their information efficiently |
| `* * *` | social worker | delete a client | remove client entries that I no longer need |
| `* * *` | social worker | find a client by name | locate details of clients without having to go through the entire list |
| `* * *` | social worker | view a client's information | review and prepare for upcoming appointments |
| `* * *` | social worker | take notes during meetings | document clients' needs and concerns |
| `* * *` | social worker | schedule meetings | keep track of all appointments and ensure there are no scheduling conflicts |
| `* * *` | social worker | delete meetings | remove meetings that have been cancelled or completed |
| `* *` | social worker | hide private contact details | minimize chance of someone else seeing them by accident |
| `*` | social worker with many clients | sort persons by name | locate a person easily |
| `*` | social worker with colleagues | switch between profiles | manage my own set of clients on the same machine |
| `*` | social worker | undo and redo my commands | easily rectify a mistaken command |

*{More to be added}*

Expand Down
12 changes: 6 additions & 6 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -501,22 +501,22 @@ _This command allows you to view a client's information in a more detailed manne
<panel header="Parameter Descriptions and Remarks" alt="Parameters" minimized>
<markdown>

| Parameter | Description | Remarks |
|-----------|----------------------------------------|------------------------------------------|
| NAME | Name of the client you want to display | Name must be present in the client list |
| Parameter | Description | Remarks |
|-----------|---------------------------------------------|------------------------------------------|
| NAME | Full name of the client you want to display | Name must be present in the client list |
</markdown>
</panel>

&nbsp;

**Examples:**

`display Peter` would display all of Peter's information as a contact card on the application.
`display Peter Crouch` would display all of Peter's information as a contact card on the application.

**Walkthrough:**

The screenshots below are what you would expect when using the `display` command. In this example, after using the `list` command,
the full clients list is displayed. Thereafter, the `display Peter` command was used, displaying Peter. The cursor automatically moves
the full clients list is displayed. Thereafter, the `display Peter Crouch` command was used, displaying Peter. The cursor automatically moves
to the description box, allowing you to make changes to Peter's details. After making the necessary changes, hit enter. The details will be updated
and you will be redirected back to the home page with the clients list. At no stage do you need to reach for the mouse!

Expand Down Expand Up @@ -574,7 +574,7 @@ _This command allows you to add an appointment with the specified parameters._

Once the command is entered, the event should be added to the events panel on the right of the application.

### Deleting Appointments: `schedule delete`
### Deleting Appointments : `schedule delete`

_This command allows you to remove an appointment with the specified parameters._

Expand Down
11 changes: 11 additions & 0 deletions src/main/java/seedu/address/history/BufferedHistory.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package seedu.address.history;

import seedu.address.history.exceptions.HistoryException;

/**
* The `BufferedHistory` class manages the history of states in the ConnectCare application, with a buffer.
* It allows for rolling back and rolling forward to previous states.
*/
public interface BufferedHistory<T> extends History<T> {
public T getCurrStateHasBuffer() throws HistoryException;
}
40 changes: 40 additions & 0 deletions src/main/java/seedu/address/history/BufferedHistoryManager.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package seedu.address.history;

import seedu.address.history.exceptions.HistoryException;

/**
* @param <T> The type of state that the abstract class keeps track of
*/
public class BufferedHistoryManager<T> extends HistoryManager<T> implements BufferedHistory<T> {

/**
* Constructs a new HistoryManager with a starting state.
*
* @param startState The initial state of the history.
*/
public BufferedHistoryManager(T startState) {
super(startState);
}

@Override
public void addState(T state) {
pullForwardPointer();
T buffer = states.get(states.size() - 1);
states.remove(states.size() - 1);
states.add(state);
states.add(buffer);
currStateIdx++;
}

private void pullForwardPointer() {
currStateIdx = states.size() - 1;
}

@Override
public T getCurrStateHasBuffer() throws HistoryException {
if (currStateIdx == states.size() - 1) {
throw new HistoryException("Cannot read from buffer");
}
return states.get(currStateIdx);
}
}
2 changes: 0 additions & 2 deletions src/main/java/seedu/address/history/History.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,4 @@ public interface History<T> {
* @return The current state.
*/
T getCurrState();

T getCurrStateHasBuffer() throws HistoryException;
}
36 changes: 6 additions & 30 deletions src/main/java/seedu/address/history/HistoryManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,18 @@
* @param <T> The type of state that the abstract class keeps track of
*/
public class HistoryManager<T> implements History<T> {
private int currStateIdx;
private final ArrayList<T> states;
private boolean hasBuffer;
protected int currStateIdx;
protected final ArrayList<T> states;

/**
* Constructs a new HistoryManager with a starting state.
*
* @param startState The initial state of the history.
*/
public HistoryManager(T startState, boolean hasBuffer) {
public HistoryManager(T startState) {
states = new ArrayList<>();
currStateIdx = 0;
states.add(startState);
this.hasBuffer = hasBuffer;
}

/**
Expand Down Expand Up @@ -50,7 +48,6 @@ public void rollBackState() throws HistoryException {
*/
@Override
public void rollForwardState() throws HistoryException {
int boundary = hasBuffer ? states.size() - 2 : states.size() - 1;
if (currStateIdx >= states.size() - 1) {
throw new HistoryException("You can't roll forward the state anymore!");
}
Expand All @@ -64,18 +61,9 @@ public void rollForwardState() throws HistoryException {
*/
@Override
public void addState(T state) {
if (hasBuffer) {
pullForwardPointer();
T buffer = states.get(states.size() - 1);
states.remove(states.size() - 1);
states.add(state);
states.add(buffer);
currStateIdx++;
} else {
truncate();
states.add(state);
currStateIdx += 1;
}
truncate();
states.add(state);
currStateIdx += 1;
}

/**
Expand All @@ -87,16 +75,4 @@ public void addState(T state) {
public T getCurrState() {
return states.get(currStateIdx);
}

private void pullForwardPointer() {
currStateIdx = states.size() - 1;
}

@Override
public T getCurrStateHasBuffer() throws HistoryException {
if (hasBuffer && currStateIdx == states.size() - 1) {
throw new HistoryException("Cannot read from buffer");
}
return states.get(currStateIdx);
}
}
35 changes: 6 additions & 29 deletions src/main/java/seedu/address/logic/commands/FindCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,8 @@
import seedu.address.commons.util.ToStringBuilder;
import seedu.address.logic.Messages;
import seedu.address.model.Model;
import seedu.address.model.person.AddressContainsKeywordsPredicate;
import seedu.address.model.person.DescriptionContainsKeywordsPredicate;
import seedu.address.model.person.EmailContainsKeywordsPredicate;
import seedu.address.model.person.KinContainsKeywordsPredicate;
import seedu.address.model.person.NameContainsKeywordsPredicate;
import seedu.address.model.person.KeywordMatcherPredicate;
import seedu.address.model.person.Person;
import seedu.address.model.person.PhoneContainsKeywordsPredicate;
import seedu.address.model.person.TagContainsKeywordsPredicate;

/**
* Finds and lists all persons in address book whose name contains any of the
* argument keywords.
Expand All @@ -42,29 +35,13 @@ public class FindCommand extends Command {

/**
* Constructor for FindCommand
* @param namePredicate
* @param phonePredicate
* @param addressPredicate
* @param emailPredicate
* @param tagPredicate
* @param kinPredicate
* @param descriptionPredicate
*/
public FindCommand(NameContainsKeywordsPredicate namePredicate, PhoneContainsKeywordsPredicate phonePredicate,
AddressContainsKeywordsPredicate addressPredicate, EmailContainsKeywordsPredicate emailPredicate,
TagContainsKeywordsPredicate tagPredicate, KinContainsKeywordsPredicate kinPredicate,
DescriptionContainsKeywordsPredicate descriptionPredicate) {
public FindCommand(KeywordMatcherPredicate... predicates) {
super.setReversible(true);
requireNonNull(namePredicate);
requireNonNull(namePredicate);
requireNonNull(phonePredicate);
requireNonNull(addressPredicate);
requireNonNull(emailPredicate);
requireNonNull(tagPredicate);
requireNonNull(kinPredicate);
requireNonNull(descriptionPredicate);
predicates = Arrays.asList(namePredicate, phonePredicate, addressPredicate,
emailPredicate, tagPredicate, kinPredicate, descriptionPredicate);
for (KeywordMatcherPredicate predicate : predicates) {
requireNonNull(predicate);
}
this.predicates = Arrays.asList(predicates);
}

@Override
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/seedu/address/model/ModelManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import seedu.address.commons.core.GuiSettings;
import seedu.address.commons.core.LogsCenter;
import seedu.address.commons.exceptions.IllegalValueException;
import seedu.address.history.BufferedHistory;
import seedu.address.history.BufferedHistoryManager;
import seedu.address.history.CommandState;
import seedu.address.history.History;
import seedu.address.history.HistoryManager;
Expand All @@ -35,7 +37,7 @@ public class ModelManager implements Model {
private FilteredList<Person> filteredPersons;
private ObservableList<Person> source;
private final History<ModelState> modelHistory;
private final History<CommandState> commandHistory;
private final BufferedHistory<CommandState> commandHistory;

/**
* Initializes a ModelManager with the given addressBook and userPrefs.
Expand Down Expand Up @@ -63,8 +65,8 @@ public ModelManager(ReadOnlyAddressBook addressBook, ReadOnlyUserPrefs userPrefs
PREDICATE_SHOW_ALL_PERSONS, calendar);
}
startCommandState = generateCommandState(getStartCommand().getCommandString());
this.modelHistory = new HistoryManager<>(startModelState, false);
this.commandHistory = new HistoryManager<>(startCommandState, true);
this.modelHistory = new HistoryManager<>(startModelState);
this.commandHistory = new BufferedHistoryManager<>(startCommandState);
}

public ModelManager() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,49 +1,18 @@
package seedu.address.model.person;

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

import seedu.address.commons.util.StringUtil;
import seedu.address.commons.util.ToStringBuilder;

/**
* Tests that a {@code Person}'s {@code Address} matches any of the keywords given.
*/
public class AddressContainsKeywordsPredicate implements Predicate<Person> {
private final List<String> keywords;
public class AddressContainsKeywordsPredicate extends KeywordMatcherPredicate {

public AddressContainsKeywordsPredicate(List<String> keywords) {
this.keywords = keywords;
super(keywords);
}

@Override
public boolean test(Person person) {
if (keywords.isEmpty()) {
return false;
}
boolean personmatches = keywords.stream()
.anyMatch(
keyword -> StringUtil.containsWordIgnoreCase(person.getAddress().get().toString(), keyword));
return personmatches;
}

@Override
public boolean equals(Object other) {
if (other == this) {
return true;
}

// instanceof handles nulls
if (!(other instanceof AddressContainsKeywordsPredicate)) {
return false;
}

AddressContainsKeywordsPredicate otherAddContainsKeywordsPredicate = (AddressContainsKeywordsPredicate) other;
return keywords.equals(otherAddContainsKeywordsPredicate.keywords);
}

@Override
public String toString() {
return new ToStringBuilder(this).add("keywords", keywords).toString();
return super.matchesKeywords(person.getAddress().get().toString());
}
}
Original file line number Diff line number Diff line change
@@ -1,50 +1,20 @@
package seedu.address.model.person;

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

import seedu.address.commons.util.StringUtil;
import seedu.address.commons.util.ToStringBuilder;

/**
* Tests that a {@code Person}'s {@code Description} matches any of the
* keywords given.
*/
public class DescriptionContainsKeywordsPredicate implements Predicate<Person> {
private final List<String> keywords;
public class DescriptionContainsKeywordsPredicate extends KeywordMatcherPredicate {

public DescriptionContainsKeywordsPredicate(List<String> keywords) {
this.keywords = keywords;
super(keywords);
}

@Override
public boolean test(Person person) {
if (keywords.isEmpty()) {
return false;
}
boolean personmatches = keywords.stream()
.anyMatch(
keyword -> StringUtil.containsWordIgnoreCase(person.getDescription().get().toString(), keyword));
return personmatches;
}

@Override
public boolean equals(Object other) {
if (other == this) {
return true;
}

// instanceof handles nulls
if (!(other instanceof DescriptionContainsKeywordsPredicate)) {
return false;
}

DescriptionContainsKeywordsPredicate otherDescPredicate = (DescriptionContainsKeywordsPredicate) other;
return keywords.equals(otherDescPredicate.keywords);
return super.matchesKeywords(person.getDescription().get().toString());
}

@Override
public String toString() {
return new ToStringBuilder(this).add("keywords", keywords).toString();
}
}
Loading

0 comments on commit d27c9d0

Please sign in to comment.