Skip to content

Commit

Permalink
Fix merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
itsme-zeix committed Oct 23, 2024
2 parents b1ec5f1 + d482979 commit 7dbe194
Show file tree
Hide file tree
Showing 28 changed files with 439 additions and 102 deletions.
8 changes: 5 additions & 3 deletions docs/diagrams/ModelClassDiagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ skinparam arrowThickness 1.1
skinparam arrowColor MODEL_COLOR
skinparam classBackgroundColor MODEL_COLOR

Package Model as ModelPackage <<Rectangle>>{
Class "<<interface>>\nReadOnlyAddressBook" as ReadOnlyAddressBook
Class "<<interface>>\nReadOnlyUserPrefs" as ReadOnlyUserPrefs
Class "<<interface>>\nModel" as Model
Expand All @@ -20,10 +19,9 @@ Class Name
Class Phone
Class Tier
Class Remark
Class Status

Class I #FFFFFF
}

Class HiddenOutside #FFFFFF
HiddenOutside ..> Model

Expand All @@ -44,13 +42,17 @@ Person *--> Email
Person *--> Address
Person *--> "0..1" Remark
Person *--> "0..1" Tier
Person *--> "1" Status

Person -[hidden]up--> I
UniquePersonList -[hidden]right-> I

Name -[hidden]right-> Phone
Phone -[hidden]right-> Address
Address -[hidden]right-> Email
Email -[hidden]right-> Tier
Tier -[hidden]right-> Remark
Remark -[hidden]right-> Status

ModelManager --> "~* filtered" Person
@enduml
Binary file modified docs/images/ModelClassDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 5 additions & 2 deletions src/main/java/seedu/address/logic/Messages.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package seedu.address.logic;

import java.util.LinkedHashSet;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
Expand Down Expand Up @@ -31,7 +32,7 @@ public static String getErrorMessageForDuplicatePrefixes(Prefix... duplicatePref
assert duplicatePrefixes.length > 0;

Set<String> duplicateFields =
Stream.of(duplicatePrefixes).map(Prefix::toString).collect(Collectors.toSet());
Stream.of(duplicatePrefixes).map(Prefix::toString).collect(Collectors.toCollection(LinkedHashSet::new));

return MESSAGE_DUPLICATE_FIELDS + String.join(" ", duplicateFields);
}
Expand All @@ -55,7 +56,9 @@ public static String format(Person person) {
.append("; Tier: ")
.append(person.getTier())
.append("; Remark: ")
.append(person.getRemark());
.append(person.getRemark())
.append("; Status: ")
.append(person.getStatus());
return builder.toString();
}

Expand Down
7 changes: 5 additions & 2 deletions src/main/java/seedu/address/logic/commands/AddCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME;
import static seedu.address.logic.parser.CliSyntax.PREFIX_NEW_REMARK;
import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_STATUS;
import static seedu.address.logic.parser.CliSyntax.PREFIX_TIER;

