Skip to content

Commit

Permalink
Add Recruiter Type
Browse files Browse the repository at this point in the history
Add RECRUITER to Type enum.

Parse recruiter type contacts in JSON.
  • Loading branch information
McNaBry committed Oct 16, 2023
1 parent 1c51bef commit 4c17572
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/main/java/seedu/address/model/person/Recruiter.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ public boolean hasOrganisation() {
return true;
}

@Override
public Type getType() {
return Type.RECRUITER;
}

// TODO: Append orgID to string.
@Override
public String toString() {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/seedu/address/model/person/Type.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/
public enum Type {
ORGANIZATION("organization"),
RECRUITER("recruiter"),
UNKNOWN("unknown");


Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/model/person/Url.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class Url {
* The first character of the url must not be a whitespace,
* otherwise " " (a blank string) becomes a valid input.
*/
public static final String VALIDATION_REGEX = ".+\\..+";
public static final String VALIDATION_REGEX = "(.+\\..+|)";

public final String value;

Expand Down
12 changes: 11 additions & 1 deletion src/main/java/seedu/address/storage/JsonAdaptedContact.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import seedu.address.model.person.Organization;
import seedu.address.model.person.Phone;
import seedu.address.model.person.Position;
import seedu.address.model.person.Recruiter;
import seedu.address.model.person.Status;
import seedu.address.model.person.Type;
import seedu.address.model.person.Url;
Expand Down Expand Up @@ -73,6 +74,9 @@ public JsonAdaptedContact(Contact source) {
if (source.getType() == Type.ORGANIZATION) {
status = ((Organization) source).getStatus().applicationStatus;
position = ((Organization) source).getPosition().jobPosition;
} else if (source.getType() == Type.RECRUITER) {
status = "";
position = "";
}

type = source.getType().toString();
Expand Down Expand Up @@ -138,7 +142,7 @@ public Contact toModelType() throws IllegalValueException {
throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, Url.class.getSimpleName()));
}
if (!Url.isValidUrl(url)) {
throw new IllegalValueException(Id.MESSAGE_CONSTRAINTS);
throw new IllegalValueException(Url.MESSAGE_CONSTRAINTS);
}
final Url modelUrl = new Url(url);

Expand All @@ -164,6 +168,12 @@ public Contact toModelType() throws IllegalValueException {
modelTags, modelStatus, modelPosition
);
}
case RECRUITER: {
return new Recruiter(
modelName, modelId, modelPhone, modelEmail, modelUrl, modelAddress,
modelTags
);
}
default:
return new Contact(modelName, modelId, modelPhone, modelEmail, modelUrl, modelAddress, modelTags);
}
Expand Down

0 comments on commit 4c17572

Please sign in to comment.