*
*/
public CompanyViewBean buildViewBeanCompany(final RequestData requestData, final Company company) throws Exception {
final Locale locale = requestData.getLocale();
final CompanyViewBean companyViewBean = new CompanyViewBean();
companyViewBean.setId(company.getId());
companyViewBean.setCode(company.getCode());
companyViewBean.setName(company.getName());
companyViewBean.setDescription(company.getDescription());
companyViewBean.setAddress1(company.getAddress1());
companyViewBean.setAddress2(company.getAddress2());
companyViewBean.setAddressAdditionalInformation(company.getAddressAdditionalInformation());
companyViewBean.setPostalCode(company.getPostalCode());
companyViewBean.setCity(company.getCity());
String stateName = referentialDataService.getStateByLocale(company.getStateCode(), locale);
companyViewBean.setStateCode(company.getStateCode());
companyViewBean.setStateName(stateName);
String areaName = referentialDataService.getAreaByLocale(company.getAreaCode(), locale);
companyViewBean.setAreaCode(company.getAreaCode());
companyViewBean.setAreaName(areaName);
String countryName = referentialDataService.getCountryByLocale(company.getCountryCode(), locale);
companyViewBean.setCountryCode(company.getCountryCode());
companyViewBean.setCountryName(countryName);
DateFormat dateFormat = requestUtil.getFormatDate(requestData, DateFormat.MEDIUM, DateFormat.MEDIUM);
if (company.getDateCreate() != null) {
companyViewBean.setDateCreate(dateFormat.format(company.getDateCreate()));
} else {
companyViewBean.setDateCreate(Constants.NOT_AVAILABLE);
}
if (company.getDateUpdate() != null) {
companyViewBean.setDateUpdate(dateFormat.format(company.getDateUpdate()));
} else {
companyViewBean.setDateUpdate(Constants.NOT_AVAILABLE);
}
companyViewBean.setDetailsUrl(backofficeUrlService.generateUrl(BoUrls.COMPANY_DETAILS, requestData, company));
companyViewBean.setEditUrl(backofficeUrlService.generateUrl(BoUrls.COMPANY_EDIT, requestData, company));
return companyViewBean;
}