Пример #1
0
  /*
   * (non-Javadoc)
   *
   * @see
   * org.openiam.idm.srvc.user.service.UserDataService#updateNote(org.openiam
   * .idm.srvc.user.dto.UserNote)
   */
  @Transactional
  public void updateNote(UserNote note) {
    if (note == null) throw new NullPointerException("Note cannot be null");
    if (StringUtils.isEmpty(note.getUserNoteId())) {
      throw new NullPointerException("noteId is null");
    }
    if (StringUtils.isEmpty(note.getUserId())) {
      throw new NullPointerException("User is not associated with this note.");
    }

    UserEntity usr = userDao.findById(note.getUserId());

    UserNoteEntity userNoteEntity = userNoteDozerConverter.convertToEntity(note, true);
    if (userNoteEntity.getUser() == null) {
      userNoteEntity.setUser(usr);
    }

    userNoteDao.merge(userNoteEntity);
  }
Пример #2
0
  /*
   * (non-Javadoc)
   *
   * @see
   * org.openiam.idm.srvc.user.service.UserDataService#removeNote(org.openiam
   * .idm.srvc.user.dto.UserNote)
   */
  @Transactional
  public void removeNote(UserNote note) {
    if (note == null) {
      throw new NullPointerException("note is null");
    }
    if (note.getUserNoteId() == null) {
      throw new NullPointerException("noteId is null");
    }

    userNoteDao.delete(userNoteDozerConverter.convertToEntity(note, true));
  }
Пример #3
0
  /*
   * (non-Javadoc)
   *
   * @see
   * org.openiam.idm.srvc.user.service.UserDataService#addNote(org.openiam
   * .idm.srvc.user.dto.UserNote)
   */
  @Transactional
  public UserNote addNote(UserNote note) {
    if (note == null) throw new NullPointerException("Note cannot be null");

    if (note.getUserId() == null) {
      throw new NullPointerException("User is not associated with this note.");
    }

    UserEntity usr = userDao.findById(note.getUserId());

    UserNoteEntity userNoteEntity = userNoteDozerConverter.convertToEntity(note, true);

    if (userNoteEntity.getUser() == null) {
      userNoteEntity.setUser(usr);
    }

    userNoteDao.persist(userNoteEntity);

    return userNoteDozerConverter.convertToDTO(userNoteEntity, true);
  }