Skip to content

Commit

Permalink
Merge branch 'yanji1221-master'
Browse files Browse the repository at this point in the history
Stable version
  • Loading branch information
erik0704 committed Oct 21, 2017
2 parents d8ce88b + 87c6349 commit dfae714
Show file tree
Hide file tree
Showing 61 changed files with 559 additions and 211 deletions.
2 changes: 2 additions & 0 deletions docs/AboutUs.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,5 @@ image::yanji1221.png[width="150", align="left"]

Role: Developer +
Responsibility: UI

'''
50 changes: 37 additions & 13 deletions docs/DeveloperGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ endif::[]
ifdef::env-github,env-browser[:outfilesuffix: .adoc]
:repoURL: https://github.com/se-edu/addressbook-level4/tree/master

By: `Team SE-EDU`      Since: `Jun 2016`      Licence: `MIT`
By: `Team B4`      Since: `Jun 2016`      Licence: `MIT`

== Setting up

Expand Down Expand Up @@ -345,6 +345,30 @@ image::UndoRedoActivityDiagram.png[width="200"]
**Cons:** Requires dealing with commands that have already been undone: We must remember to skip these commands. Violates Single Responsibility Principle and Separation of Concerns as `HistoryManager` now needs to do two different things. +
// end::undoredo[]

=== Adding a Parameter in Add Command
To add a new parameter in AddCommand, UI, Logic, Model and Storage components are to be modified accordingly. +
Be aware of the inheritance between each component when implementing.
Refer to Section 2.1 to observe the relationship between those components.

* `UI Component:` +
PersonCard should be modified to include the new parameter so that it can be shown in the information of person.

* `Logic Component:` +
AddCommand and EditCommand are the two commands that should be modified to include new parameter.
Parser should be modified accordingly to parse the new parameter information. It is also to make sure that information is present before add command
is executed. Information being added should be parse to model to create persons if command format is correct.

* `Model Component:` +
Create a new class for new parameter so that it can be used under Person class. Person class uses ReadOnlyPerson interface.
Person Class is to collect and set all information about a particular person. If all parameters is parsed correctly, a person with
collected information will be created. +
The following diagram shows the relationship of different classes in model component:

image::ModelDiagramOf AddParameter.png[width="200"]

* `Storage Component:` +
To make sure that new parameter can be stored in the xml format for future usage, xmlAdaptedPerson is used to save information of a person in xml format.

=== Logging

We are using `java.util.logging` package for logging. The `LogsCenter` class is used to manage the logging levels and logging destinations.
Expand Down Expand Up @@ -430,14 +454,14 @@ public class AddressBookParser {
}
----

Whenever 'deleteList INDEX[MORE_INDICES]' is invoked, the input data 'INDEX[MORE_INDICES]' is stored in 'arguments', which is then passed to 'DeleteListCommandParser'. The parser will then parse 'arguments' into appropriate input data for 'DeleteListCommand' to execute the logic. The final state of address book is updated at the end of this execution.
Whenever 'deleteList INDEX[MORE_INDICES]' is invoked, the input data 'INDEX[MORE_INDICES]' is stored in 'arguments', which is then passed to 'DeleteListCommandParser'. The parser will then parse 'arguments' into appropriate input data for 'DeleteListCommand' to execute the logic. The final state of address book is updated at the end of this execution.

=== FindTag Command

The findTag command utilize the same implementation as the Find command for name. Instead of logic execute search via Name attribute of Person, the command search for the TagList attribute.

Name and Tag API structure is roughly similar that they allow to extract value of the object. The search algorithm utilize a class `TagContainsKeywordsPredicate implements Predicate<ReadOnlyPerson>`
which allows the algorithm to use Java `Predicate` class method.
which allows the algorithm to use Java `Predicate` class method.

=== Configuration

Expand Down Expand Up @@ -817,28 +841,28 @@ Priorities: High (must have) - `* * \*`, Medium (nice to have) - `* \*`, Low (un

|`* * *` |user |add birthday information |remember and keep track of my family members/friends birthday

|`* *` |user |hide link:#private-contact-detail[private contact details] by default |minimize chance of someone else seeing them by accident
|`* * *` |user |find persons whose names contain a partial string |locate person whose name I forgot how to spell

|`* *` |user |add profile photo |can double check the identity if there are persons with the same name
|`* * *` |user |find persons by tags |identify a group of people with common attributes

|`* *` |user |add multiple phone number to one person |store different contact number as one person may have more than one phone number
|`* * *` |undergraduate student user |add events related to one or multiple contacts such as birthday or meetings |keep track tasks I need to do

|`* *` |user |have some important contacts |reach to my close friends easily at a click
|`* *` |user |add or remove some tags of a contact |quickly update contact information

|`*` |user with many persons in the address book |sort persons by name |locate a person easily
|`* *` |user |hide link:#private-contact-detail[private contact details] by default |minimize chance of someone else seeing them by accident

|`* * *` |user |find persons by tags |identify a group of people with common attributes
|`* *` |user |add profile photo |can double check the identity if there are persons with the same name

|`* *` |user |add or remove some tags of a contact |quickly update contact information
|`* *` |user |add multiple phone number to one person |store different contact number as one person may have more than one phone number

|`* * *` |user |find persons whose names contain a partial string |locate person whose name I forgot how to spell
|`* *` |user |have some important contacts |reach to my close friends easily at a click

|`* *` |undergraduate student user |find persons by their address |identify which friends stay in the same campus

|`* * *` |undergraduate student user |add events related to one or multiple contacts such as birthday or meetings |keep track tasks I need to do

|`* *` |undergraduate student user |have a reminder pop up when an event is coming up |remember to prepare and fulfill my responsibility

|`*` |user with many persons in the address book |sort persons by name |locate a person easily

|=======================================================================

{More to be added}
Expand Down
Binary file added docs/images/ModelDiagramOfAddParameter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/main/java/seedu/address/logic/commands/AddCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static java.util.Objects.requireNonNull;
import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS;
import static seedu.address.logic.parser.CliSyntax.PREFIX_BIRTHDAY;
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;
Expand All @@ -24,12 +25,14 @@ public class AddCommand extends UndoableCommand {
+ PREFIX_NAME + "NAME "
+ PREFIX_PHONE + "PHONE "
+ PREFIX_EMAIL + "EMAIL "
+ PREFIX_BIRTHDAY + "BIRTHDAY "
+ PREFIX_ADDRESS + "ADDRESS "
+ "[" + PREFIX_TAG + "TAG]...\n"
+ "Example: " + COMMAND_WORD + " "
+ PREFIX_NAME + "John Doe "
+ PREFIX_PHONE + "98765432 "
+ PREFIX_EMAIL + "[email protected] "
+ PREFIX_BIRTHDAY + "1995/11/03 "
+ PREFIX_ADDRESS + "311, Clementi Ave 2, #02-25 "
+ PREFIX_TAG + "friends "
+ PREFIX_TAG + "owesMoney";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package seedu.address.logic.commands;

import static java.util.Objects.requireNonNull;
import static seedu.address.logic.parser.CliSyntax.*;
import static seedu.address.logic.parser.CliSyntax.PREFIX_DATE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_DESCRIPTION;
import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME;

import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.event.Event;
import seedu.address.model.event.exceptions.DuplicateEventException;
Expand Down Expand Up @@ -51,4 +54,5 @@ public boolean equals(Object other) {
|| (other instanceof AddEventCommand // instanceof handles nulls
&& toAdd.equals(((AddEventCommand) other).toAdd));
}
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package seedu.address.logic.commands;

import java.util.*;
import java.util.ArrayList;
import java.util.List;

import seedu.address.commons.core.Messages;
import seedu.address.commons.core.index.Index;
Expand Down Expand Up @@ -33,20 +34,20 @@ public DeleteListCommand(List<Index> listTargetIndices) {
public CommandResult executeUndoableCommand() throws CommandException {

List<ReadOnlyPerson> lastShownList = model.getFilteredPersonList();
for(Index targetIndex: listTargetIndices) {
for (Index targetIndex: listTargetIndices) {
if (targetIndex.getZeroBased() >= lastShownList.size()) {
throw new CommandException(Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX);
}
}

List<ReadOnlyPerson> listPersonsToDelete= new ArrayList<ReadOnlyPerson>();
for(Index targetIndex: listTargetIndices) {
List<ReadOnlyPerson> listPersonsToDelete = new ArrayList<ReadOnlyPerson>();
for (Index targetIndex: listTargetIndices) {
ReadOnlyPerson personToDelete = lastShownList.get(targetIndex.getZeroBased());
listPersonsToDelete.add(personToDelete);
}

try {
for(ReadOnlyPerson personToDelete: listPersonsToDelete) {
for (ReadOnlyPerson personToDelete: listPersonsToDelete) {
model.deletePerson(personToDelete);
}
} catch (PersonNotFoundException pnfe) {
Expand All @@ -61,6 +62,7 @@ public boolean equals(Object other) {
return other == this // short circuit if same object
|| (other instanceof DeleteCommand // instanceof handles nulls
&& (this.listTargetIndices.containsAll(((DeleteListCommand) other).listTargetIndices)
&& ((DeleteListCommand) other).listTargetIndices.containsAll(this.listTargetIndices) )); // state check
&& ((DeleteListCommand)other).listTargetIndices
.containsAll(this.listTargetIndices))); // state check
}
}
20 changes: 18 additions & 2 deletions src/main/java/seedu/address/logic/commands/EditCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static java.util.Objects.requireNonNull;
import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS;
import static seedu.address.logic.parser.CliSyntax.PREFIX_BIRTHDAY;
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;
Expand All @@ -17,6 +18,7 @@
import seedu.address.commons.util.CollectionUtil;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.person.Address;
import seedu.address.model.person.Birthday;
import seedu.address.model.person.Email;
import seedu.address.model.person.Name;
import seedu.address.model.person.Person;
Expand All @@ -40,6 +42,7 @@ public class EditCommand extends UndoableCommand {
+ "[" + PREFIX_NAME + "NAME] "
+ "[" + PREFIX_PHONE + "PHONE] "
+ "[" + PREFIX_EMAIL + "EMAIL] "
+ "[" + PREFIX_BIRTHDAY + "BIRTHDAY]"
+ "[" + PREFIX_ADDRESS + "ADDRESS] "
+ "[" + PREFIX_TAG + "TAG]...\n"
+ "Example: " + COMMAND_WORD + " 1 "
Expand Down Expand Up @@ -98,10 +101,11 @@ private static Person createEditedPerson(ReadOnlyPerson personToEdit,
Name updatedName = editPersonDescriptor.getName().orElse(personToEdit.getName());
Phone updatedPhone = editPersonDescriptor.getPhone().orElse(personToEdit.getPhone());
Email updatedEmail = editPersonDescriptor.getEmail().orElse(personToEdit.getEmail());
Birthday updateBirthday = editPersonDescriptor.getBirthday().orElse(personToEdit.getBirthday());
Address updatedAddress = editPersonDescriptor.getAddress().orElse(personToEdit.getAddress());
Set<Tag> updatedTags = editPersonDescriptor.getTags().orElse(personToEdit.getTags());

return new Person(updatedName, updatedPhone, updatedEmail, updatedAddress, updatedTags);
return new Person(updatedName, updatedPhone, updatedEmail, updateBirthday, updatedAddress, updatedTags);
}

@Override
Expand Down Expand Up @@ -130,6 +134,7 @@ public static class EditPersonDescriptor {
private Name name;
private Phone phone;
private Email email;
private Birthday birthday;
private Address address;
private Set<Tag> tags;

Expand All @@ -139,6 +144,7 @@ public EditPersonDescriptor(EditPersonDescriptor toCopy) {
this.name = toCopy.name;
this.phone = toCopy.phone;
this.email = toCopy.email;
this.birthday = toCopy.birthday;
this.address = toCopy.address;
this.tags = toCopy.tags;
}
Expand All @@ -147,7 +153,8 @@ public EditPersonDescriptor(EditPersonDescriptor toCopy) {
* Returns true if at least one field is edited.
*/
public boolean isAnyFieldEdited() {
return CollectionUtil.isAnyNonNull(this.name, this.phone, this.email, this.address, this.tags);
return CollectionUtil.isAnyNonNull(this.name, this.phone, this.email,
this.birthday, this.address, this.tags);
}

public void setName(Name name) {
Expand All @@ -174,6 +181,14 @@ public Optional<Email> getEmail() {
return Optional.ofNullable(email);
}

public void setBirthday(Birthday birthday) {
this.birthday = birthday;
}

public Optional<Birthday> getBirthday() {
return Optional.ofNullable(birthday);
}

public void setAddress(Address address) {
this.address = address;
}
Expand Down Expand Up @@ -208,6 +223,7 @@ public boolean equals(Object other) {
return getName().equals(e.getName())
&& getPhone().equals(e.getPhone())
&& getEmail().equals(e.getEmail())
&& getBirthday().equals(e.getBirthday())
&& getAddress().equals(e.getAddress())
&& getTags().equals(e.getTags());
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/seedu/address/logic/commands/FindCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ public class FindCommand extends Command {

public static final String COMMAND_WORD = "find";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Finds all persons whose names contain fully or partially any of "
public static final String MESSAGE_USAGE = COMMAND_WORD
+ ": Finds all persons whose names contain fully or partially any of "
+ "the specified keywords (case-insensitive) and displays them as a list with index numbers.\n"
+ "Parameters: KEYWORD [MORE_KEYWORDS]...\n"
+ "Example: " + COMMAND_WORD + " alice bob charlie";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package seedu.address.logic.commands;
import seedu.address.model.*;
import seedu.address.model.person.NameContainsPhonePredicate;

import static seedu.address.logic.commands.Command.getMessageForPersonListShownSummary;
import seedu.address.model.person.NameContainsPhonePredicate;


/**
Expand Down
11 changes: 8 additions & 3 deletions src/main/java/seedu/address/logic/parser/AddCommandParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

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_BIRTHDAY;
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;
Expand All @@ -14,6 +15,7 @@
import seedu.address.logic.commands.AddCommand;
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.person.Address;
import seedu.address.model.person.Birthday;
import seedu.address.model.person.Email;
import seedu.address.model.person.Name;
import seedu.address.model.person.Person;
Expand All @@ -33,20 +35,23 @@ public class AddCommandParser implements Parser<AddCommand> {
*/
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_BIRTHDAY,
PREFIX_ADDRESS, PREFIX_TAG);

if (!arePrefixesPresent(argMultimap, PREFIX_NAME, PREFIX_ADDRESS, PREFIX_PHONE, PREFIX_EMAIL)) {
if (!arePrefixesPresent(argMultimap, PREFIX_NAME,
PREFIX_ADDRESS, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_BIRTHDAY)) {
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE));
}

try {
Name name = ParserUtil.parseName(argMultimap.getValue(PREFIX_NAME)).get();
Phone phone = ParserUtil.parsePhone(argMultimap.getValue(PREFIX_PHONE)).get();
Email email = ParserUtil.parseEmail(argMultimap.getValue(PREFIX_EMAIL)).get();
Birthday birthday = ParserUtil.parseBirthday(argMultimap.getValue(PREFIX_BIRTHDAY)).get();
Address address = ParserUtil.parseAddress(argMultimap.getValue(PREFIX_ADDRESS)).get();
Set<Tag> tagList = ParserUtil.parseTags(argMultimap.getAllValues(PREFIX_TAG));

ReadOnlyPerson person = new Person(name, phone, email, address, tagList);
ReadOnlyPerson person = new Person(name, phone, email, birthday, address, tagList);

return new AddCommand(person);
} catch (IllegalValueException ive) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
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_DATE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_DESCRIPTION;
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.PREFIX_NAME;

import java.util.Set;
import java.util.stream.Stream;

import seedu.address.commons.exceptions.IllegalValueException;
import seedu.address.logic.commands.AddCommand;
import seedu.address.logic.commands.AddEventCommand;
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.event.Event;
import seedu.address.model.event.Dates;
import seedu.address.model.event.Event;
import seedu.address.model.person.Name;


Expand Down Expand Up @@ -63,4 +57,4 @@ private static boolean arePrefixesPresent(ArgumentMultimap argumentMultimap, Pre
return Stream.of(prefixes).allMatch(prefix -> argumentMultimap.getValue(prefix).isPresent());
}

}
}
Loading

0 comments on commit dfae714

Please sign in to comment.