forked from nus-cs2103-AY2425S1/tp
-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create a field in add command (Skill Sets) #49
Merged
rithanisk
merged 25 commits into
AY2425S1-CS2103T-T09-2:master
from
thisisaditya17:feature/add-skills
Oct 11, 2024
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
a7d9494
Update AddCommand.java to have a skills field
thisisaditya17 f90e16e
Create Skills.java
thisisaditya17 f909a69
Update AddCommandParser.java to incorporate skills field
thisisaditya17 bdb0ead
Update CliSyntax.java with new prefix for skills
thisisaditya17 7165c37
Update EditCommand.java to edit skills field as well
thisisaditya17 305492f
Update EditCommandParser.java to incorporate skills field
thisisaditya17 9811d15
Update ParserUtil.java to add parseSkills method
thisisaditya17 d5d50f3
Update Person.java
thisisaditya17 1d5b80b
Update test cases
thisisaditya17 1dd2af0
Update PersonCard.java to include skills label
thisisaditya17 c3c9f65
Update PersonBuilder.java
thisisaditya17 41a207e
Update PersonListCard.fxml to add skills label
thisisaditya17 b1df8f8
Fix all the styling errors
thisisaditya17 630c26c
Fix styling error for tests
thisisaditya17 209f063
Disable test cases temporarily
thisisaditya17 e5c9cf4
Fix all the test cases to run the tests
thisisaditya17 56beb08
Add some extra test cases
thisisaditya17 c3dc13c
Fix all the changed test cases
thisisaditya17 93aaa38
Create SkillsTest class for Skills.java
thisisaditya17 9bb2a02
Merge branch 'master' into feature/add-skills
thisisaditya17 fdf0a7a
Update the test cases with new changes
thisisaditya17 8d942a9
Fix test bugs in NoteCommandTest.java
thisisaditya17 1f61808
Add example in the Add command message
thisisaditya17 89810ad
Fix the checkStyle error for Add Command
thisisaditya17 5fb84ef
Fix the skills test case bug
thisisaditya17 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_NOTE; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_SKILLS; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_STATUS; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; | ||
import static seedu.address.model.Model.PREDICATE_SHOW_ALL_PERSONS; | ||
|
@@ -29,6 +30,7 @@ | |
import seedu.address.model.person.Note; | ||
import seedu.address.model.person.Person; | ||
import seedu.address.model.person.Phone; | ||
import seedu.address.model.person.Skills; | ||
import seedu.address.model.person.Status; | ||
import seedu.address.model.tag.Tag; | ||
|
||
|
@@ -47,12 +49,17 @@ public class EditCommand extends Command { | |
+ "[" + PREFIX_PHONE + "PHONE] " | ||
+ "[" + PREFIX_EMAIL + "EMAIL] " | ||
+ "[" + PREFIX_ADDRESS + "ADDRESS] " | ||
+ "[" + PREFIX_SKILLS + "SKILLS] " | ||
+ "[" + PREFIX_STATUS + "STATUS]" | ||
+ "[" + PREFIX_NOTE + "NOTE] " | ||
+ "[" + PREFIX_TAG + "TAG]...\n" | ||
+ "Example: " + COMMAND_WORD + " 1 " | ||
+ PREFIX_PHONE + "91234567 " | ||
+ PREFIX_EMAIL + "[email protected]"; | ||
+ PREFIX_EMAIL + "[email protected]" | ||
+ PREFIX_ADDRESS + "311, Clementi Ave 2, #02-25 " | ||
+ PREFIX_SKILLS + "java, python " | ||
+ PREFIX_TAG + "friends"; | ||
|
||
|
||
public static final String MESSAGE_EDIT_PERSON_SUCCESS = "Edited Person: %1$s"; | ||
public static final String MESSAGE_NOT_EDITED = "At least one field to edit must be provided."; | ||
|
@@ -105,11 +112,12 @@ private static Person createEditedPerson(Person personToEdit, EditPersonDescript | |
Phone updatedPhone = editPersonDescriptor.getPhone().orElse(personToEdit.getPhone()); | ||
Email updatedEmail = editPersonDescriptor.getEmail().orElse(personToEdit.getEmail()); | ||
Address updatedAddress = editPersonDescriptor.getAddress().orElse(personToEdit.getAddress()); | ||
Skills updatedSkills = editPersonDescriptor.getSkills().orElse(personToEdit.getSkills()); | ||
Status updatedStatus = editPersonDescriptor.getStatus().orElse(personToEdit.getStatus()); | ||
Set<Tag> updatedTags = editPersonDescriptor.getTags().orElse(personToEdit.getTags()); | ||
Note updatedNote = editPersonDescriptor.getNote().orElse(personToEdit.getNote()); | ||
|
||
return new Person(updatedName, updatedPhone, updatedEmail, updatedAddress, | ||
return new Person(updatedName, updatedPhone, updatedEmail, updatedAddress, updatedSkills, | ||
updatedStatus, updatedNote, updatedTags); | ||
} | ||
|
||
|
@@ -146,6 +154,7 @@ public static class EditPersonDescriptor { | |
private Phone phone; | ||
private Email email; | ||
private Address address; | ||
private Skills skills; | ||
private Status status; | ||
private Note note; | ||
private Set<Tag> tags; | ||
|
@@ -161,6 +170,7 @@ public EditPersonDescriptor(EditPersonDescriptor toCopy) { | |
setPhone(toCopy.phone); | ||
setEmail(toCopy.email); | ||
setAddress(toCopy.address); | ||
setSkills(toCopy.skills); | ||
setStatus(toCopy.status); | ||
setNote(toCopy.note); | ||
setTags(toCopy.tags); | ||
|
@@ -205,6 +215,14 @@ public Optional<Address> getAddress() { | |
return Optional.ofNullable(address); | ||
} | ||
|
||
public void setSkills(Skills skills) { | ||
this.skills = skills; | ||
} | ||
|
||
public Optional<Skills> getSkills() { | ||
return Optional.ofNullable(skills); | ||
} | ||
|
||
public void setStatus(Status status) { | ||
this.status = status; | ||
} | ||
|
@@ -254,6 +272,7 @@ public boolean equals(Object other) { | |
&& Objects.equals(phone, otherEditPersonDescriptor.phone) | ||
&& Objects.equals(email, otherEditPersonDescriptor.email) | ||
&& Objects.equals(address, otherEditPersonDescriptor.address) | ||
&& Objects.equals(skills, otherEditPersonDescriptor.skills) | ||
&& Objects.equals(status, otherEditPersonDescriptor.status) | ||
&& Objects.equals(note, otherEditPersonDescriptor.note) | ||
&& Objects.equals(tags, otherEditPersonDescriptor.tags); | ||
|
@@ -266,6 +285,7 @@ public String toString() { | |
.add("phone", phone) | ||
.add("email", email) | ||
.add("address", address) | ||
.add("skills", tags) | ||
.add("status", status) | ||
.add("note", note) | ||
.add("tags", tags) | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package seedu.address.model.person; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
import static seedu.address.commons.util.AppUtil.checkArgument; | ||
|
||
/** | ||
* Represents a Person's skills in the TalentSG | ||
* Guarantees: immutable; is valid as declared in {@link #isValidSkillsString(String)} | ||
*/ | ||
public class Skills { | ||
|
||
public static final String MESSAGE_CONSTRAINTS = | ||
"Skills should be a non-empty string consisting of alphabetic characters, separated by commas. " | ||
+ "Each skill should be between 1 and 30 characters long"; | ||
public static final String VALIDATION_REGEX = "^[a-zA-Z0-9+]+(, [a-zA-Z0-9+]+)*$"; | ||
public final String value; | ||
|
||
/** | ||
* Constructs a {@code Skills}. | ||
* | ||
* @param skills A valid skills string. | ||
*/ | ||
public Skills(String skills) { | ||
requireNonNull(skills); | ||
checkArgument(isValidSkillsString(skills), MESSAGE_CONSTRAINTS); | ||
value = skills; | ||
} | ||
|
||
/** | ||
* Returns true if a given string is a valid skill input. | ||
*/ | ||
public static boolean isValidSkillsString(String test) { | ||
return test.matches(VALIDATION_REGEX); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return value; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
if (other == this) { | ||
return true; | ||
} | ||
|
||
// instanceof handles nulls | ||
if (!(other instanceof Skills)) { | ||
return false; | ||
} | ||
|
||
Skills otherSkills = (Skills) other; | ||
return value.equals(otherSkills.value); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return value.hashCode(); | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The imports are in lexicographical order! good!