@Override public Map<String, Object> populateModelVariables(String tagName, Map<String, String> tagAttributes, BroadleafTemplateContext context) { Object obj = context.parseExpression(tagAttributes.get("itemId")); String itemId = obj.toString(); RatingSummary ratingSummary = ratingService.readRatingSummary(itemId, RatingType.PRODUCT); Map<String, Object> newModelVars = new HashMap<>(); if (ratingSummary != null) { newModelVars.put(getRatingsVar(tagAttributes), ratingSummary); } Customer customer = CustomerState.getCustomer(); ReviewDetail reviewDetail = null; if (!customer.isAnonymous()) { reviewDetail = ratingService.readReviewByCustomerAndItem(customer, itemId); } if (reviewDetail != null) { newModelVars.put("currentCustomerReview", reviewDetail); } return newModelVars; }
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 RegisterCustomerForm initCustomerRegistrationForm() { Customer customer = CustomerState.getCustomer(); if (customer == null || ! customer.isAnonymous()) { customer = customerService.createCustomerFromId(null); } RegisterCustomerForm customerRegistrationForm = new RegisterCustomerForm(); customerRegistrationForm.setCustomer(customer); return customerRegistrationForm; }
/** * After a JPA merge occurs, there is a new object created representing the merged changes. The new object does * not reflect the state of transient fields that may have been set on the object that was merged. * * This method, by default, resets the state of transient properties. * and allows the user to override this method to set additional (or different) transient values. * * @param preMergedCustome * @param postMergedCustomer */ protected void resetTransientFields(Customer preMergedCustomer, Customer postMergedCustomer) { postMergedCustomer.setUnencodedPassword(preMergedCustomer.getUnencodedPassword()); postMergedCustomer.setUnencodedChallengeAnswer(preMergedCustomer.getUnencodedChallengeAnswer()); postMergedCustomer.setAnonymous(preMergedCustomer.isAnonymous()); postMergedCustomer.setCookied(preMergedCustomer.isCookied()); postMergedCustomer.setLoggedIn(preMergedCustomer.isRegistered()); postMergedCustomer.getTransientProperties().putAll(preMergedCustomer.getTransientProperties()); }
if (customer.isAnonymous()) { GatewayCustomerDTO<PaymentResponseDTO> gatewayCustomer = responseDTO.getCustomer(); if (StringUtils.isEmpty(customer.getFirstName()) && gatewayCustomer != null) {
if (!customer.isAnonymous() && shippingForm.isSaveAsDefault()) { Address address = addressService.saveAddress(shippingForm.getAddress()); CustomerAddress customerAddress = customerAddressService.create();
/** * After a JPA merge occurs, there is a new object created representing the merged changes. The new object does * not reflect the state of transient fields that may have been set on the object that was merged. * * This method, by default, resets the state of transient properties. * and allows the user to override this method to set additional (or different) transient values. * * @param preMergedCustome * @param postMergedCustomer */ protected void resetTransientFields(Customer preMergedCustomer, Customer postMergedCustomer) { postMergedCustomer.setUnencodedPassword(preMergedCustomer.getUnencodedPassword()); postMergedCustomer.setUnencodedChallengeAnswer(preMergedCustomer.getUnencodedChallengeAnswer()); postMergedCustomer.setAnonymous(preMergedCustomer.isAnonymous()); postMergedCustomer.setCookied(preMergedCustomer.isCookied()); postMergedCustomer.setLoggedIn(preMergedCustomer.isLoggedIn()); postMergedCustomer.getTransientProperties().putAll(preMergedCustomer.getTransientProperties()); }