forked from AY2324S2-CS2103T-T09-4/tp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into View-team
# Conflicts: # src/main/java/seedu/address/logic/parser/AddressBookParser.java # src/main/java/seedu/address/model/AddressBook.java # src/main/java/seedu/address/model/ReadOnlyAddressBook.java # src/main/java/seedu/address/storage/JsonAdaptedTutorialTeam.java # src/test/java/seedu/address/model/AddressBookTest.java
- Loading branch information
Showing
35 changed files
with
1,572 additions
and
57 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
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,79 @@ | ||
@startuml | ||
!include style.puml | ||
skinparam ArrowFontStyle plain | ||
|
||
box Logic LOGIC_COLOR_T1 | ||
participant ":LogicManager" as LogicManager LOGIC_COLOR | ||
participant ":AddressBookParser" as AddressBookParser LOGIC_COLOR | ||
participant ":SearchStudentCommandParser" as SearchStudentCommandParser LOGIC_COLOR | ||
participant "p:NameContainsKeywordPredicate" as NameContainsKeywordPredicate LOGIC_COLOR | ||
participant "s:SearchStudentCommand" as SearchStudentCommand LOGIC_COLOR | ||
participant "r:CommandResult" as CommandResult LOGIC_COLOR | ||
end box | ||
|
||
box Model MODEL_COLOR_T1 | ||
participant "m:Model" as Model MODEL_COLOR | ||
end box | ||
|
||
[-> LogicManager : execute("/search_student name/Bob") | ||
activate LogicManager | ||
|
||
LogicManager -> AddressBookParser : parseCommand("/search_student name/Bob") | ||
activate AddressBookParser | ||
|
||
create SearchStudentCommandParser | ||
AddressBookParser -> SearchStudentCommandParser | ||
activate SearchStudentCommandParser | ||
|
||
SearchStudentCommandParser --> AddressBookParser | ||
deactivate SearchStudentCommandParser | ||
|
||
AddressBookParser -> SearchStudentCommandParser : parse("name/Bob") | ||
activate SearchStudentCommandParser | ||
|
||
create NameContainsKeywordPredicate | ||
SearchStudentCommandParser -> NameContainsKeywordPredicate | ||
activate NameContainsKeywordPredicate | ||
|
||
NameContainsKeywordPredicate --> SearchStudentCommandParser | ||
deactivate NameContainsKeywordPredicate | ||
|
||
create SearchStudentCommand | ||
SearchStudentCommandParser -> SearchStudentCommand | ||
activate SearchStudentCommand | ||
|
||
SearchStudentCommand --> SearchStudentCommandParser : | ||
deactivate SearchStudentCommand | ||
|
||
SearchStudentCommandParser --> AddressBookParser : s | ||
deactivate SearchStudentCommandParser | ||
'Hidden arrow to position the destroy marker below the end of the activation bar. | ||
SearchStudentCommandParser -[hidden]-> AddressBookParser | ||
destroy SearchStudentCommandParser | ||
|
||
AddressBookParser --> LogicManager : s | ||
deactivate AddressBookParser | ||
|
||
LogicManager -> SearchStudentCommand : execute(m) | ||
activate SearchStudentCommand | ||
|
||
SearchStudentCommand -> Model : updateFilteredPersonList(p) | ||
activate Model | ||
|
||
Model --> SearchStudentCommand | ||
deactivate Model | ||
|
||
create CommandResult | ||
SearchStudentCommand -> CommandResult | ||
activate CommandResult | ||
|
||
CommandResult --> SearchStudentCommand | ||
deactivate CommandResult | ||
|
||
SearchStudentCommand --> LogicManager : r | ||
deactivate SearchStudentCommand | ||
|
||
[<--LogicManager | ||
deactivate LogicManager | ||
|
||
@enduml |
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
110 changes: 110 additions & 0 deletions
110
...ess/logic/commands/allocatestudenttoteamcommands/AllocateStudentToTeamByEmailCommand.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,110 @@ | ||
package seedu.address.logic.commands.allocatestudenttoteamcommands; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_MODULECODE; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_TEAMNAME; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_TUTORIALCLASS; | ||
|
||
import seedu.address.commons.util.ToStringBuilder; | ||
import seedu.address.logic.commands.CommandResult; | ||
import seedu.address.logic.commands.exceptions.CommandException; | ||
import seedu.address.model.Model; | ||
import seedu.address.model.module.ModuleCode; | ||
import seedu.address.model.module.TutorialClass; | ||
import seedu.address.model.module.TutorialTeam; | ||
import seedu.address.model.person.Email; | ||
import seedu.address.model.person.Person; | ||
|
||
/** | ||
* Allocates a student to a team in a tutorial Class in TAHelper. | ||
*/ | ||
public class AllocateStudentToTeamByEmailCommand extends AllocateStudentToTeamCommand { | ||
|
||
public static final String COMMAND_WORD = "/allocate_team"; | ||
|
||
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Allocates a student a team in the tutorial class.\n" | ||
+ "Parameters: " | ||
+ PREFIX_EMAIL + "EMAIL " | ||
+ PREFIX_MODULECODE + "MODULE CODE " | ||
+ PREFIX_TUTORIALCLASS + "TUTORIAL CLASS " | ||
+ PREFIX_TEAMNAME + "TEAM NAME" | ||
+ "Example: " + COMMAND_WORD + " " | ||
+ PREFIX_EMAIL + "[email protected] " | ||
+ PREFIX_MODULECODE + "CS2101 " | ||
+ PREFIX_TUTORIALCLASS + "T01 " | ||
+ PREFIX_TEAMNAME + "Team 1 "; | ||
|
||
private final Email email; | ||
private final ModuleCode moduleCode; | ||
private final TutorialClass tutorialClass; | ||
private final TutorialTeam tutorialTeam; | ||
|
||
/** | ||
* Creates an AllocateStudentToTeam object. | ||
*/ | ||
public AllocateStudentToTeamByEmailCommand(Email email, ModuleCode moduleCode, | ||
TutorialClass tutorialClass, TutorialTeam tutorialTeam) { | ||
this.email = email; | ||
this.moduleCode = moduleCode; | ||
this.tutorialClass = tutorialClass; | ||
this.tutorialTeam = tutorialTeam; | ||
} | ||
|
||
@Override | ||
public CommandResult execute(Model model) throws CommandException { | ||
requireNonNull(model); | ||
|
||
if (model.findTutorialClassFromList(tutorialClass, moduleCode) == null) { | ||
throw new CommandException(String.format(MESSAGE_CLASS_DOES_NOT_EXIST, tutorialClass, moduleCode)); | ||
} | ||
|
||
ModuleCode module = model.findModuleFromList(moduleCode); | ||
TutorialClass tutClass = model.findTutorialClassFromList(tutorialClass, module); | ||
|
||
Person student = model.getUniquePersonList().getPersonByEmail(email); | ||
TutorialTeam tutTeam = model.getTutorialTeam(tutClass, tutorialTeam); | ||
|
||
if (student == null) { | ||
throw new CommandException(MESSAGE_STUDENT_DOES_NOT_EXIST); | ||
} | ||
|
||
if (tutTeam == null) { | ||
throw new CommandException(String.format(MESSAGE_TEAM_DOES_NOT_EXIST, tutorialTeam, tutClass)); | ||
} | ||
|
||
// throws commandException if any condition fails | ||
checkAllocateCondition(model, student, tutClass, tutTeam); | ||
model.allocateStudentToTeam(student, tutTeam); | ||
|
||
return new CommandResult(String.format(MESSAGE_SUCCESS, tutTeam)); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
if (other == this) { | ||
return true; | ||
} | ||
|
||
// instanceof handles nulls | ||
if (!(other instanceof AllocateStudentToTeamCommand)) { | ||
return false; | ||
} | ||
|
||
AllocateStudentToTeamByEmailCommand otherAllocateCommand = (AllocateStudentToTeamByEmailCommand) other; | ||
return this.email.equals(otherAllocateCommand.email) | ||
&& this.moduleCode.equals(otherAllocateCommand.moduleCode) | ||
&& this.tutorialClass.equals(otherAllocateCommand.tutorialClass) | ||
&& this.tutorialTeam.equals(otherAllocateCommand.tutorialTeam); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return new ToStringBuilder(this) | ||
.add("email", email) | ||
.add("moduleCode", moduleCode) | ||
.add("tutorialClass", tutorialClass) | ||
.add("tutorialTeam", tutorialTeam) | ||
.toString(); | ||
} | ||
} |
Oops, something went wrong.