@Override public void updateCustomer(final CustomerData customerData) throws DuplicateUidException { validateParameterNotNullStandardMessage("customerData", customerData); final EnergizerB2BCustomerModel energizerB2BCustomerModel; if (StringUtils.isEmpty(customerData.getUid())) { energizerB2BCustomerModel = this.getModelService().create(EnergizerB2BCustomerModel.class); energizerB2BCustomerModel.setRegistrationEmailFlag(Boolean.TRUE); } else { energizerB2BCustomerModel = (EnergizerB2BCustomerModel) userService.getUserForUID(customerData.getUid()); } if (null != customerData && null != energizerB2BCustomerModel) { energizerCustomerReversePopulator.populate(customerData, energizerB2BCustomerModel); companyB2BCommerceService.saveModel(energizerB2BCustomerModel); } }
/** As per enhancement added new group b2bviewergroup */ @Override public void populateUserRoles(final SearchPageData<CustomerData> b2bCustomer) { List<String> roles = null; for (int i = 0; i < b2bCustomer.getResults().size(); i++) { roles = new ArrayList<String>(); final EnergizerB2BCustomerModel customerModel = userService.getUserForUID( b2bCustomer.getResults().get(i).getUid(), EnergizerB2BCustomerModel.class); final Set<PrincipalGroupModel> roleModels = new HashSet<PrincipalGroupModel>(customerModel.getGroups()); for (final PrincipalGroupModel role : roleModels) { // only display allowed usergroups if (energizerGroupsLookUpStrategy.getUserGroups().contains(role.getUid())) { roles.add(role.getUid()); } } b2bCustomer.getResults().get(i).setRoles(roles); } }
/** As per enhancement added new group b2bviewergroup */ public void populateRolesByCustomer(final String uuid, final CustomerData target) { final List<String> roles = new ArrayList<String>(); final EnergizerB2BCustomerModel model = userService.getUserForUID(uuid, EnergizerB2BCustomerModel.class); final Set<PrincipalGroupModel> roleModels = new HashSet<PrincipalGroupModel>(model.getGroups()); CollectionUtils.filter( roleModels, PredicateUtils.notPredicate(PredicateUtils.instanceofPredicate(B2BUnitModel.class))); CollectionUtils.filter( roleModels, PredicateUtils.notPredicate(PredicateUtils.instanceofPredicate(B2BUserGroupModel.class))); for (final PrincipalGroupModel role : roleModels) { // only display allowed usergroups if (energizerGroupsLookUpStrategy.getUserGroups().contains(role.getUid())) { roles.add(role.getUid()); } } target.setRoles(roles); }
/* * (non-Javadoc) * * @see * com.energizer.facades.accounts.EnergizerCompanyB2BCommerceFacade#updateProfile(de.hybris.platform.commercefacades * .user.data.CustomerData) */ @SuppressWarnings("deprecation") @Override public void updateProfile(final CustomerData customerData) { try { validateDataBeforeUpdate(customerData); final String name = getCustomerNameStrategy() .getName(customerData.getFirstName(), customerData.getLastName()); final EnergizerB2BCustomerModel customer = (EnergizerB2BCustomerModel) getCurrentSessionCustomer(); customer.setOriginalUid(customerData.getDisplayUid()); customer.setContactNumber(customerData.getContactNumber()); customerAccountService.updateProfile( customer, customerData.getTitleCode(), name, customerData.getUid()); getModelService().save(customer); } catch (final DuplicateUidException e) { e.printStackTrace(); } }