From 2029b22bbfadb0d7d5b0bd5782c6fbd10149e08c Mon Sep 17 00:00:00 2001 From: McNaBry Date: Wed, 18 Oct 2023 21:46:37 +0800 Subject: [PATCH 1/5] Change oid field to optional --- .../java/seedu/address/model/person/Recruiter.java | 7 ++++--- .../seedu/address/storage/JsonAdaptedContact.java | 6 ++++-- src/main/java/seedu/address/ui/ContactCard.java | 13 +++++++------ 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/main/java/seedu/address/model/person/Recruiter.java b/src/main/java/seedu/address/model/person/Recruiter.java index 72d878dd338..c77c8763873 100644 --- a/src/main/java/seedu/address/model/person/Recruiter.java +++ b/src/main/java/seedu/address/model/person/Recruiter.java @@ -1,6 +1,7 @@ package seedu.address.model.person; import java.util.Objects; +import java.util.Optional; import java.util.Set; import seedu.address.commons.util.ToStringBuilder; @@ -12,17 +13,17 @@ */ public class Recruiter extends Contact { - private final Id oid; + private final Optional oid; /** * Every field except oid must be present and not null. */ public Recruiter(Name name, Id id, Phone phone, Email email, Url url, Address address, Set tags, Id oid) { super(name, id, phone, email, url, address, tags); - this.oid = oid; + this.oid = Optional.ofNullable(oid); } - public Id getOrganizationId() { + public Optional getOrganizationId() { return oid; } diff --git a/src/main/java/seedu/address/storage/JsonAdaptedContact.java b/src/main/java/seedu/address/storage/JsonAdaptedContact.java index 868d764b37b..3e17f1a5987 100644 --- a/src/main/java/seedu/address/storage/JsonAdaptedContact.java +++ b/src/main/java/seedu/address/storage/JsonAdaptedContact.java @@ -78,10 +78,12 @@ public JsonAdaptedContact(Contact source) { position = ((Organization) source).getPosition().jobPosition; oid = ""; } else if (source.getType() == Type.RECRUITER) { + Recruiter recruiter = (Recruiter) source; status = ""; position = ""; - Id tmp = ((Recruiter) source).getOrganizationId(); - oid = tmp == null ? null : tmp.value; + oid = recruiter.getOrganizationId() + .map(oid -> oid.value) + .orElse(null); } type = source.getType().toString(); diff --git a/src/main/java/seedu/address/ui/ContactCard.java b/src/main/java/seedu/address/ui/ContactCard.java index 7148574e103..70c85b5ea8f 100644 --- a/src/main/java/seedu/address/ui/ContactCard.java +++ b/src/main/java/seedu/address/ui/ContactCard.java @@ -1,6 +1,7 @@ package seedu.address.ui; import java.util.Comparator; +import java.util.Optional; import java.util.function.Supplier; import javafx.fxml.FXML; @@ -97,14 +98,14 @@ public ContactCard(Contact contact, int displayedIndex) { case RECRUITER: { Recruiter recruiter = (Recruiter) contact; - final Id linkedOrgId = recruiter.getOrganizationId(); + final Optional linkedOrgId = recruiter.getOrganizationId(); setVboxInnerLabelText( - linkedParentOrganization, () -> linkedOrgId == null - ? null - : String.format( - "from %s (%s)", "organization" /* TODO: Use org name instead */, linkedOrgId.value - ) + linkedParentOrganization, () -> linkedOrgId.map(oid -> + String.format( + "from %s (%s)", "organization" /* TODO: Use org name instead */, oid.value + )) + .orElse(null) ); cardPaneInnerVbox.getChildren().removeAll(status, position); break; From 412a5d9cd64688248021ace2a41704c1547aeecf Mon Sep 17 00:00:00 2001 From: McNaBry Date: Thu, 19 Oct 2023 15:20:28 +0800 Subject: [PATCH 2/5] Add optional fields to Contact --- .../address/logic/commands/EditCommand.java | 21 ++- .../logic/parser/AddCommandParser.java | 143 ++++++++---------- .../address/logic/parser/ParserUtil.java | 38 ++++- .../seedu/address/model/person/Contact.java | 41 ++--- .../address/model/person/Organization.java | 20 ++- .../seedu/address/model/person/Recruiter.java | 2 +- .../java/seedu/address/model/person/Url.java | 2 +- .../address/storage/JsonAdaptedContact.java | 55 +++---- .../java/seedu/address/ui/ContactCard.java | 46 +++--- .../logic/commands/CommandTestUtil.java | 3 +- .../logic/parser/AddCommandParserTest.java | 24 +-- .../storage/JsonAdaptedContactTest.java | 24 ++- .../address/testutil/ContactBuilder.java | 18 +-- .../seedu/address/testutil/ContactUtil.java | 8 +- .../EditContactDescriptorBuilder.java | 6 +- .../address/testutil/RecruiterBuilder.java | 8 +- 16 files changed, 228 insertions(+), 231 deletions(-) diff --git a/src/main/java/seedu/address/logic/commands/EditCommand.java b/src/main/java/seedu/address/logic/commands/EditCommand.java index 3661f829193..9cb9bb46b1a 100644 --- a/src/main/java/seedu/address/logic/commands/EditCommand.java +++ b/src/main/java/seedu/address/logic/commands/EditCommand.java @@ -97,13 +97,20 @@ public CommandResult execute(Model model) throws CommandException { private static Contact createEditedContact(Contact contactToEdit, EditContactDescriptor editContactDescriptor) { assert contactToEdit != null; - Name updatedName = editContactDescriptor.getName().orElse(contactToEdit.getName()); - Id updatedId = editContactDescriptor.getId().orElse(contactToEdit.getId()); - Phone updatedPhone = editContactDescriptor.getPhone().orElse(contactToEdit.getPhone()); - Email updatedEmail = editContactDescriptor.getEmail().orElse(contactToEdit.getEmail()); - Url updatedUrl = editContactDescriptor.getUrl().orElse(contactToEdit.getUrl()); - Address updatedAddress = editContactDescriptor.getAddress().orElse(contactToEdit.getAddress()); - Set updatedTags = editContactDescriptor.getTags().orElse(contactToEdit.getTags()); + Name updatedName = editContactDescriptor.getName() + .orElse(contactToEdit.getName()); + Id updatedId = editContactDescriptor.getId() + .orElse(contactToEdit.getId()); + Phone updatedPhone = editContactDescriptor.getPhone() + .orElse(contactToEdit.getPhone().orElse(null)); + Email updatedEmail = editContactDescriptor.getEmail() + .orElse(contactToEdit.getEmail().orElse(null)); + Url updatedUrl = editContactDescriptor.getUrl() + .orElse(contactToEdit.getUrl().orElse(null)); + Address updatedAddress = editContactDescriptor.getAddress() + .orElse(contactToEdit.getAddress().orElse(null)); + Set updatedTags = editContactDescriptor.getTags() + .orElse(contactToEdit.getTags()); return new Contact(updatedName, updatedId, updatedPhone, updatedEmail, updatedUrl, updatedAddress, updatedTags); } diff --git a/src/main/java/seedu/address/logic/parser/AddCommandParser.java b/src/main/java/seedu/address/logic/parser/AddCommandParser.java index f354ac01e58..42e398ddd8d 100644 --- a/src/main/java/seedu/address/logic/parser/AddCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/AddCommandParser.java @@ -14,7 +14,7 @@ import static seedu.address.logic.parser.CliSyntax.FLAG_TAG; import static seedu.address.logic.parser.CliSyntax.FLAG_URL; -import java.util.NoSuchElementException; +import java.util.Optional; import java.util.Set; import seedu.address.logic.commands.AddCommand; @@ -39,21 +39,23 @@ public class AddCommandParser implements Parser { /** - * Parses the given {@code String} of arguments in the context of the AddCommand - * and returns an AddCommand object for execution. + * Parses the given {@code String} of arguments in the context of the AddCommand and returns an AddCommand object + * for execution. + * * @throws ParseException if the user input does not conform the expected format */ public AddCommand parse(String args) throws ParseException { ArgumentMultimap argMultimap = - ArgumentTokenizer.tokenize(args, - FLAG_NAME, FLAG_PHONE, FLAG_EMAIL, - FLAG_ADDRESS, FLAG_TAG, FLAG_URL, - FLAG_ID, FLAG_STATUS, FLAG_POSITION, - FLAG_ORGANIZATION_ID, - FLAG_ORGANIZATION, FLAG_RECRUITER); - - if (!argMultimap.hasAllOfFlags(FLAG_NAME, FLAG_PHONE, FLAG_EMAIL, FLAG_ADDRESS) - || !argMultimap.getPreamble().isEmpty()) { + ArgumentTokenizer.tokenize(args, + FLAG_NAME, FLAG_PHONE, FLAG_EMAIL, + FLAG_ADDRESS, FLAG_TAG, FLAG_URL, + FLAG_ID, FLAG_STATUS, FLAG_POSITION, + FLAG_ORGANIZATION_ID, + FLAG_ORGANIZATION, FLAG_RECRUITER + ); + + if (!argMultimap.hasAllOfFlags(FLAG_NAME) + || !argMultimap.getPreamble().isEmpty()) { throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE)); } @@ -69,21 +71,18 @@ public AddCommand parse(String args) throws ParseException { // Deprecated contact format. Will be removed in future versions. Name name = ParserUtil.parseName(argMultimap.getValue(FLAG_NAME).get()); - Id id; - try { - id = ParserUtil.parseId(argMultimap.getValue(FLAG_ID).get()); - } catch (NoSuchElementException e) { - id = new Id(); - } - Phone phone = ParserUtil.parsePhone(argMultimap.getValue(FLAG_PHONE).get()); - Email email = ParserUtil.parseEmail(argMultimap.getValue(FLAG_EMAIL).get()); - Url url; - try { - url = ParserUtil.parseUrl(argMultimap.getValue(FLAG_URL).get()); - } catch (NoSuchElementException e) { - url = new Url(); - } - Address address = ParserUtil.parseAddress(argMultimap.getValue(FLAG_ADDRESS).get()); + Optional idString = argMultimap.getValue(FLAG_ID); + Id id = idString.isPresent() + ? ParserUtil.parseId(idString.get()) + : new Id(); + Phone phone = ParserUtil.parseOptionally( + argMultimap.getValue(FLAG_PHONE), ParserUtil::parsePhone); + Email email = ParserUtil.parseOptionally( + argMultimap.getValue(FLAG_EMAIL), ParserUtil::parseEmail); + Address address = ParserUtil.parseOptionally( + argMultimap.getValue(FLAG_ADDRESS), ParserUtil::parseAddress); + Url url = ParserUtil.parseOptionally( + argMultimap.getValue(FLAG_URL), ParserUtil::parseUrl); Set tagList = ParserUtil.parseTags(argMultimap.getAllValues(FLAG_TAG)); Contact contact = new Contact(name, id, phone, email, url, address, tagList); @@ -94,70 +93,50 @@ public AddCommand parse(String args) throws ParseException { private Recruiter parseAsRecruiter(ArgumentMultimap argMultimap) throws ParseException { argMultimap.verifyNoDuplicateFlagsFor(FLAG_ORGANIZATION_ID); Name name = ParserUtil.parseName(argMultimap.getValue(FLAG_NAME).get()); - Phone phone = ParserUtil.parsePhone(argMultimap.getValue(FLAG_PHONE).get()); - Email email = ParserUtil.parseEmail(argMultimap.getValue(FLAG_EMAIL).get()); - Address address = ParserUtil.parseAddress(argMultimap.getValue(FLAG_ADDRESS).get()); - Set tagList = ParserUtil.parseTags(argMultimap.getAllValues(FLAG_TAG)); - Id id; - try { - id = ParserUtil.parseId(argMultimap.getValue(FLAG_ID).get()); - } catch (NoSuchElementException e) { - id = new Id(); - } - Url url; - try { - url = ParserUtil.parseUrl(argMultimap.getValue(FLAG_URL).get()); - } catch (NoSuchElementException e) { - url = new Url(); - } - - Id oid; - try { - oid = ParserUtil.parseId(argMultimap.getValue(FLAG_ORGANIZATION_ID).get()); - } catch (NoSuchElementException e) { - oid = null; - } + Optional idString = argMultimap.getValue(FLAG_ID); + Id id = idString.isPresent() + ? ParserUtil.parseId(idString.get()) + : new Id(); + + Phone phone = ParserUtil.parseOptionally( + argMultimap.getValue(FLAG_PHONE), ParserUtil::parsePhone); + Email email = ParserUtil.parseOptionally( + argMultimap.getValue(FLAG_EMAIL), ParserUtil::parseEmail); + Address address = ParserUtil.parseOptionally( + argMultimap.getValue(FLAG_ADDRESS), ParserUtil::parseAddress); + Url url = ParserUtil.parseOptionally( + argMultimap.getValue(FLAG_URL), ParserUtil::parseUrl); + Id oid = ParserUtil.parseOptionally( + argMultimap.getValue(FLAG_ORGANIZATION_ID), ParserUtil::parseId); + Set tagList = ParserUtil.parseTags(argMultimap.getAllValues(FLAG_TAG)); return new Recruiter(name, id, phone, email, url, address, tagList, oid); } private Organization parseAsOrganization(ArgumentMultimap argMultimap) throws ParseException { - argMultimap.verifyNoDuplicateFlagsFor(FLAG_NAME, FLAG_PHONE, FLAG_EMAIL, FLAG_ADDRESS); + argMultimap.verifyNoDuplicateFlagsFor(FLAG_POSITION, FLAG_STATUS); Name name = ParserUtil.parseName(argMultimap.getValue(FLAG_NAME).get()); - Phone phone = ParserUtil.parsePhone(argMultimap.getValue(FLAG_PHONE).get()); - Email email = ParserUtil.parseEmail(argMultimap.getValue(FLAG_EMAIL).get()); - Address address = ParserUtil.parseAddress(argMultimap.getValue(FLAG_ADDRESS).get()); - Set tagList = ParserUtil.parseTags(argMultimap.getAllValues(FLAG_TAG)); - Id id; - try { - id = ParserUtil.parseId(argMultimap.getValue(FLAG_ID).get()); - } catch (NoSuchElementException e) { - id = new Id(); - } - - Url url; - try { - url = ParserUtil.parseUrl(argMultimap.getValue(FLAG_URL).get()); - } catch (NoSuchElementException e) { - url = new Url(); - } - - Position position; - try { - position = ParserUtil.parsePosition(argMultimap.getValue(FLAG_POSITION).get()); - } catch (NoSuchElementException e) { - position = new Position(); - } - Status status; - try { - status = ParserUtil.parseStatus(argMultimap.getValue(FLAG_STATUS).get()); - } catch (NoSuchElementException e) { - status = new Status(); - } + Optional idString = argMultimap.getValue(FLAG_ID); + Id id = idString.isPresent() + ? ParserUtil.parseId(idString.get()) + : new Id(); + + Phone phone = ParserUtil.parseOptionally( + argMultimap.getValue(FLAG_PHONE), ParserUtil::parsePhone); + Email email = ParserUtil.parseOptionally( + argMultimap.getValue(FLAG_EMAIL), ParserUtil::parseEmail); + Address address = ParserUtil.parseOptionally( + argMultimap.getValue(FLAG_ADDRESS), ParserUtil::parseAddress); + Url url = ParserUtil.parseOptionally( + argMultimap.getValue(FLAG_URL), ParserUtil::parseUrl); + Position position = ParserUtil.parseOptionally( + argMultimap.getValue(FLAG_POSITION), ParserUtil::parsePosition); + Status status = ParserUtil.parseOptionally( + argMultimap.getValue(FLAG_STATUS), ParserUtil::parseStatus); + Set tagList = ParserUtil.parseTags(argMultimap.getAllValues(FLAG_TAG)); return new Organization(name, id, phone, email, url, address, tagList, status, position); } - } diff --git a/src/main/java/seedu/address/logic/parser/ParserUtil.java b/src/main/java/seedu/address/logic/parser/ParserUtil.java index 311915ed6cb..851c6b6b13e 100644 --- a/src/main/java/seedu/address/logic/parser/ParserUtil.java +++ b/src/main/java/seedu/address/logic/parser/ParserUtil.java @@ -4,6 +4,7 @@ import java.util.Collection; import java.util.HashSet; +import java.util.Optional; import java.util.Set; import seedu.address.commons.core.index.Index; @@ -27,8 +28,9 @@ public class ParserUtil { public static final String MESSAGE_INVALID_INDEX = "Index is not a non-zero unsigned integer."; /** - * Parses {@code oneBasedIndex} into an {@code Index} and returns it. Leading and trailing whitespaces will be - * trimmed. + * Parses {@code oneBasedIndex} into an {@code Index} and returns it. + * Leading and trailing whitespaces will be trimmed. + * * @throws ParseException if the specified index is invalid (not non-zero unsigned integer). */ public static Index parseIndex(String oneBasedIndex) throws ParseException { @@ -79,7 +81,7 @@ public static Status parseStatus(String status) throws ParseException { requireNonNull(status); String trimmedStatus = status.trim(); if (!Status.isValidStatus(status)) { - throw new ParseException(Name.MESSAGE_CONSTRAINTS); + throw new ParseException(Status.MESSAGE_CONSTRAINTS); } return new Status(trimmedStatus); } @@ -93,8 +95,8 @@ public static Status parseStatus(String status) throws ParseException { public static Position parsePosition(String position) throws ParseException { requireNonNull(position); String trimmedPosition = position.trim(); - if (!Name.isValidName(position)) { - throw new ParseException(Name.MESSAGE_CONSTRAINTS); + if (!Position.isValidPosition(position)) { + throw new ParseException(Position.MESSAGE_CONSTRAINTS); } return new Position(trimmedPosition); } @@ -185,4 +187,30 @@ public static Set parseTags(Collection tags) throws ParseException } return tagSet; } + + /** + * References a function that parses a string into an expected output within the {@link ParserUtil} utility class. + * @param The return result. + */ + @FunctionalInterface + public interface StringParserFunction { + R parse(String value) throws ParseException; + } + + /** + * Returns an object of type R that is given by passing the given string into {@code parseFunction} if + * {@code optionalString} is non-empty, otherwise returns null. + * + * @param The type of object returned by parsing the optionalString. + * + * @throws ParseException if the given {@code optionalString} is invalid as determined by {@code parseFunction} + */ + public static R parseOptionally(Optional optionalString, StringParserFunction parseFunction) + throws ParseException { + + if (optionalString.isPresent()) { + return parseFunction.parse(optionalString.get()); + } + return null; + } } diff --git a/src/main/java/seedu/address/model/person/Contact.java b/src/main/java/seedu/address/model/person/Contact.java index 8c969bec340..250c12822fe 100644 --- a/src/main/java/seedu/address/model/person/Contact.java +++ b/src/main/java/seedu/address/model/person/Contact.java @@ -5,6 +5,7 @@ import java.util.Collections; import java.util.HashSet; import java.util.Objects; +import java.util.Optional; import java.util.Set; import seedu.address.commons.exceptions.IllegalOperationException; @@ -13,7 +14,7 @@ /** * Represents a Contact in the address book. - * Guarantees: details are present and not null, field values are validated, immutable. + * Guarantees: name and id are present and not null, field values are immutable and if present, are validated. */ public class Contact { @@ -22,25 +23,27 @@ public class Contact { // Identity fields private final Name name; private final Id id; - private final Phone phone; - private final Email email; + private final Optional phone; + private final Optional email; // Data fields - private final Url url; - private final Address address; + private final Optional url; + private final Optional
address; private final Set tags = new HashSet<>(); /** - * Every field must be present and not null. + * Name and id fields must be non-null. + * Tags must be non-null but can be empty as well. + * The other fields can be null. */ public Contact(Name name, Id id, Phone phone, Email email, Url url, Address address, Set tags) { - requireAllNonNull(name, phone, email, address, tags); + requireAllNonNull(name, id, tags); this.name = name; this.id = id; - this.phone = phone; - this.email = email; - this.url = url; - this.address = address; + this.phone = Optional.ofNullable(phone); + this.email = Optional.ofNullable(email); + this.url = Optional.ofNullable(url); + this.address = Optional.ofNullable(address); this.tags.addAll(tags); } @@ -53,23 +56,23 @@ public Name getName() { return name; } - public Phone getPhone() { + public Id getId() { + return id; + } + + public Optional getPhone() { return phone; } - public Email getEmail() { + public Optional getEmail() { return email; } - public Address getAddress() { + public Optional
getAddress() { return address; } - public Id getId() { - return id; - } - - public Url getUrl() { + public Optional getUrl() { return url; } diff --git a/src/main/java/seedu/address/model/person/Organization.java b/src/main/java/seedu/address/model/person/Organization.java index e2e53202903..8f1538e74e7 100644 --- a/src/main/java/seedu/address/model/person/Organization.java +++ b/src/main/java/seedu/address/model/person/Organization.java @@ -1,22 +1,21 @@ package seedu.address.model.person; -import static seedu.address.commons.util.CollectionUtil.requireAllNonNull; - import java.util.Objects; +import java.util.Optional; import java.util.Set; import seedu.address.commons.util.ToStringBuilder; import seedu.address.model.tag.Tag; /** - * Represents an Organisation in the address book. Guarantees: details are present and not null, field values are - * validated, immutable. + * Represents an Organisation in the address book. + * Guarantees: Guarantees: name and id are present and not null, field values are immutable and if present, are validated. */ public class Organization extends Contact { // TODO: Override the getChildren method - private final Status status; - private final Position position; + private final Optional status; + private final Optional position; /** * Every field must be present and not null. @@ -26,9 +25,8 @@ public Organization( Address address, Set tags, Status status, Position position ) { super(name, id, phone, email, url, address, tags); - requireAllNonNull(status, position); - this.status = status; - this.position = position; + this.status = Optional.ofNullable(status); + this.position = Optional.ofNullable(position); } @Override @@ -36,11 +34,11 @@ public Type getType() { return Type.ORGANIZATION; } - public Status getStatus() { + public Optional getStatus() { return status; } - public Position getPosition() { + public Optional getPosition() { return position; } diff --git a/src/main/java/seedu/address/model/person/Recruiter.java b/src/main/java/seedu/address/model/person/Recruiter.java index c77c8763873..5dfa42ee22b 100644 --- a/src/main/java/seedu/address/model/person/Recruiter.java +++ b/src/main/java/seedu/address/model/person/Recruiter.java @@ -9,7 +9,7 @@ /** * Represents a Recruiter in the address book. - * Guarantees: details are present and not null, field values are validated, immutable. + * Guarantees: Guarantees: name and id are present and not null, field values are immutable and if present, are validated. */ public class Recruiter extends Contact { diff --git a/src/main/java/seedu/address/model/person/Url.java b/src/main/java/seedu/address/model/person/Url.java index 48a69c869cc..77c7c2e734a 100644 --- a/src/main/java/seedu/address/model/person/Url.java +++ b/src/main/java/seedu/address/model/person/Url.java @@ -12,7 +12,7 @@ public class Url { public static final String MESSAGE_CONSTRAINTS = "Url should minimally contain a dot surrounded by text, like example.com"; - 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 3e17f1a5987..6ce8be7cec0 100644 --- a/src/main/java/seedu/address/storage/JsonAdaptedContact.java +++ b/src/main/java/seedu/address/storage/JsonAdaptedContact.java @@ -74,8 +74,13 @@ public JsonAdaptedContact(@JsonProperty("type") String type, */ public JsonAdaptedContact(Contact source) { if (source.getType() == Type.ORGANIZATION) { - status = ((Organization) source).getStatus().applicationStatus; - position = ((Organization) source).getPosition().jobPosition; + Organization organization = (Organization) source; + status = organization.getStatus() + .map(status -> status.applicationStatus) + .orElse(null); + position = organization.getPosition() + .map(position -> position.jobPosition) + .orElse(null); oid = ""; } else if (source.getType() == Type.RECRUITER) { Recruiter recruiter = (Recruiter) source; @@ -88,11 +93,11 @@ public JsonAdaptedContact(Contact source) { type = source.getType().toString(); name = source.getName().fullName; - phone = source.getPhone().value; - email = source.getEmail().value; - url = source.getUrl().value; - address = source.getAddress().value; id = source.getId().value; + phone = source.getPhone().map(phone -> phone.value).orElse(null); + email = source.getEmail().map(email -> email.value).orElse(null); + url = source.getUrl().map(url -> url.value).orElse(null); + address = source.getAddress().map(address -> address.value).orElse(null); tags.addAll(source.getTags().stream() .map(JsonAdaptedTag::new) .collect(Collectors.toList())); @@ -129,45 +134,38 @@ public Contact toModelType() throws IllegalValueException { } final Id modelId = new Id(id); - if (phone == null) { - throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, Phone.class.getSimpleName())); - } - if (!Phone.isValidPhone(phone)) { + if (phone != null && !Phone.isValidPhone(phone)) { throw new IllegalValueException(Phone.MESSAGE_CONSTRAINTS); } - final Phone modelPhone = new Phone(phone); + final Phone modelPhone = phone == null ? null : new Phone(phone); - if (email == null) { - throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, Email.class.getSimpleName())); - } - if (!Email.isValidEmail(email)) { + if (email != null && !Email.isValidEmail(email)) { throw new IllegalValueException(Email.MESSAGE_CONSTRAINTS); } - final Email modelEmail = new Email(email); + final Email modelEmail = email == null ? null : new Email(email); - if (url == null) { - throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, Url.class.getSimpleName())); - } - if (!Url.isValidUrl(url)) { + if (url != null && !Url.isValidUrl(url)) { throw new IllegalValueException(Url.MESSAGE_CONSTRAINTS); } - final Url modelUrl = new Url(url); + final Url modelUrl = url == null ? null : new Url(url); - if (address == null) { - throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, Address.class.getSimpleName())); - } - if (!Address.isValidAddress(address)) { + if (address != null && !Address.isValidAddress(address)) { throw new IllegalValueException(Address.MESSAGE_CONSTRAINTS); } - final Address modelAddress = new Address(address); + final Address modelAddress = address == null ? null : new Address(address); final Set modelTags = new HashSet<>(contactTags); switch (modelType) { case ORGANIZATION: { - + if (status != null && !Status.isValidStatus(status)) { + throw new IllegalValueException(Status.MESSAGE_CONSTRAINTS); + } final Status modelStatus = status == null ? new Status() : new Status(status); + if (position != null && !Position.isValidPosition(position)) { + throw new IllegalValueException(Position.MESSAGE_CONSTRAINTS); + } final Position modelPosition = position == null ? new Position() : new Position(position); return new Organization( @@ -176,6 +174,9 @@ public Contact toModelType() throws IllegalValueException { ); } case RECRUITER: { + if (oid != null && !Id.isValidId(oid)) { + throw new IllegalValueException(Id.MESSAGE_CONSTRAINTS); + } final Id modelOid = oid == null ? null : new Id(oid); return new Recruiter( diff --git a/src/main/java/seedu/address/ui/ContactCard.java b/src/main/java/seedu/address/ui/ContactCard.java index 70c85b5ea8f..1960c511519 100644 --- a/src/main/java/seedu/address/ui/ContactCard.java +++ b/src/main/java/seedu/address/ui/ContactCard.java @@ -24,9 +24,8 @@ public class ContactCard extends UiPart { private static final String FXML = "ContactListCard.fxml"; /** - * Note: Certain keywords such as "location" and "resources" are reserved keywords in JavaFX. - * As a consequence, UI elements' variable names cannot be set to such keywords - * or an exception will be thrown by JavaFX during runtime. + * Note: Certain keywords such as "location" and "resources" are reserved keywords in JavaFX. As a consequence, UI + * elements' variable names cannot be set to such keywords or an exception will be thrown by JavaFX during runtime. * * @see The issue on AddressBook level 4 */ @@ -75,23 +74,29 @@ public ContactCard(Contact contact, int displayedIndex) { typeLabel.setId("type"); tags.getChildren().add(typeLabel); // add it to the front of tags - setVboxInnerLabelText(phone, () -> contact.getPhone().value); - setVboxInnerLabelText(address, () -> contact.getAddress().value); - setVboxInnerLabelText(email, () -> contact.getEmail().value); - setVboxInnerLabelText(url, () -> contact.getUrl().value); + setVboxInnerLabelText( + phone, () -> contact.getPhone().map(phone -> phone.value).orElse(null)); + setVboxInnerLabelText( + address, () -> contact.getAddress().map(address -> address.value).orElse(null)); + setVboxInnerLabelText( + email, () -> contact.getEmail().map(email -> email.value).orElse(null)); + setVboxInnerLabelText( + url, () -> contact.getUrl().map(url -> url.value).orElse(null)); switch (contact.getType()) { case ORGANIZATION: { Organization organization = (Organization) contact; - final String statusString = organization.getStatus().applicationStatus; - final String positionString = organization.getPosition().jobPosition; + final String statusString = organization.getStatus() + .map(status -> status.applicationStatus).orElse(null); + final String positionString = organization.getPosition() + .map(position -> position.jobPosition).orElse(null); setVboxInnerLabelText( - status, () -> StringUtil.formatWithNullFallback("Application Status: %s", statusString) - ); + status, () -> + StringUtil.formatWithNullFallback("Application Status: %s", statusString)); setVboxInnerLabelText( - position, () -> StringUtil.formatWithNullFallback("Application Position: %s", positionString) - ); + position, () -> + StringUtil.formatWithNullFallback("Application Position: %s", positionString)); cardPaneInnerVbox.getChildren().remove(linkedParentOrganization); break; } @@ -101,11 +106,10 @@ public ContactCard(Contact contact, int displayedIndex) { final Optional linkedOrgId = recruiter.getOrganizationId(); setVboxInnerLabelText( - linkedParentOrganization, () -> linkedOrgId.map(oid -> - String.format( - "from %s (%s)", "organization" /* TODO: Use org name instead */, oid.value - )) - .orElse(null) + linkedParentOrganization, () -> + linkedOrgId.map(oid -> String.format( + "from %s (%s)", "organization" /* TODO: Use org name instead */, oid.value)) + .orElse(null) ); cardPaneInnerVbox.getChildren().removeAll(status, position); break; @@ -121,10 +125,10 @@ public ContactCard(Contact contact, int displayedIndex) { } /** - * Configures the inner label contained within the vbox container to show the given string, - * or remove the label entirely if the string is empty or null. + * Configures the inner label contained within the vbox container to show the given string, or remove the label + * entirely if the string is empty or null. * - * @param label The label to set the text to. + * @param label The label to set the text to. * @param valueSupplier The string value supplier. This may be expressed as a lambda function. */ private void setVboxInnerLabelText(Label label, Supplier valueSupplier) { diff --git a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java index 1da4656b9f0..44d092adc88 100644 --- a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java +++ b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java @@ -27,7 +27,6 @@ * Contains helper methods for testing commands. */ public class CommandTestUtil { - public static final String VALID_NAME_AMY = "Amy Bee"; public static final String VALID_NAME_BOB = "Bob Choo"; public static final String VALID_ID_AMY = "3a6e0af8-5092-47c0-baf7-18d6dc535823"; @@ -64,7 +63,7 @@ public class CommandTestUtil { public static final String INVALID_ID_DESC = " " + FLAG_ID + " " + "e91724&_18273"; // '&' not allowed in ids public static final String INVALID_PHONE_DESC = " " + FLAG_PHONE + " " + "911a"; // 'a' not allowed in phones public static final String INVALID_EMAIL_DESC = " " + FLAG_EMAIL + " " + "bob!yahoo"; // missing '@' symbol - public static final String INVALID_ADDRESS_DESC = " " + FLAG_ADDRESS; // empty string not allowed for addresses + public static final String INVALID_ADDRESS_DESC = " " + FLAG_ADDRESS + " "; // address cannot be empty string public static final String INVALID_URL_DESC = " " + FLAG_URL + " " + "asdfjkl"; public static final String INVALID_TAG_DESC = " " + FLAG_TAG + " " + "hubby*"; // '*' not allowed in tags diff --git a/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java b/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java index 3c96c75c090..12d536f8afa 100644 --- a/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java +++ b/src/test/java/seedu/address/logic/parser/AddCommandParserTest.java @@ -23,10 +23,7 @@ import static seedu.address.logic.commands.CommandTestUtil.TAG_DESC_FRIEND; import static seedu.address.logic.commands.CommandTestUtil.TAG_DESC_HUSBAND; import static seedu.address.logic.commands.CommandTestUtil.URL_DESC_BOB; -import static seedu.address.logic.commands.CommandTestUtil.VALID_ADDRESS_BOB; -import static seedu.address.logic.commands.CommandTestUtil.VALID_EMAIL_BOB; import static seedu.address.logic.commands.CommandTestUtil.VALID_NAME_BOB; -import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_BOB; import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_FRIEND; import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND; import static seedu.address.logic.parser.CliSyntax.FLAG_ADDRESS; @@ -150,7 +147,7 @@ public void parse_repeatedNonTagValue_failure() { @Test public void parse_optionalFieldsMissing_success() { // zero tags, no url - Contact expectedContact = new ContactBuilder(AMY).withUrl("").withTags().build(); + Contact expectedContact = new ContactBuilder(AMY).withUrl(null).withTags().build(); assertParseSuccess( parser, NAME_DESC_AMY + ID_DESC_AMY + PHONE_DESC_AMY + EMAIL_DESC_AMY + ADDRESS_DESC_AMY, @@ -163,24 +160,7 @@ public void parse_compulsoryFieldMissing_failure() { String expectedMessage = String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE); // missing name flag - assertParseFailure(parser, VALID_NAME_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB, - expectedMessage); - - // missing phone flag - assertParseFailure(parser, NAME_DESC_BOB + VALID_PHONE_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB, - expectedMessage); - - // missing email flag - assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + VALID_EMAIL_BOB + ADDRESS_DESC_BOB, - expectedMessage); - - // missing address flag - assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + VALID_ADDRESS_BOB, - expectedMessage); - - // all flags missing - assertParseFailure(parser, VALID_NAME_BOB + VALID_PHONE_BOB + VALID_EMAIL_BOB + VALID_ADDRESS_BOB, - expectedMessage); + assertParseFailure(parser, VALID_NAME_BOB, expectedMessage); } @Test diff --git a/src/test/java/seedu/address/storage/JsonAdaptedContactTest.java b/src/test/java/seedu/address/storage/JsonAdaptedContactTest.java index 0d8f6b45a09..7c9b701f4cd 100644 --- a/src/test/java/seedu/address/storage/JsonAdaptedContactTest.java +++ b/src/test/java/seedu/address/storage/JsonAdaptedContactTest.java @@ -1,5 +1,6 @@ package seedu.address.storage; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertEquals; import static seedu.address.storage.JsonAdaptedContact.MISSING_FIELD_MESSAGE_FORMAT; import static seedu.address.testutil.Assert.assertThrows; @@ -35,10 +36,10 @@ public class JsonAdaptedContactTest { private static final String VALID_STATUS = ""; private static final String VALID_POSITION = ""; private static final String VALID_ID = "78a36caf-6d42-4fd2-a017-7f6a92fa3155"; - private static final String VALID_PHONE = BENSON.getPhone().toString(); - private static final String VALID_EMAIL = BENSON.getEmail().toString(); - private static final String VALID_URL = BENSON.getUrl().toString(); - private static final String VALID_ADDRESS = BENSON.getAddress().toString(); + private static final String VALID_PHONE = BENSON.getPhone().get().value; + private static final String VALID_EMAIL = BENSON.getEmail().get().value; + private static final String VALID_URL = BENSON.getUrl().get().value; + private static final String VALID_ADDRESS = BENSON.getAddress().get().value; private static final String VALID_OID = "78a36caf-6d42-4fd2-a017-7f6a92fa3155"; private static final List VALID_TAGS = BENSON.getTags().stream() @@ -79,12 +80,11 @@ public void toModelType_invalidPhone_throwsIllegalValueException() { } @Test - public void toModelType_nullPhone_throwsIllegalValueException() { + public void toModelType_nullPhone_doesNotThrowException() { JsonAdaptedContact person = new JsonAdaptedContact(VALID_TYPE_ORG, VALID_NAME, VALID_ID, null, VALID_EMAIL, VALID_URL, VALID_ADDRESS, VALID_STATUS, VALID_POSITION, VALID_OID, VALID_TAGS); - String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Phone.class.getSimpleName()); - assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); + assertDoesNotThrow(person::toModelType); } @Test @@ -97,12 +97,11 @@ public void toModelType_invalidEmail_throwsIllegalValueException() { } @Test - public void toModelType_nullEmail_throwsIllegalValueException() { + public void toModelType_nullEmail_doesNotThrowException() { JsonAdaptedContact person = new JsonAdaptedContact(VALID_TYPE_ORG, VALID_NAME, VALID_ID, VALID_PHONE, null, VALID_URL, VALID_ADDRESS, VALID_STATUS, VALID_POSITION, VALID_OID, VALID_TAGS); - String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Email.class.getSimpleName()); - assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); + assertDoesNotThrow(person::toModelType); } @Test @@ -115,12 +114,11 @@ public void toModelType_invalidAddress_throwsIllegalValueException() { } @Test - public void toModelType_nullAddress_throwsIllegalValueException() { + public void toModelType_nullAddress_doesNotThrowException() { JsonAdaptedContact person = new JsonAdaptedContact(VALID_TYPE_ORG, VALID_NAME, VALID_ID, VALID_PHONE, VALID_EMAIL, VALID_URL, null, VALID_STATUS, VALID_POSITION, VALID_OID, VALID_TAGS); - String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Address.class.getSimpleName()); - assertThrows(IllegalValueException.class, expectedMessage, person::toModelType); + assertDoesNotThrow(person::toModelType); } @Test diff --git a/src/test/java/seedu/address/testutil/ContactBuilder.java b/src/test/java/seedu/address/testutil/ContactBuilder.java index 88d9e00944f..3ddb559290b 100644 --- a/src/test/java/seedu/address/testutil/ContactBuilder.java +++ b/src/test/java/seedu/address/testutil/ContactBuilder.java @@ -56,10 +56,10 @@ public ContactBuilder() { public ContactBuilder(Contact contactToCopy) { name = contactToCopy.getName(); id = contactToCopy.getId(); - phone = contactToCopy.getPhone(); - email = contactToCopy.getEmail(); - url = contactToCopy.getUrl(); - address = contactToCopy.getAddress(); + phone = contactToCopy.getPhone().orElse(null); + email = contactToCopy.getEmail().orElse(null); + url = contactToCopy.getUrl().orElse(null); + address = contactToCopy.getAddress().orElse(null); tags = new HashSet<>(contactToCopy.getTags()); } @@ -83,7 +83,7 @@ public ContactBuilder withId(String id) { * Sets the {@code Status} of the {@code Contact} that we are building. */ public ContactBuilder withStatus(String status) { - this.status = new Status(status); + this.status = status == null ? null : new Status(status); return this; } @@ -99,7 +99,7 @@ public ContactBuilder withTags(String ... tags) { * Sets the {@code Url} of the {@code Contact} that we are building. */ public ContactBuilder withUrl(String url) { - this.url = new Url(url); + this.url = url == null ? null : new Url(url); return this; } @@ -107,7 +107,7 @@ public ContactBuilder withUrl(String url) { * Sets the {@code Address} of the {@code Contact} that we are building. */ public ContactBuilder withAddress(String address) { - this.address = new Address(address); + this.address = address == null ? null : new Address(address); return this; } @@ -115,7 +115,7 @@ public ContactBuilder withAddress(String address) { * Sets the {@code Phone} of the {@code Contact} that we are building. */ public ContactBuilder withPhone(String phone) { - this.phone = new Phone(phone); + this.phone = phone == null ? null : new Phone(phone); return this; } @@ -123,7 +123,7 @@ public ContactBuilder withPhone(String phone) { * Sets the {@code Email} of the {@code Contact} that we are building. */ public ContactBuilder withEmail(String email) { - this.email = new Email(email); + this.email = email == null ? null : new Email(email); return this; } diff --git a/src/test/java/seedu/address/testutil/ContactUtil.java b/src/test/java/seedu/address/testutil/ContactUtil.java index cd85395cd93..195a0339e1b 100644 --- a/src/test/java/seedu/address/testutil/ContactUtil.java +++ b/src/test/java/seedu/address/testutil/ContactUtil.java @@ -34,10 +34,10 @@ public static String getContactDetails(Contact contact) { StringBuilder sb = new StringBuilder(); sb.append(FLAG_NAME + " " + contact.getName().fullName + " "); sb.append(FLAG_ID + " " + contact.getId().value + " "); - sb.append(FLAG_PHONE + " " + contact.getPhone().value + " "); - sb.append(FLAG_EMAIL + " " + contact.getEmail().value + " "); - sb.append(FLAG_ADDRESS + " " + contact.getAddress().value + " "); - sb.append(FLAG_URL + " " + contact.getUrl().value + " "); + sb.append(FLAG_PHONE + " " + contact.getPhone().map(phone -> phone.value).orElse("") + " "); + sb.append(FLAG_EMAIL + " " + contact.getEmail().map(email -> email.value).orElse("") + " "); + sb.append(FLAG_ADDRESS + " " + contact.getAddress().map(address -> address.value).orElse("") + " "); + sb.append(FLAG_URL + " " + contact.getUrl().map(url -> url.value).orElse("") + " "); contact.getTags().stream().forEach( s -> sb.append(FLAG_TAG + s.tagName + " ") ); diff --git a/src/test/java/seedu/address/testutil/EditContactDescriptorBuilder.java b/src/test/java/seedu/address/testutil/EditContactDescriptorBuilder.java index d5738e16723..b912651d78d 100644 --- a/src/test/java/seedu/address/testutil/EditContactDescriptorBuilder.java +++ b/src/test/java/seedu/address/testutil/EditContactDescriptorBuilder.java @@ -33,9 +33,9 @@ public EditContactDescriptorBuilder(EditContactDescriptor descriptor) { public EditContactDescriptorBuilder(Contact contact) { descriptor = new EditContactDescriptor(); descriptor.setName(contact.getName()); - descriptor.setPhone(contact.getPhone()); - descriptor.setEmail(contact.getEmail()); - descriptor.setAddress(contact.getAddress()); + descriptor.setPhone(contact.getPhone().orElse(null)); + descriptor.setEmail(contact.getEmail().orElse(null)); + descriptor.setAddress(contact.getAddress().orElse(null)); descriptor.setTags(contact.getTags()); } diff --git a/src/test/java/seedu/address/testutil/RecruiterBuilder.java b/src/test/java/seedu/address/testutil/RecruiterBuilder.java index f4238bd0326..c6a9608f0e7 100644 --- a/src/test/java/seedu/address/testutil/RecruiterBuilder.java +++ b/src/test/java/seedu/address/testutil/RecruiterBuilder.java @@ -42,10 +42,10 @@ public Recruiter build() { return new Recruiter( contact.getName(), contact.getId(), - contact.getPhone(), - contact.getEmail(), - contact.getUrl(), - contact.getAddress(), + contact.getPhone().orElse(null), + contact.getEmail().orElse(null), + contact.getUrl().orElse(null), + contact.getAddress().orElse(null), contact.getTags(), oid ); From 7603694d53a1ca32c50506a5e7419e3a62de6a3b Mon Sep 17 00:00:00 2001 From: McNaBry Date: Thu, 19 Oct 2023 15:25:11 +0800 Subject: [PATCH 3/5] Fix checkstyle and javadocs --- src/main/java/seedu/address/model/person/Organization.java | 7 +++++-- src/main/java/seedu/address/model/person/Recruiter.java | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/seedu/address/model/person/Organization.java b/src/main/java/seedu/address/model/person/Organization.java index 8f1538e74e7..f7474dee3d6 100644 --- a/src/main/java/seedu/address/model/person/Organization.java +++ b/src/main/java/seedu/address/model/person/Organization.java @@ -9,7 +9,8 @@ /** * Represents an Organisation in the address book. - * Guarantees: Guarantees: name and id are present and not null, field values are immutable and if present, are validated. + * Guarantees: Guarantees: name and id are present and not null, + * field values are immutable and if present, are validated. */ public class Organization extends Contact { // TODO: Override the getChildren method @@ -18,7 +19,9 @@ public class Organization extends Contact { private final Optional position; /** - * Every field must be present and not null. + * Name and id fields must be non-null. + * Tags must be non-null but can be empty as well. + * The other fields can be null. */ public Organization( Name name, Id id, Phone phone, Email email, Url url, diff --git a/src/main/java/seedu/address/model/person/Recruiter.java b/src/main/java/seedu/address/model/person/Recruiter.java index 5dfa42ee22b..2e9ceb408ed 100644 --- a/src/main/java/seedu/address/model/person/Recruiter.java +++ b/src/main/java/seedu/address/model/person/Recruiter.java @@ -9,14 +9,17 @@ /** * Represents a Recruiter in the address book. - * Guarantees: Guarantees: name and id are present and not null, field values are immutable and if present, are validated. + * Guarantees: Guarantees: name and id are present and not null, + * field values are immutable and if present, are validated. */ public class Recruiter extends Contact { private final Optional oid; /** - * Every field except oid must be present and not null. + * Name and id fields must be non-null. + * Tags must be non-null but can be empty as well. + * The other fields can be null. */ public Recruiter(Name name, Id id, Phone phone, Email email, Url url, Address address, Set tags, Id oid) { super(name, id, phone, email, url, address, tags); From 59256a6ddd1e108acce06d0c1b74ca59a164ff2d Mon Sep 17 00:00:00 2001 From: McNaBry Date: Thu, 19 Oct 2023 15:57:07 +0800 Subject: [PATCH 4/5] Update message for AddCommand usage --- .../address/logic/commands/AddCommand.java | 60 ++++++++++++++++--- src/main/resources/view/DarkTheme.css | 2 +- src/main/resources/view/MainWindow.fxml | 2 +- src/main/resources/view/ResultDisplay.fxml | 2 +- 4 files changed, 54 insertions(+), 12 deletions(-) diff --git a/src/main/java/seedu/address/logic/commands/AddCommand.java b/src/main/java/seedu/address/logic/commands/AddCommand.java index e4f54ed29b8..65f67323dab 100644 --- a/src/main/java/seedu/address/logic/commands/AddCommand.java +++ b/src/main/java/seedu/address/logic/commands/AddCommand.java @@ -5,8 +5,14 @@ import static seedu.address.logic.parser.CliSyntax.FLAG_EMAIL; import static seedu.address.logic.parser.CliSyntax.FLAG_ID; import static seedu.address.logic.parser.CliSyntax.FLAG_NAME; +import static seedu.address.logic.parser.CliSyntax.FLAG_ORGANIZATION; +import static seedu.address.logic.parser.CliSyntax.FLAG_ORGANIZATION_ID; import static seedu.address.logic.parser.CliSyntax.FLAG_PHONE; +import static seedu.address.logic.parser.CliSyntax.FLAG_POSITION; +import static seedu.address.logic.parser.CliSyntax.FLAG_RECRUITER; +import static seedu.address.logic.parser.CliSyntax.FLAG_STATUS; import static seedu.address.logic.parser.CliSyntax.FLAG_TAG; +import static seedu.address.logic.parser.CliSyntax.FLAG_URL; import java.util.logging.Logger; @@ -24,21 +30,57 @@ public class AddCommand extends Command { public static final String COMMAND_WORD = "add"; - public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a contact to the address book. " + public static final String MESSAGE_ORGANIZATION_USAGE = "Adds an organization. " + "Parameters: " + + FLAG_ORGANIZATION + " " + FLAG_NAME + " NAME " - + FLAG_ID + " ID " - + FLAG_PHONE + " PHONE " - + FLAG_EMAIL + " EMAIL " - + FLAG_ADDRESS + " ADDRESS " + + "[" + FLAG_ID + " ID] " + + "[" + FLAG_PHONE + " PHONE] " + + "[" + FLAG_EMAIL + " EMAIL] " + + "[" + FLAG_URL + " URL] " + + "[" + FLAG_ADDRESS + " ADDRESS] " + + "[" + FLAG_STATUS + " STATUS] " + + "[" + FLAG_POSITION + " POSITION] " + "[" + FLAG_TAG + " TAG]...\n" + "Example: " + COMMAND_WORD + " " - + FLAG_NAME + " John Doe " + + FLAG_ORGANIZATION + " " + + FLAG_NAME + " JobsInc " + + FLAG_ID + " id_12345-1 " + FLAG_PHONE + " 98765432 " - + FLAG_EMAIL + " johnd@example.com " + + FLAG_EMAIL + " jobsInc@example.com " + + FLAG_URL + " www.jobsinc.com " + FLAG_ADDRESS + " 311, Clementi Ave 2, #02-25 " - + FLAG_TAG + " friends " - + FLAG_TAG + " owesMoney"; + + FLAG_STATUS + " applied " + + FLAG_POSITION + " Junior Software Engineer " + + FLAG_TAG + " softwareEngineering " + + FLAG_TAG + " competitive "; + + public static final String MESSAGE_RECRUITER_USAGE = "Adds a recruiter. " + + "Parameters: " + + FLAG_RECRUITER + " " + + FLAG_NAME + " NAME " + + "[" + FLAG_ID + " ID] " + + "[" + FLAG_ORGANIZATION_ID + " ORG_ID] " + + "[" + FLAG_PHONE + " PHONE] " + + "[" + FLAG_EMAIL + " EMAIL] " + + "[" + FLAG_URL + " URL] " + + "[" + FLAG_ADDRESS + " ADDRESS] " + + "[" + FLAG_TAG + " TAG]...\n" + + "Example: " + COMMAND_WORD + " " + + FLAG_RECRUITER + " " + + FLAG_NAME + " Steve " + + FLAG_ID + " id_98765-1 " + + FLAG_PHONE + " 83452145 " + + FLAG_EMAIL + " steveJobsInc@example.com " + + FLAG_URL + " www.linkedin.com/in/steve/ " + + FLAG_ADDRESS + " 311 W Coast Walk, #02-30 " + + FLAG_TAG + " friendly "; + + public static final String MESSAGE_USAGE = COMMAND_WORD + + ": Adds a contact to the address book of the class type Organization or Recruiter." + + " The input format varies depending on the class:\n\n" + + MESSAGE_ORGANIZATION_USAGE + "\n\n" + + MESSAGE_RECRUITER_USAGE; public static final String MESSAGE_SUCCESS = "New contact added: %1$s"; public static final String MESSAGE_DUPLICATE_CONTACT = "This contact already exists in the address book"; diff --git a/src/main/resources/view/DarkTheme.css b/src/main/resources/view/DarkTheme.css index 51cb32b4bdb..a3806dc9e9f 100644 --- a/src/main/resources/view/DarkTheme.css +++ b/src/main/resources/view/DarkTheme.css @@ -149,7 +149,7 @@ .result-display { -fx-background-color: transparent; -fx-font-family: "Segoe UI Light"; - -fx-font-size: 13pt; + -fx-font-size: 12pt; -fx-text-fill: white; } diff --git a/src/main/resources/view/MainWindow.fxml b/src/main/resources/view/MainWindow.fxml index 8599b9090d4..5eeb2b6c603 100644 --- a/src/main/resources/view/MainWindow.fxml +++ b/src/main/resources/view/MainWindow.fxml @@ -40,7 +40,7 @@ + minHeight="150" prefHeight="100" maxHeight="100"> diff --git a/src/main/resources/view/ResultDisplay.fxml b/src/main/resources/view/ResultDisplay.fxml index 01b691792a9..42a3a1591f8 100644 --- a/src/main/resources/view/ResultDisplay.fxml +++ b/src/main/resources/view/ResultDisplay.fxml @@ -5,5 +5,5 @@ -