Skip to content

Commit

Permalink
synching implementation of domain for custom partitioning module
Browse files Browse the repository at this point in the history
  • Loading branch information
eitansuez committed Sep 22, 2017
1 parent 43eab99 commit 0a43f70
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,24 @@ private static void populateCustomers(ClientCache cache) {

Customer cust1 = Customer.builder().customerNumber(5598)
.firstName("Kari").lastName("Powell")
.primaryAddress(Address.builder().postalCode("44444").build())
.address(Address.builder().postalCode("44444").build())
.bookOrder(17600L)
.build();
cust1.addOrder(17600);
customers.put(cust1.getCustomerNumber(), cust1);
log.info("Inserted a customer: " + cust1);

Customer cust2 = Customer.builder().customerNumber(5542)
.firstName("Lula").lastName("Wax")
.primaryAddress(Address.builder().postalCode("12345").build())
.build();
.address(Address.builder().postalCode("12345").build())
.build();
customers.put(cust2.getCustomerNumber(), cust2);
log.info("Inserted a customer: " + cust2);

Customer cust3 = Customer.builder().customerNumber(6024)
.firstName("Trenton").lastName("Garcia")
.primaryAddress(Address.builder().postalCode("88888").build())
.build();
cust3.addOrder(17700);
.address(Address.builder().postalCode("88888").build())
.bookOrder(17700L)
.build();
customers.put(cust3.getCustomerNumber(), cust3);
log.info("Inserted a customer: " + cust3);
}
Expand All @@ -56,17 +56,19 @@ private static void populateBookOrders(ClientCache cache) {
OrderKey key1 = new OrderKey(5598, 17600);
BookOrder order1 = BookOrder.builder().orderNumber(17600).orderDate(new Date())
.shippingCost(5.99f).shipDate(new Date())
.customerNumber(5598).totalPrice(40.98f).build();
order1.addOrderItem(BookOrderItem.builder().orderLine(1).itemNumber(123).build());
.customerNumber(5598).totalPrice(40.98f)
.orderItem(BookOrderItem.builder().orderLine(1).itemNumber(123).build())
.build();
orders.put(key1, order1);

// Order for Lula Wax book: A Treatise of Treatises & Clifford the Big Red Dog
OrderKey key2 = new OrderKey(6024, 17700);
BookOrder order2 = BookOrder.builder().orderNumber(17700).orderDate(new Date())
.shippingCost(5.99f).shipDate(new Date())
.customerNumber(6024).totalPrice(52.97f).build();
order2.addOrderItem(BookOrderItem.builder().orderLine(1).itemNumber(123).build());
order2.addOrderItem(BookOrderItem.builder().orderLine(2).itemNumber(456).build());
.customerNumber(6024).totalPrice(52.97f)
.orderItem(BookOrderItem.builder().orderLine(1).itemNumber(123).build())
.orderItem(BookOrderItem.builder().orderLine(2).itemNumber(456).build())
.build();
orders.put(key2, order2);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
import lombok.*;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@NoArgsConstructor
@Getter
@Setter
@NoArgsConstructor @Getter @Setter
@EqualsAndHashCode(of={"orderNumber"})
@ToString(of={"orderNumber", "orderDate", "customerNumber", "totalPrice"})
@AllArgsConstructor
Expand All @@ -19,11 +17,7 @@ public class BookOrder implements Serializable {
private long orderNumber;
private long customerNumber;
private Date orderDate, shipDate;
private final ArrayList<BookOrderItem> orderItems = new ArrayList<>();
@Singular private List<BookOrderItem> orderItems;
private float shippingCost, totalPrice;

public void addOrderItem(BookOrderItem item) {
orderItems.add(item);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@

import java.io.Serializable;

@NoArgsConstructor
@Getter
@Setter
@ToString(of={"orderLine", "itemNumber", "quantity", "discount"})
@NoArgsConstructor @Getter @Setter
@ToString
@AllArgsConstructor
@Builder
public class BookOrderItem implements Serializable {

private static final long serialVersionUID = 7526471155622776147L;

private int orderLine;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
import lombok.*;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

@NoArgsConstructor
@Getter
@Setter
@NoArgsConstructor @Getter @Setter
@EqualsAndHashCode(of={"customerNumber"})
@ToString(of={"customerNumber", "firstName", "lastName"})
@AllArgsConstructor
Expand All @@ -17,13 +15,10 @@ public class Customer implements Serializable {
private static final long serialVersionUID = 7526471155622776147L;

private long customerNumber;
private String firstName;
private String lastName;
private Address primaryAddress;
private final ArrayList<Long> myBookOrders = new ArrayList<>();

public void addOrder(long orderKey) {
myBookOrders.add(orderKey);
}
private String firstName, lastName;
@Singular
private List<Address> addresses;
@Singular
private List<Long> bookOrders;

}

0 comments on commit 0a43f70

Please sign in to comment.