import seedu.address.commons.util.ToStringBuilder;
Expand All @@ -32,7 +33,8 @@ public class AddCommand extends Command {
+ PREFIX_JOB + "JOB "
+ PREFIX_INCOME + "INCOME "
+ "[" + PREFIX_TIER + "TIER]...\n"
+ "[" + PREFIX_NEW_REMARK + "NEW REMARK]...\n"
+ "[" + PREFIX_NEW_REMARK + "NEW REMARK]..."
+ "[" + PREFIX_STATUS + "STATUS]...\n"
+ "Example: " + COMMAND_WORD + " "
+ PREFIX_NAME + "John Doe "
+ PREFIX_PHONE + "98765432 "
Expand All @@ -41,7 +43,8 @@ public class AddCommand extends Command {
+ PREFIX_JOB + "doctor "
+ PREFIX_INCOME + "300 "
+ PREFIX_TIER + "GOLD "
+ PREFIX_NEW_REMARK + "He is very smart ";
+ PREFIX_NEW_REMARK + "He is very smart "
+ PREFIX_STATUS + "NON_URGENT";

public static final String MESSAGE_SUCCESS = "New person added: %1$s";
public static final String MESSAGE_DUPLICATE_PERSON = "This person already exists in the address book";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
public final class CommandCommons {
public static final String DEFAULT_TIER = "";
public static final String DEFAULT_REMARK = "NA";
public static final String DEFAULT_STATUS = "NONE";
public static final Person EMPTY_PERSON = null;

}
30 changes: 23 additions & 7 deletions src/main/java/seedu/address/logic/commands/EditCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME;
import static seedu.address.logic.parser.CliSyntax.PREFIX_NEW_REMARK;
import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_STATUS;
import static seedu.address.logic.parser.CliSyntax.PREFIX_TIER;
import static seedu.address.model.Model.PREDICATE_SHOW_ALL_PERSONS;

Expand All @@ -30,6 +31,7 @@
import seedu.address.model.person.Person;
import seedu.address.model.person.Phone;
import seedu.address.model.person.Remark;
import seedu.address.model.status.Status;
import seedu.address.model.tier.Tier;

/**
Expand All @@ -52,6 +54,7 @@ public class EditCommand extends Command {
+ "[" + PREFIX_TIER + "TIER]...\n"
+ "[" + PREFIX_NEW_REMARK + "NEW REMARK] "
+ "[" + PREFIX_APPEND_REMARK + "ADD-ON TO EXISTING REMARK] "
+ "[" + PREFIX_STATUS + "STATUS] "
+ "Example: " + COMMAND_WORD + " 1 "
+ PREFIX_PHONE + "91234567 "
+ PREFIX_EMAIL + "[email protected]";
Expand Down Expand Up @@ -109,16 +112,17 @@ private static Person createEditedPerson(Person personToEdit, EditPersonDescript
Address updatedAddress = editPersonDescriptor.getAddress().orElse(personToEdit.getAddress());
Job updatedJob = editPersonDescriptor.getJob().orElse(personToEdit.getJob());
Income updatedIncome = editPersonDescriptor.getIncome().orElse(personToEdit.getIncome());
Tier updatedTier = editPersonDescriptor.getTiers().orElse(personToEdit.getTier());
Tier updatedTier = editPersonDescriptor.getTier().orElse(personToEdit.getTier());
Remark updatedRemark;
if (editPersonDescriptor.getAppendedRemark().isPresent()) {
updatedRemark = Remark.combineRemarks(personToEdit.getRemark(),
editPersonDescriptor.getAppendedRemark().get());
} else {
updatedRemark = editPersonDescriptor.getNewRemark().orElse(personToEdit.getRemark());
}
Status updatedStatus = editPersonDescriptor.getStatus().orElse(personToEdit.getStatus());
return new Person(updatedName, updatedPhone, updatedEmail, updatedAddress, updatedJob, updatedIncome,
updatedTier, updatedRemark);
updatedTier, updatedRemark, updatedStatus);
}

@Override
Expand Down Expand Up @@ -159,6 +163,7 @@ public static class EditPersonDescriptor {
private Tier tier;
private Remark remark;
private Remark appendedRemark;
private Status status;
public EditPersonDescriptor() {}

/**
Expand All @@ -175,13 +180,15 @@ public EditPersonDescriptor(EditPersonDescriptor toCopy) {
setTier(toCopy.tier);
setNewRemark(toCopy.remark);
setAppendedRemark(toCopy.appendedRemark);
setStatus(toCopy.status);
}

/**
* Returns true if at least one field is edited.
*/
public boolean isAnyFieldEdited() {
return CollectionUtil.isAnyNonNull(name, phone, email, address, job, income, tier, remark, appendedRemark);
return CollectionUtil.isAnyNonNull(name, phone, email, address, job, income, tier, remark, appendedRemark,
status);
}

public void setName(Name name) {
Expand Down Expand Up @@ -235,16 +242,16 @@ public Optional<Income> getIncome() {
* Sets {@code tags} to this object's {@code tags}.
* A defensive copy of {@code tags} is used internally.
*/
public void setTier(Tier tiers) {
this.tier = tiers;
public void setTier(Tier tier) {
this.tier = tier;
}

/**
* Returns an unmodifiable tier, which throws {@code UnsupportedOperationException}
* if modification is attempted.
* Returns {@code Optional#empty()} if {@code tags} is null.
*/
public Optional<Tier> getTiers() {
public Optional<Tier> getTier() {
return (tier != null) ? Optional.of(tier) : Optional.empty();
}

Expand All @@ -263,6 +270,13 @@ public void setAppendedRemark(Remark remark) {
public Optional<Remark> getAppendedRemark() {
return Optional.ofNullable(appendedRemark);
}
public void setStatus(Status status) {
this.status = status;
}

public Optional<Status> getStatus() {
return Optional.ofNullable(this.status);
}

@Override
public boolean equals(Object other) {
Expand All @@ -284,7 +298,8 @@ public boolean equals(Object other) {
&& Objects.equals(income, otherEditPersonDescriptor.income)
&& Objects.equals(tier, otherEditPersonDescriptor.tier)
&& Objects.equals(remark, otherEditPersonDescriptor.remark)
&& Objects.equals(appendedRemark, otherEditPersonDescriptor.appendedRemark);
&& Objects.equals(appendedRemark, otherEditPersonDescriptor.appendedRemark)
&& Objects.equals(status, otherEditPersonDescriptor.status);
}

@Override
Expand All @@ -298,6 +313,7 @@ public String toString() {
.add("income", income)
.add("tier", tier)
.add("remark", remark)
.add("status", status)
.toString();
}
}
Expand Down
12 changes: 8 additions & 4 deletions src/main/java/seedu/address/logic/parser/AddCommandParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME;
import static seedu.address.logic.parser.CliSyntax.PREFIX_NEW_REMARK;
import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_STATUS;
import static seedu.address.logic.parser.CliSyntax.PREFIX_TIER;

import java.util.stream.Stream;
Expand All @@ -23,6 +24,7 @@
import seedu.address.model.person.Person;
import seedu.address.model.person.Phone;
import seedu.address.model.person.Remark;
import seedu.address.model.status.Status;
import seedu.address.model.tier.Tier;

/**
Expand All @@ -39,7 +41,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_JOB,
PREFIX_INCOME, PREFIX_TIER, PREFIX_NEW_REMARK);
PREFIX_INCOME, PREFIX_TIER, PREFIX_NEW_REMARK, PREFIX_STATUS);

if (!arePrefixesPresent(argMultimap, PREFIX_NAME, PREFIX_ADDRESS, PREFIX_JOB, PREFIX_PHONE, PREFIX_EMAIL,
PREFIX_INCOME)
Expand All @@ -48,17 +50,19 @@ public AddCommand parse(String args) throws ParseException {
}

argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS, PREFIX_JOB,
PREFIX_INCOME, PREFIX_TIER, PREFIX_NEW_REMARK);
PREFIX_INCOME, PREFIX_TIER, PREFIX_NEW_REMARK, PREFIX_STATUS);
Name name = ParserUtil.parseName(argMultimap.getValue(PREFIX_NAME).get());
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());
Job job = ParserUtil.parseJob(argMultimap.getValue(PREFIX_JOB).get());
Income income = ParserUtil.parseIncome(argMultimap.getValue(PREFIX_INCOME).get());
Tier tier = ParserUtil.parseTier(argMultimap.getValue(PREFIX_TIER).orElse(""));
Tier tier = ParserUtil.parseTier(argMultimap.getValue(PREFIX_TIER).orElse(CommandCommons.DEFAULT_TIER));
Remark remark = ParserUtil.parseNewRemark(argMultimap.getValue(PREFIX_NEW_REMARK)
.orElse(CommandCommons.DEFAULT_REMARK));
Person person = new Person(name, phone, email, address, job, income, tier, remark);
Status status =
ParserUtil.parseStatus(argMultimap.getValue(PREFIX_STATUS).orElse(CommandCommons.DEFAULT_STATUS));
Person person = new Person(name, phone, email, address, job, income, tier, remark, status);
return new AddCommand(person);
}

Expand Down
1 change: 1 addition & 0 deletions src/main/java/seedu/address/logic/parser/CliSyntax.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ public class CliSyntax {
public static final Prefix PREFIX_REMARK = new Prefix("r/");
public static final Prefix PREFIX_NEW_REMARK = new Prefix("rn/");
public static final Prefix PREFIX_APPEND_REMARK = new Prefix("ra/");
public static final Prefix PREFIX_STATUS = new Prefix("s/");

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME;
import static seedu.address.logic.parser.CliSyntax.PREFIX_NEW_REMARK;
import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_STATUS;
import static seedu.address.logic.parser.CliSyntax.PREFIX_TIER;

import seedu.address.commons.core.index.Index;
Expand All @@ -32,7 +33,7 @@ public EditCommand parse(String args) throws ParseException {
requireNonNull(args);
ArgumentMultimap argMultimap =
ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS,
PREFIX_INCOME, PREFIX_JOB, PREFIX_TIER, PREFIX_NEW_REMARK, PREFIX_APPEND_REMARK);
PREFIX_INCOME, PREFIX_JOB, PREFIX_TIER, PREFIX_NEW_REMARK, PREFIX_APPEND_REMARK, PREFIX_STATUS);

Index index;

Expand All @@ -49,7 +50,7 @@ public EditCommand parse(String args) throws ParseException {
}

argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS,
PREFIX_INCOME, PREFIX_JOB, PREFIX_TIER, PREFIX_NEW_REMARK, PREFIX_APPEND_REMARK);
PREFIX_INCOME, PREFIX_JOB, PREFIX_TIER, PREFIX_NEW_REMARK, PREFIX_APPEND_REMARK, PREFIX_STATUS);

EditPersonDescriptor editPersonDescriptor = new EditPersonDescriptor();

Expand Down Expand Up @@ -81,6 +82,10 @@ public EditCommand parse(String args) throws ParseException {
editPersonDescriptor.setAppendedRemark(ParserUtil.parseNewRemark(
argMultimap.getValue(PREFIX_APPEND_REMARK).get()));
}
if (argMultimap.getValue(PREFIX_STATUS).isPresent()) {
editPersonDescriptor.setStatus((ParserUtil.parseStatus(
argMultimap.getValue(PREFIX_STATUS).get())));
}

if (!editPersonDescriptor.isAnyFieldEdited()) {
throw new ParseException(EditCommand.MESSAGE_NOT_EDITED);
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/seedu/address/logic/parser/ParserUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import seedu.address.model.person.Name;
import seedu.address.model.person.Phone;
import seedu.address.model.person.Remark;
import seedu.address.model.status.Status;
import seedu.address.model.tier.Tier;
import seedu.address.model.util.IncomeComparisonOperator;

Expand Down Expand Up @@ -174,6 +175,21 @@ public static Tier parseTier(String tier) throws ParseException {
return new Tier(trimmedTier);
}

/**
* Parses a {@code String status} into a {@code Status}.
* Leading and trailing whitespaces are trimmed.
*
* @throws ParseException if the given {@code status} is invalid.
*/
public static Status parseStatus(String status) throws ParseException {
requireNonNull(status);
String trimmedStatus = status.trim();
if (!Status.isValidStatus(trimmedStatus)) {
throw new ParseException(Status.MESSAGE_CONSTRAINTS);
}
return new Status(trimmedStatus);
}

/**
* Parses a {@code String operator} into a {@code IncomeComparisonOperator}.
* Leading and trailing whitespaces will be trimmed.
Expand Down
Loading

0 comments on commit 7dbe194

Please sign in to comment.