Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private Client mergeClient(Client client) {
- LOG.debug("start mergeClient");
- if (client == null) {
- return null;
- }
- LOG.debug("merging client with pwId[" + client.getId() + "] sw_id[" + client.getSeawareId() + "]");
- Client storedClient = applicationDao.fetchByRestrictions(Client.class, new Restriction("seawareId", client.getSeawareId()));
- if (storedClient != null && !storedClient.getId().equals(client.getId())) {
- LOG.debug("storedClient client with pwId[" + storedClient.getId() + "] sw_id[" + storedClient.getSeawareId() + "]");
- for (Guest guest : storedClient.getGuests()) {
- guest.setClient(null);
- applicationService.update(guest);
- }
- for (Reservation reservation : storedClient.getReservations()) {
- reservation.setReservationContact(null);
- applicationService.update(reservation);
- }
- storedClient.getGuests().clear();
- storedClient.getReservations().clear();
- applicationService.delete(storedClient.getId(), Client.class);
- }
- LOG.debug("client was merged pwId[" + client.getId() + "] sw_id[" + client.getSeawareId() + "]");
- return applicationService.merge(client);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement