Skip to content

Commit

Permalink
Merge branch 'master' into ui-and-default-data-updates
Browse files Browse the repository at this point in the history
  • Loading branch information
wxwern authored Oct 19, 2023
2 parents 9e6f0bd + 4c3128a commit fd9d6e8
Show file tree
Hide file tree
Showing 14 changed files with 355 additions and 48 deletions.
35 changes: 19 additions & 16 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ title: User Guide
* Items with `...` after them can be used multiple times including zero times.<br>
e.g. `[--tag TAG]...` can be used as ` ` (i.e. 0 times), `--tag friend`, `--tag friend --tag family` etc.

* Items separated by `/` means that only one of them can be used per command.<br>
e.g. `--org/--rec` means that either `--org` or `--rec` can be supplied as a flag but not both at the same time.

* Parameters can be in any order.<br>
e.g. if the command specifies `--name NAME --phone PHONE_NUMBER`, `--phone PHONE_NUMBER --name NAME` is also acceptable.

Expand All @@ -70,20 +73,20 @@ Format: `help`

### Adding a contact: `add`

Format: `add --type CLASS <additional parameters and values...>`
Format: `add --org/--rec <additional parameters and values...>`

Adds a contact to the address book of the given class type: Organization or Recruiter.

Notice that `CLASS` must be either _Organization_ or _Recruiter_ (or any case-insensitive unambiguous prefix match, so “org” will match “Organization” automatically)
Supplying `--org` adds an Organization while supplying `--rec` adds a Recruiter to the address book.

Details specifically on organization and recruiter level are specified in the next sections.


#### Adding an organization contact: `add --type organization`
#### Adding an organization contact: `add --org`

_{Work in progress...}_

Format: `add --type o[rganization] --name NAME [--id ID] [--phone NUMBER] [--email EMAIL] [--url URL] [--addr ADDRESS] [--stat STATUS] [--pos POSITION] [--tag TAG]... `
Format: `add --org --name NAME [--id ID] [--phone NUMBER] [--email EMAIL] [--url URL] [--addr ADDRESS] [--stat STATUS] [--pos POSITION] [--tag TAG]... `


Acceptable Parameters:
Expand All @@ -108,22 +111,22 @@ Acceptable Parameters:


Examples:
* `add --name J&J --type Organization`
* `add --org --name J&J`

* `add --name Google --type Org --id g-sg --phone 98765432 `
* `add --org --name Google --id g-sg --phone 98765432 `

* `add --name Hoyoverse --type organization --email mihoyo@example.com --tag example1 --tag example2`
* `add --org --name Hoyoverse --email mihoyo@example.com --tag example1 --tag example2`

* `add --name Example --type organi --url www.organization.org --tag freelance work`
* `add --org --name Example --url www.organization.org --tag freelance`

* `add --type o --name Examinations NUS --phone 65166269 --email examinations@nus.edu.sg --url https://luminus.nus.edu.sg/ --stat pending`
* `add --org --name Examinations NUS --phone 65166269 --email examinations@nus.edu.sg --url https://luminus.nus.edu.sg/ --stat pending`


### Adding a recruiter: `add --type recruiter`
#### Adding a recruiter contact: `add --rec`

_{Work in progress...}_

Format: `add --type r[ecruiter] --name NAME [-id ID] [--oid ORG_ID] [--phone NUMBER] [--email EMAIL] [--url URL] [--addr ADDRESS] [--tag TAG]...`
Format: `add --rec --name NAME [-id ID] [--oid ORG_ID] [--phone NUMBER] [--email EMAIL] [--url URL] [--addr ADDRESS] [--tag TAG]...`


Acceptable Parameters:
Expand All @@ -132,19 +135,19 @@ Acceptable Parameters:
* `ID` refers to a unique identifier which is used to uniquely identify the recruiter (alphanumeric and basic symbols, i.e. should only be `a-z`, `A-Z`, `0-9`, `-`, `_`).
* Specifying this sets the ID, or one unique one will be derived and generated from the name if not provided.

* `ORG_ID` refers to the unique identifier which is used to uniquely identify the organization the recruiter should be tied to.
* `ORG_ID` refers to the unique identifier which is used to uniquely identify the organization the recruiter should be tied to. It is subject to the same validation as the ID field.

