Skip to content

Commit

Permalink
Merge pull request #56 from CS2103JAN2017-W15-B4/staging
Browse files Browse the repository at this point in the history
Complete v0.2
  • Loading branch information
VeryLazyBoy authored Mar 15, 2017
2 parents 50d7be5 + 85c9d2d commit 61d0e03
Show file tree
Hide file tree
Showing 80 changed files with 1,286 additions and 634 deletions.
2 changes: 1 addition & 1 deletion src/main/java/seedu/geekeep/MainApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ private Model initModelManager(Storage storage, UserPrefs userPrefs) {
Optional<ReadOnlyTaskManager> addressBookOptional;
ReadOnlyTaskManager initialData;
try {
addressBookOptional = storage.readAddressBook();
addressBookOptional = storage.readTaskManager();
if (!addressBookOptional.isPresent()) {
logger.info("Data file not found. Will be starting with a sample AddressBook");
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/seedu/geekeep/commons/core/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class Messages {

public static final String MESSAGE_UNKNOWN_COMMAND = "Unknown command";
public static final String MESSAGE_INVALID_COMMAND_FORMAT = "Invalid command format! \n%1$s";
public static final String MESSAGE_INVALID_PERSON_DISPLAYED_INDEX = "The person index provided is invalid";
public static final String MESSAGE_PERSONS_LISTED_OVERVIEW = "%1$d persons listed!";
public static final String MESSAGE_INVALID_TASK_DISPLAYED_INDEX = "The task index provided is invalid";
public static final String MESSAGE_TASKS_LISTED_OVERVIEW = "%1$d tasks listed!";

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ public TaskManagerChangedEvent(ReadOnlyTaskManager data) {

@Override
public String toString() {
return "number of persons " + data.getPersonList().size() + ", number of tags " + data.getTagList().size();
return "number of persons " + data.getTaskList().size() + ", number of tags " + data.getTagList().size();
}
}
4 changes: 2 additions & 2 deletions src/main/java/seedu/geekeep/logic/Logic.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public interface Logic {
*/
CommandResult execute(String commandText) throws CommandException;

/** Returns the filtered list of persons */
ObservableList<ReadOnlyTask> getFilteredPersonList();
/** Returns the filtered list of tasks */
ObservableList<ReadOnlyTask> getFilteredTaskList();

}
4 changes: 2 additions & 2 deletions src/main/java/seedu/geekeep/logic/LogicManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public CommandResult execute(String commandText) throws CommandException {
}

@Override
public ObservableList<ReadOnlyTask> getFilteredPersonList() {
return model.getFilteredPersonList();
public ObservableList<ReadOnlyTask> getFilteredTaskList() {
return model.getFilteredTaskList();
}
}
24 changes: 20 additions & 4 deletions src/main/java/seedu/geekeep/logic/commands/AddCommand.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package seedu.geekeep.logic.commands;

import java.util.HashSet;
import java.util.Optional;
import java.util.Set;

import seedu.geekeep.commons.exceptions.IllegalValueException;
Expand Down Expand Up @@ -35,17 +36,32 @@ public class AddCommand extends Command {
*
* @throws IllegalValueException if any of the raw values are invalid
*/
public AddCommand(String title, String startDateTime, String endDateTime, String location, Set<String> tags)
public AddCommand(String title, Optional<String> startDateTime, Optional<String> endDateTime,
Optional<String> location, Set<String> tags)
throws IllegalValueException {
final Set<Tag> tagSet = new HashSet<>();
for (String tagName : tags) {
tagSet.add(new Tag(tagName));
}

DateTime start = null, end = null;
Location loc = null;

if (startDateTime.isPresent()) {
start = new DateTime(startDateTime.get());
}
if (endDateTime.isPresent()) {
end = new DateTime(endDateTime.get());
}
if (location.isPresent()) {
loc = new Location(location.get());
}

this.toAdd = new Task(
new Title(title),
new DateTime(startDateTime),
new DateTime(endDateTime),
new Location(location),
start,
end,
loc,
new UniqueTagList(tagSet)
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/seedu/geekeep/logic/commands/ClearCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
import seedu.geekeep.model.TaskManager;

/**
* Clears the address book.
* Clears the Task Manager.
*/
public class ClearCommand extends Command {

public static final String COMMAND_WORD = "clear";
public static final String MESSAGE_SUCCESS = "Address book has been cleared!";
public static final String MESSAGE_SUCCESS = "Task Manager has been cleared!";


@Override
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/seedu/geekeep/logic/commands/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ public abstract class Command {
protected Model model;

/**
* Constructs a feedback message to summarise an operation that displayed a listing of persons.
* Constructs a feedback message to summarise an operation that displayed a listing of tasks.
*
* @param displaySize used to generate summary
* @return summary message for persons displayed
* @return summary message for tasks displayed
*/
public static String getMessageForPersonListShownSummary(int displaySize) {
return String.format(Messages.MESSAGE_PERSONS_LISTED_OVERVIEW, displaySize);
return String.format(Messages.MESSAGE_TASKS_LISTED_OVERVIEW, displaySize);
}

/**
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/seedu/geekeep/logic/commands/DeleteCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@
import seedu.geekeep.model.task.UniqueTaskList.TaskNotFoundException;

/**
* Deletes a person identified using it's last displayed index from the address book.
* Deletes a task identified using it's last displayed index from the address book.
*/
public class DeleteCommand extends Command {

public static final String COMMAND_WORD = "delete";

public static final String MESSAGE_USAGE = COMMAND_WORD
+ ": Deletes the person identified by the index number used in the last person listing.\n"
+ ": Deletes the task identified by the index number used in the last task listing.\n"
+ "Parameters: INDEX (must be a positive integer)\n"
+ "Example: " + COMMAND_WORD + " 1";

public static final String MESSAGE_DELETE_PERSON_SUCCESS = "Deleted Person: %1$s";
public static final String MESSAGE_DELETE_TASK_SUCCESS = "Deleted task: %1$s";

public final int targetIndex;

Expand All @@ -30,21 +30,21 @@ public DeleteCommand(int targetIndex) {
@Override
public CommandResult execute() throws CommandException {

UnmodifiableObservableList<ReadOnlyTask> lastShownList = model.getFilteredPersonList();
UnmodifiableObservableList<ReadOnlyTask> lastShownList = model.getFilteredTaskList();

if (lastShownList.size() < targetIndex) {
throw new CommandException(Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX);
throw new CommandException(Messages.MESSAGE_INVALID_TASK_DISPLAYED_INDEX);
}

ReadOnlyTask personToDelete = lastShownList.get(targetIndex - 1);
ReadOnlyTask taskToDelete = lastShownList.get(targetIndex - 1);

try {
model.deletePerson(personToDelete);
model.deleteTask(taskToDelete);
} catch (TaskNotFoundException pnfe) {
assert false : "The target person cannot be missing";
assert false : "The target task cannot be missing";
}

return new CommandResult(String.format(MESSAGE_DELETE_PERSON_SUCCESS, personToDelete));
return new CommandResult(String.format(MESSAGE_DELETE_TASK_SUCCESS, taskToDelete));
}

}
44 changes: 44 additions & 0 deletions src/main/java/seedu/geekeep/logic/commands/DoneCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package seedu.geekeep.logic.commands;

import seedu.geekeep.commons.core.Messages;
import seedu.geekeep.commons.core.UnmodifiableObservableList;
import seedu.geekeep.logic.commands.exceptions.CommandException;
import seedu.geekeep.model.task.ReadOnlyTask;

/**
* Marks 'done' for task identified using it's last displayed index from the address book.
*/
public class DoneCommand extends Command {

public static final String COMMAND_WORD = "done";

public static final String MESSAGE_USAGE = COMMAND_WORD
+ ": Marks the task identified by the index number used in the last task listing as done.\n"
+ "Parameters: INDEX (must be a positive integer)\n"
+ "Example: " + COMMAND_WORD + " 1";

public static final String MESSAGE_DONE_TASK_SUCCESS = "Marked as done: %1$s";

public final int targetIndex;

public DoneCommand(int targetIndex) {
this.targetIndex = targetIndex;
}

@Override
public CommandResult execute() throws CommandException {

UnmodifiableObservableList<ReadOnlyTask> lastShownList = model.getFilteredTaskList();

if (lastShownList.size() < targetIndex) {
throw new CommandException(Messages.MESSAGE_INVALID_TASK_DISPLAYED_INDEX);
}

ReadOnlyTask taskToMark = lastShownList.get(targetIndex - 1);

model.markTaskDone(targetIndex - 1);

return new CommandResult(String.format(MESSAGE_DONE_TASK_SUCCESS, taskToMark));
}

}
80 changes: 40 additions & 40 deletions src/main/java/seedu/geekeep/logic/commands/EditCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,24 @@
import seedu.geekeep.model.task.UniqueTaskList;

/**
* Edits the details of an existing person in the address book.
* Edits the details of an existing task in the address book.
*/
public class EditCommand extends Command {

/**
* Stores the details to edit the person with. Each non-empty field value will replace the
* corresponding field value of the person.
* Stores the details to edit the task with. Each non-empty field value will replace the
* corresponding field value of the task.
*/
public static class EditPersonDescriptor {
public static class EditTaskDescriptor {
private Optional<Title> title = Optional.empty();
private Optional<DateTime> endDateTime = Optional.empty();
private Optional<DateTime> startDateTime = Optional.empty();
private Optional<Location> location = Optional.empty();
private Optional<UniqueTagList> tags = Optional.empty();

public EditPersonDescriptor() {}
public EditTaskDescriptor() {}

public EditPersonDescriptor(EditPersonDescriptor toCopy) {
public EditTaskDescriptor(EditTaskDescriptor toCopy) {
this.title = toCopy.getTitle();
this.endDateTime = toCopy.getEndDateTime();
this.startDateTime = toCopy.getStartDateTime();
Expand Down Expand Up @@ -96,70 +96,70 @@ public void setTitle(Optional<Title> title) {

public static final String COMMAND_WORD = "edit";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Edits the details of the person identified "
+ "by the index number used in the last person listing. "
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Edits the details of the task identified "
+ "by the index number used in the last task listing. "
+ "Existing values will be overwritten by the input values.\n"
+ "Parameters: INDEX (must be a positive integer) "
+ "[NAME] [p/PHONE] [e/EMAIL] [a/ADDRESS ] [t/TAG]...\n"
+ "Example: " + COMMAND_WORD + " 1 p/91234567 e/[email protected]";
public static final String MESSAGE_EDIT_PERSON_SUCCESS = "Edited Person: %1$s";
+ "[TITLE] [s/STARTING_TIME] [e/ENDING_TIME] [l/LOCATION] [t/TAG]...\n"
+ "Example: " + COMMAND_WORD + " 1 s/2017-04-01T10:16:30 e/2017-04-01T10:16:30m";
public static final String MESSAGE_EDIT_TASK_SUCCESS = "Edited Task: %1$s";
public static final String MESSAGE_NOT_EDITED = "At least one field to edit must be provided.";

public static final String MESSAGE_DUPLICATE_PERSON = "This person already exists in the address book.";
public static final String MESSAGE_DUPLICATE_TASK = "This task already exists in the task manager.";
/**
* Creates and returns a {@code Person} with the details of {@code personToEdit}
* edited with {@code editPersonDescriptor}.
* Creates and returns a {@code Task} with the details of {@code taskToEdit}
* edited with {@code editTaskDescriptor}.
*/
private static Task createEditedTask(ReadOnlyTask personToEdit,
EditPersonDescriptor editPersonDescriptor) {
assert personToEdit != null;
private static Task createEditedTask(ReadOnlyTask taskToEdit,
EditTaskDescriptor editTaskDescriptor) {
assert taskToEdit != null;

Title updatedTitle = editPersonDescriptor.getTitle().orElseGet(personToEdit::getTitle);
Title updatedTitle = editTaskDescriptor.getTitle().orElseGet(taskToEdit::getTitle);
DateTime updatedEndDateTime
= editPersonDescriptor.getEndDateTime().orElseGet(personToEdit::getEndDateTime);
= editTaskDescriptor.getEndDateTime().orElseGet(taskToEdit::getEndDateTime);
DateTime updatedStartDateTime
= editPersonDescriptor.getStartDateTime().orElseGet(personToEdit::getStartDateTime);
Location updatedLocation = editPersonDescriptor.getLocation().orElseGet(personToEdit::getLocation);
UniqueTagList updatedTags = editPersonDescriptor.getTags().orElseGet(personToEdit::getTags);
= editTaskDescriptor.getStartDateTime().orElseGet(taskToEdit::getStartDateTime);
Location updatedLocation = editTaskDescriptor.getLocation().orElseGet(taskToEdit::getLocation);
UniqueTagList updatedTags = editTaskDescriptor.getTags().orElseGet(taskToEdit::getTags);

return new Task(updatedTitle, updatedStartDateTime, updatedEndDateTime, updatedLocation, updatedTags);
}

private final int filteredPersonListIndex;
private final int filteredTaskListIndex;

private final EditPersonDescriptor editPersonDescriptor;
private final EditTaskDescriptor editTaskDescriptor;

/**
* @param filteredPersonListIndex the index of the person in the filtered person list to edit
* @param editPersonDescriptor details to edit the person with
* @param filteredTaskListIndex the index of the task in the filtered task list to edit
* @param editTaskDescriptor details to edit the task with
*/
public EditCommand(int filteredPersonListIndex, EditPersonDescriptor editPersonDescriptor) {
assert filteredPersonListIndex > 0;
assert editPersonDescriptor != null;
public EditCommand(int filteredTaskListIndex, EditTaskDescriptor editTaskDescriptor) {
assert filteredTaskListIndex > 0;
assert editTaskDescriptor != null;

// converts filteredPersonListIndex from one-based to zero-based.
this.filteredPersonListIndex = filteredPersonListIndex - 1;
// converts filteredTaskListIndex from one-based to zero-based.
this.filteredTaskListIndex = filteredTaskListIndex - 1;

this.editPersonDescriptor = new EditPersonDescriptor(editPersonDescriptor);
this.editTaskDescriptor = new EditTaskDescriptor(editTaskDescriptor);
}

@Override
public CommandResult execute() throws CommandException {
List<ReadOnlyTask> lastShownList = model.getFilteredPersonList();
List<ReadOnlyTask> lastShownList = model.getFilteredTaskList();

if (filteredPersonListIndex >= lastShownList.size()) {
throw new CommandException(Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX);
if (filteredTaskListIndex >= lastShownList.size()) {
throw new CommandException(Messages.MESSAGE_INVALID_TASK_DISPLAYED_INDEX);
}

ReadOnlyTask personToEdit = lastShownList.get(filteredPersonListIndex);
Task editedTask = createEditedTask(personToEdit, editPersonDescriptor);
ReadOnlyTask taskToEdit = lastShownList.get(filteredTaskListIndex);
Task editedTask = createEditedTask(taskToEdit, editTaskDescriptor);

try {
model.updatePerson(filteredPersonListIndex, editedTask);
model.updateTask(filteredTaskListIndex, editedTask);
} catch (UniqueTaskList.DuplicateTaskException dpe) {
throw new CommandException(MESSAGE_DUPLICATE_PERSON);
throw new CommandException(MESSAGE_DUPLICATE_TASK);
}
model.updateFilteredListToShowAll();
return new CommandResult(String.format(MESSAGE_EDIT_PERSON_SUCCESS, personToEdit));
return new CommandResult(String.format(MESSAGE_EDIT_TASK_SUCCESS, taskToEdit));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class ExitCommand extends Command {

public static final String COMMAND_WORD = "exit";

public static final String MESSAGE_EXIT_ACKNOWLEDGEMENT = "Exiting Address Book as requested ...";
public static final String MESSAGE_EXIT_ACKNOWLEDGEMENT = "Exiting Task Manager as requested ...";

@Override
public CommandResult execute() {
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/seedu/geekeep/logic/commands/FindCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
import java.util.Set;

/**
* Finds and lists all persons in address book whose name contains any of the argument keywords.
* Finds and lists all tasks in address book whose name contains any of the argument keywords.
* Keyword matching is case sensitive.
*/
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 any of "
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Finds all tasks whose titles contain any of "
+ "the specified keywords (case-sensitive) and displays them as a list with index numbers.\n"
+ "Parameters: KEYWORD [MORE_KEYWORDS]...\n"
+ "Example: " + COMMAND_WORD + " alice bob charlie";
Expand All @@ -23,8 +23,8 @@ public FindCommand(Set<String> keywords) {

@Override
public CommandResult execute() {
model.updateFilteredPersonList(keywords);
return new CommandResult(getMessageForPersonListShownSummary(model.getFilteredPersonList().size()));
model.updateFilteredTaskList(keywords);
return new CommandResult(getMessageForPersonListShownSummary(model.getFilteredTaskList().size()));
}

}
Loading

0 comments on commit 61d0e03

Please sign in to comment.