Skip to content

Commit

Permalink
Merge pull request #160 from Psyf/refactor-1.4
Browse files Browse the repository at this point in the history
Some small adjustments
  • Loading branch information
trufflepirate committed Nov 9, 2018
2 parents ba92b13 + 4c26d24 commit 9dc5874
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 112 deletions.
8 changes: 4 additions & 4 deletions preferences.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"guiSettings" : {
"windowWidth" : 1440.0,
"windowHeight" : 839.0,
"windowWidth" : 1547.199951171875,
"windowHeight" : 828.7999877929688,
"windowCoordinates" : {
"x" : 0,
"y" : 23
"x" : -4,
"y" : 0
}
},
"addressBookFilePath" : "data\\addressbook.xml",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public CommandResult execute(Model model, CommandHistory history) throws Command


model.updateAdmin(toUpdate, updatedAdmin);
model.commitAddressBook(); //TODO: not sure what this does;
model.commitAddressBook();

return new CommandResult(MESSAGE_SUCCESS);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,42 +193,6 @@ public CommandResult execute(Model model, CommandHistory history) throws Command
throw new CommandException(MESSAGE_NO_SUCH_OPTION);
}

// TODO: 11/5/2018 REMOVE IF CASE SWITCH WORKS
/*
if (option.equals(OPTION_START)) {
if (!model.isTopJob(name)) {
throw new CommandException(MESSAGE_ONLY_TOP_JOB_STARTABLE);
}
model.startJob(name);
model.commitAddressBook();
model.updateFilteredMachineList(PREDICATE_SHOW_ALL_MACHINES);
return new CommandResult(MESSAGE_STARTED_JOB);
} else if (option.equals(OPTION_RESTART)) {
if (!model.isTopJob(name)) {
throw new CommandException(MESSAGE_ONLY_TOP_JOB_STARTABLE);
}
model.restartJob(name);
model.commitAddressBook();
model.updateFilteredMachineList(PREDICATE_SHOW_ALL_MACHINES);
return new CommandResult(MESSAGE_RESTARTED_JOB);
} else if (option.equals(OPTION_CANCEL)) {
model.cancelJob(name);
model.commitAddressBook();
model.updateFilteredMachineList(PREDICATE_SHOW_ALL_MACHINES);
return new CommandResult(MESSAGE_CANCELLED_JOB);
} else if (option.equals(OPTION_DELETE)) {
if (!model.isLoggedIn()) {
throw new CommandException(MESSAGE_ACCESS_DENIED);
}
model.deleteJob(name);
model.commitAddressBook();
model.updateFilteredMachineList(PREDICATE_SHOW_ALL_MACHINES);
return new CommandResult(MESSAGE_DELETED_JOB);
} else {
return new CommandResult(MESSAGE_NO_SUCH_OPTION);
}
*/
}

@Override
Expand Down
28 changes: 0 additions & 28 deletions src/main/java/seedu/address/model/AddressBook.java
Original file line number Diff line number Diff line change
Expand Up @@ -572,34 +572,6 @@ public String toString() {
// TODO: refine later
}


/**
* list all the current's version data for addressbook
*/
/*
public void listCurrentVersionData() {
logger.info("Listing current version data");
logger.info("-----------------------Machine data---------------------");
for (Machine m : machines.asUnmodifiableObservableList()) {
logger.info(m.getName().fullName);
}
logger.info("-----------------------Jobs data-----------------------");
for (Job j : jobs.asUnmodifiableObservableList()) {
logger.info(j.getJobName().fullName);
}
logger.info("----------------------Admins data----------------------");
for (Admin a : admins.asUnmodifiableObservableList()) {
logger.info(a.getUsername().toString());
}
logger.info("-----------------------Persons data---------------------");
for (Person p : persons.asUnmodifiableObservableList()) {
logger.info(p.getName().fullName);
}
}
*/
}


