/** * Creates data transfer object, that represents info about the poll option. * * @param option the poll option */ public PollOptionDto(PollItem option) { this.id = option.getId(); this.votesCount = option.getVotesCount(); }
/** * {@inheritDoc} */ @Override @PreAuthorize("hasPermission(#pollId, 'POLL', 'GeneralPermission.WRITE')") public Poll vote(Long pollId, List<Long> selectedOptionsIds) { Poll poll = getDao().get(pollId); if (poll.isActive()) { prohibitRevote(poll); for (PollItem option : poll.getPollItems()) { if (selectedOptionsIds.contains(option.getId())) { option.increaseVotesCount(); pollOptionDao.saveOrUpdate(option); } } } return poll; }