From 4c175722ed3a068bf9444eb7d5587b9742771b87 Mon Sep 17 00:00:00 2001 From: McNaBry Date: Tue, 17 Oct 2023 01:13:13 +0800 Subject: [PATCH] Add Recruiter Type Add RECRUITER to Type enum. Parse recruiter type contacts in JSON. --- .../java/seedu/address/model/person/Recruiter.java | 5 +++++ src/main/java/seedu/address/model/person/Type.java | 1 + src/main/java/seedu/address/model/person/Url.java | 2 +- .../seedu/address/storage/JsonAdaptedContact.java | 12 +++++++++++- 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/main/java/seedu/address/model/person/Recruiter.java b/src/main/java/seedu/address/model/person/Recruiter.java index 0a1ee104f51..e9967b248b5 100644 --- a/src/main/java/seedu/address/model/person/Recruiter.java +++ b/src/main/java/seedu/address/model/person/Recruiter.java @@ -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() { diff --git a/src/main/java/seedu/address/model/person/Type.java b/src/main/java/seedu/address/model/person/Type.java index 8692e7488ef..d30341664de 100644 --- a/src/main/java/seedu/address/model/person/Type.java +++ b/src/main/java/seedu/address/model/person/Type.java @@ -7,6 +7,7 @@ */ public enum Type { ORGANIZATION("organization"), + RECRUITER("recruiter"), UNKNOWN("unknown"); diff --git a/src/main/java/seedu/address/model/person/Url.java b/src/main/java/seedu/address/model/person/Url.java index fa4faeaf1d8..82e50a98852 100644 --- a/src/main/java/seedu/address/model/person/Url.java +++ b/src/main/java/seedu/address/model/person/Url.java @@ -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; diff --git a/src/main/java/seedu/address/storage/JsonAdaptedContact.java b/src/main/java/seedu/address/storage/JsonAdaptedContact.java index 24e2f23a517..98e1a01ffad 100644 --- a/src/main/java/seedu/address/storage/JsonAdaptedContact.java +++ b/src/main/java/seedu/address/storage/JsonAdaptedContact.java @@ -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; @@ -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(); @@ -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); @@ -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); }