Skip to content

Commit

Permalink
Merge pull request #64 from karenfrilya97/v1.2
Browse files Browse the repository at this point in the history
Edit XmlAdaptedActivityTest
  • Loading branch information
jasmoon authored Mar 21, 2018
2 parents 9903599 + 36cd23c commit 1b11904
Show file tree
Hide file tree
Showing 35 changed files with 513 additions and 1,276 deletions.
15 changes: 15 additions & 0 deletions docs/DeveloperGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,21 @@ We are using `java.util.logging` package for logging. The `LogsCenter` class is

Certain properties of the application can be controlled (e.g App name, logging level) through the configuration file (default: `config.json`).

=== Storage

Our application deals with 2 main classes: Task and Event. Hence, when we store the data, we need to differentiate between these 2 classes. Our team came up with 2 possible implementations to store the data:

* **Alternative 1:** Use 1 list to store objects of both classes
** Pros: There is no need to create 2 separate lists to store the 2 different class objects.
** Cons: Whenever we want to perform an operation on an object stored, we need to check its class.

* **Alternative 2 (current choice):** Use 2 lists to store objects of the 2 classes separately
** Pros: When we want to perform an operation on all the objects stored in a list, each object can be treated equally as they are from the same class.
** Cons: More effort is required to create 2 separate lists.

While both alternatives have advantages and disadvantages, we feel that the second alternative's advantages outweigh its disadvantages in the long run. It is easier to maintain the 2 separate lists of objects, whereby each list contains objects of the same class, especially as we make the 2 classes more specialized. The inconvenience of creating 2 separate lists will be counterbalanced by the convenience in the long run.


== Documentation

We use asciidoc for writing documentation.
Expand Down
Binary file modified docs/images/StorageClassDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions src/main/java/seedu/address/logic/commands/TaskCommand.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package seedu.address.logic.commands;

import static java.util.Objects.requireNonNull;
import static seedu.address.logic.parser.CliSyntax.PREFIX_DATETIME;
import static seedu.address.logic.parser.CliSyntax.PREFIX_DATE_TIME;
import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME;
import static seedu.address.logic.parser.CliSyntax.PREFIX_REMARK;

