Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up list command and test case #88

Merged
merged 3 commits into from
Oct 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 27 additions & 26 deletions src/main/java/seedu/flexitrack/model/ModelManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public String toString() {
}
}

//TODO:

private class DateQualifier implements Qualifier {
private String keyWords;
private String dateInfo;
Expand All @@ -217,33 +217,16 @@ private class DateQualifier implements Qualifier {
.replace(ListCommand.LIST_NEXT_WEEK_COMMAND, "").replace(ListCommand.LIST_NEXT_MONTH_COMMAND, "").trim();
}

//TODO: need to refactor
@Override
public boolean run(ReadOnlyTask task) {
boolean willBeShown=true;

if (keyWords.contains(ListCommand.LIST_FUTURE_COMMAND)) {
if (task.getIsTask()){
willBeShown = DateTimeInfo.isInTheFuture(task.getDueDate());
} else if (task.getIsEvent()){
willBeShown = DateTimeInfo.isInTheFuture(task.getEndTime());
}else {
willBeShown = !task.getIsDone();
}
} else if (keyWords.contains(ListCommand.LIST_PAST_COMMAND)){
if (task.getIsTask()){
willBeShown = DateTimeInfo.isInThePast(task.getDueDate());
} else {
willBeShown = DateTimeInfo.isInThePast(task.getEndTime());
}
} else if (keyWords.contains(ListCommand.LIST_LAST_COMMAND) || keyWords.contains(ListCommand.LIST_NEXT_COMMAND)){
willBeShown = DateTimeInfo.withInTheDuration(keyWords,task);
} else if (!dateInfo.equals("")){
willBeShown = DateTimeInfo.isOnTheDate(keyWords, task);
}

boolean willBeShown = isTaskGoingToBeShown(task);

if (willBeShown==false){
return false;
}

if (keyWords.contains(ListCommand.LIST_UNMARK_COMMAND)){
return !task.getIsDone();
} else if (keyWords.contains(ListCommand.LIST_MARK_COMMAND)){
Expand All @@ -253,11 +236,29 @@ public boolean run(ReadOnlyTask task) {
return willBeShown;

}

/**
* @param task
* @param willBeShown
* @return
*/
private boolean isTaskGoingToBeShown(ReadOnlyTask task) {
if (keyWords.contains(ListCommand.LIST_FUTURE_COMMAND)) {
if (task.getIsNotFloatingTask()){
return DateTimeInfo.isInTheFuture(DateTimeInfo.getCurrentTimeInString(), task.getEndingTimeOrDueDate());
}else {
return !task.getIsDone();
}
} else if (keyWords.contains(ListCommand.LIST_PAST_COMMAND)){
return DateTimeInfo.isInThePast(DateTimeInfo.getCurrentTimeInString(), task.getEndingTimeOrDueDate());
} else if (keyWords.contains(ListCommand.LIST_LAST_COMMAND) || keyWords.contains(ListCommand.LIST_NEXT_COMMAND)){
return DateTimeInfo.withInTheDuration(keyWords, task, DateTimeInfo.getCurrentTimeInString().toString());
} else {
return DateTimeInfo.isOnTheDate(dateInfo, task);
}
// if (!dateInfo.equals(""))
}

// @Override
// public String toString() {
// return "name=" + String.join(", ", dateKeyWords);
// }
}


Expand Down
Loading