Skip to content

Commit

Permalink
Merge pull request #123 from CS2103JAN2017-W15-B4/staging
Browse files Browse the repository at this point in the history
V0.5rc Milestone
  • Loading branch information
yirui94 committed Apr 5, 2017
2 parents 93461cd + 3c7f0be commit 895e984
Show file tree
Hide file tree
Showing 81 changed files with 1,766 additions and 485 deletions.
411 changes: 374 additions & 37 deletions collated/main/A0148037E.md

Large diffs are not rendered by default.

134 changes: 125 additions & 9 deletions collated/test/A0148037E.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,149 @@
# A0148037E
###### \java\guitests\FindCommandTest.java
``` java
package guitests;

import static org.junit.Assert.assertTrue;

import org.junit.Test;

import seedu.geekeep.commons.core.Messages;
import seedu.geekeep.logic.commands.FindCommand;
import seedu.geekeep.model.tag.Tag;
import seedu.geekeep.model.task.DateTime;
import seedu.geekeep.testutil.TestTask;

public class FindCommandTest extends GeeKeepGuiTest {

@Test
public void find_nonEmptyList() {
assertFindResult("find Travel", "Travel", "", "", ""); //find with keyword, no results
assertFindResult("find a/01-01-18 0000", "", "01-01-18 0000", "", ""); //find with earliest time, no result
assertFindResult("find b/01-01-16 0000", "", "", "01-01-16 0000", ""); //find with latest time, no result
assertFindResult("find t/CS3230", "", "", "", "CS3230"); //find with tag, no results

assertFindResult("find Hackathon", "Hackathon", "", "", "", td.hackathon); //one result;
assertFindResult("find Trip a/01-01-17 0000", "Trip",
"01-01-17 0000", "", "", td.japan, td.spain); // multiple results

//find after deleting one result
commandBox.runCommand("delete 1");
assertFindResult("find Trip", "Trip", "", "", "", td.spain);
}

@Test
public void find_emptyList() {
commandBox.runCommand("clear");
assertFindResult("find Fishing", "Fishing", "", "", ""); // no results
}

@Test
public void find_invalidCommand_fail() {
commandBox.runCommand("findevent");
assertResultMessage(Messages.MESSAGE_UNKNOWN_COMMAND);

commandBox.runCommand("find a/01-01-18 b/01-01-17");
assertResultMessage(FindCommand.MESSAGE_TIME_CONSTRAINTS);

commandBox.runCommand("find ");
assertResultMessage(String.format(Messages.MESSAGE_INVALID_COMMAND_FORMAT, FindCommand.MESSAGE_USAGE));

commandBox.runCommand("find t/");
assertResultMessage(Tag.MESSAGE_TAG_CONSTRAINTS);

commandBox.runCommand("find a/ b/");
assertResultMessage(DateTime.MESSAGE_DATETIME_CONSTRAINTS);
}

private void assertFindResult(String command, String keyword,
String earliestTime, String latestTime,
String tag, TestTask... expectedHits) {
commandBox.runCommand(command);
assertListSize(expectedHits.length);
assertResultMessage(expectedHits.length + " tasks listed!"
+ getDetailedSuccessMsg(keyword, earliestTime, latestTime, tag));
assertTrue(taskListPanel.isListMatching(expectedHits));
}

private String getDetailedSuccessMsg(String keyword, String earliestTime,
String latestTime, String tag) {
String successMsg = " GeeKeep is showing all the tasks which:\n";
if (!keyword.isEmpty()) {
successMsg += "Contains any of keywords in [" + keyword + "] in title;\n";
}
if (!earliestTime.isEmpty()) {
successMsg += "Has starting time[event] or deadline[deadline] after "
+ earliestTime
+ ";\n";
}
if (!latestTime.isEmpty()) {
successMsg += "Has starting time[event] or deadline[deadline] before "
+ latestTime
+ ";\n";
}
if (!tag.isEmpty()) {
successMsg += "Has any of tags in [" + tag + "];\n";
}
return successMsg;
}
}
```
###### \java\seedu\geekeep\logic\LogicManagerTest.java
``` java
/**
*Generates related success message.
*/
public String generateDetailedSuccessMsg(String keyword, String earliestTime,
String latestTime, String tag) {
String successMsg = " GeeKeep is showing all the tasks which:\n";
if (!keyword.isEmpty()) {
successMsg += "Contains any of keywords in [" + keyword + "] in title;\n";
}
if (!earliestTime.isEmpty()) {
successMsg += "Has starting time[event] or deadline[deadline] after "
+ earliestTime
+ ";\n";
}
if (!latestTime.isEmpty()) {
successMsg += "Has starting time[event] or deadline[deadline] before "
+ latestTime
+ ";\n";
}
if (!tag.isEmpty()) {
successMsg += "Has any of tags in [" + tag + "];\n";
}
return successMsg;
}
```
###### \java\seedu\geekeep\testutil\TypicalTestTasks.java
``` java
public TestTask dance, japan, exercise, spain, hackathon, fishing, song, meeting, spend;

public TypicalTestTasks() {
try {
dance = new TaskBuilder().withTitle("Dance Camp")
.withLocation("123, Jurong West Ave 6, #08-111").withStartDateTime("01-04-17 1630")
.withDescription("123, Jurong West Ave 6, #08-111").withStartDateTime("01-04-17 1630")
.withEndDateTime("01-05-17 1630")
.withTags("friends").build();
japan = new TaskBuilder().withTitle("Trip to Japan").withLocation("Japan")
japan = new TaskBuilder().withTitle("Trip to Japan").withDescription("Japan")
.withStartDateTime("01-04-17 1630").withEndDateTime("01-05-17 1630")
.withTags("owesMoney", "friends").build();
exercise = new TaskBuilder().withTitle("Physical Exercise").withEndDateTime("01-05-17 1630")
.withStartDateTime("01-04-17 1630").withLocation("wall street").build();
.withStartDateTime("01-04-17 1630").withDescription("wall street").build();
spain = new TaskBuilder().withTitle("Trip to Spain").withEndDateTime("01-05-17 1630")
.withStartDateTime("01-04-17 1630").withLocation("Spain").build();
.withStartDateTime("01-04-17 1630").withDescription("Spain").build();
hackathon = new TaskBuilder().withTitle("Hackathon").withEndDateTime("01-05-17 1630")
.withStartDateTime("01-04-17 1630").withLocation("silicon valley").build();
.withStartDateTime("01-04-17 1630").withDescription("silicon valley").build();
fishing = new TaskBuilder().withTitle("Go Fishing").withEndDateTime("01-05-17 1630")
.withStartDateTime("01-04-17 1630").withLocation("little tokyo").build();
.withStartDateTime("01-04-17 1630").withDescription("little tokyo").build();
song = new TaskBuilder().withTitle("Compose Songs").withEndDateTime("01-05-17 1630")
.withStartDateTime("01-04-17 1630").withLocation("4th street").build();
.withStartDateTime("01-04-17 1630").withDescription("4th street").build();

// Manually added
meeting = new TaskBuilder().withTitle("Group Meeting").withEndDateTime("01-05-17 1630")
.withStartDateTime("01-04-17 1630").withLocation("little india").build();
.withStartDateTime("01-04-17 1630").withDescription("little india").build();
spend = new TaskBuilder().withTitle("Spend 30 Days").withEndDateTime("01-05-17 1630")
.withStartDateTime("01-04-17 1630").withLocation("chicago ave").build();
.withStartDateTime("01-04-17 1630").withDescription("chicago ave").build();
} catch (IllegalValueException e) {
e.printStackTrace();
assert false : "not possible";
Expand Down
2 changes: 1 addition & 1 deletion docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ Priorities: High (must have) - `* * *`, Medium (nice to have) - `* *`, Low (unli
| `* *` | user | redo last command | repeat the most recent command |
| `* *` | user | add a recurring task | have the same task repeat itself over a specified duration without manually adding all of them |
| `* *` | user | add a task with description | have miscellaneous details not clutter the task title |
| `* *` | user | add a task with a venue | see location that task takes place |
| `* *` | user | add a task with a description | see description that task takes place |
| `* *` | user | add a task with a tag | categorize the task |
| `* *` | user | list upcoming tasks for the week | see all the upcoming tasks from now till the end of the week |
| `* *` | user | list all tasks for the day | see an summary of tasks for the day |
Expand Down
14 changes: 7 additions & 7 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ You may also want to be familiar with the formats and keywords, explained furthe
> * Parameters can be in any order.
> **Parameter Format**
>
>
> * Each parameter has its own prefix, for example, the `START_DATETIME` has the prefix `s/` or `start/`. See the [Parameter Summary](#6-parameter-summary) for a complete list.
> * *DateTime*<br>The dateTime format should be `DD-MM-YY HHMM`
> * *Location*<br>The location description has no restriction.
> * *Tag*<br>Each tag is a single word.
> * *Description*<br>The description has no restriction.
> * *Tag*<br>Each tag is a single word.
> **Task Type**
>
Expand All @@ -113,7 +113,7 @@ Format: `help`

Adds a task with the specified details.

Format: `add TASKTITLE [start/START_DATETIME] [end/END_DATETIME] [loc/LOCATION] [tag/TAGS...]`
Format: `add TASKTITLE [start/START_DATETIME] [end/END_DATETIME] [d/DESCRIPTION] [tag/TAGS...]`

> * Each parameter has its own prefix. See the [Parameter Summary](#6-parameter-summary) for a complete list.
> * You can use abbreviations to represent all the parameter prefixes<br>
Expand All @@ -134,9 +134,9 @@ You should see the following after the above commands are entered.

Updates any details of existing task's to the new specified .

Format: `update TASKID [TASKTITLE] [start/START_DATETIME] [end/END_DATETIME] [loc/LOCATION] [tag/TAGS...]`
Format: `update TASKID [TASKTITLE] [start/START_DATETIME] [end/END_DATETIME] [d/DESCRIPTOIN] [tag/TAGS...]`

> * Updates the task at the specified *TaskID*.
> * Updates the task at the specified *TaskID*.
> * *TaskID* refers to the number shown beside the title of the task.
> * At least one of the optional fields must be provided.
> * Existing values will be updated to the input values.
Expand Down Expand Up @@ -313,7 +313,7 @@ Format: `exit`
| TASKTITLE | - | Alphanumeric Characters and spaces | :x: |`CS2103 Assignment 1`|
| START_DATETIME | `start/` | `DD-MM-YY HHMM` | :heavy_check_mark: |`01-04-17 0000`|
| END_DATETIME | `end/` | `DD-MM-YY HHMM` | :heavy_check_mark: | `01-04-17 2359`|
| LOCATION | `loc/` | No restriction | :heavy_check_mark: | `School of Computing`|
| DESCRIPTION | `d/` | No restriction | :heavy_check_mark: | `School of Computing`|

**[⬆ back to top](#table-of-contents)**

Expand Down
27 changes: 15 additions & 12 deletions src/main/java/seedu/geekeep/MainApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,23 @@
import javafx.application.Application;
import javafx.application.Platform;
import javafx.stage.Stage;
import seedu.geekeep.commons.core.Config;
import seedu.geekeep.commons.core.EventsCenter;
import seedu.geekeep.commons.core.LogsCenter;
import seedu.geekeep.commons.core.Version;
import seedu.geekeep.commons.events.ui.ExitAppRequestEvent;
import seedu.geekeep.commons.exceptions.DataConversionException;
import seedu.geekeep.commons.util.ConfigUtil;
import seedu.geekeep.commons.util.StringUtil;
import seedu.geekeep.logic.Logic;
import seedu.geekeep.logic.LogicManager;
import seedu.geekeep.model.Config;
import seedu.geekeep.model.GeeKeep;
import seedu.geekeep.model.Model;
import seedu.geekeep.model.ModelManager;
import seedu.geekeep.model.ReadOnlyGeeKeep;
import seedu.geekeep.model.UserPrefs;
import seedu.geekeep.model.util.SampleDataUtil;
import seedu.geekeep.storage.ConfigStorage;
import seedu.geekeep.storage.JsonConfigStorage;
import seedu.geekeep.storage.Storage;
import seedu.geekeep.storage.StorageManager;
import seedu.geekeep.ui.Ui;
Expand All @@ -52,14 +53,18 @@ public void init() throws Exception {
logger.info("=============================[ Initializing GeeKeep ]===========================");
super.init();

config = initConfig(getApplicationParameter("config"));
storage = new StorageManager(config.getGeekeepFilePath(), config.getUserPrefsFilePath());
String configFilePath = getApplicationParameter("config");
config = initConfig(configFilePath);
if (configFilePath == null) {
configFilePath = Config.DEFAULT_CONFIG_FILE;
}
storage = new StorageManager(configFilePath, config.getGeekeepFilePath(), config.getUserPrefsFilePath());

userPrefs = initPrefs(config);

initLogging(config);

model = initModelManager(storage, userPrefs);
model = initModelManager(config, storage, userPrefs);

logic = new LogicManager(model);

Expand All @@ -77,7 +82,7 @@ private String getApplicationParameter(String parameterName) {
}
}

private Model initModelManager(Storage storage, UserPrefs userPrefs) {
private Model initModelManager(Config config, Storage storage, UserPrefs userPrefs) {
Optional<ReadOnlyGeeKeep> geeKeepOptional;
ReadOnlyGeeKeep initialData;
try {
Expand All @@ -94,7 +99,7 @@ private Model initModelManager(Storage storage, UserPrefs userPrefs) {
initialData = new GeeKeep();
}

return new ModelManager(initialData, userPrefs);
return new ModelManager(config, initialData, userPrefs);
}

private void initLogging(Config config) {
Expand All @@ -114,8 +119,9 @@ protected Config initConfig(String configFilePath) {

logger.info("Using config file : " + configFilePathUsed);

ConfigStorage configStorage = new JsonConfigStorage(configFilePathUsed);
try {
Optional<Config> configOptional = ConfigUtil.readConfig(configFilePathUsed);
Optional<Config> configOptional = configStorage.readConfig();
initializedConfig = configOptional.orElse(new Config());
} catch (DataConversionException e) {
logger.warning("Config file at " + configFilePathUsed + " is not in the correct format. " +
Expand All @@ -125,7 +131,7 @@ protected Config initConfig(String configFilePath) {

//Update config file in case it was missing to begin with or there are new/unused fields
try {
ConfigUtil.saveConfig(initializedConfig, configFilePathUsed);
configStorage.saveConfig(initializedConfig);
} catch (IOException e) {
logger.warning("Failed to save config file : " + StringUtil.getDetails(e));
}
Expand All @@ -146,9 +152,6 @@ protected UserPrefs initPrefs(Config config) {
logger.warning("UserPrefs file at " + prefsFilePath + " is not in the correct format. " +
"Using default user prefs");
initializedPrefs = new UserPrefs();
} catch (IOException e) {
logger.warning("Problem while reading from the file. Will be starting with an empty GeeKeep");
initializedPrefs = new UserPrefs();
}

//Update prefs file in case it was missing to begin with or there are new/unused fields
Expand Down
1 change: 1 addition & 0 deletions src/main/java/seedu/geekeep/commons/core/LogsCenter.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.util.logging.SimpleFormatter;

import seedu.geekeep.commons.events.BaseEvent;
import seedu.geekeep.model.Config;

/**
* Configures and manages loggers and handlers, including their logging level
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package seedu.geekeep.commons.events.model;

import seedu.geekeep.commons.events.BaseEvent;
import seedu.geekeep.model.Config;
import seedu.geekeep.model.ReadOnlyGeeKeep;

/** Indicates the GeeKeep in the model has changed*/
public class GeekeepFilePathChangedEvent extends BaseEvent {

public final Config config;
public final ReadOnlyGeeKeep geekeep;

public GeekeepFilePathChangedEvent(Config config, ReadOnlyGeeKeep geekeep) {
this.config = config;
this.geekeep = geekeep;
}

@Override
public String toString() {
return "GeeKeep file path = " + config.getGeekeepFilePath() + "\nnumber of tasks "
+ geekeep.getTaskList().size()
+ ", number of tags " + geekeep.getTagList().size();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import seedu.geekeep.commons.core.TaskCategory;
import seedu.geekeep.commons.events.BaseEvent;

/** Indicates it is time to switch the tabs in mainwindow*/
public class SwitchTaskCategoryEvent extends BaseEvent {
public TaskCategory category;

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/geekeep/commons/util/ConfigUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import java.io.IOException;
import java.util.Optional;

import seedu.geekeep.commons.core.Config;
import seedu.geekeep.commons.exceptions.DataConversionException;
import seedu.geekeep.model.Config;

/**
* A class for accessing the Config File.
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/seedu/geekeep/logic/Logic.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package seedu.geekeep.logic;

import java.util.List;

import javafx.collections.ObservableList;
import seedu.geekeep.logic.commands.CommandResult;
import seedu.geekeep.logic.commands.exceptions.CommandException;
Expand Down Expand Up @@ -30,4 +32,7 @@ public interface Logic {
/** Returns the filtered list of floating tasks */
ObservableList<ReadOnlyTask> getFilteredDeadlineList();

/** Retruns command history */
List<String> getCommandHistory();

}
Loading

0 comments on commit 895e984

Please sign in to comment.