Package org.hoteia.qalingo.core.web.mvc.viewbean

Examples of org.hoteia.qalingo.core.web.mvc.viewbean.CustomerViewBean


     * @throws Exception
     *
     */
    @Override
    public CustomerViewBean buildViewBeanCustomer(final RequestData requestData, final Customer customer) throws Exception {
        CustomerViewBean customerViewBean = super.buildViewBeanCustomer(requestData, customer);

        customerViewBean.setDetailsUrl(backofficeUrlService.generateUrl(BoUrls.CUSTOMER_DETAILS, requestData, customer));
        customerViewBean.setEditUrl(backofficeUrlService.generateUrl(BoUrls.CUSTOMER_EDIT, requestData, customer));

        return customerViewBean;
    }
View Full Code Here


   
    // WE RELOAD THE CUSTOMER FOR THE PERSISTANCE PROXY FILTER
    // IT AVOIDS LazyInitializationException: could not initialize proxy - no Session
    final Customer reloadedCustomer = customerService.getCustomerByLoginOrEmail(customer.getLogin());
   
    final CustomerViewBean customerView = frontofficeViewBeanFactory.buildViewBeanCustomer(requestUtil.getRequestData(request), reloadedCustomer);
    model.addAttribute(ModelConstants.CUSTOMER_DETAILS_VIEW_BEAN, customerView);
   
    Object[] params = { customer.getLastname(), customer.getFirstname() };
        overrideDefaultSeoPageTitleAndMainContentTitle(request, modelAndView, FoUrls.CUSTOMER_DETAILS.getKey(), params);
View Full Code Here

     *
     */
    public CustomerViewBean buildViewBeanCustomer(final RequestData requestData, final Customer customer) throws Exception {
        final HttpServletRequest request = requestData.getRequest();
        final Locale locale = requestData.getLocale();
        final CustomerViewBean customerViewBean = new CustomerViewBean();
        if (customer != null) {
            customerViewBean.setCode(customer.getCode());
            customerViewBean.setAvatarImg(requestUtil.getCustomerAvatar(request, customer));
            customerViewBean.setTitle(referentialDataService.getTitleByLocale(customer.getTitle(), locale));
            customerViewBean.setFirstname(customer.getFirstname());
            customerViewBean.setLastname(customer.getLastname());
            customerViewBean.setEmail(customer.getEmail());
            customerViewBean.setLogin(customer.getLogin());

            DateFormat dateFormat = requestUtil.getFormatDate(requestData, DateFormat.MEDIUM, DateFormat.MEDIUM);
            if (customer.getDateCreate() != null) {
                customerViewBean.setDateCreate(dateFormat.format(customer.getDateCreate()));
            }
            if (customer.getDateUpdate() != null) {
                customerViewBean.setDateUpdate(dateFormat.format(customer.getDateUpdate()));
            }

            final Set<CustomerGroup> groups = customer.getGroups();
            for (Iterator<CustomerGroup> iteratorGroup = groups.iterator(); iteratorGroup.hasNext();) {
                CustomerGroup group = (CustomerGroup) iteratorGroup.next();
                String keyCustomerGroup = group.getCode();
                String valueCustomerGroup = group.getName();
                customerViewBean.getGroups().put(keyCustomerGroup, valueCustomerGroup);

                final Set<CustomerRole> roles = group.getRoles();
                for (Iterator<CustomerRole> iteratorRole = roles.iterator(); iteratorRole.hasNext();) {
                    CustomerRole role = (CustomerRole) iteratorRole.next();
                    String keyCustomerRole = role.getCode();
                    String valueCustomerRole = role.getName();
                    customerViewBean.getRoles().put(keyCustomerRole, valueCustomerRole);

                    final Set<CustomerPermission> permissions = role.getPermissions();
                    for (Iterator<CustomerPermission> iteratorPermission = permissions.iterator(); iteratorPermission.hasNext();) {
                        CustomerPermission permission = (CustomerPermission) iteratorPermission.next();
                        String keyCustomerPermission = permission.getCode();
                        String valueCustomerPermission = permission.getName();
                        customerViewBean.getPermissions().put(keyCustomerPermission, valueCustomerPermission);
                    }
                }
            }
           
            final Set<CustomerConnectionLog> connectionLogs = customer.getConnectionLogs();
            if (connectionLogs != null && Hibernate.isInitialized(connectionLogs) && connectionLogs.size() > 0) {
                CustomerConnectionLog customerConnectionLog = connectionLogs.iterator().next();
                if (customerConnectionLog.getLoginDate() != null) {
                    customerViewBean.setLastConnectionDate(dateFormat.format(customerConnectionLog.getLoginDate()));
                } else {
                    customerViewBean.setLastConnectionDate(Constants.NOT_AVAILABLE);
                }
            }
           
            customerViewBean.setActive(customer.isActive());

            final ValueBean customerScreenNameValueBean = new ValueBean();
            customerScreenNameValueBean.setKey(getSpecificMessage(ScopeWebMessage.CUSTOMER, "screenname.label", locale));
            customerScreenNameValueBean.setValue(customer.getScreenName());
            customerViewBean.getCustomerAttributes().put(CustomerViewBean.SCREEN_NAME, customerScreenNameValueBean);

        }
        return customerViewBean;
    }
View Full Code Here

        final String customerCode = request.getParameter(RequestConstants.REQUEST_PARAMETER_CUSTOMER_CODE);
        if(StringUtils.isNotEmpty(customerCode)){
            // EDIT MODE
            final Customer customer = customerService.getCustomerByCode(customerCode);

            CustomerViewBean customerViewBean = backofficeViewBeanFactory.buildViewBeanCustomer(requestData, customer);
            request.setAttribute(ModelConstants.CUSTOMER_VIEW_BEAN, customerViewBean);

            Object[] params = {customer.getLastname() + " " + customer.getFirstname()};
            overrideDefaultSeoPageTitleAndMainContentTitle(request, modelAndView,  BoUrls.CUSTOMER_EDIT.getKey(), params);
View Full Code Here

TOP

Related Classes of org.hoteia.qalingo.core.web.mvc.viewbean.CustomerViewBean

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.