public void hideAnonymous(UserDao userDao, Set<Integer> hideSet) throws SQLException, UserNotFoundException { if (comment != null) { User commentAuthor = userDao.getUserCached(comment.getUserid()); if (commentAuthor.isAnonymousScore()) { hideNode(hideSet); } } if (comment == null || !hideSet.contains(comment.getId())) { for (CommentNode child : childs) { child.hideAnonymous(userDao, hideSet); } } }
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED) public void deleteImage(User editor, Image image) { EditHistoryDto info = new EditHistoryDto(); info.setEditor(editor.getId()); info.setMsgid(image.getTopicId()); info.setOldimage(image.getId()); info.setObjectType(EditHistoryObjectTypeEnum.TOPIC); imageDao.deleteImage(image); editHistoryService.insert(info); topicDao.updateLastmod(image.getTopicId(), false); }
public List<TrackerItem> getTrackAll( TrackerFilterEnum filter, User currentUser, Date startDate, int topics, int offset, final int messagesInPage) { MapSqlParameterSource parameter = new MapSqlParameterSource(); parameter.addValue("interval", startDate); parameter.addValue("topics", topics); parameter.addValue("offset", offset); String partIgnored; if (currentUser != null) { partIgnored = queryPartIgnored + queryPartTagIgnored; parameter.addValue("userid", currentUser.getId()); } else { partIgnored = ""; } String partFilter; switch (filter) { case ALL: partFilter = ""; break; case NOTALKS: partFilter = queryPartNoTalks; break; case MAIN: partFilter = queryPartMain; break; case TECH: partFilter = queryPartTech; break; default: partFilter = ""; } boolean showUncommited = currentUser != null && (currentUser.isModerator() || currentUser.isCorrector()); String partUncommited = showUncommited ? "" : noUncommited; String query; query = String.format( queryTrackerMain, partUncommited, partIgnored, partFilter, partUncommited, partIgnored, partFilter); SqlRowSet resultSet = jdbcTemplate.queryForRowSet(query, parameter); List<TrackerItem> res = new ArrayList<>(topics); while (resultSet.next()) { User author = userDao.getUserCached(resultSet.getInt("author")); int msgid = resultSet.getInt("id"); Timestamp lastmod = resultSet.getTimestamp("lastmod"); int stat1 = resultSet.getInt("stat1"); int groupId = resultSet.getInt("gid"); String groupTitle = resultSet.getString("gtitle"); String title = StringUtil.makeTitle(resultSet.getString("title")); int cid = resultSet.getInt("cid"); User lastCommentBy; try { int id = resultSet.getInt("last_comment_by"); if (id != 0) { lastCommentBy = userDao.getUserCached(id); } else { lastCommentBy = null; } } catch (UserNotFoundException e) { throw new RuntimeException(e); } boolean resolved = resultSet.getBoolean("resolved"); int section = resultSet.getInt("section"); String groupUrlName = resultSet.getString("urlname"); Timestamp postdate = resultSet.getTimestamp("postdate"); boolean uncommited = resultSet.getBoolean("smod") && !resultSet.getBoolean("moderate"); int pages = Topic.getPageCount(stat1, messagesInPage); ImmutableList<String> tags; tags = topicTagService.getTagsForTitle(msgid); res.add( new TrackerItem( author, msgid, lastmod, stat1, groupId, groupTitle, title, cid, lastCommentBy, resolved, section, groupUrlName, postdate, uncommited, pages, tags)); } return res; }