}
public ProductBrandForm buildProductBrandForm(final RequestData requestData, final ProductBrand productBrand) throws Exception {
final MarketArea currentMarketArea = requestData.getMarketArea();
final ProductBrandForm productBrandForm = new ProductBrandForm();
if(productBrand != null){
productBrandForm.setId(productBrand.getId().toString());
productBrandForm.setName(productBrand.getName());
productBrandForm.setCode(productBrand.getCode());
productBrandForm.setDescription(productBrand.getDescription());
List<ProductBrandAttribute> globalAttributes = productBrand.getGlobalAttributes();
for (Iterator<ProductBrandAttribute> iterator = globalAttributes.iterator(); iterator.hasNext();) {
ProductBrandAttribute productBrandAttribute = (ProductBrandAttribute) iterator.next();
productBrandForm.getGlobalAttributes().put(productBrandAttribute.getAttributeDefinition().getCode(), productBrandAttribute.getValueAsString());
}
List<ProductBrandAttribute> marketAreaAttributes = productBrand.getMarketAreaAttributes(currentMarketArea.getId());
for (Iterator<ProductBrandAttribute> iterator = marketAreaAttributes.iterator(); iterator.hasNext();) {
ProductBrandAttribute productBrandAttribute = (ProductBrandAttribute) iterator.next();
productBrandForm.getMarketAreaAttributes().put(productBrandAttribute.getAttributeDefinition().getCode(), productBrandAttribute.getValueAsString());
}
}
return productBrandForm;
}