Skip to content

Commit

Permalink
Merge pull request nus-cs2103-AY2021S1#76 from TCQian/TCQian-Refracto…
Browse files Browse the repository at this point in the history
…r-Phone-To-Deadlline-In-Project

Refactor phone to deadlline in project
  • Loading branch information
lll-jy authored Oct 5, 2020
2 parents 33c0ea1 + 9f0910f commit fb37946
Show file tree
Hide file tree
Showing 36 changed files with 483 additions and 370 deletions.
4 changes: 2 additions & 2 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ Use case ends.
**MSS:**

1. Team leader create a new team member profile.
2. TMTS asks for the details of the team member such as projectName, phone number and email projectDescription.
2. TMTS asks for the details of the team member such as projectName, deadline, email and projectDescription.
3. Team leader keys in the details.
4. TMTS stores the team member's profile into the data file.

Expand All @@ -353,7 +353,7 @@ Use case ends.
1. Team leader chooses to edit a team member's profile.
2. PTS asks for the projectName of the team member whose profile is to be edited.
3. Team leader keys in the projectName of the team member.
4. TMTS asks for the new information of team member such as projectName, phone number and email projectDescription.
4. TMTS asks for the new information of team member such as projectName, deadline, email and projectDescription.
5. Team leader keys in the details.
6. TMTS stores the team member's profile into the data file.

Expand Down
4 changes: 2 additions & 2 deletions docs/tutorials/RemovingFields.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private Label projectDescription;

