Skip to content

Commit

Permalink
Bug fix json not reading outlet correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
H4mes committed Mar 28, 2024
1 parent 9248296 commit 0838441
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ public class AddArticleCommandParser implements Parser<AddArticleCommand> {
*/
public AddArticleCommand parse(String args) throws ParseException {
ArgumentMultimap argMultimap =
ArgumentTokenizer.tokenize(args, PREFIX_TITLE, PREFIX_AUTHOR, PREFIX_SOURCE, PREFIX_OUTLET,
PREFIX_PUBLICATION_DATE, PREFIX_ARTICLETAG, PREFIX_STATUS);
//Temporarily reinstate source requirement
ArgumentTokenizer.tokenize(args, PREFIX_TITLE, PREFIX_AUTHOR, PREFIX_SOURCE, PREFIX_ARTICLETAG,
PREFIX_OUTLET, PREFIX_PUBLICATION_DATE, PREFIX_STATUS);
//TODO: REMOVE PUBLICATION DATE REQUIREMENT
if (!arePrefixesPresent(argMultimap, PREFIX_TITLE, PREFIX_PUBLICATION_DATE, PREFIX_STATUS)
|| !argMultimap.getPreamble().isEmpty()) {
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddArticleCommand.MESSAGE_USAGE));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
import static seedu.address.logic.parser.CliSyntax.PREFIX_ARTICLETAG;
import static seedu.address.logic.parser.CliSyntax.PREFIX_AUTHOR;
import static seedu.address.logic.parser.CliSyntax.PREFIX_OUTLET;
import static seedu.address.logic.parser.CliSyntax.PREFIX_PUBLICATION_DATE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_SOURCE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_STATUS;
Expand Down Expand Up @@ -36,8 +37,8 @@ public class EditArticleCommandParser {
public EditArticleCommand parse(String args) throws ParseException {
requireNonNull(args);
ArgumentMultimap argMultimap =
ArgumentTokenizer.tokenize(args, PREFIX_TITLE, PREFIX_AUTHOR, PREFIX_PUBLICATION_DATE, PREFIX_SOURCE,
PREFIX_ARTICLETAG, PREFIX_STATUS);
ArgumentTokenizer.tokenize(args, PREFIX_TITLE, PREFIX_AUTHOR, PREFIX_SOURCE,
PREFIX_ARTICLETAG, PREFIX_OUTLET, PREFIX_PUBLICATION_DATE, PREFIX_STATUS);

Index index;

Expand All @@ -63,6 +64,9 @@ public EditArticleCommand parse(String args) throws ParseException {
editArticleDescriptor.setStatus((Article.Status) ParserUtil.parseStatus(argMultimap.getValue(PREFIX_STATUS)
.get()));
}
if (argMultimap.getValue(PREFIX_OUTLET).isPresent()) {
editArticleDescriptor.setOutlet(ParserUtil.parseOutlet(argMultimap.getValue(PREFIX_OUTLET).get()));
}

parseAuthorsForEdit(argMultimap.getAllValues(PREFIX_AUTHOR)).ifPresent(editArticleDescriptor::setAuthors);
parseSourcesForEdit(argMultimap.getAllValues(PREFIX_SOURCE)).ifPresent(editArticleDescriptor::setSources);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/seedu/address/storage/JsonAdaptedArticle.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public JsonAdaptedArticle(@JsonProperty("title") String title,
@JsonProperty("authors") List<JsonAdaptedAuthor> authors,
@JsonProperty("sources") List<JsonAdaptedSource> sources,
@JsonProperty("tags") List<JsonAdaptedTag> tags,
@JsonProperty("outlet") Outlet outlet,
@JsonProperty("outlet") String outlet,
@JsonProperty("publicationDate") LocalDateTime publicationDate,
@JsonProperty("status") Article.Status status) {
this.title = title;
Expand All @@ -59,7 +59,7 @@ public JsonAdaptedArticle(@JsonProperty("title") String title,
if (tags != null) {
this.tags.addAll(tags);
}
this.outlet = outlet.outletName;
this.outlet = outlet;
this.publicationDate = publicationDate;
this.status = status;
}
Expand Down

0 comments on commit 0838441

Please sign in to comment.