List of usage examples for com.liferay.portal.kernel.comment Comment getCommentId
public long getCommentId();
From source file:com.liferay.comment.demo.data.creator.internal.MultipleCommentDemoDataCreatorImpl.java
License:Open Source License
private int _addComments(List<Long> userIds, ClassedModel classedModel, long commentId, int maxComments, int level) throws PortalException { int commentsCount = 0; int maxReplies = RandomUtil.nextInt(_MAX_REPLIES / level); int repliesCount = 0; while ((commentsCount < maxComments) && (repliesCount < maxReplies)) { Comment comment = null; long userId = _getRandomElement(userIds); if (commentId == _COMMENT_ID) { comment = _commentDemoDataCreator.create(userId, classedModel); } else {/* w w w. j a v a2 s . c o m*/ comment = _commentDemoDataCreator.create(userId, commentId); repliesCount++; } commentsCount++; if (level < _MAX_LEVEL) { commentsCount += _addComments(userIds, classedModel, comment.getCommentId(), maxComments - commentsCount, level + 1); } } return commentsCount; }
From source file:com.liferay.message.boards.comment.internal.search.SearchResultUtilMBMessageTest.java
License:Open Source License
@Test public void testMBMessageAttachment() throws Exception { SearchResult searchResult = assertOneSearchResult( SearchTestUtil.createAttachmentDocument(_MB_MESSAGE_CLASS_NAME)); Assert.assertEquals(SearchTestUtil.ATTACHMENT_OWNER_CLASS_NAME, searchResult.getClassName()); Assert.assertEquals(SearchTestUtil.ATTACHMENT_OWNER_CLASS_PK, searchResult.getClassPK()); List<RelatedSearchResult<Comment>> relatedSearchResults = searchResult.getCommentRelatedSearchResults(); RelatedSearchResult<Comment> relatedSearchResult = relatedSearchResults.get(0); Comment comment = relatedSearchResult.getModel(); Assert.assertEquals(_mbMessage.getMessageId(), comment.getCommentId()); Assert.assertEquals(relatedSearchResults.toString(), 1, relatedSearchResults.size()); Assert.assertNull(searchResult.getSummary()); assertEmptyFileEntryRelatedSearchResults(searchResult); assertEmptyVersions(searchResult);// ww w .j av a 2s. com }
From source file:com.liferay.message.boards.comment.search.SearchResultUtilMBMessageTest.java
License:Open Source License
@Test public void testMBMessageAttachment() throws Exception { SearchResult searchResult = assertOneSearchResult( SearchTestUtil.createAttachmentDocument(_MB_MESSAGE_CLASS_NAME)); Assert.assertEquals(SearchTestUtil.ATTACHMENT_OWNER_CLASS_NAME, searchResult.getClassName()); Assert.assertEquals(SearchTestUtil.ATTACHMENT_OWNER_CLASS_PK, searchResult.getClassPK()); List<RelatedSearchResult<Comment>> relatedSearchResults = searchResult.getCommentRelatedSearchResults(); RelatedSearchResult<Comment> relatedSearchResult = relatedSearchResults.get(0); Comment comment = relatedSearchResult.getModel(); Assert.assertEquals(_mbMessage.getMessageId(), comment.getCommentId()); Assert.assertEquals(1, relatedSearchResults.size()); Assert.assertNull(searchResult.getSummary()); assertEmptyFileEntryRelatedSearchResults(searchResult); assertEmptyVersions(searchResult);/*from w w w . jav a 2 s . c o m*/ }
From source file:com.liferay.screens.service.impl.ScreensCommentServiceImpl.java
License:Open Source License
protected JSONObject toJSONObject(Comment comment, DiscussionPermission discussionPermission) throws PortalException { JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); jsonObject.put("body", comment.getBody()); jsonObject.put("commentId", Long.valueOf(comment.getCommentId())); Date createDate = comment.getCreateDate(); jsonObject.put("createDate", Long.valueOf(createDate.getTime())); jsonObject.put("deletePermission", discussionPermission.hasDeletePermission(comment.getCommentId())); Date modifiedDate = comment.getModifiedDate(); jsonObject.put("modifiedDate", Long.valueOf(modifiedDate.getTime())); jsonObject.put("updatePermission", discussionPermission.hasUpdatePermission(comment.getCommentId())); jsonObject.put("userId", Long.valueOf(comment.getUserId())); jsonObject.put("userName", comment.getUserName()); return jsonObject; }