Skip to content

Commit

Permalink
Merge branch 'master' into refactor-remove-person
Browse files Browse the repository at this point in the history
  • Loading branch information
jellywaiyan authored Nov 6, 2023
2 parents ba5511a + 45d93ad commit b46adbb
Show file tree
Hide file tree
Showing 17 changed files with 267 additions and 53 deletions.
9 changes: 5 additions & 4 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,13 @@ How the parsing works:
<img src="images/ModelClassDiagram.png" width="450" />


The `Assignment` component,
The `Assignment`, `InternshipRole`, `InternshipTask` component,

* stores the address book data i.e., all `Assignment` objects (which are contained in a `UniqueList` object).
* stores the currently 'selected' `Assignment` objects (e.g., results of a search query) as a separate _filtered_ list which is exposed to outsiders as an unmodifiable `ObservableList<Assignment>` that can be 'observed' e.g. the UI can be bound to this list so that the UI automatically updates when the data in the list change.
* these components implement the Unique Interface.
* stores the address book data i.e., all `Assignment`, `InternshipRole`, `InternshipTask` objects (are contained in a separate `UniqueList` object).
* stores the currently 'selected' component objects (e.g., results of a search query) as a separate _filtered_ list which is exposed to outsiders as an unmodifiable `ObservableList` that can be 'observed' e.g. the UI can be bound to this list so that the UI automatically updates when the data in the list change.
* stores a `UserPref` object that represents the user’s preferences. This is exposed to the outside as a `ReadOnlyUserPref` objects.
* does not depend on any of the other three components (as the `Assignment` represents data entities of the domain, they should make sense on their own without depending on other components)
* does not depend on any of the other three components (as these components represent data entities of the domain, they should make sense on their own without depending on other components)



Expand Down
2 changes: 1 addition & 1 deletion docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ To add an internship role into CampusCompanion.

#### Editing an internship role

```edit-i-role i/INDEX d/DESCRIPTION```
```edit-i-role i/INDEX [c/CYCLE] [d/DESCRIPTION] [p/PAY] [o/OUTCOME] [l/LOCATION]```

To view internship role parameter information, click [here](#internship-role-parameters)

Expand Down
41 changes: 32 additions & 9 deletions docs/diagrams/ModelClassDiagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,17 @@ Class UserPrefs

Class UniqueList
Class Assignment
Class InternshipRole
Class InternshipTask
Class Status
Class IsoDate
Class Cycle
Class Pay
Class Role
Class Location
Class ApplicationOutcome
Class TaskOutcome
Class Name
Class Date
Class Description
Class Tag

Expand All @@ -36,23 +43,39 @@ ModelManager -left-> "1" AddressBook
ModelManager -right-> "1" UserPrefs
UserPrefs .up.|> ReadOnlyUserPrefs

AddressBook *--> "1" UniqueList
AddressBook *--> "3" UniqueList
UniqueList --> "~* all" Assignment
Assignment *--> Name
Assignment *--> IsoDate
Assignment *--> Status
Assignment *--> Description
Assignment *--> Date
UniqueList --> "~* all" InternshipRole
UniqueList --> "~* all" InternshipTask
Assignment *--> "1" Name
Assignment *--> "1" IsoDate
Assignment *--> "1" Status
Assignment *--> "0..1" Description
Assignment *--> "*" Tag

InternshipRole *--> "1" Name
InternshipRole *--> "1" Role
InternshipRole *--> "1" Cycle
InternshipRole *--> "0..1" Description
InternshipRole *--> "0..1" Pay
InternshipRole *--> "1" ApplicationOutcome
InternshipRole *--> "0..1" Location
InternshipRole *--> "*" Tag

InternshipTask *--> "1" Name
InternshipTask *--> "1" InternshipRole
InternshipTask *--> "1" TaskOutcome
InternshipTask *--> "1" Status
InternshipTask *--> "1" IsoDate
InternshipTask *--> "*" Tag


Assignment -[hidden]up--> I
UniqueList -[hidden]right-> I

Name -[hidden]right-> IsoDate
IsoDate -[hidden]right-> Status
Status -[hidden]right-> Description
Description -[hidden]right-> Date
Date -[hidden]right-> Tag

ModelManager --> "~* filtered" Assignment
@enduml
38 changes: 30 additions & 8 deletions docs/diagrams/UiClassDiagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,16 @@ Class UiManager
Class MainWindow
Class HelpWindow
Class ResultDisplay
Class PersonListPanel
Class PersonCard
Class AssignmentListPanel
Class AssignmentCard
Class StatusBarFooter
Class CommandBox
Class InternPanel
Class InternshipRolePanel
Class InternshipTaskPanel
Class InternshipRoleCard
Class InternshipTaskCard
Class Calendar
}

