Skip to content

Commit

Permalink
Refactor class methods and variables
Browse files Browse the repository at this point in the history
  • Loading branch information
tsulim committed Mar 11, 2024
1 parent 8b55376 commit 5777297
Show file tree
Hide file tree
Showing 50 changed files with 185 additions and 185 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'
12 changes: 6 additions & 6 deletions src/main/java/staffconnect/MainApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void init() throws Exception {

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

Check warning on line 61 in src/main/java/staffconnect/MainApp.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/staffconnect/MainApp.java#L60-L61

Added lines #L60 - L61 were not covered by tests

model = initModelManager(storage, userPrefs);
Expand All @@ -73,19 +73,19 @@ public void init() throws Exception {
* 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());

Check warning on line 76 in src/main/java/staffconnect/MainApp.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/staffconnect/MainApp.java#L76

Added line #L76 was not covered by tests

Optional<ReadOnlyStaffBook> staffBookOptional;
ReadOnlyStaffBook initialData;
try {
staffBookOptional = storage.readAddressBook();
staffBookOptional = storage.readStaffBook();

Check warning on line 81 in src/main/java/staffconnect/MainApp.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/staffconnect/MainApp.java#L81

Added line #L81 was not covered by tests
if (!staffBookOptional.isPresent()) {
logger.info("Creating a new data file " + storage.getAddressBookFilePath()
logger.info("Creating a new data file " + storage.getStaffBookFilePath()

Check warning on line 83 in src/main/java/staffconnect/MainApp.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/staffconnect/MainApp.java#L83

Added line #L83 was not covered by tests
+ " populated with a sample StaffBook.");
}
initialData = staffBookOptional.orElseGet(SampleDataUtil::getSampleAddressBook);
initialData = staffBookOptional.orElseGet(SampleDataUtil::getSampleStaffBook);

Check warning on line 86 in src/main/java/staffconnect/MainApp.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/staffconnect/MainApp.java#L86

Added line #L86 was not covered by tests
} catch (DataLoadingException e) {
logger.warning("Data file at " + storage.getAddressBookFilePath() + " could not be loaded."
logger.warning("Data file at " + storage.getStaffBookFilePath() + " could not be loaded."

Check warning on line 88 in src/main/java/staffconnect/MainApp.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/staffconnect/MainApp.java#L88

Added line #L88 was not covered by tests
+ " Will be starting with an empty StaffBook.");
initialData = new StaffBook();

Check warning on line 90 in src/main/java/staffconnect/MainApp.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/staffconnect/MainApp.java#L90

Added line #L90 was not covered by tests
}
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
8 changes: 4 additions & 4 deletions src/main/java/staffconnect/logic/Logic.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ public interface Logic {
/**
* Returns the StaffBook.
*
* @see staffconnect.model.Model#getAddressBook()
* @see staffconnect.model.Model#getStaffBook()
*/
ReadOnlyStaffBook getAddressBook();
ReadOnlyStaffBook getStaffBook();

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

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

/**
* Returns the user prefs' GUI settings.
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/staffconnect/logic/LogicManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public CommandResult execute(String commandText) throws CommandException, ParseE
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 ReadOnlyStaffBook getAddressBook() {
return model.getAddressBook();
public ReadOnlyStaffBook getStaffBook() {
return model.getStaffBook();

Check warning on line 66 in src/main/java/staffconnect/logic/LogicManager.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/staffconnect/logic/LogicManager.java#L66

Added line #L66 was not covered by tests
}

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

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

Check warning on line 77 in src/main/java/staffconnect/logic/LogicManager.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/staffconnect/logic/LogicManager.java#L76-L77

Added lines #L76 - L77 were not covered by tests

@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
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class ClearCommand extends Command {
@Override
public CommandResult execute(Model model) {
requireNonNull(model);
model.setAddressBook(new StaffBook());
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
12 changes: 6 additions & 6 deletions src/main/java/staffconnect/model/Model.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,22 @@ public interface Model {
void setGuiSettings(GuiSettings guiSettings);

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

/**
* Sets the user prefs' staff book file path.
* Sets the user prefs' StaffConnect file path.
*/
void setAddressBookFilePath(Path addressBookFilePath);
void setStaffConnectFilePath(Path staffConnectFilePath);

/**
* Replaces staff book data with the data in {@code staffBook}.
*/
void setAddressBook(ReadOnlyStaffBook staffBook);
void setStaffBook(ReadOnlyStaffBook staffBook);

/** Returns the StaffBook */
ReadOnlyStaffBook getAddressBook();
ReadOnlyStaffBook getStaffBook();

/**
* Returns true if a person with the same identity as {@code person} exists in the staff book.
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/staffconnect/model/ModelManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,25 +65,25 @@ public void setGuiSettings(GuiSettings guiSettings) {
}

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

@Override
public void setAddressBookFilePath(Path addressBookFilePath) {
requireNonNull(addressBookFilePath);
userPrefs.setAddressBookFilePath(addressBookFilePath);
public void setStaffConnectFilePath(Path staffConnectFilePath) {
requireNonNull(staffConnectFilePath);
userPrefs.setStaffConnectFilePath(staffConnectFilePath);
}

//=========== StaffBook ================================================================================

@Override
public void setAddressBook(ReadOnlyStaffBook staffBook) {
public void setStaffBook(ReadOnlyStaffBook staffBook) {
this.staffBook.resetData(staffBook);
}

@Override
public ReadOnlyStaffBook getAddressBook() {
public ReadOnlyStaffBook getStaffBook() {
return staffBook;
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/staffconnect/model/ReadOnlyUserPrefs.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ public interface ReadOnlyUserPrefs {

GuiSettings getGuiSettings();

Path getAddressBookFilePath();
Path getStaffConnectFilePath();

}
2 changes: 1 addition & 1 deletion src/main/java/staffconnect/model/StaffBook.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import staffconnect.model.person.UniquePersonList;

/**
* Wraps all data at the fundamental level
* Wraps all data at the address-book level
* Duplicates are not allowed (by .isSamePerson comparison)
*/
public class StaffBook implements ReadOnlyStaffBook {
Expand Down
20 changes: 10 additions & 10 deletions src/main/java/staffconnect/model/UserPrefs.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
public class UserPrefs implements ReadOnlyUserPrefs {

private GuiSettings guiSettings = new GuiSettings();
private Path addressBookFilePath = Paths.get("data" , "addressbook.json");
private Path staffConnectFilePath = Paths.get("data" , "staffconnect.json");

/**
* Creates a {@code UserPrefs} with default values.
Expand All @@ -35,7 +35,7 @@ public UserPrefs(ReadOnlyUserPrefs userPrefs) {
public void resetData(ReadOnlyUserPrefs newUserPrefs) {
requireNonNull(newUserPrefs);
setGuiSettings(newUserPrefs.getGuiSettings());
setAddressBookFilePath(newUserPrefs.getAddressBookFilePath());
setStaffConnectFilePath(newUserPrefs.getStaffConnectFilePath());
}

public GuiSettings getGuiSettings() {
Expand All @@ -47,13 +47,13 @@ public void setGuiSettings(GuiSettings guiSettings) {
this.guiSettings = guiSettings;
}

public Path getAddressBookFilePath() {
return addressBookFilePath;
public Path getStaffConnectFilePath() {
return staffConnectFilePath;
}

public void setAddressBookFilePath(Path addressBookFilePath) {
requireNonNull(addressBookFilePath);
this.addressBookFilePath = addressBookFilePath;
public void setStaffConnectFilePath(Path staffConnectFilePath) {
requireNonNull(staffConnectFilePath);
this.staffConnectFilePath = staffConnectFilePath;
}

@Override
Expand All @@ -69,19 +69,19 @@ public boolean equals(Object other) {

UserPrefs otherUserPrefs = (UserPrefs) other;
return guiSettings.equals(otherUserPrefs.guiSettings)
&& addressBookFilePath.equals(otherUserPrefs.addressBookFilePath);
&& staffConnectFilePath.equals(otherUserPrefs.staffConnectFilePath);
}

@Override
public int hashCode() {
return Objects.hash(guiSettings, addressBookFilePath);
return Objects.hash(guiSettings, staffConnectFilePath);
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("Gui Settings : " + guiSettings);
sb.append("\nLocal data file location : " + addressBookFilePath);
sb.append("\nLocal data file location : " + staffConnectFilePath);
return sb.toString();
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/staffconnect/model/person/Address.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import static staffconnect.commons.util.AppUtil.checkArgument;

/**
* Represents a Person's address in the address book.
* Represents a Person's address in the staff book.
* Guarantees: immutable; is valid as declared in {@link #isValidAddress(String)}
*/
public class Address {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/staffconnect/model/person/Email.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import static staffconnect.commons.util.AppUtil.checkArgument;

/**
* Represents a Person's email in the address book.
* Represents a Person's email in the staff book.
* Guarantees: immutable; is valid as declared in {@link #isValidEmail(String)}
*/
public class Email {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/staffconnect/model/person/Name.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import static staffconnect.commons.util.AppUtil.checkArgument;

/**
* Represents a Person's name in the address book.
* Represents a Person's name in the staff book.
* Guarantees: immutable; is valid as declared in {@link #isValidName(String)}
*/
public class Name {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/staffconnect/model/person/Person.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import staffconnect.model.tag.Tag;

/**
* Represents a Person in the address book.
* Represents a Person in the staff book.
* Guarantees: details are present and not null, field values are validated, immutable.
*/
public class Person {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/staffconnect/model/person/Phone.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import static staffconnect.commons.util.AppUtil.checkArgument;

/**
* Represents a Person's phone number in the address book.
* Represents a Person's phone number in the staff book.
* Guarantees: immutable; is valid as declared in {@link #isValidPhone(String)}
*/
public class Phone {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/staffconnect/model/tag/Tag.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import static staffconnect.commons.util.AppUtil.checkArgument;

/**
* Represents a Tag in the address book.
* Represents a Tag in the staff book.
* Guarantees: immutable; name is valid as declared in {@link #isValidTagName(String)}
*/
public class Tag {
Expand Down
Loading

0 comments on commit 5777297

Please sign in to comment.