@Override public void determineIfSavedAddressIsSelected(Model model, ShippingInfoForm shippingInfoForm, PaymentInfoForm paymentInfoForm) { Customer customer = CustomerState.getCustomer(); boolean isSavedShippingAddress = false; boolean isSavedBillingAddress = false; for (CustomerAddress customerAddress : customer.getCustomerAddresses()) { if (addressesContentsAreEqual(shippingInfoForm.getAddress(), customerAddress.getAddress())) { isSavedShippingAddress = true; break; } } for (CustomerAddress customerAddress : customer.getCustomerAddresses()) { if (addressesContentsAreEqual(paymentInfoForm.getAddress(), customerAddress.getAddress())) { isSavedBillingAddress = true; break; } } model.addAttribute("isSavedShippingAddress", isSavedShippingAddress); model.addAttribute("isSavedBillingAddress", isSavedBillingAddress); }
List<CustomerAddress> addressList = customer.getCustomerAddresses(); for (CustomerAddress address : addressList) { address.setArchived('Y');
CustomerAddress clonedEntry = entry.createOrRetrieveCopyInstance(context).getClone(); clonedEntry.setCustomer(cloned); cloned.getCustomerAddresses().add(clonedEntry);
customer.getCustomerAddresses().clear(); .collect(toList()) .ifPresent(customerAddresses -> customer.getCustomerAddresses().addAll(customerAddresses));
@Override public CustomerDto createDto(final Customer customer, final boolean embed, final boolean link) { final CustomerDto customerDto = CustomerDto.builder() .firstName(customer.getFirstName()) .lastName(customer.getLastName()) .username(customer.getUsername()) .email(customer.getEmailAddress()) .locale(Optional.ofNullable(customer.getCustomerLocale()).map(Locale::getLocaleCode).orElse(null)) .addresses( customer.getCustomerAddresses().stream() .collect(toMap( CustomerAddress::getAddressName, customerAddress -> addressConverter.createDto(customerAddress.getAddress(), embed, link) )) ) .build(); customerDto.add(ControllerLinkBuilder.linkTo(methodOn(CustomerController.class).readOneCustomer(null, customer.getId().toString(), null, null)).withSelfRel()); if (link) { customerDto.add(linkTo(methodOn(CustomerController.class).createAuthorizationCode(null, customer.getId().toString())).withRel("authorization")); } return customerDto; }