/**
*
*/
public PaymentGatewayViewBean buildViewBeanPaymentGateway(final RequestData requestData, final AbstractPaymentGateway paymentGateway) throws Exception {
final MarketArea marketArea = requestData.getMarketArea();
final PaymentGatewayViewBean paymentGatewayViewBean = new PaymentGatewayViewBean();
if (paymentGateway != null) {
paymentGatewayViewBean.setCode(paymentGateway.getCode());
paymentGatewayViewBean.setName(paymentGateway.getName());
paymentGatewayViewBean.setDescription(paymentGateway.getDescription());
if(Hibernate.isInitialized(paymentGateway.getMarketAreas())
&& paymentGateway.getMarketAreas() != null){
paymentGatewayViewBean.setActive(paymentGateway.getMarketAreas().contains(marketArea));
}
List<PaymentGatewayAttribute> globalAttributes = paymentGateway.getGlobalAttributes();
if(globalAttributes != null){
for (Iterator<PaymentGatewayAttribute> iterator = globalAttributes.iterator(); iterator.hasNext();) {
PaymentGatewayAttribute attribute = (PaymentGatewayAttribute) iterator.next();
paymentGatewayViewBean.getGlobalAttributes().put(attribute.getAttributeDefinition().getCode(), attribute.getValueAsString());
}
}
List<PaymentGatewayAttribute> marketAreaAttributes = paymentGateway.getMarketAreaAttributes(marketArea.getId());
if(marketAreaAttributes != null){
for (Iterator<PaymentGatewayAttribute> iterator = marketAreaAttributes.iterator(); iterator.hasNext();) {
PaymentGatewayAttribute attribute = (PaymentGatewayAttribute) iterator.next();
paymentGatewayViewBean.getMarketAreaAttributes().put(attribute.getAttributeDefinition().getCode(), attribute.getValueAsString());
}