errors.rejectValue("phoneNumber", "register.wrongphone");
return showForm(request, errors, getFormView());
}
//end checkDTO
Client client = clientDTO.getClient();
if (client == null) {
client = new Client();
try {
Address address = createAddress(clientDTO);
client.setAddressID(address.getId());
client.setAddressCashe(address.getAsStringCashe());
} catch (Exception ex) {
errors.rejectValue("area", "register.wrongaddress");
return showForm(request, errors, getFormView());
}
}else{
Address address = getDao().getById(Address.class, client.getAddressID());
address.setAddressObject(clientDTO.getStreet());
address.setBuilding(clientDTO.getBuilding());
address.setFlat(clientDTO.getFlat());
try {
AddressManager.correctAddress(getDao(), address);
} catch (Exception ex) {
errors.rejectValue("area", "register.wrongaddress");
return showForm(request, errors, getFormView());
}
getDao().save(address);
client.setAddressCashe(address.getAsStringCashe());
}
client.setBorn(getBornDate(clientDTO));
//STUB
//client.setAddress(null);
//client.setDistrict(null);
//client.setOms(urdto.getOms());
//END STUB
client.setName(getDirectoryItem(Name.class, clientDTO.getName()));
client.setPatronymic(getDirectoryItem(Patronymic.class, clientDTO.getPatronymic()));
client.setTelephones(clientDTO.getPhoneNumber());
client.setSex(clientDTO.getSex());
client.setSurname(getDirectoryItem(Surname.class, clientDTO.getSurname()));
getDao().save(client);
return new ModelAndView("redirect:selectclient.htm");
}