Skip to content

Commit

Permalink
Merge pull request #191 from Amoscheong97/Branch_InsertFeature
Browse files Browse the repository at this point in the history
Edit insert feature
  • Loading branch information
Cherweijie authored Mar 19, 2020
2 parents 34cae27 + 47c8ec6 commit c43e91c
Show file tree
Hide file tree
Showing 24 changed files with 100 additions and 106 deletions.
3 changes: 2 additions & 1 deletion docs/DeveloperGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ The `Model`,
* does not depend on any of the other three components.

[NOTE]
Better Model Class Diagram
An Order class consists of nine different fields as shown in the image. Every order is part of a UniqueOrderList and
every UniqueOrderList is part of an OrderBook.
image:BetterModelClassDiagram.png[]

[[Design-Storage]]
Expand Down
4 changes: 1 addition & 3 deletions docs/diagrams/BetterModelClassDiagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ skinparam arrowThickness 1.1
skinparam arrowColor MODEL_COLOR
skinparam classBackgroundColor MODEL_COLOR

AddressBook *-right-> "1" UniqueOrderList
OrderBook *-right-> "1" UniqueOrderList

UniqueOrderList o-right-> Order

Order o-up-> "*" Tag

Order *--> TransactionId
Order *--> Name
Order *--> Phone
Expand Down
13 changes: 6 additions & 7 deletions docs/diagrams/StorageClassDiagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,18 @@ skinparam classBackgroundColor STORAGE_COLOR

Interface Storage <<Interface>>
Interface UserPrefsStorage <<Interface>>
Interface AddressBookStorage <<Interface>>
Interface OrderBookStorage <<Interface>>

Class StorageManager
Class JsonUserPrefsStorage
Class JsonAddressBookStorage
Class JsonOrderBookStorage

StorageManager .left.|> Storage
StorageManager o-right-> UserPrefsStorage
StorageManager o--> AddressBookStorage
StorageManager o--> OrderBookStorage