* `NUMBER` should be a valid phone number.

* `EMAIL` should be a valid email.

* `ADDRESS` can accept any value. It designates the contact’s physical address.

* `TAG `can accept any value and may have multiple inputs.
* `TAG` can accept any value and may have multiple inputs.


Examples:
* `add --name John Doe --type Recruiter --oid paypal-sg`
* `add --rec --name John Doe --oid paypal-sg`


### Listing all contacts: `list`
Expand Down Expand Up @@ -248,8 +251,8 @@ If your changes to the data file makes its format invalid, Jobby will discard al

Action | Format, Examples
--------|------------------
**Add Organization** | `add --type o[rganization] --name <NAME> [--id ID] [--phone NUMBER] [--email EMAIL] [--url URL] [--addr ADDRESS] [--stat STATUS] [--pos POSITION] [--tag TAG]...`<br> e.g., `add --type o --name NUS --phone 0123456789 --email example@nus.edu.sg --url https://www.nus.edu.sg/ --stat pending --pos Research`
**Add Recruiter** | `add --type r[ecruiter] --name <NAME> [--id ID] [--oid ORG_ID] [--phone NUMBER] [--email EMAIL] [--url URL] [--addr ADDRESS] [--tag TAG]...`<br> e.g., `add --name John Doe --type Recruiter --oid paypal-sg`
**Add Organization** | `add --org --name <NAME> [--id ID] [--phone NUMBER] [--email EMAIL] [--url URL] [--addr ADDRESS] [--stat STATUS] [--pos POSITION] [--tag TAG]...`<br> e.g., `add --org --name NUS --phone 0123456789 --email example@nus.edu.sg --url https://www.nus.edu.sg/ --stat pending --pos Research`
**Add Recruiter** | `add --rec --name <NAME> [--id ID] [--oid ORG_ID] [--phone NUMBER] [--email EMAIL] [--url URL] [--addr ADDRESS] [--tag TAG]...`<br> e.g., `add --rec --name John Doe --oid paypal-sg`
**Clear** | `clear`
**Delete** | `delete INDEX`<br> e.g., `delete 3`
**Edit** | Coming soon...
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import java.util.Set;

import seedu.address.logic.commands.AddCommand;
import seedu.address.logic.commands.AddOrganizationCommand;
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.person.Address;
import seedu.address.model.person.Contact;
Expand Down Expand Up @@ -63,7 +62,7 @@ public AddCommand parse(String args) throws ParseException {

if (argMultimap.hasFlag(FLAG_ORGANIZATION)) {
Organization organization = parseAsOrganization(argMultimap);
return new AddOrganizationCommand(organization);
return new AddCommand(organization);
} else if (argMultimap.hasFlag(FLAG_RECRUITER)) {
Recruiter recruiter = parseAsRecruiter(argMultimap);
return new AddCommand(recruiter);
Expand Down Expand Up @@ -136,7 +135,8 @@ private Organization parseAsOrganization(ArgumentMultimap argMultimap) throws Pa
Status status = ParserUtil.parseOptionally(
argMultimap.getValue(FLAG_STATUS), ParserUtil::parseStatus);
Set<Tag> tagList = ParserUtil.parseTags(argMultimap.getAllValues(FLAG_TAG));
Set<Id> ridList = Set.of(); // TODO: This should be dynamically determined from oid in Recruiter.

return new Organization(name, id, phone, email, url, address, tagList, status, position);
return new Organization(name, id, phone, email, url, address, tagList, status, position, ridList);
}
}
2 changes: 2 additions & 0 deletions src/main/java/seedu/address/logic/parser/CliSyntax.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,7 @@ public class CliSyntax {
public static final Flag FLAG_ID = new Flag("id");
public static final Flag FLAG_RECURSIVE = new Flag("recursive");
public static final Flag FLAG_ORGANIZATION_ID = new Flag("oid");
public static final Flag FLAG_RECRUITER_ID = new Flag("rid");


}
13 changes: 13 additions & 0 deletions src/main/java/seedu/address/logic/parser/ParserUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,19 @@ public static Set<Tag> parseTags(Collection<String> tags) throws ParseException
return tagSet;
}

