lab4/order-service/src/main/java/com/amazon/aws/partners/saasfactory/DynamoDbHelper.java [115:147]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    public static Map<String, AttributeValue> toAttributeValueMap(Order order) {
        Map<String, AttributeValue> map = new HashMap<>();
        map.put("id", AttributeValue.builder().s(order.getId().toString()).build());
        LocalDate orderDate = order.getOrderDate();
        if (orderDate != null) {
            map.put("orderDate", AttributeValue.builder().s(orderDate.toString()).build());
        }
        LocalDate shipDate = order.getShipDate();
        if (shipDate != null) {
            map.put("shipDate", AttributeValue.builder().s(shipDate.toString()).build());
        }
        Purchaser purchaser = order.getPurchaser();
        if (purchaser != null) {
            map.put("purchaser", AttributeValue.builder().m(toAttributeValueMap(purchaser)).build());
        }
        Address shipAddress = order.getShipAddress();
        if (shipAddress != null) {
            map.put("shipAddress", AttributeValue.builder().m(toAttributeValueMap(shipAddress)).build());
        }
        Address billAddress = order.getBillAddress();
        if (billAddress != null) {
            map.put("billAddress", AttributeValue.builder().m(toAttributeValueMap(billAddress)).build());
        }
        List<AttributeValue> lineItems = new ArrayList<>();
        order.getLineItems().forEach(lineItem -> {
            lineItems.add(AttributeValue.builder().m(toAttributeValueMap(lineItem)).build());
        });
        if (!lineItems.isEmpty()) {
            map.put("lineItems", AttributeValue.builder().l(lineItems).build());
        }
        map.put("total", AttributeValue.builder().n(order.getTotal().toPlainString()).build());
        return map;
    }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



lab3/order-service/src/main/java/com/amazon/aws/partners/saasfactory/DynamoDbHelper.java [115:147]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    public static Map<String, AttributeValue> toAttributeValueMap(Order order) {
        Map<String, AttributeValue> map = new HashMap<>();
        map.put("id", AttributeValue.builder().s(order.getId().toString()).build());
        LocalDate orderDate = order.getOrderDate();
        if (orderDate != null) {
            map.put("orderDate", AttributeValue.builder().s(orderDate.toString()).build());
        }
        LocalDate shipDate = order.getShipDate();
        if (shipDate != null) {
            map.put("shipDate", AttributeValue.builder().s(shipDate.toString()).build());
        }
        Purchaser purchaser = order.getPurchaser();
        if (purchaser != null) {
            map.put("purchaser", AttributeValue.builder().m(toAttributeValueMap(purchaser)).build());
        }
        Address shipAddress = order.getShipAddress();
        if (shipAddress != null) {
            map.put("shipAddress", AttributeValue.builder().m(toAttributeValueMap(shipAddress)).build());
        }
        Address billAddress = order.getBillAddress();
        if (billAddress != null) {
            map.put("billAddress", AttributeValue.builder().m(toAttributeValueMap(billAddress)).build());
        }
        List<AttributeValue> lineItems = new ArrayList<>();
        order.getLineItems().forEach(lineItem -> {
            lineItems.add(AttributeValue.builder().m(toAttributeValueMap(lineItem)).build());
        });
        if (!lineItems.isEmpty()) {
            map.put("lineItems", AttributeValue.builder().l(lineItems).build());
        }
        map.put("total", AttributeValue.builder().n(order.getTotal().toPlainString()).build());
        return map;
    }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