JsonUserPrefsStorage .left.|> UserPrefsStorage
JsonAddressBookStorage .left.|> AddressBookStorage
JsonAddressBookStorage .down.> JsonSerializableAddressBookStorage
JsonSerializableAddressBookStorage .right.> JsonSerializablePerson
JsonSerializablePerson .right.> JsonAdaptedTag
JsonAddressBookStorage .left.|> OrderBookStorage
JsonAddressBookStorage .down.> JsonSerializableOrderBookStorage
JsonSerializableOrderBookStorage .right.> JsonSerializablePerson
@enduml
Binary file modified docs/images/BetterModelClassDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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.
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.
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/logic/Logic.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public interface Logic {
*/
ReadOnlyOrderBook getOrderBook();

/** Returns an unmodifiable view of the filtered list of persons */
/** Returns an unmodifiable view of the filtered list of orders */
ObservableList<Order> getFilteredOrderList();

/**
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/seedu/address/logic/commands/DeleteCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
import seedu.address.model.order.Order;

/**
* Deletes a person identified using it's displayed index from the address book.
* Deletes an order identified using it's displayed index from the address book.
*/
public class DeleteCommand extends Command {

public static final String COMMAND_WORD = "delete";

public static final String MESSAGE_USAGE = COMMAND_WORD
+ ": Deletes the person identified by the index number used in the displayed person list.\n"
+ ": Deletes the order identified by the index number used in the displayed order list.\n"
+ "Parameters: INDEX (must be a positive integer)\n"
+ "Example: " + COMMAND_WORD + " 1";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,41 +18,41 @@
/**
* Adds a order to the order book.
*/
public class AddCommand extends Command {
public class InsertCommand extends Command {

public static final String COMMAND_WORD = "add";
public static final String COMMAND_WORD = "insert";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds an order to the order book. "
+ "Parameters: "
+ PREFIX_TID + "TRANSACTION_ID"
+ PREFIX_TID + "TRANSACTION_ID "
+ PREFIX_NAME + "NAME "
+ PREFIX_PHONE + "PHONE "
+ PREFIX_ADDRESS + "ADDRESS "
+ PREFIX_DELIVERY_TIMESTAMP + "Delivery_DATE_&_TIME "
+ PREFIX_WAREHOUSE + "WAREHOUSE_LOCATION "
+ PREFIX_COD + "CASH_ON_DELIVERY"
+ PREFIX_WAREHOUSE + "WAREHOUSE_LOCATION " + "\n"
+ PREFIX_COD + "CASH_ON_DELIVERY "
+ "[" + PREFIX_COMMENT + "COMMENT] "
+ "[" + PREFIX_TYPE + "TYPE_OF_ITEM] "
+ "[" + PREFIX_TYPE + "TYPE_OF_ITEM] " + "\n"
+ "Example: " + COMMAND_WORD + " "
+ PREFIX_TID + "A999999 "
+ PREFIX_NAME + "John Doe "
+ PREFIX_PHONE + "98765432 "
+ PREFIX_ADDRESS + "311, Clementi Ave 2, #02-25 "
+ PREFIX_DELIVERY_TIMESTAMP + "2019-12-02 1500 "
+ PREFIX_WAREHOUSE + "5 Toh Guan Rd E, #02-30 S608831 "
+ PREFIX_COD + "$2"
+ PREFIX_COD + "$2 "
+ PREFIX_COMMENT + "NIL "
+ PREFIX_TYPE + "glass";
+ PREFIX_TYPE + "glass ";

public static final String MESSAGE_SUCCESS = "New order added: %1$s";
public static final String MESSAGE_DUPLICATE_ORDER = "This order already exists in the order book";

private final Order toAdd;

/**
* Creates an AddCommand to add the specified {@code Order}
* Creates an InsertCommand to add the specified {@code Order}
*/
public AddCommand(Order order) {
public InsertCommand(Order order) {
requireNonNull(order);
toAdd = order;
}
Expand All @@ -72,7 +72,7 @@ public CommandResult execute(Model model) throws CommandException {
@Override
public boolean equals(Object other) {
return other == this // short circuit if same object
|| (other instanceof AddCommand // instanceof handles nulls
&& toAdd.equals(((AddCommand) other).toAdd));
|| (other instanceof InsertCommand // instanceof handles nulls
&& toAdd.equals(((InsertCommand) other).toAdd));
}
}
16 changes: 8 additions & 8 deletions src/main/java/seedu/address/logic/parser/AddCommandParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import java.util.stream.Stream;

import seedu.address.logic.commands.AddCommand;
import seedu.address.logic.commands.InsertCommand;
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.comment.Comment;
import seedu.address.model.itemtype.TypeOfItem;
Expand All @@ -27,17 +27,17 @@
import seedu.address.model.order.Warehouse;

/**
* Parses input arguments and creates a new AddCommand object
* Parses input arguments and creates a new InsertCommand object
*/
public class AddCommandParser implements Parser<AddCommand> {
public class AddCommandParser implements Parser<InsertCommand> {

/**
* Parses the given {@code String} of arguments in the context of the AddCommand
* and returns an AddCommand object for execution.
* Parses the given {@code String} of arguments in the context of the InsertCommand
* and returns an InsertCommand object for execution.
*
* @throws ParseException if the user input does not conform the expected format
*/
public AddCommand parse(String args) throws ParseException {
public InsertCommand parse(String args) throws ParseException {
ArgumentMultimap argMultimap =
ArgumentTokenizer.tokenize(args, PREFIX_TID, PREFIX_NAME, PREFIX_PHONE, PREFIX_ADDRESS,
PREFIX_DELIVERY_TIMESTAMP, PREFIX_WAREHOUSE, PREFIX_COD, PREFIX_TYPE,
Expand All @@ -46,7 +46,7 @@ public AddCommand parse(String args) throws ParseException {
PREFIX_DELIVERY_TIMESTAMP, PREFIX_WAREHOUSE,
PREFIX_PHONE, PREFIX_COD)
|| !argMultimap.getPreamble().isEmpty()) {
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE));
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, InsertCommand.MESSAGE_USAGE));
}

TransactionId tid = ParserUtil.parseTid(argMultimap.getValue(PREFIX_TID).get());
Expand All @@ -65,7 +65,7 @@ public AddCommand parse(String args) throws ParseException {

Order order = new Order(tid, name, phone, address, timeStamp, warehouse, cash, comment, type);

return new AddCommand(order);
return new InsertCommand(order);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/seedu/address/logic/parser/OrderBookParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import seedu.address.logic.commands.AddCommand;
import seedu.address.logic.commands.ClearCommand;
import seedu.address.logic.commands.Command;
import seedu.address.logic.commands.DeleteCommand;
import seedu.address.logic.commands.EditCommand;
import seedu.address.logic.commands.ExitCommand;
import seedu.address.logic.commands.HelpCommand;
import seedu.address.logic.commands.InsertCommand;
import seedu.address.logic.commands.ListCommand;
import seedu.address.logic.commands.NearbyCommand;
import seedu.address.logic.commands.SearchCommand;
Expand Down Expand Up @@ -46,7 +46,7 @@ public Command parseCommand(String userInput) throws ParseException {
final String arguments = matcher.group("arguments");

switch (commandWord) {
case AddCommand.COMMAND_WORD:
case InsertCommand.COMMAND_WORD:
return new AddCommandParser().parse(arguments);

case EditCommand.COMMAND_WORD:
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/logic/parser/ParserUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public static Comment parseComment(String comment) throws ParseException {
public static TypeOfItem parseItemType(String itemType) throws ParseException {
requireNonNull(itemType);
String itemTypeTrimmed = itemType.trim();
if (!TypeOfItem.isValidItemName(itemTypeTrimmed)) {
if (!TypeOfItem.isValidItemType(itemTypeTrimmed)) {
throw new ParseException(TypeOfItem.MESSAGE_CONSTRAINTS);
}

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/seedu/address/model/itemtype/TypeOfItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

/**
* Represents the type of item in the order book.
* Guarantees: immutable; item is valid as declared in {@link #isValidItemName(String)}}
* Guarantees: immutable; item is valid as declared in {@link #isValidItemType(String)}}
*/

public class TypeOfItem {
Expand All @@ -29,14 +29,14 @@ public class TypeOfItem {
*/
public TypeOfItem(String itemType) {
requireNonNull(itemType);
checkArgument(isValidItemName(itemType), MESSAGE_CONSTRAINTS);
checkArgument(isValidItemType(itemType), MESSAGE_CONSTRAINTS);
this.itemType = itemType;
}

/**
* Returns true if a given string is a valid Item.
*/
public static boolean isValidItemName(String test) {
public static boolean isValidItemType(String test) {
return test.matches(VALIDATION_REGEX);
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/storage/JsonAdaptedOrder.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public Order toModelType() throws IllegalValueException {
if (itemType == null) {
modelItem = new TypeOfItem("NIL");
} else {
if (!TypeOfItem.isValidItemName(itemType)) {
if (!TypeOfItem.isValidItemType(itemType)) {
throw new IllegalValueException(TypeOfItem.MESSAGE_CONSTRAINTS);
}
modelItem = new TypeOfItem(itemType);
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/view/DarkTheme.css
Original file line number Diff line number Diff line change
Expand Up @@ -348,12 +348,12 @@
-fx-background-radius: 0;
}

#tags {
#itemType {
-fx-hgap: 7;
-fx-vgap: 3;
}

#tags .label {
#itemType .label {
-fx-text-fill: white;
-fx-background-color: #3e7b91;
-fx-padding: 1 3 1 3;
Expand Down
19 changes: 7 additions & 12 deletions src/main/resources/view/OrderListCard.fxml
Original file line number Diff line number Diff line change
@@ -1,31 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.FlowPane?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.Region?>
<?import javafx.scene.layout.VBox?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<HBox id="cardPane" fx:id="cardPane" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
<HBox id="cardPane" fx:id="cardPane" xmlns="http://javafx.com/javafx/10.0.2-internal" xmlns:fx="http://javafx.com/fxml/1">
<GridPane HBox.hgrow="ALWAYS">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10" prefWidth="150" />
</columnConstraints>
<VBox alignment="CENTER_LEFT" minHeight="105" GridPane.columnIndex="0">
<padding>
<Insets top="5" right="5" bottom="5" left="15" />
<Insets bottom="5" left="15" right="5" top="5" />
</padding>
<HBox spacing="5" alignment="CENTER_LEFT">
<HBox alignment="CENTER_LEFT" spacing="5">
<Label fx:id="id" styleClass="cell_big_label">
<minWidth>
<!-- Ensures that the label text is never truncated -->
<Region fx:constant="USE_PREF_SIZE" />
</minWidth>
</Label>
<Label fx:id="tid" text="\$tid" styleClass="cell_big_label" />
<Label fx:id="tid" styleClass="cell_big_label" text="\$tid" />
</HBox>
<FlowPane fx:id="itemType"/>
<Label fx:id="name" styleClass="cell_small_label" text="\$first" />
Expand Down
10 changes: 5 additions & 5 deletions src/test/java/seedu/address/logic/LogicManagerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;

import seedu.address.logic.commands.AddCommand;
import seedu.address.logic.commands.CommandResult;
import seedu.address.logic.commands.InsertCommand;
import seedu.address.logic.commands.ListCommand;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.logic.parser.exceptions.ParseException;
Expand Down Expand Up @@ -82,7 +82,7 @@ public void execute_storageThrowsIoException_throwsCommandException() {
logic = new LogicManager(model, storage);

// Execute add command
String addCommand = AddCommand.COMMAND_WORD + TID_DESC_AMY + NAME_DESC_AMY + PHONE_DESC_AMY
String addCommand = InsertCommand.COMMAND_WORD + TID_DESC_AMY + NAME_DESC_AMY + PHONE_DESC_AMY
+ ADDRESS_DESC_AMY + DELIVERY_TIMESTAMP_DESC_AMY + WAREHOUSE_DESC_AMY + COD_DESC_AMY;
Order expectedOrder = new OrderBuilder(AMY).build();
ModelManager expectedModel = new ModelManager();
Expand All @@ -91,12 +91,12 @@ public void execute_storageThrowsIoException_throwsCommandException() {
assertCommandFailure(addCommand, CommandException.class, expectedMessage, expectedModel);
}

/*

@Test
public void getFilteredOrderList_modifyList_throwsUnsupportedOperationException() {
assertThrows(UnsupportedOperationException.class, () -> logic.getFilteredPersonList().remove(0));
assertThrows(UnsupportedOperationException.class, () -> logic.getFilteredOrderList().remove(0));
}
*/


/**
* Executes the command and confirms that
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
import seedu.address.testutil.OrderBuilder;

/**
* Contains integration tests (interaction with the Model) for {@code AddCommand}.
* Contains integration tests (interaction with the Model) for {@code InsertCommand}.
*/
public class AddCommandIntegrationTest {
public class InsertCommandIntegrationTest {

private Model model;

Expand All @@ -32,14 +32,14 @@ public void execute_newOrder_success() {
Model expectedModel = new ModelManager(model.getOrderBook(), new UserPrefs());
expectedModel.addOrder(validOrder);

assertCommandSuccess(new AddCommand(validOrder), model,
String.format(AddCommand.MESSAGE_SUCCESS, validOrder), expectedModel);
assertCommandSuccess(new InsertCommand(validOrder), model,
String.format(InsertCommand.MESSAGE_SUCCESS, validOrder), expectedModel);
}

@Test
public void execute_duplicateOrder_throwsCommandException() {
Order orderInList = model.getOrderBook().getOrderList().get(0);
assertCommandFailure(new AddCommand(orderInList), model, AddCommand.MESSAGE_DUPLICATE_ORDER);
assertCommandFailure(new InsertCommand(orderInList), model, InsertCommand.MESSAGE_DUPLICATE_ORDER);
}

}
Loading

0 comments on commit c43e91c

Please sign in to comment.