Skip to content

Commit

Permalink
Merge pull request #57 from tsulim/branch-rename-classes
Browse files Browse the repository at this point in the history
Rename classes, methods and variables for consistency
  • Loading branch information
Pluiexo authored Mar 12, 2024
2 parents 0e15fa1 + 5777297 commit e70311e
Show file tree
Hide file tree
Showing 65 changed files with 535 additions and 535 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ dependencies {
}

shadowJar {
archiveFileName = 'addressbook.jar'
archiveFileName = 'StaffConnect.jar'
}

defaultTasks 'clean', 'test'
2 changes: 1 addition & 1 deletion docs/diagrams/ArchitectureSequenceDiagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ activate model MODEL_COLOR
model -[MODEL_COLOR]-> logic
deactivate model

logic -[LOGIC_COLOR]> storage : saveAddressBook(addressBook)
logic -[LOGIC_COLOR]> storage : saveAddressBook(staffBook)
activate storage STORAGE_COLOR

storage -[STORAGE_COLOR]> storage : Save to file
Expand Down
46 changes: 23 additions & 23 deletions src/main/java/staffconnect/MainApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
import staffconnect.commons.util.StringUtil;
import staffconnect.logic.Logic;
import staffconnect.logic.LogicManager;
import staffconnect.model.AddressBook;
import staffconnect.model.Model;
import staffconnect.model.ModelManager;
import staffconnect.model.ReadOnlyAddressBook;
import staffconnect.model.ReadOnlyStaffBook;
import staffconnect.model.ReadOnlyUserPrefs;
import staffconnect.model.StaffBook;
import staffconnect.model.UserPrefs;
import staffconnect.model.util.SampleDataUtil;
import staffconnect.storage.AddressBookStorage;
import staffconnect.storage.JsonAddressBookStorage;
import staffconnect.storage.JsonStaffBookStorage;
import staffconnect.storage.JsonUserPrefsStorage;
import staffconnect.storage.StaffBookStorage;
import staffconnect.storage.Storage;
import staffconnect.storage.StorageManager;
import staffconnect.storage.UserPrefsStorage;
Expand All @@ -48,7 +48,7 @@ public class MainApp extends Application {

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

AppParameters appParameters = AppParameters.parse(getParameters());
Expand All @@ -57,8 +57,8 @@ public void init() throws Exception {

UserPrefsStorage userPrefsStorage = new JsonUserPrefsStorage(config.getUserPrefsFilePath());
UserPrefs userPrefs = initPrefs(userPrefsStorage);
AddressBookStorage addressBookStorage = new JsonAddressBookStorage(userPrefs.getAddressBookFilePath());
storage = new StorageManager(addressBookStorage, userPrefsStorage);
StaffBookStorage staffBookStorage = new JsonStaffBookStorage(userPrefs.getStaffConnectFilePath());
storage = new StorageManager(staffBookStorage, userPrefsStorage);

model = initModelManager(storage, userPrefs);

Expand All @@ -68,26 +68,26 @@ public void init() throws Exception {
}

/**
* Returns a {@code ModelManager} with the data from {@code storage}'s address book and {@code userPrefs}. <br>
* The data from the sample address book will be used instead if {@code storage}'s address book is not found,
* or an empty address book will be used instead if errors occur when reading {@code storage}'s address book.
* Returns a {@code ModelManager} with the data from {@code storage}'s staff book and {@code userPrefs}. <br>
* The data from the sample staff book will be used instead if {@code storage}'s staff book is not found,
* or an empty staff book will be used instead if errors occur when reading {@code storage}'s staff book.
*/
private Model initModelManager(Storage storage, ReadOnlyUserPrefs userPrefs) {
logger.info("Using data file : " + storage.getAddressBookFilePath());
logger.info("Using data file : " + storage.getStaffBookFilePath());

Optional<ReadOnlyAddressBook> addressBookOptional;
ReadOnlyAddressBook initialData;
Optional<ReadOnlyStaffBook> staffBookOptional;
ReadOnlyStaffBook initialData;
try {
addressBookOptional = storage.readAddressBook();
if (!addressBookOptional.isPresent()) {
logger.info("Creating a new data file " + storage.getAddressBookFilePath()
+ " populated with a sample AddressBook.");
staffBookOptional = storage.readStaffBook();
if (!staffBookOptional.isPresent()) {
logger.info("Creating a new data file " + storage.getStaffBookFilePath()
+ " populated with a sample StaffBook.");
}
initialData = addressBookOptional.orElseGet(SampleDataUtil::getSampleAddressBook);
initialData = staffBookOptional.orElseGet(SampleDataUtil::getSampleStaffBook);
} catch (DataLoadingException e) {
logger.warning("Data file at " + storage.getAddressBookFilePath() + " could not be loaded."
+ " Will be starting with an empty AddressBook.");
initialData = new AddressBook();
logger.warning("Data file at " + storage.getStaffBookFilePath() + " could not be loaded."
+ " Will be starting with an empty StaffBook.");
initialData = new StaffBook();
}

return new ModelManager(initialData, userPrefs);
Expand Down Expand Up @@ -170,13 +170,13 @@ protected UserPrefs initPrefs(UserPrefsStorage storage) {

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

@Override
public void stop() {
logger.info("============================ [ Stopping Address Book ] =============================");
logger.info("============================ [ Stopping StaffConnect ] =============================");
try {
storage.saveUserPrefs(model.getUserPrefs());
} catch (IOException e) {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/staffconnect/commons/core/LogsCenter.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
public class LogsCenter {
private static final int MAX_FILE_COUNT = 5;
private static final int MAX_FILE_SIZE_IN_BYTES = (int) (Math.pow(2, 20) * 5); // 5MB
private static final String LOG_FILE = "addressbook.log";
private static final String LOG_FILE = "staffconnect.log";
private static final Logger logger; // logger for this class
private static Logger baseLogger; // to be used as the parent of all other loggers created by this class.
private static Level currentLogLevel = Level.INFO;
Expand Down Expand Up @@ -75,11 +75,11 @@ private static void removeHandlers(Logger logger) {
}

/**
* Creates a logger named 'ab3', containing a {@code ConsoleHandler} and a {@code FileHandler}.
* Creates a logger named 'sc', containing a {@code ConsoleHandler} and a {@code FileHandler}.
* Sets it as the {@code baseLogger}, to be used as the parent logger of all other loggers.
*/
private static void setBaseLogger() {
baseLogger = Logger.getLogger("ab3");
baseLogger = Logger.getLogger("sc");
baseLogger.setUseParentHandlers(false);
removeHandlers(baseLogger);

Expand Down
12 changes: 6 additions & 6 deletions src/main/java/staffconnect/logic/Logic.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import staffconnect.logic.commands.CommandResult;
import staffconnect.logic.commands.exceptions.CommandException;
import staffconnect.logic.parser.exceptions.ParseException;
import staffconnect.model.ReadOnlyAddressBook;
import staffconnect.model.ReadOnlyStaffBook;
import staffconnect.model.person.Person;

/**
Expand All @@ -24,19 +24,19 @@ public interface Logic {
CommandResult execute(String commandText) throws CommandException, ParseException;

/**
* Returns the AddressBook.
* Returns the StaffBook.
*
* @see Model#getAddressBook()
* @see staffconnect.model.Model#getStaffBook()
*/
ReadOnlyAddressBook getAddressBook();
ReadOnlyStaffBook getStaffBook();

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

/**
* Returns the user prefs' address book file path.
* Returns the user prefs' StaffConnect file path.
*/
Path getAddressBookFilePath();
Path getStaffConnectFilePath();

/**
* Returns the user prefs' GUI settings.
Expand Down
20 changes: 10 additions & 10 deletions src/main/java/staffconnect/logic/LogicManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
import staffconnect.logic.commands.Command;
import staffconnect.logic.commands.CommandResult;
import staffconnect.logic.commands.exceptions.CommandException;
import staffconnect.logic.parser.AddressBookParser;
import staffconnect.logic.parser.StaffConnectParser;
import staffconnect.logic.parser.exceptions.ParseException;
import staffconnect.model.Model;
import staffconnect.model.ReadOnlyAddressBook;
import staffconnect.model.ReadOnlyStaffBook;
import staffconnect.model.person.Person;
import staffconnect.storage.Storage;

Expand All @@ -31,27 +31,27 @@ public class LogicManager implements Logic {

private final Model model;
private final Storage storage;
private final AddressBookParser addressBookParser;
private final StaffConnectParser staffConnectParser;

/**
* Constructs a {@code LogicManager} with the given {@code Model} and {@code Storage}.
*/
public LogicManager(Model model, Storage storage) {
this.model = model;
this.storage = storage;
addressBookParser = new AddressBookParser();
staffConnectParser = new StaffConnectParser();
}

@Override
public CommandResult execute(String commandText) throws CommandException, ParseException {
logger.info("----------------[USER COMMAND][" + commandText + "]");

CommandResult commandResult;
Command command = addressBookParser.parseCommand(commandText);
Command command = staffConnectParser.parseCommand(commandText);
commandResult = command.execute(model);

try {
storage.saveAddressBook(model.getAddressBook());
storage.saveStaffBook(model.getStaffBook());
} catch (AccessDeniedException e) {
throw new CommandException(String.format(FILE_OPS_PERMISSION_ERROR_FORMAT, e.getMessage()), e);
} catch (IOException ioe) {
Expand All @@ -62,8 +62,8 @@ public CommandResult execute(String commandText) throws CommandException, ParseE
}

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

@Override
Expand All @@ -72,8 +72,8 @@ public ObservableList<Person> getFilteredPersonList() {
}

@Override
public Path getAddressBookFilePath() {
return model.getAddressBookFilePath();
public Path getStaffConnectFilePath() {
return model.getStaffConnectFilePath();
}

@Override
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/staffconnect/logic/commands/AddCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
import staffconnect.model.person.Person;

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

public static final String COMMAND_WORD = "add";

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 person to the staff book. "
+ "Parameters: "
+ PREFIX_NAME + "NAME "
+ PREFIX_PHONE + "PHONE "
Expand All @@ -36,7 +36,7 @@ public class AddCommand extends Command {
+ PREFIX_TAG + "owesMoney";

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_DUPLICATE_PERSON = "This person already exists in the staff book";

private final Person toAdd;

Expand Down
9 changes: 4 additions & 5 deletions src/main/java/staffconnect/logic/commands/ClearCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,21 @@

import static java.util.Objects.requireNonNull;

import staffconnect.model.AddressBook;
import staffconnect.model.Model;
import staffconnect.model.StaffBook;

/**
* Clears the address book.
* Clears the staff book.
*/
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 = "Staff book has been cleared!";

@Override
public CommandResult execute(Model model) {
requireNonNull(model);
model.setAddressBook(new AddressBook());
model.setStaffBook(new StaffBook());
return new CommandResult(MESSAGE_SUCCESS);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import staffconnect.model.person.Person;

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

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/staffconnect/logic/commands/EditCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import staffconnect.model.tag.Tag;

/**
* Edits the details of an existing person in the address book.
* Edits the details of an existing person in the staff book.
*/
public class EditCommand extends Command {

Expand All @@ -50,7 +50,7 @@ public class EditCommand extends Command {

public static final String MESSAGE_EDIT_PERSON_SUCCESS = "Edited Person: %1$s";
public static final String MESSAGE_NOT_EDITED = "At least one field to edit must be provided.";
public static final String MESSAGE_DUPLICATE_PERSON = "This person already exists in the address book.";
public static final String MESSAGE_DUPLICATE_PERSON = "This person already exists in the staff book.";

private final Index index;
private final EditPersonDescriptor editPersonDescriptor;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/staffconnect/logic/commands/ExitCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class ExitCommand extends Command {

public static final String COMMAND_WORD = "exit";

public static final String MESSAGE_EXIT_ACKNOWLEDGEMENT = "Exiting Address Book as requested ...";
public static final String MESSAGE_EXIT_ACKNOWLEDGEMENT = "Exiting StaffConnect as requested ...";

@Override
public CommandResult execute(Model model) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/staffconnect/logic/commands/FindCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import staffconnect.model.person.NameContainsKeywordsPredicate;

/**
* Finds and lists all persons in address book whose name contains any of the argument keywords.
* Finds and lists all persons in staff book whose name contains any of the argument keywords.
* Keyword matching is case insensitive.
*/
public class FindCommand extends Command {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/staffconnect/logic/commands/ListCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import staffconnect.model.Model;

/**
* Lists all persons in the address book to the user.
* Lists all persons in the staff book to the user.
*/
public class ListCommand extends Command {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
/**
* Parses user input.
*/
public class AddressBookParser {
public class StaffConnectParser {

/**
* Used for initial separation of command word and args.
*/
private static final Pattern BASIC_COMMAND_FORMAT = Pattern.compile("(?<commandWord>\\S+)(?<arguments>.*)");
private static final Logger logger = LogsCenter.getLogger(AddressBookParser.class);
private static final Logger logger = LogsCenter.getLogger(StaffConnectParser.class);

/**
* Parses user input into command for execution.
Expand Down
Loading

0 comments on commit e70311e

Please sign in to comment.