public String viewCustomerAddress(HttpServletRequest request, Model model, Long customerAddressId) { CustomerAddress customerAddress = customerAddressService.readCustomerAddressById(customerAddressId); if (customerAddress == null) { throw new IllegalArgumentException("Customer Address not found with the specified customerAddressId"); } validateCustomerOwnedData(customerAddress); CustomerAddressForm form = new CustomerAddressForm(); form.setAddress(customerAddress.getAddress()); form.setAddressName(customerAddress.getAddressName()); form.setCustomerAddressId(customerAddress.getId()); model.addAttribute("customerAddressForm", form); return getCustomerAddressesView(); }
@Override public ShippingInfoForm prePopulateShippingInfoForm(ShippingInfoForm shippingInfoForm, Order cart) { FulfillmentGroup firstShippableFulfillmentGroup = fulfillmentGroupService.getFirstShippableFulfillmentGroup(cart); if (firstShippableFulfillmentGroup != null) { //if the cart has already has fulfillment information if (firstShippableFulfillmentGroup.getAddress() != null) { shippingInfoForm.setAddress(firstShippableFulfillmentGroup.getAddress()); } else { //check for a default address for the customer CustomerAddress defaultAddress = customerAddressService.findDefaultCustomerAddress(CustomerState.getCustomer().getId()); if (defaultAddress != null) { shippingInfoForm.setAddress(defaultAddress.getAddress()); shippingInfoForm.setAddressName(defaultAddress.getAddressName()); } } FulfillmentOption fulfillmentOption = firstShippableFulfillmentGroup.getFulfillmentOption(); if (fulfillmentOption != null) { shippingInfoForm.setFulfillmentOption(fulfillmentOption); shippingInfoForm.setFulfillmentOptionId(fulfillmentOption.getId()); } } return shippingInfoForm; }