if(StringUtils.isEmpty(deliveryMethodCode)){
final String urlRedirect = backofficeUrlService.generateUrl(BoUrls.DELIVERY_METHOD_LIST, requestData);
return new ModelAndView(new RedirectView(urlRedirect));
}
final DeliveryMethod deliveryMethod = deliveryMethodService.getDeliveryMethodByCode(deliveryMethodCode);
// SANITY CHECK
if(deliveryMethod != null){
modelAndView.addObject(ModelConstants.DELIVERY_METHOD_VIEW_BEAN, backofficeViewBeanFactory.buildViewBeanDeliveryMethod(requestData, deliveryMethod));
} else {
final String url = requestUtil.getLastRequestUrl(request);
return new ModelAndView(new RedirectView(url));
}
final List<WarehouseViewBean> warehouseViewBeans = new ArrayList<WarehouseViewBean>();
final List<Warehouse> warehouses = warehouseService.findWarehousesByDeliveryMethodId(deliveryMethod.getId());
for (Iterator<Warehouse> iterator = warehouses.iterator(); iterator.hasNext();) {
Warehouse warehouse = (Warehouse) iterator.next();
warehouseViewBeans.add(backofficeViewBeanFactory.buildViewBeanWarehouse(requestUtil.getRequestData(request), warehouse));
}
request.setAttribute(ModelConstants.WAREHOUSES_VIEW_BEAN, warehouseViewBeans);
model.addAttribute(ModelConstants.URL_BACK, backofficeUrlService.generateUrl(BoUrls.DELIVERY_METHOD_LIST, requestData));
Object[] params = {deliveryMethod.getName() + " (" + deliveryMethod.getCode() + ")"};
overrideDefaultSeoPageTitleAndMainContentTitle(request, modelAndView, BoUrls.DELIVERY_METHOD_DETAILS.getKey(), params);
return modelAndView;
}