@Override
public void submitView(AjaxRequestTarget target, List<User> usersToAdd) {
// TODO Auto-generated method stub
long roomId = getModelObject().getRooms_id();
RoomModeratorsDao moderatorsDao = getBean(RoomModeratorsDao.class);
List<RoomModerator> moderators = moderatorsDao.getRoomModeratorByRoomId(roomId);
moderatorsInRoom = (moderatorsInRoom == null) ? new ArrayList<RoomModerator>() : moderatorsInRoom;
for (User u : usersToAdd) {
boolean found = false;
for ( RoomModerator rm : moderators) {
if (rm.getUser().getUser_id().equals(u.getUser_id())) {
found = true;
break;
}
}
if (!found) {
RoomModerator rModerator = new RoomModerator();
rModerator.setUser(u);
rModerator.setIsSuperModerator(false);
rModerator.setStarttime(new Date());
rModerator.setDeleted(false);
rModerator.setRoomId(roomId);
moderatorsInRoom.add(rModerator);
moderatorsDao.addRoomModeratorByUserId(u, false, roomId);
}
}
updateModerators(target);
}