package Model <<Rectangle>> {
Expand All @@ -32,26 +38,42 @@ UiManager .left.|> Ui
UiManager -down-> "1" MainWindow
MainWindow *-down-> "1" CommandBox
MainWindow *-down-> "1" ResultDisplay
MainWindow *-down-> "1" PersonListPanel
MainWindow *-down-> "1" AssignmentListPanel
MainWindow *-down-> "1" InternPanel
MainWindow *-down-> "1" Calendar
MainWindow *-down-> "1" StatusBarFooter
MainWindow --> "0..1" HelpWindow

PersonListPanel -down-> "*" PersonCard

AssignmentListPanel -down-> "*" AssignmentCard
InternPanel -down-> "1" InternshipRolePanel
InternPanel -down-> "1" InternshipTaskPanel
InternshipRolePanel -down-> "*" InternshipRoleCard
InternshipTaskPanel -down-> "*" InternshipTaskCard

MainWindow -left-|> UiPart

ResultDisplay --|> UiPart
CommandBox --|> UiPart
PersonListPanel --|> UiPart
PersonCard --|> UiPart
AssignmentListPanel --|> UiPart
AssignmentCard --|> UiPart
StatusBarFooter --|> UiPart
HelpWindow --|> UiPart
InternPanel --|> UiPart
InternshipRolePanel --|> UiPart
InternshipTaskPanel --|> UiPart
InternshipRoleCard --|> UiPart
InternshipTaskCard --|> UiPart
Calendar --|> UiPart

PersonCard ..> Model
AssignmentCard ..> Model
InternshipRoleCard ..> Model
InternshipTaskCard ..> Model
Calendar ..> Model
UiManager -right-> Logic
MainWindow -left-> Logic

PersonListPanel -[hidden]left- HelpWindow
AssignmentListPanel -[hidden]left- HelpWindow
HelpWindow -[hidden]left- CommandBox
CommandBox -[hidden]left- ResultDisplay
ResultDisplay -[hidden]left- StatusBarFooter
Expand Down
Binary file modified docs/images/ModelClassDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/Ui.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/UiClassDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion src/main/java/seedu/address/logic/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ public class Messages {
+ " provided is invalid";
public static final String MESSAGE_DUPLICATE_FIELDS =
"Multiple values specified for the following single-valued field(s): ";

public static final String MESSAGE_EDIT_LEADS_TO_DUPLICATE_ROLES = "This will lead to duplicate internship roles"
+ " existing!";
public static final String MESSAGE_EDITED_FIELDS_ARE_THE_SAME = "You do not have to specify fields if they are"
+ " to remain the same";
/**
* Returns an error message indicating the duplicate prefixes.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ public CommandResult execute(Model model) throws CommandException {
requireNonNull(model);

List<InternshipRole> lastShownRoleList = model.getFilteredInternshipRoleList();
List<InternshipTask> lastShownTaskList = model.getFilteredInternshipTaskList();
List<InternshipTask> unfilteredTaskList = model.getUnfilteredInternshipTaskList();
List<InternshipTask> taskListToDelete = new ArrayList<>();

if (targetIndex.getZeroBased() >= lastShownRoleList.size()) {
throw new CommandException(Messages.MESSAGE_INVALID_INTERNSHIP_ROLE_DISPLAYED_INDEX);
}
InternshipRole internshipRoleToDelete = lastShownRoleList.get(targetIndex.getZeroBased());

lastShownTaskList.stream()
unfilteredTaskList.stream()
.forEach(task -> {
if (new InternshipTaskHasSameInternshipRolePredicate(internshipRoleToDelete).test(task)) {
taskListToDelete.add(task);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
package seedu.address.logic.commands.internship.role;

import static java.util.Objects.requireNonNull;
import static seedu.address.logic.Messages.MESSAGE_EDITED_FIELDS_ARE_THE_SAME;
import static seedu.address.logic.Messages.MESSAGE_EDIT_LEADS_TO_DUPLICATE_ROLES;
import static seedu.address.logic.parser.assignment.CliSyntax.PREFIX_DESCRIPTION;
import static seedu.address.logic.parser.assignment.CliSyntax.PREFIX_INDEX;
import static seedu.address.logic.parser.internship.role.CliSyntax.PREFIX_CYCLE;
import static seedu.address.logic.parser.internship.role.CliSyntax.PREFIX_LOCATION;
import static seedu.address.logic.parser.internship.role.CliSyntax.PREFIX_OUTCOME;
import static seedu.address.logic.parser.internship.role.CliSyntax.PREFIX_PAY;

import java.util.List;

Expand All @@ -14,7 +20,12 @@
import seedu.address.logic.commands.internship.InternshipCommand;
import seedu.address.model.Model;
import seedu.address.model.fields.ApplicationOutcome;
import seedu.address.model.fields.Cycle;
import seedu.address.model.fields.Description;
import seedu.address.model.fields.Location;
import seedu.address.model.fields.Pay;
import seedu.address.model.internship.role.InternshipRole;
import seedu.address.model.internship.task.InternshipTask;

/**
* A command that edits the application outcome of an InternshipRole when executed.
Expand All @@ -25,25 +36,39 @@ public class EditInternshipRoleCommand extends InternshipCommand {
public static final String MESSAGE_USAGE = COMMAND_WORD
+ ": Edits the application outcome of an InternshipRole. "
+ "Parameters: "
+ PREFIX_INDEX + "INDEX (must be a positive integer)" + "\n"
+ PREFIX_OUTCOME + "OUTCOME" + "\n"
+ "Example: " + COMMAND_WORD + "i/ 1" + " o/ accepted";
+ PREFIX_INDEX + "INDEX (must be a positive integer) and AT LEAST one of the following: "
+ "[" + PREFIX_CYCLE + "CYCLE " + "]"
+ "[" + PREFIX_DESCRIPTION + "DESCRIPTION " + "]"
+ "[" + PREFIX_PAY + "PAY " + "]"
+ "[" + PREFIX_OUTCOME + "OUTCOME " + "]"
+ "[" + PREFIX_LOCATION + "LOCATION " + "]\n"
+ "Example: " + COMMAND_WORD + " i/ 1" + " o/ accepted" + " p/3000";

public static final String MESSAGE_SUCCESS = "Internship role outcome updated to: %1$s";

public static final String MESSAGE_INVALID_ROLE = "This internship role does not exist in the address book";

private final Index index;
private final Cycle newCycle;
private final Description newDescription;
private final Pay newPay;
private final ApplicationOutcome newOutcome;
private final Location newLocation;

/**
* The constructor for an EditInternshipRoleCommand
* @param index The index of the InternshipRole to be edited
*
* @param index The index of the InternshipRole to be edited
* @param newOutcome The new outcome for the target InternshipRole
*/
public EditInternshipRoleCommand(Index index, ApplicationOutcome newOutcome) {
public EditInternshipRoleCommand(Index index, Cycle newCycle, Description newDescription, Pay newPay,
ApplicationOutcome newOutcome, Location newLocation) {
this.index = index;
this.newCycle = newCycle;
this.newDescription = newDescription;
this.newPay = newPay;
this.newOutcome = newOutcome;
this.newLocation = newLocation;
}

@Override
Expand All @@ -60,9 +85,48 @@ public CommandResult execute(Model model) throws CommandException {
throw new CommandException(MESSAGE_INVALID_ROLE);
}

InternshipRole roleWithNewOutcome = roleToEdit.getNewInternshipRoleWithOutcome(newOutcome);
model.setInternshipRole(roleToEdit, roleWithNewOutcome);
return new CommandResult(String.format(MESSAGE_SUCCESS, Messages.format(roleWithNewOutcome)));
InternshipRole editedRole = roleToEdit;
if (newCycle != null) {
editedRole = editedRole.getNewInternshipRoleWithCycle(newCycle);
}
if (newDescription != null) {
editedRole = editedRole.getNewInternshipRoleWithDescription(newDescription);
}
if (newPay != null) {
editedRole = editedRole.getNewInternshipRoleWithPay(newPay);
}
if (newOutcome != null) {
editedRole = editedRole.getNewInternshipRoleWithOutcome(newOutcome);
}
if (newLocation != null) {
editedRole = editedRole.getNewInternshipRoleWithLocation(newLocation);
}

if (roleToEdit.equals(editedRole)) {
throw new CommandException(MESSAGE_EDITED_FIELDS_ARE_THE_SAME);
}

if (!editedRole.isDuplicate(roleToEdit) && model.hasInternshipRole(editedRole)) {
throw new CommandException(MESSAGE_EDIT_LEADS_TO_DUPLICATE_ROLES);
}

model.setInternshipRole(roleToEdit, editedRole);

for (InternshipTask internshipTask : model.getUnfilteredInternshipTaskList()) {
if (internshipTask.getInternshipRole().equals(roleToEdit)) {
model.setInternshipTask(internshipTask, internshipTask.editInternshipRole(editedRole));
}
}

// Force a Re render with updated values, by calling the set method

model.setInternshipRole(editedRole, editedRole);

for (InternshipTask internshipTask : model.getUnfilteredInternshipTaskList()) {
model.setInternshipTask(internshipTask, internshipTask);
}

return new CommandResult(String.format(MESSAGE_SUCCESS, Messages.format(editedRole)));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ public class EditInternshipTaskCommand extends InternshipCommand {
public static final String MESSAGE_USAGE = COMMAND_WORD
+ ": Edits the outcome of an InternshipTask to the app. "
+ "Parameters: "
+ PREFIX_INDEX + "INDEX (must be a positive integer)" + "\n"
+ PREFIX_INDEX + "INDEX (must be a positive integer)"
+ PREFIX_OUTCOME + "OUTCOME" + "\n"
+ "Example: " + COMMAND_WORD + "i/ 1" + " o/ follow-up";
+ "Example: " + COMMAND_WORD + " i/ 1" + " o/ follow-up";

public static final String MESSAGE_SUCCESS = "Internship task outcome updated to: %1$s";

Expand Down Expand Up @@ -60,6 +60,12 @@ public CommandResult execute(Model model) throws CommandException {
throw new CommandException(MESSAGE_INVALID_TASK);
}

/*if (newOutcome.getTaskOutcome() == Outcome.OFFERED) {
EditInternshipRoleCommand editRoleCommand = new EditInternshipRoleCommand(index,
new ApplicationOutcome(Outcome.OFFERED));
editRoleCommand.execute(model);
}*/

InternshipTask taskWithNewOutcome = taskToEdit.getNewInternshipTaskWithOutcome(newOutcome);
model.setInternshipTask(taskToEdit, taskWithNewOutcome);
return new CommandResult(String.format(MESSAGE_SUCCESS, Messages.format(taskWithNewOutcome)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,12 @@

import static java.util.Objects.requireNonNull;

import java.util.ArrayList;
import java.util.List;

import seedu.address.commons.util.ToStringBuilder;
import seedu.address.logic.Messages;
import seedu.address.logic.commands.CommandResult;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.logic.commands.internship.InternshipCommand;
import seedu.address.model.Model;
import seedu.address.model.internship.role.InternshipRole;
import seedu.address.model.internship.task.InternshipTask;
import seedu.address.model.internship.task.InternshipTaskNameContainsKeywordsPredicate;

Expand Down Expand Up @@ -42,12 +38,15 @@ public CommandResult execute(Model model) throws CommandException {

model.updateFilteredInternshipTaskList(predicate);

// List the roles of these tasks
List<InternshipRole> internshipRoles = new ArrayList<>();
for (InternshipTask internshipTask : model.getFilteredInternshipTaskList()) {
internshipRoles.add(internshipTask.getInternshipRole());
}
model.updateFilteredInternshipRoleList(internshipRoles::contains);
model.updateFilteredInternshipRoleList(role -> {
for (InternshipTask internshipTask : model.getFilteredInternshipTaskList()) {
if (internshipTask.getInternshipRole().equals(role)) {
return true;
}
}
return false;
});

return new CommandResult(
String.format(Messages.MESSAGE_INTERNSHIPS_LISTED_OVERVIEW,
model.getFilteredInternshipTaskList().size()));
Expand Down
Loading

0 comments on commit b46adbb

Please sign in to comment.