Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/main/java/seedu/address/logic/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public static String format(Person person) {
.append(person.getEmail())
.append("; Address: ")
.append(person.getAddress())
.append("; Social: ")
.append(person.getSocial())
.append("; Tags: ");
person.getTags().forEach(builder::append);
return builder.toString();
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/seedu/address/logic/commands/EditCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import seedu.address.model.person.Name;
import seedu.address.model.person.Person;
import seedu.address.model.person.Phone;
import seedu.address.model.person.Social;
import seedu.address.model.tag.Tag;

/**
Expand Down Expand Up @@ -99,9 +100,10 @@ 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());
Social updatedSocial = personToEdit.getSocial();
Set<Tag> updatedTags = editPersonDescriptor.getTags().orElse(personToEdit.getTags());

return new Person(updatedName, updatedPhone, updatedEmail, updatedAddress, updatedTags);
return new Person(updatedName, updatedPhone, updatedEmail, updatedAddress, updatedSocial, updatedTags);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL;
import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME;
import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_SOCIAL;
import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG;

import java.util.Set;
Expand All @@ -17,6 +18,7 @@
import seedu.address.model.person.Name;
import seedu.address.model.person.Person;
import seedu.address.model.person.Phone;
import seedu.address.model.person.Social;
import seedu.address.model.tag.Tag;

/**
Expand All @@ -31,7 +33,7 @@ public class AddCommandParser implements Parser<AddCommand> {
*/
public AddCommand parse(String args) throws ParseException {
ArgumentMultimap argMultimap =
ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS, PREFIX_TAG);
ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS, PREFIX_SOCIAL, PREFIX_TAG);

