-
Notifications
You must be signed in to change notification settings - Fork 411
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Alfred-specific parser classes. * Modify prefixes. * Implement Add Command Parsers.
- Loading branch information
1 parent
6a38281
commit 812a9d2
Showing
40 changed files
with
901 additions
and
225 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
54 changes: 54 additions & 0 deletions
54
src/main/java/seedu/address/logic/parser/AddCommandParsers/AddMentorCommandParser.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,54 @@ | ||
package seedu.address.logic.parser.AddCommandParsers; | ||
|
||
import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_ORGANISATION; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_SPECIALISATION; | ||
import seedu.address.logic.commands.addcommand.AddCommand; | ||
import seedu.address.logic.commands.addcommand.AddMentorCommand; | ||
import seedu.address.logic.parser.ArgumentMultimap; | ||
import seedu.address.logic.parser.ArgumentTokenizer; | ||
import seedu.address.logic.parser.Parser; | ||
import seedu.address.logic.parser.AlfredParserUtil; | ||
import seedu.address.logic.parser.exceptions.ParseException; | ||
import seedu.address.model.entity.Email; | ||
import seedu.address.model.entity.Id; | ||
import seedu.address.model.entity.Mentor; | ||
import seedu.address.model.entity.Phone; | ||
import seedu.address.model.entity.SubjectName; | ||
import seedu.address.model.entity.Name; | ||
import seedu.address.model.entitylist.MentorList; | ||
|
||
/** | ||
* Parses input arguments and creates a new AddCommand object | ||
*/ | ||
public class AddMentorCommandParser implements Parser<AddCommand> { | ||
|
||
/** | ||
* Parses the given {@code String} of arguments in the context of the AddCommand | ||
* and returns an AddCommand object for execution. | ||
* @throws ParseException if the user input does not conform the expected format | ||
*/ | ||
public AddMentorCommand parse(String args) throws ParseException { | ||
|
||
/** | ||
* Added the below code as a placeholder. We will replace it with proper code | ||
* once the Mentor class is finalised. | ||
*/ | ||
|
||
ArgumentMultimap argMultimap = | ||
ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ORGANISATION, | ||
PREFIX_SPECIALISATION); | ||
Name name = AlfredParserUtil.parseName(argMultimap.getValue(PREFIX_NAME).get()); | ||
Phone phone = AlfredParserUtil.parsePhone(argMultimap.getValue(PREFIX_PHONE).get()); | ||
Email email = AlfredParserUtil.parseEmail(argMultimap.getValue(PREFIX_EMAIL).get()); | ||
Name organisation = AlfredParserUtil.parseName(argMultimap.getValue(PREFIX_ORGANISATION).get()); | ||
SubjectName subject = AlfredParserUtil.parseSubject(argMultimap.getValue(PREFIX_SPECIALISATION).get()); | ||
Id id = new MentorList().generateID(); | ||
|
||
Mentor mentor = new Mentor(name, id, phone, email, organisation, subject); | ||
|
||
return new AddMentorCommand(mentor); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
src/main/java/seedu/address/logic/parser/AddCommandParsers/AddParticipantCommandParser.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,47 @@ | ||
package seedu.address.logic.parser.AddCommandParsers; | ||
|
||
import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; | ||
import seedu.address.logic.commands.addcommand.AddParticipantCommand; | ||
import seedu.address.logic.parser.ArgumentMultimap; | ||
import seedu.address.logic.parser.ArgumentTokenizer; | ||
import seedu.address.logic.parser.Parser; | ||
import seedu.address.logic.parser.AlfredParserUtil; | ||
import seedu.address.logic.parser.exceptions.ParseException; | ||
import seedu.address.model.entity.Email; | ||
import seedu.address.model.entity.Id; | ||
import seedu.address.model.entity.Name; | ||
import seedu.address.model.entity.Participant; | ||
import seedu.address.model.entity.Phone; | ||
import seedu.address.model.entitylist.ParticipantList; | ||
|
||
/** | ||
* Parses input arguments and creates a new AddCommand object | ||
*/ | ||
public class AddParticipantCommandParser implements Parser<AddParticipantCommand> { | ||
|
||
/** | ||
* Parses the given {@code String} of arguments in the context of the AddCommand | ||
* and returns an AddCommand object for execution. | ||
* @throws ParseException if the user input does not conform the expected format | ||
*/ | ||
public AddParticipantCommand parse(String args) throws ParseException { | ||
|
||
/** | ||
* Added the below code as a placeholder. We will replace it with proper code | ||
* once the Participant class is finalised. | ||
*/ | ||
|
||
ArgumentMultimap argMultimap = | ||
ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL); | ||
Name name = AlfredParserUtil.parseName(argMultimap.getValue(PREFIX_NAME).get()); | ||
Phone phone = AlfredParserUtil.parsePhone(argMultimap.getValue(PREFIX_PHONE).get()); | ||
Email email = AlfredParserUtil.parseEmail(argMultimap.getValue(PREFIX_EMAIL).get()); | ||
Id id = new ParticipantList().generateID(); | ||
|
||
Participant participant = new Participant(name, id, email, phone); | ||
|
||
return new AddParticipantCommand(participant); | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
src/main/java/seedu/address/logic/parser/AddCommandParsers/AddTeamCommandParser.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,58 @@ | ||
package seedu.address.logic.parser.AddCommandParsers; | ||
|
||
import static seedu.address.logic.parser.CliSyntax.PREFIX_LOCATION; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_PROJECT_NAME; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_PROJECT_TYPE; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_SPECIALISATION; | ||
import java.util.LinkedList; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import seedu.address.logic.commands.addcommand.AddCommand; | ||
import seedu.address.logic.commands.addcommand.AddTeamCommand; | ||
import seedu.address.logic.parser.ArgumentMultimap; | ||
import seedu.address.logic.parser.ArgumentTokenizer; | ||
import seedu.address.logic.parser.Parser; | ||
import seedu.address.logic.parser.AlfredParserUtil; | ||
import seedu.address.logic.parser.exceptions.ParseException; | ||
import seedu.address.model.entity.Id; | ||
import seedu.address.model.entity.Location; | ||
import seedu.address.model.entity.Mentor; | ||
import seedu.address.model.entity.Name; | ||
import seedu.address.model.entity.Participant; | ||
import seedu.address.model.entity.ProjectType; | ||
import seedu.address.model.entity.Score; | ||
import seedu.address.model.entity.SubjectName; | ||
import seedu.address.model.entity.Team; | ||
import seedu.address.model.entitylist.TeamList; | ||
|
||
/** | ||
* Parses input arguments and creates a new AddCommand object | ||
*/ | ||
public class AddTeamCommandParser implements Parser<AddCommand> { | ||
|
||
/** | ||
* Parses the given {@code String} of arguments in the context of the AddCommand | ||
* and returns an AddCommand object for execution. | ||
* @throws ParseException if the user input does not conform the expected format | ||
*/ | ||
public AddTeamCommand parse(String args) throws ParseException { | ||
ArgumentMultimap argMultimap = | ||
ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_SPECIALISATION, PREFIX_PROJECT_NAME, | ||
PREFIX_PROJECT_TYPE, PREFIX_LOCATION); | ||
|
||
Name name = AlfredParserUtil.parseName(argMultimap.getValue(PREFIX_NAME).get()); | ||
SubjectName subject = AlfredParserUtil.parseSubject(argMultimap.getValue(PREFIX_SPECIALISATION).get()); | ||
Name projectName = AlfredParserUtil.parseName(argMultimap.getValue(PREFIX_PROJECT_NAME).get()); | ||
ProjectType projectType = AlfredParserUtil.parseProjectType(argMultimap.getValue(PREFIX_PROJECT_TYPE).get()); | ||
Location location = AlfredParserUtil.parseLocation(argMultimap.getValue(PREFIX_LOCATION).get()); | ||
Id id = new TeamList().generateID(); | ||
List<Participant> participants = new LinkedList<>(); | ||
Score score = new Score(0); | ||
Optional<Mentor> mentor = Optional.empty(); | ||
|
||
Team team = new Team(id, name, participants, mentor, subject, score, projectName, projectType, location); | ||
|
||
return new AddTeamCommand(team); | ||
} | ||
} |
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.