forked from nus-cs2103-AY1718S2/addressbook-level4
-
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.
Update classes for job management and remove address (nus-cs2103-AY17…
…18S2#56) * Create command classes for job management features * Update Model API to support addJob and closeJob * Add new prefixes in CliSyntax to support adding of job * Rename command for remark * Add closeJob and addJob methods in ModelManager and AddCommandTest class * Rename attribute in Job class * Update AddJobCommand class * Update message in AddJobCommand class * UserGuide.adoc: update job adding feature format * Add parse method in ParserUtil class for VehicleNumber * Add new class AddJobCommandParser (incomplete) * Update authorship to classes * Update Logic and Model component to support job management * Remove all address parameter for add employee * Update ui classes to remove address field
- Loading branch information
Showing
54 changed files
with
421 additions
and
413 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,7 @@ e.g. typing *`help`* and pressing kbd:[Enter] will open the help window. | |
* Words in `UPPER_CASE` are the parameters to be supplied by the user e.g. in `adde n/NAME`, `NAME` is a parameter which can be used as `adde n/John Doe`. | ||
* Items in square brackets are optional e.g `n/NAME [t/TAG]` can be used as `n/John Doe t/mechanic` or as `n/John Doe`. | ||
* Items with `…` after them can be used multiple times including zero times e.g. `[t/TAG]...` can be used as `{nbsp}` (i.e. 0 times), `t/mechanic`, `t/technician` etc. | ||
* Items with `+` after them can be used multiple times but has to be used **at least once** e.g. `w/ASSIGNED_EMPLOYEE_INDEX+` can be used as `w/4`, `w/5` etc. | ||
* Parameters can be in any order e.g. if the command specifies `n/NAME p/PHONE_NUMBER`, `p/PHONE_NUMBER n/NAME` is also acceptable. | ||
==== | ||
|
||
|
@@ -63,12 +64,12 @@ Format: `help` | |
=== Adding an job entry: `addj` | ||
|
||
Adds a job entry to CarviciM + | ||
Format: `addj n/NAME p/PHONE_NUMBER e/EMAIL v/VEHICLE_NUMBER w/EMPLOYEE_INDEX` | ||
Format: `addj n/NAME p/PHONE_NUMBER e/EMAIL v/VEHICLE_NUMBER w/ASSIGNED_EMPLOYEE_INDEX+` | ||
|
||
Examples: | ||
|
||
* `addj n/John Doe p/98765432 e/[email protected] v/bhj123 w/33` | ||
* `addj n/Betsy Crowe p/93939393 e/[email protected] v/ss888 w/2` | ||
* `addj n/John Doe p/98765432 e/[email protected] v/bhj123 w/3` | ||
* `addj n/Betsy Crowe p/93939393 e/[email protected] v/ss888 w/2 w/3 w/5` | ||
|
||
=== Closing a job entry: `closej` | ||
|
||
|
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 |
---|---|---|
@@ -1,7 +1,6 @@ | ||
package seedu.address.logic.commands; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS; | ||
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; | ||
|
@@ -23,13 +22,11 @@ public class AddCommand extends UndoableCommand { | |
+ PREFIX_NAME + "NAME " | ||
+ PREFIX_PHONE + "PHONE " | ||
+ PREFIX_EMAIL + "EMAIL " | ||
+ PREFIX_ADDRESS + "ADDRESS " | ||
+ "[" + PREFIX_TAG + "TAG]...\n" | ||
+ "Example: " + COMMAND_WORD + " " | ||
+ PREFIX_NAME + "John Doe " | ||
+ PREFIX_PHONE + "98765432 " | ||
+ PREFIX_EMAIL + "[email protected] " | ||
+ PREFIX_ADDRESS + "311, Clementi Ave 2, #02-25 " | ||
+ PREFIX_TAG + "friends " | ||
+ PREFIX_TAG + "owesMoney"; | ||
|
||
|
60 changes: 60 additions & 0 deletions
60
src/main/java/seedu/address/logic/commands/AddJobCommand.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,60 @@ | ||
package seedu.address.logic.commands; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_ASSIGNED_EMPLOYEE; | ||
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 static seedu.address.logic.parser.CliSyntax.PREFIX_VEHICLE_NUMBER; | ||
|
||
import seedu.address.model.job.Job; | ||
|
||
/** | ||
* Adds a job to CarviciM | ||
*/ | ||
public class AddJobCommand extends UndoableCommand { | ||
|
||
public static final String COMMAND_WORD = "addj"; | ||
|
||
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a job to the CarviciM. " | ||
+ "Parameters: " | ||
+ PREFIX_NAME + "CLIENT_NAME " | ||
+ PREFIX_PHONE + "PHONE " | ||
+ PREFIX_EMAIL + "EMAIL " | ||
+ PREFIX_VEHICLE_NUMBER + "VEHICLE_NUMBER " | ||
+ PREFIX_ASSIGNED_EMPLOYEE + "ASSIGNED_EMPLOYEE_INDEX+\n" | ||
+ "Example: " + COMMAND_WORD + " " | ||
+ PREFIX_NAME + "John Doe " | ||
+ PREFIX_PHONE + "98765432 " | ||
+ PREFIX_EMAIL + "[email protected] " | ||
+ PREFIX_VEHICLE_NUMBER + "SHG123A " | ||
+ PREFIX_ASSIGNED_EMPLOYEE + "3 " | ||
+ PREFIX_ASSIGNED_EMPLOYEE + "6 "; | ||
|
||
public static final String MESSAGE_SUCCESS = "New job added: %1$s"; | ||
|
||
private final Job toAdd; | ||
|
||
/** | ||
* Creates an AddJobCommand to add the specified {@code Job} | ||
*/ | ||
public AddJobCommand(Job job) { | ||
requireNonNull(job); | ||
toAdd = job; | ||
} | ||
|
||
@Override | ||
public CommandResult executeUndoableCommand() { | ||
requireNonNull(model); | ||
model.addJob(toAdd); | ||
return new CommandResult(String.format(MESSAGE_SUCCESS, toAdd)); | ||
|
||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
return other == this // short circuit if same object | ||
|| (other instanceof AddJobCommand // instanceof handles nulls | ||
&& toAdd.equals(((AddJobCommand) other).toAdd)); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/seedu/address/logic/commands/CloseJobCommand.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,7 @@ | ||
package seedu.address.logic.commands; | ||
|
||
/** | ||
* Closes an ongoing job in CarviciM | ||
*/ | ||
public class CloseJobCommand { | ||
} |
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
7 changes: 7 additions & 0 deletions
7
src/main/java/seedu/address/logic/commands/RemarkCommand.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,7 @@ | ||
package seedu.address.logic.commands; | ||
|
||
/** | ||
* Adds a remark to a job in CarviciM | ||
*/ | ||
public class RemarkCommand { | ||
} |
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
45 changes: 45 additions & 0 deletions
45
src/main/java/seedu/address/logic/parser/AddJobCommandParser.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,45 @@ | ||
package seedu.address.logic.parser; | ||
|
||
import static seedu.address.logic.parser.CliSyntax.PREFIX_ASSIGNED_EMPLOYEE; | ||
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 static seedu.address.logic.parser.CliSyntax.PREFIX_VEHICLE_NUMBER; | ||
|
||
import java.util.stream.Stream; | ||
|
||
import seedu.address.logic.commands.AddJobCommand; | ||
import seedu.address.logic.parser.exceptions.ParseException; | ||
|
||
//@@author whenzei | ||
/** | ||
* Parses the input arguments and creates a new AddJobCommand object | ||
*/ | ||
public class AddJobCommandParser implements Parser<AddJobCommand> { | ||
|
||
/** | ||
* Parses the given {@code String} of arguments in the context of the AddJobCommand | ||
* and returns an AddJobCommand object for execution. | ||
* @throws ParseException if the user input does not conform the expected format | ||
*/ | ||
public AddJobCommand parse(String args) throws ParseException { | ||
ArgumentMultimap argMultimap = | ||
ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, | ||
PREFIX_EMAIL, PREFIX_VEHICLE_NUMBER, PREFIX_ASSIGNED_EMPLOYEE); | ||
|
||
if (!arePrefixesPresent(argMultimap, PREFIX_NAME, PREFIX_PHONE, | ||
PREFIX_EMAIL, PREFIX_VEHICLE_NUMBER, PREFIX_ASSIGNED_EMPLOYEE)) { | ||
} | ||
|
||
//More to be added | ||
return null; //Stub | ||
} | ||
|
||
/** | ||
* Returns true if none of the prefixes contains empty {@code Optional} values in the given | ||
* {@code ArgumentMultimap}. | ||
*/ | ||
private static boolean arePrefixesPresent(ArgumentMultimap argumentMultimap, Prefix... prefixes) { | ||
return Stream.of(prefixes).allMatch(prefix -> argumentMultimap.getValue(prefix).isPresent()); | ||
} | ||
} |
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.