forked from nus-cs2103-AY2122S1/tp
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Auto-Archive feature and Sort Command (#155)
* Implement Auto-Archive feature and Sort Command * Fix checkstyle * Add stashed changes * Fix test cases
- Loading branch information
Showing
21 changed files
with
211 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/main/java/seedu/docit/logic/commands/SortAppointmentsCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package seedu.docit.logic.commands; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
import java.util.List; | ||
|
||
import seedu.docit.logic.commands.exceptions.CommandException; | ||
import seedu.docit.model.Model; | ||
import seedu.docit.model.appointment.Appointment; | ||
|
||
/** | ||
* Archives an appointment identified using it's displayed index from the appointment book. | ||
*/ | ||
public class SortAppointmentsCommand extends AppointmentCommand { | ||
|
||
public static final String COMMAND_WORD = "sort"; | ||
|
||
public static final String MESSAGE_USAGE = "apmt " + COMMAND_WORD | ||
+ ": Sorts appointments based on their urgency and name.\n" | ||
+ "Parameters: [parameter to sort by..]\n" + "Example: apmt " + COMMAND_WORD + ""; // TODO | ||
|
||
public static final String MESSAGE_SORT_APPOINTMENT_SUCCESS = "Sorted Appointments based on " | ||
+ "default settings."; | ||
|
||
public SortAppointmentsCommand() { | ||
|
||
} | ||
|
||
@Override public CommandResult execute(Model model) throws CommandException { | ||
requireNonNull(model); | ||
List<Appointment> lastShownList = model.getFilteredAppointmentList(); | ||
|
||
model.sortAppointments(); | ||
return new CommandResult(String.format(MESSAGE_SORT_APPOINTMENT_SUCCESS)); | ||
} | ||
|
||
@Override public boolean equals(Object other) { | ||
return other == this // short circuit if same object | ||
|| (other instanceof SortAppointmentsCommand); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package seedu.docit.model; | ||
|
||
/** | ||
* Runnable task to auto archive appointments that are 1-day past. | ||
*/ | ||
public class AutoArchiveApmts implements Runnable { | ||
private final Model model; | ||
|
||
AutoArchiveApmts(Model model) { | ||
this.model = model; | ||
} | ||
|
||
@Override | ||
public void run() { | ||
model.archivePastAppointments(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.