Esempio n. 1
0
 /*
  * (non-Javadoc)
  *
  * @see
  * org.openiam.idm.srvc.user.service.UserDataService#getNote(java.lang.String
  * )
  */
 @Transactional(readOnly = true)
 public UserNote getNote(java.lang.String noteId) {
   if (noteId == null) {
     throw new NullPointerException("attrId is null");
   }
   UserNoteEntity userNoteEntity = userNoteDao.findById(noteId);
   return userNoteDozerConverter.convertToDTO(userNoteEntity, true);
 }
Esempio n. 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));
  }
Esempio n. 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);
  }
Esempio n. 4
0
  /*
   * (non-Javadoc)
   *
   * @see
   * org.openiam.idm.srvc.user.service.UserDataService#getAllNotes(java.lang
   * .String)
   */
  @Transactional(readOnly = true)
  public List<UserNote> getAllNotes(String userId) {

    if (userId == null) {
      throw new NullPointerException("userId is null");
    }
    List<UserNoteEntity> noteEntityList = userNoteDao.findUserNotes(userId);
    if (noteEntityList == null || noteEntityList.isEmpty()) {
      return null;
    }

    return userNoteDozerConverter.convertToDTOList(noteEntityList, false);
  }
Esempio n. 5
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);
  }