@Override public Optional<GatewayCustomerData> getCustomerData(Customer customer, String gatewayId) { Key key = new Key(customer.getId(), gatewayId, "customer"); if (store.containsKey(key)) { return Optional.of((GatewayCustomerData) store.get(key)); } return Optional.absent(); }
@Override public Optional<GatewayCustomerData> getCustomerData(Customer customer, String gatewayId) { GatewayCustomerData result = dao.getCustomerData(customer.getId(), gatewayId); if (result == null) { return Optional.absent(); } return Optional.of(result); }
@Override public void delete(@Valid Customer entity) throws EntityDoesNotExistException { Integer updatedRows = 0; this.dao.begin(); updatedRows += this.dao.deleteEntityEntityById(CUSTOMER_TABLE_NAME, entity.getId()); updatedRows += this.dao.detachChildren(entity.getId()); updatedRows += this.dao.deleteEntityAndChildrenById(entity.getId()); this.dao.commit(); if (updatedRows <= 0) { throw new EntityDoesNotExistException("No rows was updated when trying to delete customer"); } }
@Override public void supply(User user, Map<String, Object> data) { Customer customer = customerStore.get().findByUserId(user.getId()); if (customer == null) { return; } CustomerWebObject customerWebObject = new CustomerWebObject().withCustomer(customer); Address delivery = addressStore.get().findByCustomerIdAndType(customer.getId(), "delivery"); if (delivery != null) { customerWebObject.withDeliveryAddress(delivery); } Address billing = addressStore.get().findByCustomerIdAndType(customer.getId(), "billing"); if (billing != null) { customerWebObject.withBillingAddress(billing); } if (customer != null) { data.put("customer", customerWebObject); } } }
Customer customer = customerStore.get().findByUserId(webContext.getUser().getId()); if (customer != null) { Address deliveryAddress = addressStore.get().findByCustomerIdAndType(customer.getId(), "delivery"); Address billingAddress = addressStore.get().findByCustomerIdAndType(customer.getId(), "billing"); checkoutRequest = new CheckoutRequest(); checkoutRequest.setCustomer(customer);