Skip to content

Commit

Permalink
Merge pull request #1 from CS2103AUG2016-F10-C3/master
Browse files Browse the repository at this point in the history
Update local repo
  • Loading branch information
shaocloud authored Nov 3, 2016
2 parents 5fa1970 + cbe978b commit 201a591
Show file tree
Hide file tree
Showing 21 changed files with 778 additions and 78 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[![Build Status](https://travis-ci.org/se-edu/addressbook-level4.svg?branch=master)](https://travis-ci.org/se-edu/addressbook-level4)
[![Coverage Status](https://coveralls.io/repos/github/CS2103AUG2016-F10-C3/main/badge.svg?branch=master)](https://coveralls.io/github/CS2103AUG2016-F10-C3/main?branch=master)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/72e712e19dd241cfa8820139dbab0bef)](https://www.codacy.com/app/shwetha-ravi3/main?utm_source=github.com&utm_medium=referral&utm_content=CS2103AUG2016-F10-C3/main&utm_campaign=Badge_Grade)

# Tary

Expand Down
25 changes: 14 additions & 11 deletions docs/AboutUs.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,29 @@ We are a team based in the [School of Computing, National University of Singapor

## Project Team

#### [Joshua Lee](http://github.com/lejolly)
<img src="images/JoshuaLee.jpg" width="150"><br>
Role: Developer <br>
Responsibilities: UI

-----

#### [Ravi Shwetha](http://github.com/ravishwetha)
<img src="images/RaviShwetha.jpg" width="150"><br>
Role: Developer <br>
Responsibilities: Storage and Testing

* Components in charge of: [Storage and Testing](https://github.com/se-edu/addressbook-level4/blob/master/docs/DeveloperGuide.md#storage-component)
* Aspects/tools in charge of: Testing, Git
* Features implemented:
* [Basic undo and multiple undo](https://github.com/se-edu/addressbook-level4/blob/master/docs/UserGuide.md#listing-all-persons--list)
* [Edit task](https://github.com/se-edu/addressbook-level4/blob/master/docs/UserGuide.md#deleting-a-person--delete)
* [Find searches for exact keywords first](https://github.com/se-edu/addressbook-level4/blob/master/docs/UserGuide.md#deleting-a-person--delete)
* [Natural language processing for dates using Natty API](https://github.com/se-edu/addressbook-level4/blob/master/docs/UserGuide.md#deleting-a-person--delete)
* Code written: [[functional code](A0146130W.md)][[test code](A0146130W.md)][[docs](A0146130W.md)]
* Other major contributions:
* Did the initial refactoring from Person model to Task model [[#133](https://github.com/se-edu/addressbook-level4/pull/152) ]
* Set up Coveralls and Collate
* Change browser to search task location on google maps

-----

#### [Tan Shao Yun](http://github.com/shaocloud)
<img src="images/ShaoYun.jpg" width="150"><br>
Role: Developer <br>
Responsibilities: UI


-----

#### [Voon Soo Yin](http://github.com/tessav)
Expand All @@ -37,6 +40,6 @@ Responsibilities: UI

#### [Chan Jun Wei](http://github.com/chanjunweimy)
<img src="images/ChanJunWei.jpg" width="150"><br>
Role: Module Tutor <br>
Role: Module Tutor and Project Supervisor <br>

Code modified from : https://github.com/nus-cs2103-AY1617S1/addressbook-level4
165 changes: 152 additions & 13 deletions libs/A0146130W.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,13 @@
###### /src/main/java/seedu/gtd/logic/commands/FindCommand.java
``` java
private final String keywords;
private final Set<String> keywordSet;
private Set<String> keywordSet;
private final String cmd;

public FindCommand(String keywords, Set<String> keywordSet) {
public FindCommand(String keywords, Set<String> keywordSet, String cmd) {
this.keywords = keywords;
this.keywordSet = keywordSet;
this.cmd = cmd;
}

private String getMessageForTaskListShownSummaryIfExactPhraseNotFound(int displaySize) {
Expand All @@ -86,20 +88,68 @@
String MESSAGE_IF_EXACT_PHRASE_NOT_FOUND = "The exact phrase '" + keywords + "' was not found. Listing " + displaySize + " " + task_tasks + " containing the keywords entered instead.";
return String.format(MESSAGE_IF_EXACT_PHRASE_NOT_FOUND);
}

private String getMessageForTaskListShownSummaryIfExactFieldNotFound(int displaySize) {
String task_tasks = (displaySize == 1) ? "task" : "tasks";

String MESSAGE_IF_EXACT_PHRASE_NOT_FOUND = "The exact phrase '" + keywords + "' was not found in the specified field type. Listing " + displaySize + " " + task_tasks + " containing the keywords entered instead.";
return String.format(MESSAGE_IF_EXACT_PHRASE_NOT_FOUND);
}

@Override
public CommandResult execute() {
model.updateFilteredTaskList(keywords, keywordSet);

if(model.getFilteredTaskList().isEmpty()) {
model.updateFilteredTaskList(keywordSet);
if(!model.getFilteredTaskList().isEmpty()) return new CommandResult(getMessageForTaskListShownSummaryIfExactPhraseNotFound(model.getFilteredTaskList().size()));
}

System.out.println("command: " + cmd);

// search by parameter if specified
if (cmd != "nil") {
model.updateFilteredTaskList(keywords, cmd);
} else {
// search by exact name
model.updateFilteredTaskList(keywords, keywordSet);
}
if (!model.getFilteredTaskList().isEmpty()) {
return new CommandResult(getMessageForTaskListShownSummary(model.getFilteredTaskList().size()));
}

// search by keywords
model.updateFilteredTaskList(keywords, "nil");

if (!model.getFilteredTaskList().isEmpty()) {
if (cmd == "nil") {
return new CommandResult(getMessageForTaskListShownSummaryIfExactPhraseNotFound(model.getFilteredTaskList().size()));
} else {
return new CommandResult(getMessageForTaskListShownSummaryIfExactFieldNotFound(model.getFilteredTaskList().size()));
}
}

return new CommandResult(getMessageForTaskListShownSummary(model.getFilteredTaskList().size()));
}
}
```
###### /src/main/java/seedu/gtd/logic/commands/UndoCommand.java
``` java

package seedu.gtd.logic.commands;

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

public static final String COMMAND_WORD = "undo";
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Un-does the most recent modification of the task list.";
public static final String MESSAGE_SUCCESS = "Undo change";

public UndoCommand() {}

@Override
public CommandResult execute() {
model.undoAddressBookChange();
return new CommandResult(MESSAGE_SUCCESS);
}

}
```
###### /src/main/java/seedu/gtd/logic/parser/DateNaturalLanguageProcessor.java
``` java

Expand All @@ -109,7 +159,7 @@
public class DateNaturalLanguageProcessor implements NaturalLanguageProcessor {

private static final com.joestelmach.natty.Parser parser = new com.joestelmach.natty.Parser();
private static final String DATE_FORMAT = "dd/MM/yyyy HH:mm:ss";
private static final String DATE_FORMAT = "dd/MM/yyyy HH:mm";

@Override
public String formatString(String naturalLanguageDate) {
Expand Down Expand Up @@ -165,6 +215,12 @@ public interface NaturalLanguageProcessor {
return nlp.formatString(dueDateRaw);
}

// remove time on date parsed to improve search results
private String removeTimeOnDate(String dueDateRaw) {
String[] dateTime = dueDateRaw.split(" ");
return dateTime[0];
}

```
###### /src/main/java/seedu/gtd/logic/parser/Parser.java
``` java
Expand Down Expand Up @@ -237,11 +293,19 @@ public interface NaturalLanguageProcessor {
``` java
@Override
public synchronized void editTask(int targetIndex, Task task) throws TaskNotFoundException {
savePreviousAddressBook();
System.out.println("editing task..");
addressBook.editTask(targetIndex, task);
updateFilteredListToShowAll();
indicateAddressBookChanged();
}

@Override
public void clearTaskList() {
savePreviousAddressBook();
resetData(AddressBook.getEmptyAddressBook());
}

```
###### /src/main/java/seedu/gtd/model/task/UniqueTaskList.java
``` java
Expand All @@ -258,6 +322,18 @@ public interface NaturalLanguageProcessor {
internalList.set(targetIndex, toEdit);
}

public void done(int targetIndex, Task taskdone) throws TaskNotFoundException {
System.out.println("in uniquetasklist");
System.out.println(taskdone.getName() + " " + taskdone.getisDone());
System.out.println("index at final:" + targetIndex);
assert taskdone != null;
if (invalidIndex(targetIndex)) {
throw new TaskNotFoundException();
}
System.out.println("marked done in model");
internalList.set(targetIndex, taskdone);
}

private boolean invalidIndex(int i) {
if(i < 0 || i >= internalList.size()) return true;
return false;
Expand Down Expand Up @@ -312,9 +388,9 @@ public class EditCommandTest extends AddressBookGuiTest {
}

/**
* Runs the delete command to delete the task at specified index and confirms the result is correct.
* @param targetIndexOneIndexed e.g. to delete the first task in the list, 1 should be given as the target index.
* @param currentList A copy of the current list of tasks (before deletion).
* Runs the edit command to edit the task at specified index and confirms the result is correct.
* @param targetIndexOneIndexed e.g. to edit the first task in the list, 1 should be given as the target index.
* @param currentList A copy of the current list of tasks (before editing).
*/
private void assertEditSuccess(int targetIndexOneIndexed, String change, final TestTask[] currentList) {
TestTask taskToEdit = currentList[targetIndexOneIndexed-1]; //-1 because array uses zero indexing
Expand All @@ -328,6 +404,69 @@ public class EditCommandTest extends AddressBookGuiTest {
assertResultMessage(String.format(MESSAGE_EDIT_TASK_SUCCESS, expectedRemainder[targetIndexOneIndexed-1]));
}

}
```
###### /src/test/java/guitests/UndoCommandTest.java
``` java

package guitests;

import org.junit.Test;

import seedu.gtd.testutil.TestTask;
import seedu.gtd.testutil.TestUtil;

import static org.junit.Assert.assertTrue;
import static seedu.gtd.logic.commands.UndoCommand.MESSAGE_SUCCESS;;

public class UndoCommandTest extends AddressBookGuiTest {

@Test
public void undo() {

//undo the addition of the first task
TestTask[] currentList = td.getTypicalTasks();
TestTask[] previousList = currentList;
commandBox.runCommand(td.george.getAddCommand());
assertUndoSuccess(previousList);

//undo editing the dueDate of the last task in the list
int targetIndex = currentList.length;
String change = "d/2";
previousList = currentList;
commandBox.runCommand("edit " + targetIndex + " " + change);
assertUndoSuccess(previousList);

//undo deleting a task from the middle of the list
targetIndex = currentList.length/2;
previousList = currentList;
commandBox.runCommand("delete " + targetIndex);
assertUndoSuccess(previousList);

//undo clearing list
previousList = currentList;
commandBox.runCommand("clear");
assertUndoSuccess(previousList);

//undo marking the middle task as done
previousList = currentList;
commandBox.runCommand("done " + targetIndex);
assertUndoSuccess(previousList);
}

/**
* Runs the undo command to undo the last change to the task list
*/
private void assertUndoSuccess(final TestTask[] previousList) {
commandBox.runCommand("undo");

//confirm the list now contains all previous tasks except the deleted task
assertTrue(taskListPanel.isListMatching(previousList));

//confirm the result message is correct
assertResultMessage(String.format(MESSAGE_SUCCESS));
}

}
```
###### /src/test/java/seedu/gtd/testutil/TestUtil.java
Expand Down
Loading

0 comments on commit 201a591

Please sign in to comment.