/**
* Parses {@code Collection<String> ids} into a {@code Set<Tag>}.
*/
public static Set<Id> parseIds(Collection<String> ids) throws ParseException {
requireNonNull(ids);
final Set<Id> idSet = new HashSet<>();
for (String idName : ids) {
idSet.add(parseId(idName));
}
return idSet;
}


/**
* References a function that parses a string into an expected output within the {@link ParserUtil} utility class.
* @param <R> The return result.
Expand Down
16 changes: 15 additions & 1 deletion src/main/java/seedu/address/model/person/Organization.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package seedu.address.model.person;

import java.util.Collections;
import java.util.HashSet;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
Expand All @@ -18,18 +20,23 @@ public class Organization extends Contact {
private final Optional<Status> status;
private final Optional<Position> position;

private final Set<Id> rids = new HashSet<>();


/**
* 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,
Address address, Set<Tag> tags, Status status, Position position
Address address, Set<Tag> tags, Status status, Position position,
Set<Id> rids
) {
super(name, id, phone, email, url, address, tags);
this.status = Optional.ofNullable(status);
this.position = Optional.ofNullable(position);
this.rids.addAll(rids);
}

@Override
Expand All @@ -45,6 +52,13 @@ public Optional<Position> getPosition() {
return position;
}

/**
* Returns an immutable tag set, which throws {@code UnsupportedOperationException}
* if modification is attempted.
*/
public Set<Id> getRecruiterIds() {
return Collections.unmodifiableSet(rids);
}
@Override
public boolean equals(Object other) {
if (other == this) {
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/seedu/address/model/util/SampleDataUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,13 @@ public static Set<Tag> getTagSet(String... strings) {
.collect(Collectors.toSet());
}

/**
* Returns a id set containing the list of strings given.
*/
public static Set<Id> getIdSet(String... strings) {
return Arrays.stream(strings)
.map(Id::new)
.collect(Collectors.toSet());
}

}
5 changes: 4 additions & 1 deletion src/main/java/seedu/address/storage/JsonAdaptedContact.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class JsonAdaptedContact {
private String oid;
private final List<JsonAdaptedTag> tags = new ArrayList<>();


/**
* Constructs a {@code JsonAdaptedContact} with the given contact details.
*/
Expand Down Expand Up @@ -158,6 +159,8 @@ public Contact toModelType() throws IllegalValueException {

switch (modelType) {
case ORGANIZATION: {
final Set<Id> modelRids = new HashSet<>();

if (status != null && !Status.isValidStatus(status)) {
throw new IllegalValueException(Status.MESSAGE_CONSTRAINTS);
}
Expand All @@ -170,7 +173,7 @@ public Contact toModelType() throws IllegalValueException {

return new Organization(
modelName, modelId, modelPhone, modelEmail, modelUrl, modelAddress,
modelTags, modelStatus, modelPosition
modelTags, modelStatus, modelPosition, modelRids
);
}
case RECRUITER: {
Expand Down
49 changes: 49 additions & 0 deletions src/main/java/seedu/address/storage/JsonAdaptedId.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package seedu.address.storage;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

import seedu.address.commons.exceptions.IllegalValueException;
import seedu.address.model.person.Id;

/**
* Jackson-friendly version of {@link Id}.
*/
class JsonAdaptedId {

private final String idName;

/**
* Constructs a {@code JsonAdaptedId} with the given {@code idName}.
*/
@JsonCreator
public JsonAdaptedId(String idName) {
this.idName = idName;
}

/**
* Converts a given {@code Id} into this class for Jackson use.
*/
public JsonAdaptedId(Id source) {
idName = source.value;
}

@JsonValue
public String getIdName() {
return idName;
}

/**
* Converts this Jackson-friendly adapted tag object into the model's {@code Id} object.
*
* @throws IllegalValueException if there were any data constraints violated in the adapted tag.
*/
public Id toModelType() throws IllegalValueException {
if (!Id.isValidId(idName)) {
throw new IllegalValueException(Id.MESSAGE_CONSTRAINTS);
}
return new Id(idName);
}

}

Loading

0 comments on commit fd9d6e8

Please sign in to comment.