}
public ProductMarketingForm buildProductMarketingForm(final RequestData requestData, final ProductMarketing productMarketing) throws Exception {
final MarketArea currentMarketArea = requestData.getMarketArea();
final ProductMarketingForm productMarketingForm = new ProductMarketingForm();
if(productMarketing != null){
productMarketingForm.setId(productMarketing.getId().toString());
productMarketingForm.setName(productMarketing.getName());
productMarketingForm.setCode(productMarketing.getCode());
productMarketingForm.setDescription(productMarketing.getDescription());
List<ProductMarketingAttribute> globalAttributes = productMarketing.getGlobalAttributes();
for (Iterator<ProductMarketingAttribute> iterator = globalAttributes.iterator(); iterator.hasNext();) {
ProductMarketingAttribute productMarketingAttribute = (ProductMarketingAttribute) iterator.next();
productMarketingForm.getGlobalAttributes().put(productMarketingAttribute.getAttributeDefinition().getCode(), productMarketingAttribute.getValueAsString());
}
List<ProductMarketingAttribute> marketAreaAttributes = productMarketing.getMarketAreaAttributes(currentMarketArea.getId());
for (Iterator<ProductMarketingAttribute> iterator = marketAreaAttributes.iterator(); iterator.hasNext();) {
ProductMarketingAttribute productMarketingAttribute = (ProductMarketingAttribute) iterator.next();
productMarketingForm.getMarketAreaAttributes().put(productMarketingAttribute.getAttributeDefinition().getCode(), productMarketingAttribute.getValueAsString());
}
}
return productMarketingForm;
}