Skip to content

Commit

Permalink
Merge pull request #115
Browse files Browse the repository at this point in the history
More bug fixes and list command modification
  • Loading branch information
ginloy authored Mar 31, 2023
2 parents c323a84 + 55b2740 commit 10b57fe
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 15 deletions.
16 changes: 12 additions & 4 deletions src/main/java/seedu/address/logic/commands/ListCommand.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package seedu.address.logic.commands;

import static java.util.Objects.requireNonNull;
import static seedu.address.model.Model.PREDICATE_SHOW_ALL_PERSONS;
import static seedu.address.model.Model.PREDICATE_SHOW_ALL_APPOINTMENTS;
import static seedu.address.model.Model.PREDICATE_SHOW_ALL_CUSTOMERS;
import static seedu.address.model.Model.PREDICATE_SHOW_ALL_SERVICES;
import static seedu.address.model.Model.PREDICATE_SHOW_ALL_TECHNICIANS;
import static seedu.address.model.Model.PREDICATE_SHOW_ALL_VEHICLES;

import seedu.address.model.Model;

Expand All @@ -12,14 +16,18 @@ public class ListCommand extends Command {

public static final String COMMAND_WORD = "list";

public static final String MESSAGE_SUCCESS = "Currently listing all persons";
public static final String MESSAGE_SUCCESS = "Currently listing everything";


@Override
public CommandResult execute(Model model) {
requireNonNull(model);
model.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS);
return new CommandResult(MESSAGE_SUCCESS);
model.updateFilteredCustomerList(PREDICATE_SHOW_ALL_CUSTOMERS);
model.updateFilteredAppointmentList(PREDICATE_SHOW_ALL_APPOINTMENTS);
model.updateFilteredServiceList(PREDICATE_SHOW_ALL_SERVICES);
model.updateFilteredVehicleList(PREDICATE_SHOW_ALL_VEHICLES);
model.updateFilteredTechnicianList(PREDICATE_SHOW_ALL_TECHNICIANS);
return new CommandResult(MESSAGE_SUCCESS, Tab.ALL);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public CommandResult executeUndoableCommand(Model model) throws CommandException
throw new CommandException(MESSAGE_INSUFFICIENT_PART);
}
service.getRequiredParts().decreasePartQuantity(this.partName, this.quantity);
model.resetMaps();
return new CommandResult(String.format(MESSAGE_SUCCESS_FORMAT, this.partName, this.quantity,
this.serviceId), Tab.SERVICES);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public CommandResult executeUndoableCommand(Model model) throws CommandException
throw new CommandException(MESSAGE_TECHNICIAN_NOT_FOUND);
}
appointment.removeTechnician(this.techId);
model.resetMaps();
return new CommandResult(String.format(MESSAGE_SUCCESS_FORMAT, this.techId, this.appointmentId),
Tab.APPOINTMENTS);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public CommandResult executeUndoableCommand(Model model) throws CommandException
.findFirst()
.orElseThrow();
service.removeTechnician(technician);
model.resetMaps();
return new CommandResult(String.format(MESSAGE_SUCCESS_FORMAT, this.techId, this.serviceId),
Tab.SERVICES);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import seedu.address.logic.commands.ListCustomersCommand;
import seedu.address.logic.commands.ListPartsCommand;
import seedu.address.logic.commands.ListServicesCommand;
import seedu.address.logic.commands.ListTechniciansCommand;
import seedu.address.logic.commands.ListVehiclesCommand;
import seedu.address.logic.commands.RedoCommand;
import seedu.address.logic.commands.RemovePartFromServiceCommand;
Expand Down Expand Up @@ -157,6 +158,9 @@ public Command parseCommand(String userInput) throws ParseException {
case ListServicesCommand.COMMAND_WORD:
return new ListServicesCommand();

case ListTechniciansCommand.COMMAND_WORD:
return new ListTechniciansCommand();

case ListAppointmentsCommand.COMMAND_WORD:
return new ListAppointmentsCommand();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
import static seedu.address.logic.parser.CliSyntax.PREFIX_APPOINTMENT_ID;
import static seedu.address.logic.parser.CliSyntax.PREFIX_SERVICE_ID;
import static seedu.address.logic.parser.CliSyntax.PREFIX_TECHNICIAN_ID;

import java.util.stream.Stream;
Expand Down Expand Up @@ -31,9 +30,9 @@ public RemoveTechnicianFromAppointmentCommand parse(String args) throws ParseExc
}

int techId = ParserUtil.parseInt(argMultimap.getValue(PREFIX_TECHNICIAN_ID).get());
int serviceId = ParserUtil.parseInt(argMultimap.getValue(PREFIX_SERVICE_ID).get());
int appointmentId = ParserUtil.parseInt(argMultimap.getValue(PREFIX_APPOINTMENT_ID).get());

return new RemoveTechnicianFromAppointmentCommand(techId, serviceId);
return new RemoveTechnicianFromAppointmentCommand(techId, appointmentId);
}

/**
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/seedu/address/model/Model.java
Original file line number Diff line number Diff line change
Expand Up @@ -400,4 +400,9 @@ public interface Model {
* @param cmp Technician comparator
*/
void updateTechnicianComparator(Comparator<? super Technician> cmp);

/**
* Update mappings
*/
void resetMaps();
}
3 changes: 2 additions & 1 deletion src/main/java/seedu/address/model/ModelManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ public ModelManager() {
this(new AddressBook(), new UserPrefs(), new Shop());
}

private void resetMaps() {
@Override
public void resetMaps() {
this.customerVehicleMap.reset(this.shop.getCustomerList(), this.shop.getVehicleList(),
this.shop.getAppointmentList());
this.vehicleDataMap.reset(this.shop.getVehicleList(), this.shop.getCustomerList(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,11 @@ public void updateTechnicianComparator(Comparator<? super Technician> cmp) {
throw new AssertionError("This method should not be called.");
}

@Override
public void resetMaps() {
throw new AssertionError("This method should not be called.");
}


@Override
public ReadOnlyShop getShop() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package seedu.address.logic.commands;

import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess;
import static seedu.address.logic.commands.CommandTestUtil.showPersonAtIndex;
import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_PERSON;
import static seedu.address.testutil.TypicalPersons.getTypicalAddressBook;

import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -32,9 +30,4 @@ public void execute_listIsNotFiltered_showsSameList() {
assertCommandSuccess(new ListCommand(), model, ListCommand.MESSAGE_SUCCESS, expectedModel);
}

@Test
public void execute_listIsFiltered_showsEverything() {
showPersonAtIndex(model, INDEX_FIRST_PERSON);
assertCommandSuccess(new ListCommand(), model, ListCommand.MESSAGE_SUCCESS, expectedModel);
}
}

0 comments on commit 10b57fe

Please sign in to comment.