Expand All @@ -20,11 +20,11 @@ public class TaskCommand extends UndoableCommand {
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a task to the desk board. "
+ "Parameters: "
+ PREFIX_NAME + "NAME "
+ PREFIX_DATETIME + "DATETIME "
+ PREFIX_DATE_TIME + "DATETIME "
+ "[" + PREFIX_REMARK + "REMARK]\n"
+ "Example: " + COMMAND_WORD + " "
+ PREFIX_NAME + "Software Engineering Milestone 1 "
+ PREFIX_DATETIME + "01/08/2018 17:00 "
+ PREFIX_DATE_TIME + "01/08/2018 17:00 "
+ PREFIX_REMARK + "Enhance major component";

public static final String MESSAGE_SUCCESS = "New task added: %1$s";
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/logic/parser/CliSyntax.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class CliSyntax {

/* Prefix definitions */
public static final Prefix PREFIX_NAME = new Prefix("n/");
public static final Prefix PREFIX_DATETIME = new Prefix("d/");
public static final Prefix PREFIX_DATE_TIME = new Prefix("d/");
public static final Prefix PREFIX_REMARK = new Prefix("r/");
public static final Prefix PREFIX_TAG = new Prefix("t/");
public static final Prefix PREFIX_START_DATETIME = new Prefix("s/");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package seedu.address.logic.parser;

import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
import static seedu.address.logic.parser.CliSyntax.PREFIX_DATETIME;
import static seedu.address.logic.parser.CliSyntax.PREFIX_DATE_TIME;
import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME;
import static seedu.address.logic.parser.CliSyntax.PREFIX_REMARK;
import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG;
Expand Down Expand Up @@ -32,16 +32,16 @@ public class TaskCommandParser implements Parser<TaskCommand> {
*/
public TaskCommand parse(String args) throws ParseException {
ArgumentMultimap argMultimap =
ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_DATETIME, PREFIX_REMARK, PREFIX_TAG);
ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_DATE_TIME, PREFIX_REMARK, PREFIX_TAG);

if (!arePrefixesPresent(argMultimap, PREFIX_NAME, PREFIX_DATETIME)
if (!arePrefixesPresent(argMultimap, PREFIX_NAME, PREFIX_DATE_TIME)
|| !argMultimap.getPreamble().isEmpty()) {
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, TaskCommand.MESSAGE_USAGE));
}

try {
Name name = ParserUtil.parseName(argMultimap.getValue(PREFIX_NAME)).get();
DateTime datetime = ParserUtil.parseDateTime(argMultimap.getValue(PREFIX_DATETIME)).get();
DateTime datetime = ParserUtil.parseDateTime(argMultimap.getValue(PREFIX_DATE_TIME)).get();
Remark remark = ParserUtil.parseRemark(argMultimap.getValue(PREFIX_REMARK)).get();
Set<Tag> tagList = ParserUtil.parseTags(argMultimap.getAllValues(PREFIX_TAG));

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/model/activity/Activity.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public int hashCode() {
public String toString() {
final StringBuilder builder = new StringBuilder();
builder.append(getName())
.append(" Date And Time: ")
.append(" Date/Time: ")
.append(getDateTime())
.append(" Remark: ")
.append(getRemark())
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/seedu/address/model/activity/Location.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ public class Location {
*/
public Location(String location) {
requireNonNull(location);
checkArgument(isValidName(location), MESSAGE_LOCATION_CONSTRAINTS);
checkArgument(isValidLocation(location), MESSAGE_LOCATION_CONSTRAINTS);
this.value = location;
}

/**
* Returns true if a given string is a valid activity name.
*/
public static boolean isValidName(String test) {
public static boolean isValidLocation(String test) {
return test.matches(LOCATION_VALIDATION_REGEX);
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/storage/XmlAdaptedEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public Event toModelType() throws IllegalValueException {
throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT,
Location.class.getSimpleName()));
}
if (!Location.isValidName(this.location)) {
if (!Location.isValidLocation(this.location)) {
throw new IllegalValueException(Location.MESSAGE_LOCATION_CONSTRAINTS);
}
final Location location = new Location(this.location);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
public class XmlSerializableDeskBoard {

@XmlElement
private List<XmlAdaptedActivity> persons;
private List<XmlAdaptedActivity> activities;
@XmlElement
private List<XmlAdaptedTag> tags;

Expand All @@ -27,7 +27,7 @@ public class XmlSerializableDeskBoard {
* This empty constructor is required for marshalling.
*/
public XmlSerializableDeskBoard() {
persons = new ArrayList<>();
activities = new ArrayList<>();
tags = new ArrayList<>();
}

Expand All @@ -36,7 +36,7 @@ public XmlSerializableDeskBoard() {
*/
public XmlSerializableDeskBoard(ReadOnlyDeskBoard src) {
this();
persons.addAll(src.getActivityList().stream().map(XmlAdaptedActivity::new).collect(Collectors.toList()));
activities.addAll(src.getActivityList().stream().map(XmlAdaptedActivity::new).collect(Collectors.toList()));
tags.addAll(src.getTagList().stream().map(XmlAdaptedTag::new).collect(Collectors.toList()));
}

Expand All @@ -51,8 +51,8 @@ public DeskBoard toModelType() throws IllegalValueException {
for (XmlAdaptedTag t : tags) {
deskBoard.addTag(t.toModelType());
}
for (XmlAdaptedActivity p : persons) {
deskBoard.addActivity(p.toModelType());
for (XmlAdaptedActivity a : activities) {
deskBoard.addActivity(a.toModelType());
}
return deskBoard;
}
Expand All @@ -68,6 +68,6 @@ public boolean equals(Object other) {
}

XmlSerializableDeskBoard otherAb = (XmlSerializableDeskBoard) other;
return persons.equals(otherAb.persons) && tags.equals(otherAb.tags);
return activities.equals(otherAb.activities) && tags.equals(otherAb.tags);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<addressbook>
<!-- Activity with invalid name field -->
<activities>
<name>Ha!ns Mu@ster</name>
<dateTime isPrivate="false">9482424</dateTime>
<remark isPrivate="false">4th street</remark>
<name>Ellen's B'day</name>
<dateTime>10/10/2010 10:10</dateTime>
<remark> </remark>
</activities>
</addressbook>

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addressbook>
<!-- Activity with invalid dateTime field -->
<activities>
<name>CS1231!</name>
<dateTime>9482424</dateTime>
<remark> </remark>
</activities>
</addressbook>
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!-- DeskBoard save file which contains the same Activity values as in
{@code TypicalActivities#getTypicalDeskBoard()}-->
<addressbook>
<activities>
<name>CS2101Assignment</name>
<dateTime>04/03/2018 23:59</dateTime>
<remark> </remark>
<tagged>CS2101</tagged>
</activities>
<activities>
<name>CS2102Assignment</name>
<dateTime>15/03/2018 23:59</dateTime>
<remark> </remark>
<tagged>CS2102</tagged>
</activities>
<activities>
<name>CS2101Quiz</name>
<dateTime>19/03/2018 23:59</dateTime>
<remark>IVLE Quiz</remark>
</activities>
<activities>
<name>CCA</name>
<dateTime>01/04/2018 20:00</dateTime>
<endDateTime>01/04/2018 21:00</endDateTime>
<location>Campus</location>
<remark>nil</remark>
</activities>
<activities>
<name>CIP</name>
<dateTime>02/04/2018 08:00</dateTime>
<endDateTime>02/04/2018 12:00</endDateTime>
<location>michegan ave</location>
<remark></remark>
<tagged>CIP</tagged>
</activities>
<activities>
<name>CS2101Exam</name>
<dateTime>28/04/2018 09:00</dateTime>
<endDateTime>28/04/2018 11:00</endDateTime>
<location>MPSH</location>
<remark></remark>
<tagged>CS2101</tagged>
</activities>
<activities>
<name>InterFacultyGame</name>
<dateTime>04/01/2018 20:00</dateTime>
<endDateTime>04/01/2018 22:00</endDateTime>
<location>MPSH 1</location>
<remark></remark>
</activities>
<tags>CS2101</tags>
<tags>CS2102</tags>
<tags>MA2108</tags>
<tags>CS2010</tags>
<tags>CIP</tags>
</addressbook>
4 changes: 2 additions & 2 deletions src/test/data/XmlUtilTest/tempAddressBook.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addressbook>
<deskboard>
<activities>
<id>1</id>
<firstName>John</firstName>
Expand All @@ -12,4 +12,4 @@
<tags>
<name>Friends</name>
</tags>
</addressbook>
</deskboard>
File renamed without changes.
Loading

0 comments on commit 1b11904

Please sign in to comment.