Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public ModelBO update(UserDTO userDto, long userId) throws NonExistingEntityException {
- final ModelDTO dto = castToSpecificDto(userDto);
- final ModelTable existing = castToSpecificTable(userRepository.findByUserId(userId));
- if (existing == null) {
- throw new NonExistingEntityException(String.format("User with a given id='%d' doesn't exist.", userId));
- }
- final ModelTable updated = new ModelTable(existing.getUserTablePK().getUserId(),
- dto.getEthnicity() != null ? dto.getEthnicity() : existing.getEthnicity(), dto.getHeight() != null ? dto.getHeight() : existing.getHeight(),
- dto.getBust() != null ? dto.getBust() : existing.getBust(), dto.getWaist() != null ? dto.getWaist() : existing.getWaist(),
- dto.getHips() != null ? dto.getHips() : existing.getHips(), dto.getShoes() != null ? dto.getShoes() : existing.getShoes(),
- dto.getEyes() != null ? dto.getEyes() : existing.getEyes(), dto.getHair() != null ? dto.getHair() : existing.getHair(), existing.getEmail(), // can't
- // change
- // email
- // here
- existing.getPassword(), // can't change password here
- dto.getFirstName() != null ? dto.getFirstName() : existing.getFirstName(),
- dto.getLastName() != null ? dto.getLastName() : existing.getLastName(),
- dto.getDateOfBirth() != null ? dto.getDateOfBirth() : existing.getDateOfBirth(),
- dto.getGender() != null ? dto.getGender() : existing.getGender(), existing.getProfileType(), // can't
- // change
- // profile
- // type
- dto.getAboutMe() != null ? dto.getAboutMe() : existing.getAboutMe(), existing.getDateJoined(), // can't
- // change
- // date
- // joined
- dto.getContactNumber() != null ? dto.getContactNumber() : existing.getContactNumber(),
- dto.getBase() != null ? dto.getBase() : existing.getBase());
- userRepository.save(updated);
- return new ModelBO(updated);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement