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

Morph addressbook to entrybook #21

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
dcdef32
Refactor Person -> Entry
epicfailname Feb 25, 2019
c2f5829
Refactor Name -> Title
epicfailname Feb 25, 2019
4f31e47
Refactor Email -> Link
epicfailname Feb 25, 2019
54bd083
Refactor Phone -> Comment
epicfailname Feb 25, 2019
9e8b9d6
Fix checkstyle bugs
epicfailname Feb 25, 2019
ca49f07
Refactor NameContains... -> TitleContains..
epicfailname Feb 26, 2019
86d4e8a
Change default data file path
epicfailname Feb 26, 2019
50bff52
Fix checkstyle bugs
epicfailname Feb 26, 2019
c4dd87e
Refactor AddressBook -> EntryBook
epicfailname Feb 26, 2019
1607160
Fix checkstyle bugs
epicfailname Feb 26, 2019
b0a209f
Refactor .json files for Storage tests
epicfailname Feb 26, 2019
7f0a97b
Refactor Json..AddressBook.. -> Json..EntryBook..
epicfailname Feb 26, 2019
a6becf7
Remove .json config and data files
epicfailname Feb 26, 2019
e30dce6
Refactor Person Excetions, Person -> Entry
epicfailname Feb 26, 2019
a42cc92
Refactor JsonAdaptedPerson -> JsonAdaptedEntry
epicfailname Feb 26, 2019
67e99d1
Refactor UI name Person -> Entry
epicfailname Feb 26, 2019
0dff1da
Refactor AddressBookParser -> EntryBookParser
epicfailname Feb 26, 2019
c9176d9
Refactor rename tests
epicfailname Feb 26, 2019
b0d698a
Toggle visibility of "Address" field
epicfailname Feb 26, 2019
d0a4902
Refactor rename app window title/ status bar info
epicfailname Feb 26, 2019
f6d33dd
Remove visibility of "Address" field in Entry
epicfailname Feb 26, 2019
e55dc29
Refactor argument prefixes
epicfailname Feb 26, 2019
088729d
Updated parsers for Title, Comment and Link
epicfailname Feb 27, 2019
59e57d1
Remove debugging code
epicfailname Feb 27, 2019
5521a18
Fix checkstyle bugs
epicfailname Feb 27, 2019
7f39bd0
Refactor UI messages for commands
epicfailname Feb 27, 2019
82a4f5a
Revert debugging code changes
epicfailname Feb 27, 2019
5ed2a7a
Fix checkstyle bugs
epicfailname Feb 27, 2019
fcdc94d
Fix dead link and incorrect URL example
epicfailname Feb 27, 2019
7eaaf30
Refactor to-be deprecated parser for Address
epicfailname Feb 28, 2019
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
32 changes: 16 additions & 16 deletions src/main/java/seedu/address/MainApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
import seedu.address.commons.util.StringUtil;
import seedu.address.logic.Logic;
import seedu.address.logic.LogicManager;
import seedu.address.model.AddressBook;
import seedu.address.model.EntryBook;
import seedu.address.model.Model;
import seedu.address.model.ModelManager;
import seedu.address.model.ReadOnlyAddressBook;
import seedu.address.model.ReadOnlyEntryBook;
import seedu.address.model.ReadOnlyUserPrefs;
import seedu.address.model.UserPrefs;
import seedu.address.model.util.SampleDataUtil;
import seedu.address.storage.AddressBookStorage;
import seedu.address.storage.JsonAddressBookStorage;
import seedu.address.storage.EntryBookStorage;
import seedu.address.storage.JsonEntryBookStorage;
import seedu.address.storage.JsonUserPrefsStorage;
import seedu.address.storage.Storage;
import seedu.address.storage.StorageManager;
Expand All @@ -48,16 +48,16 @@ public class MainApp extends Application {

@Override
public void init() throws Exception {
logger.info("=============================[ Initializing AddressBook ]===========================");
logger.info("=============================[ Initializing EntryBook ]===========================");
super.init();

AppParameters appParameters = AppParameters.parse(getParameters());
config = initConfig(appParameters.getConfigPath());

UserPrefsStorage userPrefsStorage = new JsonUserPrefsStorage(config.getUserPrefsFilePath());
UserPrefs userPrefs = initPrefs(userPrefsStorage);
AddressBookStorage addressBookStorage = new JsonAddressBookStorage(userPrefs.getAddressBookFilePath());
storage = new StorageManager(addressBookStorage, userPrefsStorage);
EntryBookStorage entryBookStorage = new JsonEntryBookStorage(userPrefs.getAddressBookFilePath());
storage = new StorageManager(entryBookStorage, userPrefsStorage);

initLogging(config);

Expand All @@ -74,20 +74,20 @@ public void init() throws Exception {
* or an empty address book will be used instead if errors occur when reading {@code storage}'s address book.
*/
private Model initModelManager(Storage storage, ReadOnlyUserPrefs userPrefs) {
Optional<ReadOnlyAddressBook> addressBookOptional;
ReadOnlyAddressBook initialData;
Optional<ReadOnlyEntryBook> addressBookOptional;
ReadOnlyEntryBook initialData;
try {
addressBookOptional = storage.readAddressBook();
if (!addressBookOptional.isPresent()) {
logger.info("Data file not found. Will be starting with a sample AddressBook");
logger.info("Data file not found. Will be starting with a sample EntryBook");
}
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();
logger.warning("Data file not in the correct format. Will be starting with an empty EntryBook");
initialData = new EntryBook();
} catch (IOException e) {
logger.warning("Problem while reading from the file. Will be starting with an empty AddressBook");
initialData = new AddressBook();
logger.warning("Problem while reading from the file. Will be starting with an empty EntryBook");
initialData = new EntryBook();
}

return new ModelManager(initialData, userPrefs);
Expand Down Expand Up @@ -151,7 +151,7 @@ protected UserPrefs initPrefs(UserPrefsStorage storage) {
+ "Using default user prefs");
initializedPrefs = new UserPrefs();
} catch (IOException e) {
logger.warning("Problem while reading from the file. Will be starting with an empty AddressBook");
logger.warning("Problem while reading from the file. Will be starting with an empty EntryBook");
initializedPrefs = new UserPrefs();
}

Expand All @@ -167,7 +167,7 @@ protected UserPrefs initPrefs(UserPrefsStorage storage) {

@Override
public void start(Stage primaryStage) {
logger.info("Starting AddressBook " + MainApp.VERSION);
logger.info("Starting EntryBook " + MainApp.VERSION);
ui.start(primaryStage);
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/seedu/address/commons/core/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class Messages {

public static final String MESSAGE_UNKNOWN_COMMAND = "Unknown command";
public static final String MESSAGE_INVALID_COMMAND_FORMAT = "Invalid command format! \n%1$s";
public static final String MESSAGE_INVALID_PERSON_DISPLAYED_INDEX = "The person index provided is invalid";
public static final String MESSAGE_PERSONS_LISTED_OVERVIEW = "%1$d persons listed!";
public static final String MESSAGE_INVALID_PERSON_DISPLAYED_INDEX = "The entry index provided is invalid";
public static final String MESSAGE_PERSONS_LISTED_OVERVIEW = "%1$d entries listed!";

}
22 changes: 11 additions & 11 deletions src/main/java/seedu/address/logic/Logic.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import seedu.address.logic.commands.CommandResult;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.ReadOnlyAddressBook;
import seedu.address.model.person.Person;
import seedu.address.model.ReadOnlyEntryBook;
import seedu.address.model.entry.Entry;

/**
* API of the Logic component
Expand All @@ -25,14 +25,14 @@ public interface Logic {
CommandResult execute(String commandText) throws CommandException, ParseException;

/**
* Returns the AddressBook.
* Returns the EntryBook.
*
* @see seedu.address.model.Model#getAddressBook()
*/
ReadOnlyAddressBook getAddressBook();
ReadOnlyEntryBook getAddressBook();

/** Returns an unmodifiable view of the filtered list of persons */
ObservableList<Person> getFilteredPersonList();
ObservableList<Entry> getFilteredPersonList();

/**
* Returns an unmodifiable view of the list of commands entered by the user.
Expand All @@ -56,17 +56,17 @@ public interface Logic {
void setGuiSettings(GuiSettings guiSettings);

/**
* Selected person in the filtered person list.
* null if no person is selected.
* Selected entry in the filtered entry list.
* null if no entry is selected.
*
* @see seedu.address.model.Model#selectedPersonProperty()
*/
ReadOnlyProperty<Person> selectedPersonProperty();
ReadOnlyProperty<Entry> selectedPersonProperty();

/**
* Sets the selected person in the filtered person list.
* Sets the selected entry in the filtered entry list.
*
* @see seedu.address.model.Model#setSelectedPerson(Person)
* @see seedu.address.model.Model#setSelectedPerson(Entry)
*/
void setSelectedPerson(Person person);
void setSelectedPerson(Entry entry);
}
22 changes: 11 additions & 11 deletions src/main/java/seedu/address/logic/LogicManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
import seedu.address.logic.commands.Command;
import seedu.address.logic.commands.CommandResult;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.logic.parser.AddressBookParser;
import seedu.address.logic.parser.EntryBookParser;
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.Model;
import seedu.address.model.ReadOnlyAddressBook;
import seedu.address.model.person.Person;
import seedu.address.model.ReadOnlyEntryBook;
import seedu.address.model.entry.Entry;
import seedu.address.storage.Storage;

/**
Expand All @@ -28,14 +28,14 @@ public class LogicManager implements Logic {
private final Model model;
private final Storage storage;
private final CommandHistory history;
private final AddressBookParser addressBookParser;
private final EntryBookParser entryBookParser;
private boolean addressBookModified;

public LogicManager(Model model, Storage storage) {
this.model = model;
this.storage = storage;
history = new CommandHistory();
addressBookParser = new AddressBookParser();
entryBookParser = new EntryBookParser();

// Set addressBookModified to true whenever the models' address book is modified.
model.getAddressBook().addListener(observable -> addressBookModified = true);
Expand All @@ -48,7 +48,7 @@ public CommandResult execute(String commandText) throws CommandException, ParseE

CommandResult commandResult;
try {
Command command = addressBookParser.parseCommand(commandText);
Command command = entryBookParser.parseCommand(commandText);
commandResult = command.execute(model, history);
} finally {
history.add(commandText);
Expand All @@ -67,12 +67,12 @@ public CommandResult execute(String commandText) throws CommandException, ParseE
}

@Override
public ReadOnlyAddressBook getAddressBook() {
public ReadOnlyEntryBook getAddressBook() {
return model.getAddressBook();
}

@Override
public ObservableList<Person> getFilteredPersonList() {
public ObservableList<Entry> getFilteredPersonList() {
return model.getFilteredPersonList();
}

Expand All @@ -97,12 +97,12 @@ public void setGuiSettings(GuiSettings guiSettings) {
}

@Override
public ReadOnlyProperty<Person> selectedPersonProperty() {
public ReadOnlyProperty<Entry> selectedPersonProperty() {
return model.selectedPersonProperty();
}

@Override
public void setSelectedPerson(Person person) {
model.setSelectedPerson(person);
public void setSelectedPerson(Entry entry) {
model.setSelectedPerson(entry);
}
}
45 changes: 21 additions & 24 deletions src/main/java/seedu/address/logic/commands/AddCommand.java
Original file line number Diff line number Diff line change
@@ -1,51 +1,48 @@
package seedu.address.logic.commands;

import static java.util.Objects.requireNonNull;
import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS;
import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL;
import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME;
import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_COMMENT;
import static seedu.address.logic.parser.CliSyntax.PREFIX_LINK;
import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG;
import static seedu.address.logic.parser.CliSyntax.PREFIX_TITLE;

import seedu.address.logic.CommandHistory;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
import seedu.address.model.person.Person;
import seedu.address.model.entry.Entry;

/**
* Adds a person to the address book.
* Adds a entry to the address book.
*/
public class AddCommand extends Command {

public static final String COMMAND_WORD = "add";
public static final String COMMAND_ALIAS = "a";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a person to the address book. "
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a entry to the entry book. "
+ "Parameters: "
+ PREFIX_NAME + "NAME "
+ PREFIX_PHONE + "PHONE "
+ PREFIX_EMAIL + "EMAIL "
+ PREFIX_ADDRESS + "ADDRESS "
+ PREFIX_TITLE + "TITLE "
+ PREFIX_COMMENT + "COMMENT "
+ PREFIX_LINK + "LINK "
+ "[" + PREFIX_TAG + "TAG]...\n"
+ "Example: " + COMMAND_WORD + " "
+ PREFIX_NAME + "John Doe "
+ PREFIX_PHONE + "98765432 "
+ PREFIX_EMAIL + "[email protected] "
+ PREFIX_ADDRESS + "311, Clementi Ave 2, #02-25 "
+ PREFIX_TAG + "friends "
+ PREFIX_TAG + "owesMoney";
+ PREFIX_TITLE + "Title example "
+ PREFIX_COMMENT + "Comment example "
+ PREFIX_LINK + "https://example.com "
+ PREFIX_TAG + "science "
+ PREFIX_TAG + "tech";

public static final String MESSAGE_SUCCESS = "New person added: %1$s";
public static final String MESSAGE_DUPLICATE_PERSON = "This person already exists in the address book";
public static final String MESSAGE_SUCCESS = "New entry added: %1$s";
public static final String MESSAGE_DUPLICATE_PERSON = "This entry already exists in the entry book";

private final Person toAdd;
private final Entry toAdd;

/**
* Creates an AddCommand to add the specified {@code Person}
* Creates an AddCommand to add the specified {@code Entry}
*/
public AddCommand(Person person) {
requireNonNull(person);
toAdd = person;
public AddCommand(Entry entry) {
requireNonNull(entry);
toAdd = entry;
}

@Override
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/seedu/address/logic/commands/ClearCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import static java.util.Objects.requireNonNull;

import seedu.address.logic.CommandHistory;
import seedu.address.model.AddressBook;
import seedu.address.model.EntryBook;
import seedu.address.model.Model;

/**
Expand All @@ -12,13 +12,13 @@
public class ClearCommand extends Command {

public static final String COMMAND_WORD = "clear";
public static final String MESSAGE_SUCCESS = "Address book has been cleared!";
public static final String MESSAGE_SUCCESS = "Entry book has been cleared!";


@Override
public CommandResult execute(Model model, CommandHistory history) {
requireNonNull(model);
model.setAddressBook(new AddressBook());
model.setAddressBook(new EntryBook());
model.commitAddressBook();
return new CommandResult(MESSAGE_SUCCESS);
}
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/seedu/address/logic/commands/DeleteCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@
import seedu.address.logic.CommandHistory;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
import seedu.address.model.person.Person;
import seedu.address.model.entry.Entry;

/**
* Deletes a person identified using it's displayed index from the address book.
* Deletes a entry identified using it's displayed index from the address book.
*/
public class DeleteCommand extends Command {

public static final String COMMAND_WORD = "delete";

public static final String MESSAGE_USAGE = COMMAND_WORD
+ ": Deletes the person identified by the index number used in the displayed person list.\n"
+ ": Deletes the entry identified by the index number used in the displayed entry list.\n"
+ "Parameters: INDEX (must be a positive integer)\n"
+ "Example: " + COMMAND_WORD + " 1";

public static final String MESSAGE_DELETE_PERSON_SUCCESS = "Deleted Person: %1$s";
public static final String MESSAGE_DELETE_PERSON_SUCCESS = "Deleted Entry: %1$s";

private final Index targetIndex;

Expand All @@ -34,16 +34,16 @@ public DeleteCommand(Index targetIndex) {
@Override
public CommandResult execute(Model model, CommandHistory history) throws CommandException {
requireNonNull(model);
List<Person> lastShownList = model.getFilteredPersonList();
List<Entry> lastShownList = model.getFilteredPersonList();

if (targetIndex.getZeroBased() >= lastShownList.size()) {
throw new CommandException(Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX);
}

Person personToDelete = lastShownList.get(targetIndex.getZeroBased());
model.deletePerson(personToDelete);
Entry entryToDelete = lastShownList.get(targetIndex.getZeroBased());
model.deletePerson(entryToDelete);
model.commitAddressBook();
return new CommandResult(String.format(MESSAGE_DELETE_PERSON_SUCCESS, personToDelete));
return new CommandResult(String.format(MESSAGE_DELETE_PERSON_SUCCESS, entryToDelete));
}

@Override
Expand Down
Loading