``` xml
...
<Label fx:id="phone" styleClass="cell_small_label" text="\$phone" />
<Label fx:id="deadline" styleClass="cell_small_label" text="\$deadline" />
<Label fx:id="projectDescription" styleClass="cell_small_label" text="\$projectDescription" />
<Label fx:id="email" styleClass="cell_small_label" text="\$email" />
...
Expand All @@ -93,7 +93,7 @@ In `src/test/data/`, data meant for testing purposes are stored. While keeping t
{
"projects": [ {
"projectName": "Project with invalid projectName field: Ha!ns Mu@ster",
"phone": "9482424",
"deadline": "21-03-2020 00:00:00",
"email": "hans@example.com",
"projectDescription": "4th street"
} ]
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/seedu/address/logic/commands/AddCommand.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package seedu.address.logic.commands;

import static java.util.Objects.requireNonNull;
import static seedu.address.logic.parser.CliSyntax.PREFIX_DEADLINE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL;
import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_PROJECT_DESCRIPTION;
import static seedu.address.logic.parser.CliSyntax.PREFIX_PROJECT_NAME;
import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG;
Expand All @@ -22,14 +22,14 @@ public class AddCommand extends Command {
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a project to the main catalogue. "
+ "Parameters: "
+ PREFIX_PROJECT_NAME + "PROJECT NAME "
+ PREFIX_PHONE + "PHONE "
+ PREFIX_DEADLINE + "DEADLINE "
+ PREFIX_EMAIL + "EMAIL "
+ PREFIX_PROJECT_DESCRIPTION + "PROJECT DESCRIPTION "
+ "[" + PREFIX_TAG + "TAG]...\n"
+ "[" + PREFIX_TASK + "TASK]...\n"
+ "Example: " + COMMAND_WORD + " "
+ PREFIX_PROJECT_NAME + "John Doe "
+ PREFIX_PHONE + "98765432 "
+ PREFIX_DEADLINE + "29-02-2020 00:00:00"
+ PREFIX_EMAIL + "johnd@example.com "
+ PREFIX_PROJECT_DESCRIPTION + "311, Clementi Ave 2, #02-25 "
+ PREFIX_TAG + "friends "
Expand Down
29 changes: 14 additions & 15 deletions src/main/java/seedu/address/logic/commands/EditCommand.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package seedu.address.logic.commands;

import static java.util.Objects.requireNonNull;
import static seedu.address.logic.parser.CliSyntax.PREFIX_DEADLINE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL;
import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_PROJECT_DESCRIPTION;
import static seedu.address.logic.parser.CliSyntax.PREFIX_PROJECT_NAME;
import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG;
Expand All @@ -21,14 +21,13 @@
import seedu.address.commons.util.CollectionUtil;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
import seedu.address.model.project.Deadline;
import seedu.address.model.project.Email;
import seedu.address.model.project.Phone;
import seedu.address.model.project.Project;
import seedu.address.model.project.ProjectDescription;
import seedu.address.model.project.ProjectName;
import seedu.address.model.tag.Tag;
import seedu.address.model.task.Task;

/**
* Edits the details of an existing project in the main catalogue.
*/
Expand All @@ -41,13 +40,13 @@ public class EditCommand extends Command {
+ "Existing values will be overwritten by the input values.\n"
+ "Parameters: INDEX (must be a positive integer) "
+ "[" + PREFIX_PROJECT_NAME + "PROJECTNAME] "
+ "[" + PREFIX_PHONE + "PHONE] "
+ "[" + PREFIX_DEADLINE + "DEADLINE] "
+ "[" + PREFIX_EMAIL + "EMAIL] "
+ "[" + PREFIX_PROJECT_DESCRIPTION + "PROJECTDESCRIPTION] "
+ "[" + PREFIX_TAG + "TAG]...\n"
+ "[" + PREFIX_TASK + "TASK]...\n"
+ "Example: " + COMMAND_WORD + " 1 "
+ PREFIX_PHONE + "91234567 "
+ PREFIX_DEADLINE + "29-02-2020 00:00:00 "
+ PREFIX_EMAIL + "johndoe@example.com";

public static final String MESSAGE_EDIT_PROJECT_SUCCESS = "Edited Project: %1$s";
Expand Down Expand Up @@ -98,14 +97,14 @@ private static Project createEditedProject(Project projectToEdit, EditProjectDes
assert projectToEdit != null;

ProjectName updatedProjectName = editProjectDescriptor.getProjectName().orElse(projectToEdit.getProjectName());
Phone updatedPhone = editProjectDescriptor.getPhone().orElse(projectToEdit.getPhone());
Deadline updatedDeadline = editProjectDescriptor.getDeadline().orElse(projectToEdit.getDeadline());
Email updatedEmail = editProjectDescriptor.getEmail().orElse(projectToEdit.getEmail());
ProjectDescription updatedProjectDescription = editProjectDescriptor.getProjectDescription()
.orElse(projectToEdit.getProjectDescription());
Set<Tag> updatedTags = editProjectDescriptor.getTags().orElse(projectToEdit.getTags());
Set<Task> updatedTasks = editProjectDescriptor.getTasks().orElse(projectToEdit.getTasks());

return new Project(updatedProjectName, updatedPhone, updatedEmail, updatedProjectDescription,
return new Project(updatedProjectName, updatedDeadline, updatedEmail, updatedProjectDescription,
updatedTags, new HashMap<>(), updatedTasks);
}

Expand Down Expand Up @@ -133,7 +132,7 @@ public boolean equals(Object other) {
*/
public static class EditProjectDescriptor {
private ProjectName projectName;
private Phone phone;
private Deadline deadline;
private Email email;
private ProjectDescription projectDescription;
private Set<Tag> tags;
Expand All @@ -147,7 +146,7 @@ public EditProjectDescriptor() {}
*/
public EditProjectDescriptor(EditProjectDescriptor toCopy) {
setProjectName(toCopy.projectName);
setPhone(toCopy.phone);
setDeadline(toCopy.deadline);
setEmail(toCopy.email);
setProjectDescription(toCopy.projectDescription);
setTags(toCopy.tags);
Expand All @@ -158,7 +157,7 @@ public EditProjectDescriptor(EditProjectDescriptor toCopy) {
* Returns true if at least one field is edited.
*/
public boolean isAnyFieldEdited() {
return CollectionUtil.isAnyNonNull(projectName, phone, email, projectDescription, tags, tasks);
return CollectionUtil.isAnyNonNull(projectName, deadline, email, projectDescription, tags, tasks);
}

public void setProjectName(ProjectName projectName) {
Expand All @@ -169,12 +168,12 @@ public Optional<ProjectName> getProjectName() {
return Optional.ofNullable(projectName);
}

public void setPhone(Phone phone) {
this.phone = phone;
public void setDeadline(Deadline deadline) {
this.deadline = deadline;
}

public Optional<Phone> getPhone() {
return Optional.ofNullable(phone);
public Optional<Deadline> getDeadline() {
return Optional.ofNullable(deadline);
}

public void setEmail(Email email) {
Expand Down Expand Up @@ -243,7 +242,7 @@ public boolean equals(Object other) {
EditProjectDescriptor e = (EditProjectDescriptor) other;

return getProjectName().equals(e.getProjectName())
&& getPhone().equals(e.getPhone())
&& getDeadline().equals(e.getDeadline())
&& getEmail().equals(e.getEmail())
&& getProjectDescription().equals(e.getProjectDescription())
&& getTags().equals(e.getTags())
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/seedu/address/logic/parser/AddCommandParser.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package seedu.address.logic.parser;

import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
import static seedu.address.logic.parser.CliSyntax.PREFIX_DEADLINE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL;
import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_PROJECT_DESCRIPTION;
import static seedu.address.logic.parser.CliSyntax.PREFIX_PROJECT_NAME;
import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG;
Expand All @@ -14,8 +14,8 @@

import seedu.address.logic.commands.AddCommand;
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.project.Deadline;
import seedu.address.model.project.Email;
import seedu.address.model.project.Phone;
import seedu.address.model.project.Project;
import seedu.address.model.project.ProjectDescription;
import seedu.address.model.project.ProjectName;
Expand All @@ -34,24 +34,24 @@ public class AddCommandParser implements Parser<AddCommand> {
*/
public AddCommand parse(String args) throws ParseException {
ArgumentMultimap argMultimap =
ArgumentTokenizer.tokenize(args, PREFIX_PROJECT_NAME, PREFIX_PHONE, PREFIX_EMAIL,
ArgumentTokenizer.tokenize(args, PREFIX_PROJECT_NAME, PREFIX_DEADLINE, PREFIX_EMAIL,
PREFIX_PROJECT_DESCRIPTION, PREFIX_TAG, PREFIX_TASK);

if (!arePrefixesPresent(argMultimap, PREFIX_PROJECT_NAME,
PREFIX_PROJECT_DESCRIPTION, PREFIX_PHONE, PREFIX_EMAIL)
PREFIX_PROJECT_DESCRIPTION, PREFIX_DEADLINE, PREFIX_EMAIL)
|| !argMultimap.getPreamble().isEmpty()) {
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE));
}

ProjectName projectName = ParserUtil.parseProjectName(argMultimap.getValue(PREFIX_PROJECT_NAME).get());
Phone phone = ParserUtil.parsePhone(argMultimap.getValue(PREFIX_PHONE).get());
Deadline deadline = ParserUtil.parseDeadline(argMultimap.getValue(PREFIX_DEADLINE).get());
Email email = ParserUtil.parseEmail(argMultimap.getValue(PREFIX_EMAIL).get());
ProjectDescription projectDescription = ParserUtil.projectDescription(argMultimap.getValue(
PREFIX_PROJECT_DESCRIPTION).get());
Set<Tag> tagList = ParserUtil.parseTags(argMultimap.getAllValues(PREFIX_TAG));
Set<Task> taskList = ParserUtil.parseTasks(argMultimap.getAllValues(PREFIX_TASK));

Project project = new Project(projectName, phone, email, projectDescription, tagList,
Project project = new Project(projectName, deadline, email, projectDescription, tagList,
new HashMap<>(), taskList);

return new AddCommand(project);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/logic/parser/CliSyntax.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class CliSyntax {

/* Prefix definitions */
public static final Prefix PREFIX_PROJECT_NAME = new Prefix("n/");
public static final Prefix PREFIX_PHONE = new Prefix("p/");
public static final Prefix PREFIX_DEADLINE = new Prefix("dl/");
public static final Prefix PREFIX_EMAIL = new Prefix("e/");
public static final Prefix PREFIX_PROJECT_DESCRIPTION = new Prefix("d/");
public static final Prefix PREFIX_TAG = new Prefix("tg/");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import static java.util.Objects.requireNonNull;
import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
import static seedu.address.logic.parser.CliSyntax.PREFIX_DEADLINE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL;
import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_PROJECT_DESCRIPTION;
import static seedu.address.logic.parser.CliSyntax.PREFIX_PROJECT_NAME;
import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG;
Expand Down Expand Up @@ -34,7 +34,7 @@ public class EditCommandParser implements Parser<EditCommand> {
public EditCommand parse(String args) throws ParseException {
requireNonNull(args);
ArgumentMultimap argMultimap =
ArgumentTokenizer.tokenize(args, PREFIX_PROJECT_NAME, PREFIX_PHONE, PREFIX_EMAIL,
ArgumentTokenizer.tokenize(args, PREFIX_PROJECT_NAME, PREFIX_DEADLINE, PREFIX_EMAIL,
PREFIX_PROJECT_DESCRIPTION, PREFIX_TAG, PREFIX_TASK);

Index index;
Expand All @@ -50,8 +50,8 @@ public EditCommand parse(String args) throws ParseException {
editProjectDescriptor.setProjectName(ParserUtil.parseProjectName(
argMultimap.getValue(PREFIX_PROJECT_NAME).get()));
}
if (argMultimap.getValue(PREFIX_PHONE).isPresent()) {
editProjectDescriptor.setPhone(ParserUtil.parsePhone(argMultimap.getValue(PREFIX_PHONE).get()));
if (argMultimap.getValue(PREFIX_DEADLINE).isPresent()) {
editProjectDescriptor.setDeadline(ParserUtil.parseDeadline(argMultimap.getValue(PREFIX_DEADLINE).get()));
}
if (argMultimap.getValue(PREFIX_EMAIL).isPresent()) {
editProjectDescriptor.setEmail(ParserUtil.parseEmail(argMultimap.getValue(PREFIX_EMAIL).get()));
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/seedu/address/logic/parser/ParserUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import seedu.address.commons.core.index.Index;
import seedu.address.commons.util.StringUtil;
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.project.Deadline;
import seedu.address.model.project.Email;
import seedu.address.model.project.Phone;
import seedu.address.model.project.ProjectDescription;
import seedu.address.model.project.ProjectName;
import seedu.address.model.tag.Tag;
Expand Down Expand Up @@ -52,18 +52,18 @@ public static ProjectName parseProjectName(String projectName) throws ParseExcep
}

/**
* Parses a {@code String phone} into a {@code Phone}.
* Parses a {@code String deadline} into a {@code Deadline}.
* Leading and trailing whitespaces will be trimmed.
*
* @throws ParseException if the given {@code phone} is invalid.
* @throws ParseException if the given {@code deadline} is invalid.
*/
public static Phone parsePhone(String phone) throws ParseException {
requireNonNull(phone);
String trimmedPhone = phone.trim();
if (!Phone.isValidPhone(trimmedPhone)) {
throw new ParseException(Phone.MESSAGE_CONSTRAINTS);
public static Deadline parseDeadline(String deadline) throws ParseException {
requireNonNull(deadline);
String trimmedDeadline = deadline.trim();
if (!Deadline.isValidDeadline(trimmedDeadline)) {
throw new ParseException(Deadline.MESSAGE_CONSTRAINTS);
}
return new Phone(trimmedPhone);
return new Deadline(trimmedDeadline);
}

/**
Expand Down
Loading

0 comments on commit fb37946

Please sign in to comment.