@SuppressWarnings("deprecation")
@Override
public Customer convertFrom(CustomerEntity source, Customer destination) {
Customer result = null;
CustomerEntity tmp = null;
if (source != null) {
tmp = HibernateHelper.initializeAndUnproxy(source);
}
if (tmp instanceof CorporateCustomerEntity) {
CorporateCustomer corporateCustomer = new CorporateCustomer();
corporateCustomer.setId(tmp.getId());
corporateCustomer.setApartment(tmp.getApartment());
List<Car> cars = DozerHelper.mapList(tmp.getCars(), Car.class);
corporateCustomer.setCars(cars);
corporateCustomer.setCity(tmp.getCity());
corporateCustomer.setCompanyName(((CorporateCustomerEntity) tmp)
.getCompanyName());
corporateCustomer.setCountry(tmp.getCountry());
corporateCustomer.setEmail(tmp.getEmail());
corporateCustomer.setHouse(tmp.getHouse());
corporateCustomer.setHousing(tmp.getHousing());
corporateCustomer.setName(tmp.getName());
corporateCustomer.setPassword(tmp.getPassword());
corporateCustomer.setPatronymic(tmp.getPatronymic());
corporateCustomer.setPhone(tmp.getPhone());
corporateCustomer.setProvince(tmp.getProvince());
corporateCustomer.setRole(tmp.getRole());
corporateCustomer.setStreet(tmp.getStreet());
corporateCustomer.setSurname(tmp.getSurname());
corporateCustomer.setVatRegNo(((CorporateCustomerEntity) tmp)
.getVatRegNo());
corporateCustomer.setZip(tmp.getZip());
result = corporateCustomer;
}
if (tmp instanceof PersonalCustomerEntity) {
PersonalCustomer personalCustomer = new PersonalCustomer();
personalCustomer.setId(tmp.getId());
personalCustomer.setApartment(tmp.getApartment());
List<Car> cars = DozerHelper.mapList(tmp.getCars(), Car.class);
personalCustomer.setCars(cars);
personalCustomer.setCity(tmp.getCity());
personalCustomer.setCountry(tmp.getCountry());
personalCustomer.setEmail(tmp.getEmail());
personalCustomer.setHouse(tmp.getHouse());
personalCustomer.setHousing(tmp.getHousing());
personalCustomer.setName(tmp.getName());
personalCustomer.setPassword(tmp.getPassword());
personalCustomer.setPatronymic(tmp.getPatronymic());
personalCustomer.setPhone(tmp.getPhone());
personalCustomer.setProvince(tmp.getProvince());
personalCustomer.setRole(tmp.getRole());
personalCustomer.setStreet(tmp.getStreet());
personalCustomer.setSurname(tmp.getSurname());
personalCustomer.setZip(tmp.getZip());
personalCustomer.setBirthdate(((PersonalCustomerEntity) tmp)
.getBirthdate());
personalCustomer.setPassportRegNo(((PersonalCustomerEntity) tmp)
.getPassportRegNo());