if (!arePrefixesPresent(argMultimap, PREFIX_NAME, PREFIX_ADDRESS, PREFIX_PHONE, PREFIX_EMAIL)
|| !argMultimap.getPreamble().isEmpty()) {
Expand All @@ -43,9 +45,10 @@ public AddCommand parse(String args) throws ParseException {
Phone phone = ParserUtil.parsePhone(argMultimap.getValue(PREFIX_PHONE).get());
Email email = ParserUtil.parseEmail(argMultimap.getValue(PREFIX_EMAIL).get());
Address address = ParserUtil.parseAddress(argMultimap.getValue(PREFIX_ADDRESS).get());
Social social = ParserUtil.parseSocial(argMultimap.getValue(PREFIX_SOCIAL).get());
Set<Tag> tagList = ParserUtil.parseTags(argMultimap.getAllValues(PREFIX_TAG));

Person person = new Person(name, phone, email, address, tagList);
Person person = new Person(name, phone, email, address, social, tagList);

return new AddCommand(person);
}
Expand Down
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 @@ -10,6 +10,8 @@ public class CliSyntax {
public static final Prefix PREFIX_PHONE = new Prefix("p/");
public static final Prefix PREFIX_EMAIL = new Prefix("e/");
public static final Prefix PREFIX_ADDRESS = new Prefix("a/");
public static final Prefix PREFIX_SOCIAL = new Prefix("s/");
public static final Prefix PREFIX_TAG = new Prefix("t/");


}
14 changes: 14 additions & 0 deletions src/main/java/seedu/address/logic/parser/ParserUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import seedu.address.model.person.Email;
import seedu.address.model.person.Name;
import seedu.address.model.person.Phone;
import seedu.address.model.person.Social;
import seedu.address.model.tag.Tag;

/**
Expand Down Expand Up @@ -95,6 +96,17 @@ public static Email parseEmail(String email) throws ParseException {
return new Email(trimmedEmail);
}

/**
* Parses a {@code String social} into a {@code Social}.
* Leading and trailing whitespaces will be trimmed.
*
*/
public static Social parseSocial(String social) throws ParseException {
String trimmedSocial = social.trim();

return new Social(trimmedSocial);
}

/**
* Parses a {@code String tag} into a {@code Tag}.
* Leading and trailing whitespaces will be trimmed.
Expand All @@ -110,6 +122,8 @@ public static Tag parseTag(String tag) throws ParseException {
return new Tag(trimmedTag);
}



/**
* Parses {@code Collection<String> tags} into a {@code Set<Tag>}.
*/
Expand Down
9 changes: 8 additions & 1 deletion src/main/java/seedu/address/model/person/Person.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,19 @@ public class Person {

// Data fields
private final Address address;
private final Social social;
private final Set<Tag> tags = new HashSet<>();

/**
* Every field must be present and not null.
*/
public Person(Name name, Phone phone, Email email, Address address, Set<Tag> tags) {
public Person(Name name, Phone phone, Email email, Address address, Social social, Set<Tag> tags) {
requireAllNonNull(name, phone, email, address, tags);
this.name = name;
this.phone = phone;
this.email = email;
this.address = address;
this.social = social;
this.tags.addAll(tags);
}

Expand All @@ -53,6 +55,10 @@ public Address getAddress() {
return address;
}

public Social getSocial() {
return social;
}

/**
* Returns an immutable tag set, which throws {@code UnsupportedOperationException}
* if modification is attempted.
Expand Down Expand Up @@ -110,6 +116,7 @@ public String toString() {
.add("phone", phone)
.add("email", email)
.add("address", address)
.add("social", social)
.add("tags", tags)
.toString();
}
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/seedu/address/model/person/Social.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package seedu.address.model.person;

public class Social {
public final String value;
public Social(String social) {
this.value = social;
}

@Override
public String toString() {
return value;
}

}
13 changes: 7 additions & 6 deletions src/main/java/seedu/address/model/util/SampleDataUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import seedu.address.model.person.Name;
import seedu.address.model.person.Person;
import seedu.address.model.person.Phone;
import seedu.address.model.person.Social;
import seedu.address.model.tag.Tag;

/**
Expand All @@ -20,22 +21,22 @@ public class SampleDataUtil {
public static Person[] getSamplePersons() {
return new Person[] {
new Person(new Name("Alex Yeoh"), new Phone("87438807"), new Email("alexyeoh@example.com"),
new Address("Blk 30 Geylang Street 29, #06-40"),
new Address("Blk 30 Geylang Street 29, #06-40"), new Social("@alexyeoh"),
getTagSet("friends")),
new Person(new Name("Bernice Yu"), new Phone("99272758"), new Email("berniceyu@example.com"),
new Address("Blk 30 Lorong 3 Serangoon Gardens, #07-18"),
new Address("Blk 30 Lorong 3 Serangoon Gardens, #07-18"), new Social("@berniceyu"),
getTagSet("colleagues", "friends")),
new Person(new Name("Charlotte Oliveiro"), new Phone("93210283"), new Email("charlotte@example.com"),
new Address("Blk 11 Ang Mo Kio Street 74, #11-04"),
new Address("Blk 11 Ang Mo Kio Street 74, #11-04"), new Social("@charlotte"),
getTagSet("neighbours")),
new Person(new Name("David Li"), new Phone("91031282"), new Email("lidavid@example.com"),
new Address("Blk 436 Serangoon Gardens Street 26, #16-43"),
new Address("Blk 436 Serangoon Gardens Street 26, #16-43"), new Social("@lidavid"),
getTagSet("family")),
new Person(new Name("Irfan Ibrahim"), new Phone("92492021"), new Email("irfan@example.com"),
new Address("Blk 47 Tampines Street 20, #17-35"),
new Address("Blk 47 Tampines Street 20, #17-35"), new Social("@irfan"),
getTagSet("classmates")),
new Person(new Name("Roy Balakrishnan"), new Phone("92624417"), new Email("royb@example.com"),
new Address("Blk 45 Aljunied Street 85, #11-31"),
new Address("Blk 45 Aljunied Street 85, #11-31"), new Social("@royb"),
getTagSet("colleagues"))
};
}
Expand Down
9 changes: 7 additions & 2 deletions src/main/java/seedu/address/storage/JsonAdaptedPerson.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import seedu.address.model.person.Name;
import seedu.address.model.person.Person;
import seedu.address.model.person.Phone;
import seedu.address.model.person.Social;
import seedu.address.model.tag.Tag;

/**
Expand All @@ -28,6 +29,7 @@ class JsonAdaptedPerson {
private final String phone;
private final String email;
private final String address;
private final String social;
private final List<JsonAdaptedTag> tags = new ArrayList<>();

/**
Expand All @@ -36,11 +38,12 @@ class JsonAdaptedPerson {
@JsonCreator
public JsonAdaptedPerson(@JsonProperty("name") String name, @JsonProperty("phone") String phone,
@JsonProperty("email") String email, @JsonProperty("address") String address,
@JsonProperty("tags") List<JsonAdaptedTag> tags) {
@JsonProperty("social") String social, @JsonProperty("tags") List<JsonAdaptedTag> tags) {
this.name = name;
this.phone = phone;
this.email = email;
this.address = address;
this.social = social;
if (tags != null) {
this.tags.addAll(tags);
}
Expand All @@ -54,6 +57,7 @@ public JsonAdaptedPerson(Person source) {
phone = source.getPhone().value;
email = source.getEmail().value;
address = source.getAddress().value;
social = source.getSocial().value;
tags.addAll(source.getTags().stream()
.map(JsonAdaptedTag::new)
.collect(Collectors.toList()));
Expand Down Expand Up @@ -101,9 +105,10 @@ public Person toModelType() throws IllegalValueException {
throw new IllegalValueException(Address.MESSAGE_CONSTRAINTS);
}
final Address modelAddress = new Address(address);
final Social modelSocial = new Social(social);

final Set<Tag> modelTags = new HashSet<>(personTags);
return new Person(modelName, modelPhone, modelEmail, modelAddress, modelTags);
return new Person(modelName, modelPhone, modelEmail, modelAddress, modelSocial, modelTags);
}

}
3 changes: 3 additions & 0 deletions src/main/java/seedu/address/ui/PersonCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public class PersonCard extends UiPart<Region> {
@FXML
private Label email;
@FXML
private Label social;
@FXML
private FlowPane tags;

/**
Expand All @@ -52,6 +54,7 @@ public PersonCard(Person person, int displayedIndex) {
phone.setText(person.getPhone().value);
address.setText(person.getAddress().value);
email.setText(person.getEmail().value);
social.setText(person.getSocial().value);
person.getTags().stream()
.sorted(Comparator.comparing(tag -> tag.tagName))
.forEach(tag -> tags.getChildren().add(new Label(tag.tagName)));
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/view/PersonListCard.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<FlowPane fx:id="tags" />
<Label fx:id="phone" styleClass="cell_small_label" text="\$phone" />
<Label fx:id="address" styleClass="cell_small_label" text="\$address" />
<Label fx:id="social" styleClass="cell_small_label" text="\$social" />
<Label fx:id="email" styleClass="cell_small_label" text="\$email" />
</VBox>
</GridPane>
Expand Down