forked from nus-cs2103-AY1819S2/addressbook-level4
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added Tooth and Teeth skeleton codes * Added Teeth as an attribute to Person * Added Tooth isPresent attribute, with getter method * Added hasStatus getter method * Modified and added constructors to initialise all attributes * Added new Status class to represent Tooth status * Added crucial attributes to Status class * Added relevant getter methods to uphold OOP information hiding * Implemented Status variable, and its getter and setter methods * Assigned default values to Tooth attributes * Added skeleton code for Tooth getter method * Added relevant static teeth counts * Minor fixes for readability * Minor fixes * Minor changes to code style * Added ImportCommand to AddressBookParser.java * Added ImportCommand.java * Added ImportCommandParser.java * Added parseFile() to ParserUtil.java * Added ImportCommand to parseCommand() of AddressBookParser.java * Updated regex for parseFile() in ParserUtil.java * Updated comments for ImportCommandParser.java * Updated parseFile() for file validation in ParserUtil.java * Updated ImportCommandParser.java * Added data folder filepath to concat with input file in ParserUtil.java * Added readFile() to ImportCommand.java * Added ExportCommand.java * Removed unused import statements from ImportCommand.java * Added ExportCommand to parseCommand() of AddressBookParser.java * Updated code for ExportCommand.java * Added ExportCommandParser.java * Added parseFile() to ParserUtil.java * Changed command word to 'export' in ExportCommand.java * Updated ParserUtil.java to work with ExportCommand * Updated ExportCommandParser.java to receive exception message from ParserUtil.java * Updated ExportCommand.java * Updated ParserUtil.java to work with ExportCommand.java * Updated ImportCommandParser.java to receive exception message from ParserUtil.java * Updated readFile() to be private in ImportCommand.java * Updated ImportCommandParser.java to handle import validation * Added comments to ImportCommand.java * Updated writeFile() to be private in ExportCommand.java * Updated writeFile() to be private in ExportCommand.java * Created empty attribute classes for Date,Time,Description, Procedure, and Record * Impletemented code for the attribute classes Description & Procedure * Minor code comment fix * Implemented code for attribute classes Date & Time * Implemented code for Record class * Updated code to match codeStyle * Added import and export commands to UserGuide.adoc * Removed unused imports in ExportCommand.java * Renamed variable to match camelCase in ParserUtil.java * Renamed variable to match camelCase in ParserUtil.java * Fixed codestyle in ImportCommand.java * Fixed codestyle in ImportCommand.java * Fixed codestyle in ImportCommandParser.java * Fixed codestyle in ExportCommandParser.java * Fixed ImportCommand.java codestyle * Fixed ExportCommand.java codestyle * Add CopyCommand class * Add CopyCommand class * Add CopyTag class * Add CopyTag class for copy information * Modified Person class for temporary duplicates * Modified EditCommand for removal of copy information * Main logic for CopyCommand * Command info for CopyCommand * Add CopyCommandParser class * Copy command can be called * Cleared a bug by typo * = Add methods to help check copies * = Add Copy tag for copies * = Add checkNoCopy method into Model interface * = Add logger info for copy status * = Change isSamePerson logic for loading saved data * = Change error in INFO display * = Style check change * = Style check change * = Style check change * Added LoginWindow class and LoginWindow.fxml * Removed unnecessary segments from skeleton of LoginWindow class * Removed GUI portions for skeleton base of LoginWindow.fxml * Added textbox to plain LoginWindow.fxml and created handleStringEntered function in LoginWindow class * Added hide function to LoginWindow class * Changed hide function to close function * Fixed coding style * Fixed Import Style, removed unused Imports in LoginWindow.fxml * Created blank personal detail attribute classes (Age, DrugAllergy, Nric, Sex) * Implemented personal detail attribute classes (Age, DrugAllergy, Nric, Sex) * Minor checkstyle change * Renamed photos * Updated UserGuide.adoc * Updated image file * Testing UserGuide.adoc * Test * Test * Minor update * Test * Rename Date & Time to DateCustom & TimeCustom so it doesn't interfere with the existing inbuilt Java classes * Updated date & time occurances to DateCustom & TimeCustom * Minor checkStyle changes * Created empty command & parser classes for Sort and Stats * updated badges on README * Updated devGuide with all discussed userStories
- Loading branch information
Showing
42 changed files
with
1,321 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
File renamed without changes
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
src/main/java/seedu/address/logic/commands/CopyCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package seedu.address.logic.commands; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
import static seedu.address.model.Model.PREDICATE_SHOW_ALL_PERSONS; | ||
|
||
import java.util.List; | ||
|
||
import seedu.address.commons.core.Messages; | ||
import seedu.address.commons.core.index.Index; | ||
import seedu.address.logic.CommandHistory; | ||
import seedu.address.logic.commands.exceptions.CommandException; | ||
import seedu.address.model.Model; | ||
import seedu.address.model.person.Person; | ||
|
||
/** | ||
* Adds a person to the address book. | ||
*/ | ||
public class CopyCommand extends Command { | ||
|
||
public static final String COMMAND_WORD = "copy"; | ||
|
||
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Have a temporary duplicate person in the addressbook. " | ||
+ "Parameters: Index (Must be an integer)" | ||
+ "Example: " + COMMAND_WORD + " 1 "; | ||
|
||
public static final String MESSAGE_SUCCESS = "Person copied: %1$s"; | ||
|
||
private final Index index; | ||
|
||
/** | ||
* Creates an AddCommand to add the specified {@code Person} | ||
*/ | ||
public CopyCommand(Index index) { | ||
requireNonNull(index); | ||
this.index = index; | ||
} | ||
|
||
@Override | ||
public CommandResult execute(Model model, CommandHistory history) throws CommandException { | ||
requireNonNull(model); | ||
List<Person> lastShownList = model.getFilteredPersonList(); | ||
|
||
if (index.getZeroBased() >= lastShownList.size()) { | ||
throw new CommandException(Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); | ||
} | ||
|
||
Person personToCopy = lastShownList.get(index.getZeroBased()); | ||
Person copyPerson = personToCopy.copy(); | ||
|
||
model.addPerson(copyPerson); | ||
model.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS); | ||
model.commitAddressBook(); | ||
return new CommandResult(String.format(MESSAGE_SUCCESS, copyPerson)); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
return other == this // short circuit if same object | ||
|| (other instanceof CopyCommand // instanceof handles nulls | ||
&& index.equals(((CopyCommand) other).index)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
src/main/java/seedu/address/logic/commands/ExportCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package seedu.address.logic.commands; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
import static seedu.address.model.Model.PREDICATE_SHOW_ALL_PERSONS; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.util.logging.Logger; | ||
|
||
import seedu.address.MainApp; | ||
import seedu.address.commons.core.LogsCenter; | ||
import seedu.address.logic.CommandHistory; | ||
import seedu.address.model.Model; | ||
import seedu.address.storage.AddressBookStorage; | ||
import seedu.address.storage.JsonAddressBookStorage; | ||
import seedu.address.storage.StorageManager; | ||
|
||
/** | ||
* Exports records to a text file. | ||
*/ | ||
public class ExportCommand extends Command { | ||
|
||
public static final String COMMAND_WORD = "export"; | ||
|
||
public static final String MESSAGE_USAGE = COMMAND_WORD | ||
+ ": Exports to text file in the \"data\" folder \n" | ||
+ "Parameters: FILENAME\n" | ||
+ "Example: " + COMMAND_WORD + " records1.json"; | ||
|
||
public static final String MESSAGE_SUCCESS = "Exported the records!"; | ||
private static final String MESSAGE_FAILURE = "Problem while writing to the file."; | ||
|
||
private final File file; | ||
|
||
public ExportCommand(File file) { | ||
this.file = file; | ||
} | ||
|
||
@Override | ||
public CommandResult execute(Model model, CommandHistory history) { | ||
requireNonNull(model); | ||
writeFile(model); | ||
model.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS); | ||
return new CommandResult(MESSAGE_SUCCESS); | ||
} | ||
|
||
/** | ||
* writeFile() writes or overwrites a file with the contents of the current address book. | ||
*/ | ||
private void writeFile(Model model) { | ||
AddressBookStorage addressBookStorage = new JsonAddressBookStorage(file.toPath()); | ||
|
||
StorageManager storage = new StorageManager(addressBookStorage, null); | ||
|
||
final Logger logger = LogsCenter.getLogger(MainApp.class); | ||
|
||
try { | ||
storage.saveAddressBook(model.getAddressBook(), file.toPath()); | ||
} catch (IOException e) { | ||
logger.warning(MESSAGE_FAILURE); | ||
} | ||
} | ||
} |
82 changes: 82 additions & 0 deletions
82
src/main/java/seedu/address/logic/commands/ImportCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package seedu.address.logic.commands; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
import static seedu.address.model.Model.PREDICATE_SHOW_ALL_PERSONS; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.util.Optional; | ||
import java.util.logging.Logger; | ||
|
||
import seedu.address.MainApp; | ||
import seedu.address.commons.core.LogsCenter; | ||
import seedu.address.commons.exceptions.DataConversionException; | ||
import seedu.address.logic.CommandHistory; | ||
import seedu.address.model.AddressBook; | ||
import seedu.address.model.Model; | ||
import seedu.address.model.ReadOnlyAddressBook; | ||
import seedu.address.model.util.SampleDataUtil; | ||
import seedu.address.storage.AddressBookStorage; | ||
import seedu.address.storage.JsonAddressBookStorage; | ||
import seedu.address.storage.StorageManager; | ||
|
||
/** | ||
* Imports records from a text file. | ||
*/ | ||
public class ImportCommand extends Command { | ||
|
||
public static final String COMMAND_WORD = "import"; | ||
|
||
public static final String MESSAGE_USAGE = COMMAND_WORD | ||
+ ": Imports a text file in the \"data\" folder \n" | ||
+ "Parameters: FILENAME\n" | ||
+ "Example: " + COMMAND_WORD + " records1.json"; | ||
|
||
public static final String MESSAGE_SUCCESS = "Imported the records!"; | ||
|
||
private final File file; | ||
|
||
public ImportCommand(File file) { | ||
this.file = file; | ||
} | ||
|
||
@Override | ||
public CommandResult execute(Model model, CommandHistory history) { | ||
requireNonNull(model); | ||
readFile(model); | ||
model.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS); | ||
return new CommandResult(MESSAGE_SUCCESS); | ||
} | ||
|
||
/** | ||
* readFile() overwrites the current address book with the contents of the file. | ||
*/ | ||
private void readFile(Model model) { | ||
AddressBookStorage addressBookStorage = new JsonAddressBookStorage(file.toPath()); | ||
|
||
StorageManager storage = new StorageManager(addressBookStorage, null); | ||
|
||
final Logger logger = LogsCenter.getLogger(MainApp.class); | ||
|
||
Optional<ReadOnlyAddressBook> addressBookOptional; | ||
ReadOnlyAddressBook initialData; | ||
|
||
try { | ||
addressBookOptional = storage.readAddressBook(); | ||
if (!addressBookOptional.isPresent()) { | ||
logger.info("Data file not found. Will be starting with a sample AddressBook"); | ||
} | ||
initialData = addressBookOptional.orElseGet(SampleDataUtil::getSampleAddressBook); | ||
} catch (DataConversionException e) { | ||
logger.warning("Data file not in the correct format. " | ||
+ "Will be starting with an empty AddressBook"); | ||
initialData = new AddressBook(); | ||
} catch (IOException e) { | ||
logger.warning("Problem while reading from the file. " | ||
+ "Will be starting with an empty AddressBook"); | ||
initialData = new AddressBook(); | ||
} | ||
|
||
model.setAddressBook(initialData); | ||
} | ||
} |
Oops, something went wrong.