protected void addCustomerData(Map<String, Object> attrMap) { Customer customer = CustomerState.getCustomer(); String firstName = ""; String lastName = ""; boolean anonymous = false; if (customer != null) { if (!StringUtils.isEmpty(customer.getFirstName())) { firstName = customer.getFirstName(); } if (!StringUtils.isEmpty(customer.getLastName())) { lastName = customer.getLastName(); } if (customer.isAnonymous()) { anonymous = true; } } attrMap.put("firstName", firstName); attrMap.put("lastName", lastName); attrMap.put("anonymous", anonymous); }
@Override public String getMainEntityName() { String customerName = null; String orderNumber = getOrderNumber(); if (!StringUtils.isEmpty(getCustomer().getFirstName()) && !StringUtils.isEmpty(getCustomer().getLastName())) { customerName = getCustomer().getFirstName() + " " + getCustomer().getLastName(); } if (!StringUtils.isEmpty(orderNumber) && !StringUtils.isEmpty(customerName)) { return orderNumber + " - " + customerName; } if (!StringUtils.isEmpty(orderNumber)) { return orderNumber; } if (!StringUtils.isEmpty(customerName)) { return customerName; } return ""; }
public String viewUpdateAccount(HttpServletRequest request, Model model, UpdateAccountForm form) { Customer customer = CustomerState.getCustomer(); form.setEmailAddress(customer.getEmailAddress()); form.setFirstName(customer.getFirstName()); form.setLastName(customer.getLastName()); return getUpdateAccountView(); }
public void validate(Customer customer, String password, String passwordConfirm, Errors errors) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "password", "password.required"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "passwordConfirm", "passwordConfirm.required"); errors.pushNestedPath("customer"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "firstName", "firstName.required"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "lastName", "lastName.required"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "emailAddress", "emailAddress.required"); errors.popNestedPath(); if (errors.hasErrors()){ if (!passwordConfirm.equals(password)) { errors.rejectValue("passwordConfirm", "invalid"); } if (!customer.getFirstName().matches(getValidNameRegex())) { errors.rejectValue("firstName", "firstName.invalid", null, null); } if (!customer.getLastName().matches(getValidNameRegex())) { errors.rejectValue("lastName", "lastName.invalid", null, null); } if (!customer.getPassword().matches(getValidPasswordRegex())) { errors.rejectValue("password", "password.invalid", null, null); } if (!password.equals(passwordConfirm)) { errors.rejectValue("password", "passwordConfirm.invalid", null, null); } if (!GenericValidator.isEmail(customer.getEmailAddress())) { errors.rejectValue("emailAddress", "emailAddress.invalid", null, null); } } }
@Override public PaymentRequestDTO populateCustomerInfo(PaymentRequestDTO requestDTO, Customer customer, String defaultEmailAddress) { String phoneNumber = null; for (CustomerPhone phone : ListUtils.emptyIfNull(customer.getCustomerPhones())) { if (phone.getPhone().isDefault()) { phoneNumber = phone.getPhone().getPhoneNumber(); } } String emailAddress = (customer.getEmailAddress() == null)? defaultEmailAddress : customer.getEmailAddress(); return requestDTO.customer() .customerId(customer.getId().toString()) .firstName(customer.getFirstName()) .lastName(customer.getLastName()) .email(emailAddress) .phone(phoneNumber) .done(); } }
customer.setFirstName(gatewayCustomer.getFirstName()); if (StringUtils.isEmpty(customer.getLastName()) && gatewayCustomer != null) { customer.setLastName(gatewayCustomer.getLastName());
@PUT @Path("/customers/{id}") @Consumes(MediaType.APPLICATION_JSON) public Response updateCustomer(@PathParam("id") long id, Customer updateCustomer) { Customer customer = customerService.getCustomerById(id); if (customer == null) { throw new WebApplicationException("Can't find it", 404); } customer.setFirstName(updateCustomer.getFirstName()); customer.setLastName(updateCustomer.getLastName()); ... return Response.noContent().build(); }
.accept(MediaType.APPLICATION_XML) .get(Customer.class); System.out.println(customer.getLastName() + ", "+ customer.getFirstName());
for(Customer c: customers) { if(c.getFirstName().equalsIgnoreCase(name[0]) && c.getLastName().equalsIgnoreCase(name[1]) { for(Account a : c.getAccounts()) { if(a.getAccountId() == account) {
@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; }
final Customer customer = item.getModelObject(); item.add(new Label("id", customer.getId())); item.add(new Label("lastname", customer.getLastName())); item.add(new Label("firstname", customer.getFirstName())); item.add(new Label("age", customer.getAge()));