33 changes: 15 additions & 18 deletions src/main/java/seedu/address/model/ModelManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import seedu.address.commons.core.LogsCenter;
import seedu.address.commons.events.model.AddressBookChangedEvent;
import seedu.address.commons.events.model.AdminListChangedEvent;
import seedu.address.commons.events.model.JobListChangedEvent;
import seedu.address.commons.events.model.MachineListChangedEvent;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.admin.Admin;
Expand Down Expand Up @@ -61,7 +60,21 @@ public ModelManager(ReadOnlyAddressBook addressBook, UserPrefs userPrefs) {
filteredMachines = new FilteredList<>(versionedAddressBook.getMachineList());
filteredAdmins = new FilteredList<>(versionedAddressBook.getAdminList());

Timer refreshTimer = refreshUiTimer();

}

public ModelManager() {
this(new AddressBook(), new UserPrefs());
}

/**
* Helps refresh the Ui and show changes instantaneously
* @return
*/
private Timer refreshUiTimer() {
// Timer for auto print cleanup

// credit: https://dzone.com/articles/how-schedule-task-run-interval
TimerTask task = new TimerTask() {
@Override
Expand All @@ -85,10 +98,7 @@ public void run() {
long intervalPeriod = 1000;
timer.scheduleAtFixedRate(task, delay, intervalPeriod);

}

public ModelManager() {
this(new AddressBook(), new UserPrefs());
return timer;
}

@Override
Expand Down Expand Up @@ -123,19 +133,6 @@ private void indicateMachineListChanged() {
raise(new MachineListChangedEvent(versionedAddressBook));
}

// TODO: 11/3/2018 REMOVE UNUSED METHOD

/**
* Raises an event to indicate the model has changed
*/
private void indicateJobListChanged() {
raise(new JobListChangedEvent(versionedAddressBook));
/**
* Since when job changes, it implicitly implies that machine list will change too
*/
raise(new MachineListChangedEvent(versionedAddressBook));
}

// ============================== Person methods ======================================= //
@Override
public boolean hasPerson(Person person) {
Expand Down
14 changes: 0 additions & 14 deletions src/main/java/seedu/address/storage/admin/XmlAdaptedAdmin.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,27 +57,13 @@ public Admin toModelType() throws IllegalValueException {
Username.class.getSimpleName()));
}

//TODO: don't forget this
/*
if (!Name.isValidName(name)) {
throw new IllegalValueException(Name.MESSAGE_NAME_CONSTRAINTS);
}
*/

final Username modelUsername = new Username(username);

if (password == null) {
throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT,
Password.class.getSimpleName()));
}

//TODO: Don't forget this
/*
if (!Phone.isValidPhone(phone)) {
throw new IllegalValueException(Phone.MESSAGE_PHONE_CONSTRAINTS);
}
*/

final Password modelPassword = new Password(password);

return new Admin(modelUsername, modelPassword);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public class XmlSerializableMakerManagerAdmins {
/**
* Creates an empty XmlSerializableMakerManagerAdmins.
* This empty constructor is required for marshalling.
* TODO: What is marshalling?
*/
public XmlSerializableMakerManagerAdmins() {
admins = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ public void execute_addAdmin_success() throws Exception {
assertEquals(modelStub.adminList, Arrays.asList(adminToAdd));
}

//TODO: equals not tested

/**
* A default model stub that has some methods failing
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public void execute_alreadyLoggedIn_throwsCommandException() throws Exception {
ModelStub modelStub = new ModelStub();
Admin admin = new Admin(new Username("Notice how this is never made idiot proof"), new Password("oldPW"));
modelStub.setLogin(admin);
//TODO: make modelManager.setLogin idiotProof

thrown.expect(CommandException.class);
thrown.expectMessage(LoginCommand.MESSAGE_ALREADY_LOGGED_IN);
Expand All @@ -64,9 +63,6 @@ public void execute_wrongUsername_throwsCommandException() throws Exception {
loginCommand.execute(modelStub, commandHistory);
}

//TODO: test successful login by bypassing jBCrypt
//TODO: equals Method not tested

/**
* A default model stub that has some methods failing
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ public void execute_logout_successful() throws Exception {
assertEquals(modelStub.isLoggedIn(), false);
}

//TODO: did not test equals

/**
* A default model stub that have some methods
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ public void execute_removeLoggedIn_success() throws Exception {
assertEquals(modelStub.isLoggedIn(), false);
}

//TODO: equals not tested

/**
* A default model stub that has some methods failing
*/
Expand Down

0 comments on commit 9dc5874

Please sign in to comment.