Skip to content

Commit

Permalink
Fix tags parser in edit command parser
Browse files Browse the repository at this point in the history
  • Loading branch information
SHni99 committed Mar 25, 2023
1 parent df3c5c0 commit 549ebd7
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public List<String> getAllValues(Prefix prefix) {
if (!argMultimap.containsKey(prefix)) {
return new ArrayList<>();
}
System.out.println(argMultimap.get(prefix));
return new ArrayList<>(argMultimap.get(prefix));
}

Expand Down
12 changes: 10 additions & 2 deletions src/main/java/seedu/address/logic/parser/EditCommandParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import static java.util.Objects.requireNonNull;
import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS;
import static seedu.address.logic.parser.CliSyntax.PREFIX_COMMITMENT_TAG;
import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL;
import static seedu.address.logic.parser.CliSyntax.PREFIX_MODULE_TAG;
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_STATUS;
Expand All @@ -13,6 +15,8 @@
import java.util.Collections;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import seedu.address.commons.core.index.Index;
import seedu.address.logic.commands.EditCommand;
Expand All @@ -35,7 +39,7 @@ public EditCommand parse(String args) throws ParseException {
requireNonNull(args);
ArgumentMultimap argMultimap =
ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_STATUS, PREFIX_PHONE, PREFIX_EMAIL,
PREFIX_ADDRESS, PREFIX_TAG);
PREFIX_ADDRESS, PREFIX_TAG, PREFIX_COMMITMENT_TAG, PREFIX_MODULE_TAG);

Index index;

Expand All @@ -61,7 +65,11 @@ public EditCommand parse(String args) throws ParseException {
if (argMultimap.getValue(PREFIX_ADDRESS).isPresent()) {
editPersonDescriptor.setAddress(ParserUtil.parseAddress(argMultimap.getValue(PREFIX_ADDRESS).get()));
}
parseTagsForEdit(argMultimap.getAllValues(PREFIX_TAG)).ifPresent(editPersonDescriptor::setTags);
Collection<String> allTags = Stream.of(argMultimap.getAllValues(PREFIX_TAG),
argMultimap.getAllValues(PREFIX_MODULE_TAG), argMultimap.getAllValues(PREFIX_COMMITMENT_TAG))
.flatMap(Collection::stream)
.collect(Collectors.toList());
parseTagsForEdit(allTags).ifPresent(editPersonDescriptor::setTags);

if (!editPersonDescriptor.isAnyFieldEdited()) {
throw new ParseException(EditCommand.MESSAGE_NOT_EDITED);
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/seedu/address/model/tag/Tag.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
*/
public class Tag {

public static final String MESSAGE_CONSTRAINTS = "Tags names should be alphanumeric";
public static final String MESSAGE_CONSTRAINTS = "Tags names should be alphanumeric, do not include"
+ " characters like @,#,*,- or white space between words";
public static final String VALIDATION_REGEX = "\\p{Alnum}+";

public final String tagName;
Expand Down
1 change: 0 additions & 1 deletion src/main/java/seedu/address/ui/PersonalPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Region;
import javafx.scene.text.TextAlignment;
import seedu.address.model.person.Person;
import seedu.address.model.tag.Tag;
import seedu.address.model.util.ImageUtil;
Expand Down

0 comments on commit 549ebd7

Please sign in to comment.