Skip to content

Commit

Permalink
Merge pull request #88 from CS2103AUG2016-T14-C2/V0.4-Qh-Collate
Browse files Browse the repository at this point in the history
Merge V0.4-Qh-Collate
  • Loading branch information
qhng authored Oct 26, 2016
2 parents e83270f + e760248 commit c16278e
Show file tree
Hide file tree
Showing 19 changed files with 2,168 additions and 28 deletions.
1,430 changes: 1,430 additions & 0 deletions collated/main/A0139915W.md

Large diffs are not rendered by default.

660 changes: 660 additions & 0 deletions collated/test/A0139915W.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
import seedu.savvytasker.commons.events.BaseEvent;
import seedu.savvytasker.model.task.ReadOnlyTask;

//@@author A0139915W

/**
* Represents a selection change in the Person List Panel
* Represents a selection change in the Task List Panel
*/
public class TaskPanelSelectionChangedEvent extends BaseEvent {

Expand All @@ -24,3 +26,4 @@ public ReadOnlyTask getNewSelection() {
return newSelection;
}
}
//@@author
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import seedu.savvytasker.logic.parser.DateParser.InferredDate;

//@@author A0139915W
/**
* Helper functions for handling dates.
* @author A0139915W
Expand Down Expand Up @@ -127,7 +128,12 @@ private void parseStart(InferredDate startDateTime) {
calendar.set(Calendar.SECOND, 59);
this.endDateTime = calendar.getTime();
}


/**
* Sets the starting and ending date/time based on defaults for providing both
* start and end times
* @param startDateTime start time supplied
*/
private void parseStartAndEnd(InferredDate startDateTime, InferredDate endDateTime) {
assert endDateTime.getInferredDateTime() != null;
assert startDateTime.getInferredDateTime() != null;
Expand All @@ -149,4 +155,5 @@ public Date getStartDate() {
public Date getEndDate() {
return endDateTime;
}
}
}
//@@author A0139915W
6 changes: 5 additions & 1 deletion src/main/java/seedu/savvytasker/commons/util/StringUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,21 @@
* Helper functions for handling strings.
*/
public class StringUtil {
//@@author A0139915W
// reused original implementation of 'containsIgnoreCase' to find exact matches
public static boolean containsExactIgnoreCase(String source, String query) {
List<String> strings = Arrays.asList(source);
return strings.stream().filter(s -> s.equalsIgnoreCase(query)).count() > 0;
}


// reused original implementation of 'containsIgnoreCase' to find partial matches
public static boolean containsPartialIgnoreCase(String source, String query) {
if (source == null) return false;
String[] split = source.toLowerCase().split("\\s+");
List<String> strings = Arrays.asList(split);
return strings.stream().filter(s -> s.contains(query.toLowerCase())).count() > 0;
}
//@@author A0139915W

public static boolean containsIgnoreCase(String source, String query) {
String[] split = source.toLowerCase().split("\\s+");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public class AddCommand extends ModelRequiringCommand {

private Task toAdd;

//@@author A0139915W
/**
* Creates an add command.
*/
Expand All @@ -61,7 +62,6 @@ private void createTask() {
final boolean isArchived = false; // all tasks are first added as active tasks
final int taskId = 0; // taskId to be assigned by ModelManager, leave as 0

//TODO: Smart defaults for date
SmartDefaultDates sdd = new SmartDefaultDates(startDateTime, endDateTime);
this.toAdd = new Task(taskId, taskName, sdd.getStartDate(), sdd.getEndDate(),
location, priority, recurringType, numberOfRecurrence,
Expand All @@ -83,6 +83,7 @@ public CommandResult execute() {
}

}
//@@author A0139915W

/**
* Checks if a command can perform undo operations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ public class DeleteCommand extends ModelRequiringCommand {
//private LinkedList<Task> tasksToUndo = new LinkedList<Task>();
private ReadOnlySavvyTasker original;
private final int[] targetIndices;


//@@author A0139915W
public DeleteCommand(int[] targetIndices) {
this.targetIndices = targetIndices;
}
Expand Down Expand Up @@ -63,6 +64,7 @@ public CommandResult execute() {

return new CommandResult(resultSb.toString());
}
//@@author A0139915W

/**
* Checks if a command can perform undo operations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public class ListCommand extends ModelRequiringCommand {
public static final String MESSAGE_SUCCESS = "Listed all tasks";

private final ListType listType;


//@@author A0139915W
/**
* Creates the List command to list the specified tasks
* @author A0139915W
Expand Down Expand Up @@ -50,6 +51,7 @@ public CommandResult execute() {
}
return new CommandResult(getMessageForTaskListShownSummary(model.getFilteredTaskList().size()));
}
//@@author A0139915W

/**
* Checks if a command can perform undo operations
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/seedu/savvytasker/model/Model.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public interface Model {
/** Returns Savvy Tasker */
ReadOnlySavvyTasker getSavvyTasker();

//@@author A0139915W
/** Deletes the given Task. */
void deleteTask(ReadOnlyTask target) throws TaskNotFoundException;

Expand Down Expand Up @@ -52,6 +53,7 @@ public interface Model {

/** Updates the filter of the filtered task list to filter by the given keywords*/
void updateFilteredTaskList(FindType findType, String[] keywords);
//@@author A0139915W

/** Adds the given AliasSymbol */
void addAliasSymbol(AliasSymbol symbol) throws DuplicateSymbolKeywordException;
Expand Down
15 changes: 12 additions & 3 deletions src/main/java/seedu/savvytasker/model/ModelManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,13 @@
public class ModelManager extends ComponentManager implements Model {
private static final Logger logger = LogsCenter.getLogger(ModelManager.class);

//@@author A0139915W
private final SavvyTasker savvyTasker;
private final FilteredList<Task> filteredTasks;
private final SortedList<Task> sortedAndFilteredTasks;
//@@author A0139915W

//@@author A0139915W
/**
* Initializes a ModelManager with the given SavvyTasker
* and its variables should not be null
Expand Down Expand Up @@ -79,6 +82,7 @@ public ReadOnlySavvyTasker getSavvyTasker() {
private void indicateSavvyTaskerChanged() {
raise(new SavvyTaskerChangedEvent(savvyTasker));
}
//@@author A0139915W

private void indicateAliasSymbolAdded(AliasSymbol symbol) {
raise(new AliasSymbolChangedEvent(symbol, AliasSymbolChangedEvent.Action.Added));
Expand All @@ -89,6 +93,7 @@ private void indicateAliasSymbolRemoved(AliasSymbol symbol) {
}


//@@author A0139915W
@Override
public synchronized void deleteTask(ReadOnlyTask target) throws TaskNotFoundException {
savvyTasker.removeTask(target);
Expand All @@ -108,6 +113,7 @@ public synchronized void addTask(Task t) throws DuplicateTaskException, InvalidD
updateFilteredListToShowActive();
indicateSavvyTaskerChanged();
}
//@@author A0139915W

@Override
public synchronized void addAliasSymbol(AliasSymbol symbol) throws DuplicateSymbolKeywordException {
Expand All @@ -125,6 +131,7 @@ public synchronized void removeAliasSymbol(AliasSymbol symbol) throws SymbolKeyw

//=========== Filtered/Sorted Task List Accessors ===============================================================

//@@author A0139915W
@Override
public UnmodifiableObservableList<ReadOnlyTask> getFilteredTaskList() {
return new UnmodifiableObservableList<ReadOnlyTask>(sortedAndFilteredTasks);
Expand All @@ -144,12 +151,11 @@ public void updateFilteredListToShowActiveSortedByDueDate() {
public void updateFilteredListToShowActiveSortedByPriorityLevel() {
updateFilteredListToShowActive(new TaskSortedByPriorityLevel());
}

@Override
public void updateFilteredListToShowActive() {
updateFilteredTaskList(new PredicateExpression(new TaskIsActiveQualifier()));
}

private void updateFilteredListToShowActive(Comparator<Task> comparator) {
updateFilteredTaskList(
new PredicateExpression(new TaskIsActiveQualifier()),
Expand All @@ -160,7 +166,7 @@ private void updateFilteredListToShowActive(Comparator<Task> comparator) {
public void updateFilteredListToShowArchived() {
updateFilteredTaskList(new PredicateExpression(new TaskIsArchivedQualifier()));
}

@Override
public void updateFilteredTaskList(FindType findType, String[] keywords) {
assert findType != null;
Expand Down Expand Up @@ -193,6 +199,7 @@ private void updateFilteredTaskList(Expression expression, Comparator<Task> comp
filteredTasks.setPredicate(expression::satisfies);
sortedAndFilteredTasks.setComparator(comparator);
}
//@@author A0139915W

//========== Inner classes/interfaces used for filtering ==================================================

Expand Down Expand Up @@ -237,6 +244,7 @@ default Set<String> createSet(String[] keywords) {
}
}

//@@author A0139915W
/**
* Qualifier matching a partial word from the set of keywords
* @author A0139915W
Expand Down Expand Up @@ -470,5 +478,6 @@ public int compare(Task task1, Task task2) {
}

}
//@@author A0139915W

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,24 @@
* Unmodifiable view of a task list
*/
public interface ReadOnlySavvyTasker {
//@@author A0139915W
/**
* Returns a defensively copied task list.
*/
TaskList getTaskList();
//@@author A0139915W

/**
* Returns a defensively copied alias symbol list.
*/

AliasSymbolList getAliasSymbolList();
//@@author A0139915W
/**
* Returns an unmodifiable view of task list
*/
List<ReadOnlyTask> getReadOnlyListOfTasks();
//@@author A0139915W

/**
* Returns unmodifiable view of symbols list
Expand Down
20 changes: 9 additions & 11 deletions src/main/java/seedu/savvytasker/model/SavvyTasker.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@
*/
public class SavvyTasker implements ReadOnlySavvyTasker {

//@@author A0139915W
private final TaskList tasks;
//@@author A0139915W
private final AliasSymbolList symbols;

//@@author A0139915W
public SavvyTasker() {
this.tasks = new TaskList();
this.symbols = new AliasSymbolList();
Expand Down Expand Up @@ -63,9 +66,11 @@ public void resetData(Collection<? extends ReadOnlyTask> newTasks) {
public void resetData(ReadOnlySavvyTasker newData) {
resetData(newData.getReadOnlyListOfTasks());
}
//@@author A0139915W

//// symbol/task-level operations


//@@author A0139915W
/**
* Returns the next available id for use to uniquely identify a task.
* @author A0139915W
Expand All @@ -90,11 +95,7 @@ public void addTask(Task t) throws DuplicateTaskException, InvalidDateException
* @throws TaskNotFoundException if the task to be removed does not exist
*/
public boolean removeTask(ReadOnlyTask key) throws TaskNotFoundException {
if (tasks.remove(key)) {
return true;
} else {
throw new TaskList.TaskNotFoundException();
}
return tasks.remove(key);
}

/**
Expand All @@ -104,12 +105,9 @@ public boolean removeTask(ReadOnlyTask key) throws TaskNotFoundException {
* @throws TaskNotFoundException if the task to be removed does not exist
*/
public boolean replaceTask(ReadOnlyTask key, Task replacement) throws TaskNotFoundException, InvalidDateException {
if (tasks.contains(key)) {
return tasks.replace(key, replacement);
} else {
throw new TaskList.TaskNotFoundException();
}
return tasks.replace(key, replacement);
}
//@@author A0139915W

/**
* Adds an alias symbol to savvy tasker.
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/seedu/savvytasker/model/task/TaskList.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import seedu.savvytasker.commons.exceptions.DuplicateDataException;
import seedu.savvytasker.commons.exceptions.IllegalValueException;

//@@author A0139915W
/**
* A list of tasks that enforces uniqueness between its elements and does not allow nulls.
*
Expand Down Expand Up @@ -184,3 +185,4 @@ public int hashCode() {
return internalList.hashCode();
}
}
//@@author A0139915W
2 changes: 2 additions & 0 deletions src/test/java/guitests/AddCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import static org.junit.Assert.assertTrue;

//@@author A0139915W
public class AddCommandTest extends SavvyTaskerGuiTest {

@Test
Expand Down Expand Up @@ -47,3 +48,4 @@ private void assertAddSuccess(TestTask taskToAdd, TestTask... currentList) {
}

}
//@@author A0139915W
2 changes: 2 additions & 0 deletions src/test/java/guitests/guihandles/TaskListPanelHandle.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import static org.junit.Assert.assertTrue;

//@@author A0139915W
/**
* Provides a handle for the panel containing the person list.
*/
Expand Down Expand Up @@ -172,3 +173,4 @@ public int getNumberOfTasks() {
return getListView().getItems().size();
}
}
//@@author A0139915W
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import seedu.savvytasker.model.task.TaskList.DuplicateTaskException;
import seedu.savvytasker.model.task.TaskList.InvalidDateException;

//@@author A0139915W
/**
* A utility class to help with building SavvyTasker objects.
* Example usage: <br>
Expand All @@ -27,3 +28,4 @@ public SavvyTasker build(){
return savvyTasker;
}
}
//@@author A0139915W
4 changes: 3 additions & 1 deletion src/test/java/seedu/savvytasker/testutil/TaskBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
import seedu.savvytasker.model.task.PriorityLevel;
import seedu.savvytasker.model.task.RecurrenceType;

//@@author A0139915W
/**
*
* Helper to build Task objects
*/
public class TaskBuilder {

Expand Down Expand Up @@ -77,3 +78,4 @@ public TestTask build() {
}

}
//@@author A0139915W
Loading

0 comments on commit c16278e

Please sign in to comment.