forked from nus-cs2103-AY2021S1/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.
Merge branch 'master' into branch-sort-revenue
- Loading branch information
Showing
78 changed files
with
2,691 additions
and
83 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
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
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
11 changes: 11 additions & 0 deletions
11
src/main/java/seedu/homerce/logic/commands/schedule/AbstractWeekCommand.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,11 @@ | ||
package seedu.homerce.logic.commands.schedule; | ||
|
||
import seedu.homerce.logic.commands.Command; | ||
|
||
/** Wrapper class for both current and custom week commands. It is unknown whether | ||
* the user's schedule command has no parameters or contains a date. Thus, the parser | ||
* has to account for both scenarios by returning an abstract week command that is | ||
* either to display the current week or a custom week.*/ | ||
public abstract class AbstractWeekCommand extends Command { | ||
public static final String COMMAND_WORD = "schedule"; | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/seedu/homerce/logic/commands/schedule/CurrentWeekCommand.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,16 @@ | ||
package seedu.homerce.logic.commands.schedule; | ||
|
||
import seedu.homerce.logic.commands.CommandResult; | ||
import seedu.homerce.logic.commands.exceptions.CommandException; | ||
import seedu.homerce.model.Model; | ||
import seedu.homerce.model.manager.HistoryManager; | ||
import seedu.homerce.ui.schedulepanel.SchedulePanel; | ||
|
||
public class CurrentWeekCommand extends AbstractWeekCommand { | ||
private static final String MESSAGE_CURRENT_WEEK_SUCCESS = "Showing schedule of appointments for the current week."; | ||
|
||
@Override | ||
public CommandResult execute(Model model, HistoryManager historyManager) throws CommandException { | ||
return new CommandResult(MESSAGE_CURRENT_WEEK_SUCCESS, SchedulePanel.TAB_NAME); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/main/java/seedu/homerce/logic/commands/schedule/CustomWeekCommand.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,42 @@ | ||
package seedu.homerce.logic.commands.schedule; | ||
|
||
import java.util.Calendar; | ||
|
||
import seedu.homerce.logic.commands.CommandResult; | ||
import seedu.homerce.logic.commands.exceptions.CommandException; | ||
import seedu.homerce.model.Model; | ||
import seedu.homerce.model.appointment.predicate.AppointmentPaginationPredicate; | ||
import seedu.homerce.model.manager.HistoryManager; | ||
import seedu.homerce.model.util.attributes.Date; | ||
import seedu.homerce.ui.schedulepanel.SchedulePanel; | ||
|
||
public class CustomWeekCommand extends AbstractWeekCommand { | ||
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Navigate to appointment schedule. " | ||
+ "Without parameters, this command will simply navigate to the schedule tab.\nIf provided with a date, " | ||
+ "Homerce will show the schedule of the week containing that date.\n" | ||
+ "Parameters: [dt/DATE]*\n" | ||
+ "Example: " + COMMAND_WORD + " dt/25-10-2020"; | ||
|
||
private static final String MESSAGE_LIST_SCHEDULE_SUCCESS = "Showing schedule of appointments. Week of "; | ||
private final Date dateToNavigate; | ||
|
||
public CustomWeekCommand(Date dateToNavigate) { | ||
this.dateToNavigate = dateToNavigate; | ||
} | ||
|
||
@Override | ||
public CommandResult execute(Model model, HistoryManager historyManager) throws CommandException { | ||
Calendar calendar = Calendar.getInstance(); | ||
calendar.setTime(java.sql.Date.valueOf(dateToNavigate.getLocalDate())); | ||
// Change state of current week in the Appointment Manager. | ||
model.setAppointmentManagerCalendar(calendar); | ||
// Create predicate to show only entries on the particular week. | ||
AppointmentPaginationPredicate predicate = new AppointmentPaginationPredicate(calendar); | ||
model.updateFilteredSchedule(predicate); | ||
return new CommandResult( | ||
MESSAGE_LIST_SCHEDULE_SUCCESS | ||
+ predicate.toString(), | ||
SchedulePanel.TAB_NAME | ||
); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/seedu/homerce/logic/commands/schedule/NextWeekCommand.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,18 @@ | ||
package seedu.homerce.logic.commands.schedule; | ||
|
||
import seedu.homerce.logic.commands.CommandResult; | ||
import seedu.homerce.logic.commands.exceptions.CommandException; | ||
import seedu.homerce.model.Model; | ||
import seedu.homerce.model.manager.HistoryManager; | ||
import seedu.homerce.ui.schedulepanel.SchedulePanel; | ||
|
||
public class NextWeekCommand extends AbstractWeekCommand { | ||
public static final String COMMAND_WORD = "nextweek"; | ||
private static final String MESSAGE_NEXT_PAGE_SUCCESS = "Navigated to next week."; | ||
|
||
@Override | ||
public CommandResult execute(Model model, HistoryManager historyManager) throws CommandException { | ||
model.nextSchedulePage(); | ||
return new CommandResult(MESSAGE_NEXT_PAGE_SUCCESS, SchedulePanel.TAB_NAME); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/seedu/homerce/logic/commands/schedule/PreviousWeekCommand.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,18 @@ | ||
package seedu.homerce.logic.commands.schedule; | ||
|
||
import seedu.homerce.logic.commands.CommandResult; | ||
import seedu.homerce.logic.commands.exceptions.CommandException; | ||
import seedu.homerce.model.Model; | ||
import seedu.homerce.model.manager.HistoryManager; | ||
import seedu.homerce.ui.schedulepanel.SchedulePanel; | ||
|
||
public class PreviousWeekCommand extends AbstractWeekCommand { | ||
public static final String COMMAND_WORD = "previousweek"; | ||
private static final String MESSAGE_NEXT_PAGE_SUCCESS = "Navigated to previous week."; | ||
|
||
@Override | ||
public CommandResult execute(Model model, HistoryManager historyManager) throws CommandException { | ||
model.previousSchedulePage(); | ||
return new CommandResult(MESSAGE_NEXT_PAGE_SUCCESS, SchedulePanel.TAB_NAME); | ||
} | ||
} |
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
44 changes: 44 additions & 0 deletions
44
src/main/java/seedu/homerce/logic/parser/schedule/ScheduleCommandParser.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,44 @@ | ||
package seedu.homerce.logic.parser.schedule; | ||
|
||
import static seedu.homerce.logic.parser.CliSyntax.PREFIX_DATE; | ||
|
||
import seedu.homerce.logic.commands.schedule.AbstractWeekCommand; | ||
import seedu.homerce.logic.commands.schedule.CurrentWeekCommand; | ||
import seedu.homerce.logic.commands.schedule.CustomWeekCommand; | ||
import seedu.homerce.logic.parser.ArgumentMultimap; | ||
import seedu.homerce.logic.parser.ArgumentTokenizer; | ||
import seedu.homerce.logic.parser.Parser; | ||
import seedu.homerce.logic.parser.ParserUtil; | ||
import seedu.homerce.logic.parser.Prefix; | ||
import seedu.homerce.logic.parser.exceptions.ParseException; | ||
import seedu.homerce.model.util.attributes.Date; | ||
|
||
public class ScheduleCommandParser implements Parser<AbstractWeekCommand> { | ||
private static final String MESSAGE_INVALID_COMMAND_FORMAT = "Invalid parameters for schedule command.\n%1$s"; | ||
|
||
@Override | ||
public AbstractWeekCommand parse(String userInput) throws ParseException { | ||
String trimmedArgs = userInput.trim(); | ||
if (trimmedArgs.isEmpty()) { | ||
return new CurrentWeekCommand(); | ||
} | ||
ArgumentMultimap argMultimap = ArgumentTokenizer.tokenize(userInput, PREFIX_DATE); | ||
if (!isPrefixPresent(argMultimap, PREFIX_DATE) || !argMultimap.getPreamble().isEmpty()) { | ||
throw new ParseException( | ||
String.format( | ||
MESSAGE_INVALID_COMMAND_FORMAT, | ||
CustomWeekCommand.MESSAGE_USAGE | ||
) | ||
); | ||
} | ||
Date dateToNavigate = ParserUtil.parseDate(argMultimap.getValue(PREFIX_DATE).get()); | ||
return new CustomWeekCommand(dateToNavigate); | ||
} | ||
|
||
/** | ||
* Returns true if the prefix is present in the user's command. | ||
*/ | ||
private static boolean isPrefixPresent(ArgumentMultimap argumentMultimap, Prefix prefix) { | ||
return argumentMultimap.getValue(prefix).isPresent(); | ||
} | ||
} |
Oops, something went wrong.