Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. @Override
  2. public void create(DistrictsJSONImportDto model) {
  3. if (!ValidationUtil.isValid(model)){
  4. throw new IllegalArgumentException();
  5. }
  6. Town town = townRepository.findByName(model.getTownName());
  7. District district = districtRepository.findByName(model.getName());
  8. if (district != null){
  9. throw new IllegalStateException("duplicate data");
  10. }
  11. district = mapper.convert(model, District.class);
  12. district.setTown(town);
  13. districtRepository.save(district);
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement