/**
*
*/
public OrderViewBean buildViewBeanOrder(final RequestData requestData, final OrderCustomer order) throws Exception {
final Locale locale = requestData.getLocale();
final OrderViewBean orderViewBean = new OrderViewBean();
orderViewBean.setOrderNum(order.getOrderNum());
if (order != null) {
DateFormat dateFormat = requestUtil.getFormatDate(requestData, DateFormat.MEDIUM, DateFormat.MEDIUM);
if (order.getExpectedDeliveryDate() != null) {
orderViewBean.setExpectedDeliveryDate(dateFormat.format(order.getExpectedDeliveryDate()));
} else {
orderViewBean.setExpectedDeliveryDate(Constants.NOT_AVAILABLE);
}
if (order.getDateCreate() != null) {
orderViewBean.setDateCreate(dateFormat.format(order.getDateCreate()));
}
if (order.getDateUpdate() != null) {
orderViewBean.setDateUpdate(dateFormat.format(order.getDateUpdate()));
}
// ITEMS PART
final List<OrderItemViewBean> orderItemViewBeans = new ArrayList<OrderItemViewBean>();
final Set<OrderItem> orderItems = order.getOrderItems();
for (Iterator<OrderItem> iterator = orderItems.iterator(); iterator.hasNext();) {
OrderItem orderItem = (OrderItem) iterator.next();
orderItemViewBeans.add(buildViewBeanOrderItem(requestData, orderItem));
}
orderViewBean.setOrderItems(orderItemViewBeans);
// SUB PART : Shippings
final List<OrderShippingViewBean> orderShippingViewBeans = new ArrayList<OrderShippingViewBean>();
final Set<OrderShipment> orderShipments = order.getOrderShipments();
if (Hibernate.isInitialized(orderShipments) && orderShipments != null) {
for (Iterator<OrderShipment> iterator = orderShipments.iterator(); iterator.hasNext();) {
final OrderShipment orderShipment = (OrderShipment) iterator.next();
final OrderShippingViewBean orderShippingViewBean = new OrderShippingViewBean();
Object[] params = { orderShipment.getName() };
orderShippingViewBean.setOrderShippingTotalLabel(getSpecificMessage(ScopeWebMessage.COMMON, "shoppingcart.amount.deliveryMethods", params, locale));
orderShippingViewBeans.add(orderShippingViewBean);
}
orderViewBean.setOrderShippings(orderShippingViewBeans);
}
// SUB PART : Taxes
final List<OrderTaxViewBean> orderTaxViewBeans = new ArrayList<OrderTaxViewBean>();
final Set<OrderTax> orderTaxes = order.getOrderTaxes();
if (Hibernate.isInitialized(orderTaxes) && orderTaxes != null) {
for (Iterator<OrderTax> iterator = orderTaxes.iterator(); iterator.hasNext();) {
final OrderTax orderTax = (OrderTax) iterator.next();
final OrderTaxViewBean orderTaxViewBean = new OrderTaxViewBean();
Object[] params = { orderTax.getAmount() };
orderTaxViewBean.setOrderTaxTotal(order.getCurrency().formatPriceWithStandardCurrencySign(orderTax.getAmount()));
orderTaxViewBean.setOrderTaxTotalLabel(getSpecificMessage(ScopeWebMessage.COMMON, "shoppingcart.amount.taxes", params, locale));
orderTaxViewBeans.add(orderTaxViewBean);
}
orderViewBean.setOrderTaxes(orderTaxViewBeans);
}
orderViewBean.setOrderItemsTotalWithCurrencySign(order.getOrderItemTotalWithStandardCurrencySign());
orderViewBean.setOrderShippingTotalWithCurrencySign(order.getShippingTotalWithStandardCurrencySign());
orderViewBean.setOrderTaxesTotalWithCurrencySign(order.getTaxTotalWithStandardCurrencySign());
orderViewBean.setOrderTotalWithCurrencySign(order.getOrderTotalWithStandardCurrencySign());
Map<String, String> getParams = new HashMap<String, String>();
getParams.put(RequestConstants.REQUEST_PARAMETER_CUSTOMER_ORDER_GUID, order.getId().toString());
orderViewBean.setDetailsUrl(urlService.generateUrl(FoUrls.PERSONAL_ORDER_DETAILS, requestData, getParams));
}
return orderViewBean;
}