/**
* @throws Exception
*
*/
public DeliveryMethodViewBean buildViewBeanDeliveryMethod(final RequestData requestData, final DeliveryMethod deliveryMethod) throws Exception {
final DeliveryMethodViewBean deliveryMethodViewBean = new DeliveryMethodViewBean();
deliveryMethodViewBean.setId(deliveryMethod.getId());
deliveryMethodViewBean.setVersion(deliveryMethod.getVersion());
deliveryMethodViewBean.setName(deliveryMethod.getName());
deliveryMethodViewBean.setDescription(deliveryMethod.getDescription());
deliveryMethodViewBean.setCode(deliveryMethod.getCode());
final Set<DeliveryMethodPrice> prices = deliveryMethod.getPrices();
if(Hibernate.isInitialized(prices) && prices != null){
for (DeliveryMethodPrice deliveryMethodPrice : prices) {
// TODO : denis : fix the context
// if(deliveryMethodPrice.getMarketAreaId().equals(marketArea.getId()) && deliveryMethodPrice.getRetailerId().equals(retailer.getId())) {
// }
deliveryMethodViewBean.setCatalogPrice(deliveryMethodPrice.getPrice().toString());
deliveryMethodViewBean.setSalePrice(deliveryMethodPrice.getSalePrice().toString());
deliveryMethodViewBean.setPriceWithCurrencySign(deliveryMethodPrice.getPriceWithStandardCurrencySign());
deliveryMethodViewBean.setCurrencySign(deliveryMethodPrice.getCurrency().getSign());
deliveryMethodViewBean.setCurrencyAbbreviated(deliveryMethodPrice.getCurrency().getAbbreviated());
break;
}
}
DateFormat dateFormat = requestUtil.getFormatDate(requestData, DateFormat.MEDIUM, DateFormat.MEDIUM);
if (deliveryMethod.getDateCreate() != null) {
deliveryMethodViewBean.setDateCreate(dateFormat.format(deliveryMethod.getDateCreate()));
}
if (deliveryMethod.getDateUpdate() != null) {
deliveryMethodViewBean.setDateUpdate(dateFormat.format(deliveryMethod.getDateUpdate()));
}
// TODO : CMS page to describe Delivery Methods
// deliveryMethodViewBean.setDetailsUrl(urlService.generateUrl(FoUrls.DELIVERY_METHOD_DETAILS, requestData, deliveryMethod));
// deliveryMethodViewBean.setEditUrl(urlService.generateUrl(FoUrls.DELIVERY_METHOD_EDIT, requestData, deliveryMethod));