Skip to content

Commit

Permalink
Update comments and author for collate
Browse files Browse the repository at this point in the history
  • Loading branch information
INCENDE committed Oct 25, 2016
1 parent 1f081df commit 94de0f6
Show file tree
Hide file tree
Showing 19 changed files with 61 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import seedu.agendum.commons.events.BaseEvent;

/** Indicates the ToDoList in the model has changed*/
//@@author A0148095X
/** Indicates a request from model to load data **/
public class LoadDataRequestEvent extends BaseEvent {

public final String loadLocation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

import seedu.agendum.commons.events.BaseEvent;

/**
* Indicates an exception during a file saving
*/
//@@author A0148095X
/** Indicates an exception during a file loading **/
public class DataLoadingExceptionEvent extends BaseEvent {

public Exception exception;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import seedu.agendum.commons.events.BaseEvent;
import seedu.agendum.model.ReadOnlyToDoList;

/** Indicates the ToDoList in the model has changed*/
//@@author A0148095X
/** Indicates the ToDoList load request has completed successfully **/
public class LoadDataCompleteEvent extends BaseEvent {

public final ReadOnlyToDoList data;
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/seedu/agendum/commons/util/FileUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
public class FileUtil {
private static final String CHARSET = "UTF-8";

//@@author A0148095X
public static void deleteFile(String filePath) throws FileDeletionException {
assert StringUtil.isValidPathToFile(filePath);

Expand Down Expand Up @@ -53,7 +54,8 @@ public static boolean isFileExists(String filePath) {
File file = new File(filePath);
return isFileExists(file);
}


//@@author
public static boolean isFileExists(File file) {
return file.exists() && file.isFile();
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/seedu/agendum/commons/util/StringUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public static boolean isUnsignedInteger(String s){
return s != null && s.matches("^0*[1-9]\\d*$");
}

//@@author A0148095X
/**
* Checks whether the string matches an approved file path.
* <p>
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/seedu/agendum/commons/util/XmlUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
public class XmlUtil {

//@@author A0148095X
public static boolean isFileCorrectFormat(String filePath) {
File file = new File(filePath);
try {
Expand All @@ -25,6 +26,7 @@ public static boolean isFileCorrectFormat(String filePath) {
}
}

//@@author
/**
* Returns the xml data in the file as an object of the specified type.
*
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/seedu/agendum/logic/commands/LoadCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
import seedu.agendum.commons.util.StringUtil;
import seedu.agendum.commons.util.XmlUtil;

/**
* Allow the user to specify a folder as the data storage location
*/
//@@author A0148095X
/** Allow the user to load a file in the correct todolist format **/
public class LoadCommand extends Command {

public static final String COMMAND_WORD = "load";
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/seedu/agendum/logic/commands/StoreCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
import seedu.agendum.commons.util.FileUtil;
import seedu.agendum.commons.util.StringUtil;

/**
* Allow the user to specify a folder as the data storage location
*/
//@@author A0148095X
/** Allow the user to specify a folder as the data storage location **/
public class StoreCommand extends Command {

public static final String COMMAND_WORD = "store";
Expand Down
27 changes: 16 additions & 11 deletions src/main/java/seedu/agendum/model/ModelManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ private void indicateToDoListChanged() {
raise(new ToDoListChangedEvent(toDoList));
}

//@@author A0148095X
/** Raises an event to indicate that save location has changed */
private void indicateChangeSaveLocationRequest(String location) {
raise(new ChangeSaveLocationRequestEvent(location));
Expand All @@ -93,6 +94,7 @@ private void indicateLoadDataRequest(String location) {
raise(new LoadDataRequestEvent(location));
}

//@@author
@Override
public synchronized void deleteTasks(List<ReadOnlyTask> targets) throws TaskNotFoundException {
for (ReadOnlyTask target: targets) {
Expand All @@ -111,16 +113,7 @@ public synchronized void addTask(Task task) throws UniqueTaskList.DuplicateTaskE
updateFilteredListToShowAll();
indicateToDoListChanged();
}

@Override
public synchronized void loadFromLocation(String location) {
assert StringUtil.isValidPathToFile(location);
assert XmlUtil.isFileCorrectFormat(location);

changeSaveLocation(location);
indicateLoadDataRequest(location);
}


@Override
public synchronized void updateTask(ReadOnlyTask target, Task updatedTask)
throws UniqueTaskList.TaskNotFoundException, UniqueTaskList.DuplicateTaskException {
Expand Down Expand Up @@ -170,13 +163,24 @@ private void backupNewToDoList() {
previousLists.push(latestList);
}

// Storage method
//=========== Storage Methods ==========================================================================

//@@author A0148095X
@Override
public synchronized void changeSaveLocation(String location){
assert StringUtil.isValidPathToFile(location);
indicateChangeSaveLocationRequest(location);
}

//@@author A0148095X
@Override
public synchronized void loadFromLocation(String location) {
assert StringUtil.isValidPathToFile(location);
assert XmlUtil.isFileCorrectFormat(location);

changeSaveLocation(location);
indicateLoadDataRequest(location);
}

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

Expand Down Expand Up @@ -252,6 +256,7 @@ public String toString() {
}

//========== event handling ==================================================
//@@author A0148095X
@Override
@Subscribe
public void handleLoadDataCompleteEvent(LoadDataCompleteEvent event) {
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/seedu/agendum/storage/StorageManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ public void saveToDoList(ReadOnlyToDoList toDoList, String filePath) throws IOEx
logger.fine("Attempting to write to data file: " + filePath);
toDoListStorage.saveToDoList(toDoList, filePath);
}


//@@author A0148095X
@Override
public void setToDoListFilePath(String filePath){
assert StringUtil.isValidPathToFile(filePath);
Expand All @@ -99,6 +100,7 @@ private void saveConfigFile() {
}
}

//@@author
@Override
@Subscribe
public void handleToDoListChangedEvent(ToDoListChangedEvent event) {
Expand All @@ -109,7 +111,8 @@ public void handleToDoListChangedEvent(ToDoListChangedEvent event) {
raise(new DataSavingExceptionEvent(e));
}
}


//@@author A0148095X
@Override
@Subscribe
public void handleChangeSaveLocationRequestEvent(ChangeSaveLocationRequestEvent event) {
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/seedu/agendum/ui/StatusBarFooter.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,15 @@ public void handleToDoListChangedEvent(ToDoListChangedEvent event) {
logger.info(LogsCenter.getEventHandlingLogMessage(event, "Setting last updated status to " + lastUpdated));
setSyncStatus("Last Updated: " + lastUpdated);
}


//@@author A0148095X
@Subscribe
public void handleChangeSaveLocationRequestEvent(ChangeSaveLocationRequestEvent event) {
String saveLocation = event.location;
logger.info(LogsCenter.getEventHandlingLogMessage(event, "Setting save location to: " + saveLocation));
setSaveLocation(saveLocation);
}
//@@author
}

class DigitalClock extends Label {
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/seedu/agendum/ui/UiManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,14 @@ private void showFatalErrorDialogAndShutdown(String title, Throwable e) {

//==================== Event Handling Code =================================================================

//@@author A0148095X
@Subscribe
private void handleDataLoadingExceptionEvent(DataLoadingExceptionEvent event) {
logger.info(LogsCenter.getEventHandlingLogMessage(event));
showFileOperationAlertAndWait("Could not load data", "Could not load data from file", event.exception);
}

}

//@@author
@Subscribe
private void handleDataSavingExceptionEvent(DataSavingExceptionEvent event) {
logger.info(LogsCenter.getEventHandlingLogMessage(event));
Expand Down
1 change: 1 addition & 0 deletions src/test/java/guitests/LoadCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import seedu.agendum.model.task.Task;
import seedu.agendum.storage.XmlToDoListStorage;

//@@author A0148095X
public class LoadCommandTest extends ToDoListGuiTest {

private String command;
Expand Down
1 change: 1 addition & 0 deletions src/test/java/guitests/StoreCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import seedu.agendum.commons.util.FileUtil;
import seedu.agendum.logic.commands.StoreCommand;

//@@author A0148095X
public class StoreCommandTest extends ToDoListGuiTest {

@Test
Expand Down
6 changes: 4 additions & 2 deletions src/test/java/seedu/agendum/commons/util/FileUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ public class FileUtilTest {
@Rule
public ExpectedException thrown = ExpectedException.none();



//@@author A0148095X
@Test
public void isFileExists() throws IOException, FileDeletionException {
String filePath = "test.file";
Expand Down Expand Up @@ -100,7 +101,8 @@ public void isPathAvailable_pathAvailable() throws IOException, FileDeletionExce
// delete the file
FileUtil.deleteFile(availablePath);
}


//@@author
@Test
public void getPath(){

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public void getDetails_nullGiven_assertionError(){
StringUtil.getDetails(null);
}

//@@author A0148095X
/*
* Valid equivalence partitions for path to file:
* - file path is valid
Expand All @@ -67,7 +68,6 @@ public void getDetails_nullGiven_assertionError(){
*
* The test method below tries to verify all above with a reasonably low number of test cases.
*/

@Test
public void isValidPathToFile(){
// null and empty file paths
Expand Down
8 changes: 5 additions & 3 deletions src/test/java/seedu/agendum/logic/LogicManagerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ public void execute_delete_removesCorrectMultipleTasks() throws Exception {
expectedTDL.getTaskList());
}


//@@author A0148095X
@Test
public void execute_store_successful() throws Exception {
// setup expectations
Expand Down Expand Up @@ -457,7 +457,7 @@ public void execute_store_fail_fileExists() throws Exception {
// delete file
FileUtil.deleteFile(location);
}

//@@author

@Test
public void execute_markInvalidArgsFormat_errorMessageShown() throws Exception {
Expand Down Expand Up @@ -826,6 +826,7 @@ public void execute_undo_reversePreviousMutatingCommand() throws Exception {

}

//@@author A0148095X
@Test
public void execute_load_successful() throws Exception {
// setup expectations
Expand All @@ -847,7 +848,8 @@ public void execute_load_successful() throws Exception {

FileUtil.deleteFile(filePath);
}


//@@author
/**
* A utility class to generate test data.
*/
Expand Down
5 changes: 3 additions & 2 deletions src/test/java/seedu/agendum/storage/StorageManagerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ public void handleToDoListChangedEvent_exceptionThrown_eventRaised() throws IOEx
storage.handleToDoListChangedEvent(new ToDoListChangedEvent(new ToDoList()));
assertTrue(eventCollector.get(0) instanceof DataSavingExceptionEvent);
}


//@@author A0148095X
@Test
public void handleSaveLocationChangedEvent_validFilePath() {
String validPath = "data/test.xml";
Expand Down Expand Up @@ -133,7 +134,7 @@ public void setToDoListFilePath() {
storageManager.setToDoListFilePath(validPath);
assertEquals(validPath, storageManager.getToDoListFilePath());
}

//@@author

/**
* A Stub class to throw an exception when the save method is called
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ public void saveToDoList_nullFilePath_assertionFailure() throws IOException {
thrown.expect(AssertionError.class);
saveToDoList(new ToDoList(), null);
}


//@@author A0148095X
@Test
public void setToDoListFilePath() {
String filePath = testFolder.getRoot().getPath() + "TempToDoList.xml";
Expand Down

0 comments on commit 94de0f6

Please sign in to comment.