use of com.pratilipi.data.client.CommentData in project pratilipi by Pratilipi.
the class CommentDataUtil method createCommentData.
public static CommentData createCommentData(Comment comment) {
CommentData commentData = new CommentData(comment.getId());
commentData.setUserId(comment.getUserId());
commentData.setParentType(comment.getParentType());
commentData.setParentId(comment.getParentId());
commentData.setReferenceType(comment.getReferenceType());
commentData.setReferenceId(comment.getReferenceId());
commentData.setContent(comment.getContent());
commentData.setState(comment.getState());
commentData.setCreationDate(comment.getCreationDate());
commentData.setLastUpdated(comment.getLastUpdated());
commentData.setAccessToUpdate(hasAccessToUpdateCommentData(comment));
return commentData;
}
use of com.pratilipi.data.client.CommentData in project pratilipi by Pratilipi.
the class CommentDataUtil method getCommentList.
public static DataListCursorTuple<CommentData> getCommentList(CommentParentType parentType, String parentId, String cursor, Integer offset, Integer resultCount) throws UnexpectedServerException {
DocAccessor docAccessor = DataAccessorFactory.getDocAccessor();
if (parentType == CommentParentType.REVIEW) {
Long userId = Long.parseLong(parentId.substring(0, parentId.indexOf('-')));
Long pratilipiId = Long.parseLong(parentId.substring(parentId.indexOf('-') + 1));
PratilipiReviewsDoc reviewsDoc = docAccessor.getPratilipiReviewsDoc(pratilipiId);
List<CommentDoc> commentDocList = null;
for (UserPratilipiDoc reviewDoc : reviewsDoc.getReviews()) {
if (reviewDoc.getUserId().equals(userId)) {
commentDocList = reviewDoc.getComments();
break;
}
}
int fromIndex = (cursor == null ? 0 : Integer.parseInt(cursor)) + (offset == null ? 0 : offset);
int toIndex = resultCount == null ? commentDocList.size() : fromIndex + resultCount;
commentDocList = commentDocList.subList(Math.min(fromIndex, commentDocList.size()), Math.min(toIndex, commentDocList.size()));
List<CommentData> commentDataList = createCommentDataList(commentDocList);
return new DataListCursorTuple<CommentData>(commentDataList, toIndex + "", (long) (int) reviewsDoc.getReviews().size());
}
return null;
}
use of com.pratilipi.data.client.CommentData in project pratilipi by Pratilipi.
the class EmailDataUtil method _createDataModelForCommentReviewEmail.
private static Object[] _createDataModelForCommentReviewEmail(Long commentId) throws UnexpectedServerException {
DataAccessor dataAccessor = DataAccessorFactory.getDataAccessor();
CommentData comment = CommentDataUtil.createCommentData(dataAccessor.getComment(commentId));
comment.setUser(UserDataUtil.createUserData(dataAccessor.getUser(comment.getUserId())));
UserPratilipiData review = UserPratilipiDataUtil.createUserPratilipiData(dataAccessor.getUserPratilipi(comment.getParentId()));
PratilipiData pratilipi = PratilipiDataUtil.createPratilipiData(dataAccessor.getPratilipi(review.getPratilipiId()));
Map<String, Object> dataModel = new HashMap<>();
dataModel.put("pratilipi_title", pratilipi.getTitle() != null ? pratilipi.getTitle() : pratilipi.getTitleEn());
dataModel.put("pratilipi_page_url", _getDomainName(pratilipi.getLanguage()) + pratilipi.getPageUrl());
dataModel.put("reviewer_name", review.getUser().getAuthor().getName() != null ? review.getUser().getAuthor().getName() : review.getUser().getAuthor().getNameEn());
dataModel.put("reviewer_page_url", _getDomainName(review.getUser().getAuthor().getLanguage()) + review.getUser().getProfilePageUrl());
dataModel.put("reviewer_image_url", review.getUser().getAuthor().getProfileImageUrl(64));
dataModel.put("review_date", _getDateFormat(review.getReviewDate()));
dataModel.put("review_review", HtmlUtil.truncateText(review.getReview(), 250));
dataModel.put("commentor_name", comment.getUser().getAuthor().getName() != null ? comment.getUser().getAuthor().getName() : comment.getUser().getAuthor().getNameEn());
dataModel.put("commentor_page_url", _getDomainName(comment.getUser().getAuthor().getLanguage()) + comment.getUser().getProfilePageUrl());
dataModel.put("commentor_image_url", comment.getUser().getAuthor().getProfileImageUrl(50));
dataModel.put("comment_date", _getDateFormat(comment.getCreationDate()));
dataModel.put("comment_comment", HtmlUtil.truncateText(comment.getContent(), 200));
return new Object[] { dataModel, pratilipi.getLanguage() };
}
use of com.pratilipi.data.client.CommentData in project pratilipi by Pratilipi.
the class CommentDataUtil method createCommentDataList.
public static List<CommentData> createCommentDataList(List<CommentDoc> commentDocList) {
List<Long> userIdList = new ArrayList<>(commentDocList.size());
for (CommentDoc commentDoc : commentDocList) if (!userIdList.contains(commentDoc.getUserId()))
userIdList.add(commentDoc.getUserId());
Map<Long, UserData> userDataMap = UserDataUtil.createUserDataList(userIdList, true);
List<CommentData> commentDataList = new ArrayList<>(commentDocList.size());
for (CommentDoc commentDoc : commentDocList) {
CommentData commentData = createCommentData(commentDoc);
commentData.setUser(userDataMap.get(commentDoc.getUserId()));
commentDataList.add(commentData);
}
return commentDataList;
}
use of com.pratilipi.data.client.CommentData in project pratilipi by Pratilipi.
the class EmailDataUtil method _createDataModelForVoteCommentEmail.
private static Object[] _createDataModelForVoteCommentEmail(String voteId) throws UnexpectedServerException {
DataAccessor dataAccessor = DataAccessorFactory.getDataAccessor();
VoteData vote = VoteDataUtil.createVoteData(dataAccessor.getVote(voteId));
vote.setUser(UserDataUtil.createUserData(dataAccessor.getUser(vote.getUserId())));
CommentData comment = CommentDataUtil.createCommentData(dataAccessor.getComment(vote.getParentIdLong()));
comment.setUser(UserDataUtil.createUserData(dataAccessor.getUser(comment.getUserId())));
UserPratilipiData review = UserPratilipiDataUtil.createUserPratilipiData(dataAccessor.getUserPratilipi(comment.getParentId()));
PratilipiData pratilipi = PratilipiDataUtil.createPratilipiData(dataAccessor.getPratilipi(review.getPratilipiId()));
Map<String, Object> dataModel = new HashMap<>();
dataModel.put("voter_name", vote.getUser().getAuthor().getName() != null ? vote.getUser().getAuthor().getName() : vote.getUser().getAuthor().getNameEn());
dataModel.put("pratilipi_title", pratilipi.getTitle() != null ? pratilipi.getTitle() : pratilipi.getTitleEn());
dataModel.put("pratilipi_page_url", _getDomainName(pratilipi.getLanguage()) + pratilipi.getPageUrl());
dataModel.put("reviewer_name", review.getUser().getAuthor().getName() != null ? review.getUser().getAuthor().getName() : review.getUser().getAuthor().getNameEn());
dataModel.put("reviewer_page_url", _getDomainName(review.getUser().getAuthor().getLanguage()) + review.getUser().getProfilePageUrl());
dataModel.put("reviewer_image_url", review.getUser().getAuthor().getProfileImageUrl(64));
dataModel.put("review_date", _getDateFormat(review.getReviewDate()));
dataModel.put("review_review", HtmlUtil.truncateText(review.getReview(), 250));
dataModel.put("commentor_name", comment.getUser().getAuthor().getName() != null ? comment.getUser().getAuthor().getName() : comment.getUser().getAuthor().getNameEn());
dataModel.put("commentor_page_url", _getDomainName(comment.getUser().getAuthor().getLanguage()) + comment.getUser().getProfilePageUrl());
dataModel.put("commentor_image_url", comment.getUser().getAuthor().getProfileImageUrl(50));
dataModel.put("comment_date", _getDateFormat(comment.getCreationDate()));
dataModel.put("comment_comment", HtmlUtil.truncateText(comment.getContent(), 200));
return new Object[] { dataModel, pratilipi.getLanguage() };
}
Aggregations