Advertisement
Guest User

Untitled

a guest
Jan 27th, 2015
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.30 KB | None | 0 0
  1. private Client mergeClient(Client client) {
  2.         LOG.debug("start mergeClient");
  3.         if (client == null) {
  4.             return null;
  5.         }
  6.         LOG.debug("merging client with pwId[" + client.getId() + "] sw_id[" + client.getSeawareId() + "]");
  7.         Client storedClient = applicationDao.fetchByRestrictions(Client.class, new Restriction("seawareId", client.getSeawareId()));
  8.         if (storedClient != null && !storedClient.getId().equals(client.getId())) {
  9.             LOG.debug("storedClient client with pwId[" + storedClient.getId() + "] sw_id[" + storedClient.getSeawareId() + "]");
  10.             for (Guest guest : storedClient.getGuests()) {
  11.                 guest.setClient(null);
  12.                 applicationService.update(guest);
  13.             }
  14.             for (Reservation reservation : storedClient.getReservations()) {
  15.                 reservation.setReservationContact(null);
  16.                 applicationService.update(reservation);
  17.             }
  18.             storedClient.getGuests().clear();
  19.             storedClient.getReservations().clear();
  20.             applicationService.delete(storedClient.getId(), Client.class);
  21.         }
  22.         LOG.debug("client was merged pwId[" + client.getId() + "] sw_id[" + client.getSeawareId() + "]");
  23.         return applicationService.merge(client);
  24.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement