use of com.pratilipi.data.client.UserPratilipiData in project pratilipi by Pratilipi.
the class UserPratilipiDataUtil method createUserPratilipiData.
private static UserPratilipiData createUserPratilipiData(UserPratilipiDoc userPratilipiDoc) {
DataAccessor dataAccessor = DataAccessorFactory.getDataAccessor();
User user = dataAccessor.getUser(userPratilipiDoc.getUserId());
UserData userData = UserDataUtil.createUserData(user);
UserPratilipiData userPratilipiData = new UserPratilipiData();
userPratilipiData.setId(userPratilipiDoc.getId());
userPratilipiData.setUserId(userPratilipiDoc.getUserId());
userPratilipiData.setUser(userData);
userPratilipiData.setUserName(userData.getDisplayName());
userPratilipiData.setUserImageUrl(userData.getProfileImageUrl());
userPratilipiData.setUserProfilePageUrl(userData.getProfilePageUrl());
userPratilipiData.setRating(userPratilipiDoc.getRating());
userPratilipiData.setReview(processReview(userPratilipiDoc.getReviewTitle(), userPratilipiDoc.getReview()));
userPratilipiData.setReviewDate(userPratilipiDoc.getReviewDate());
userPratilipiData.setLikeCount(userPratilipiDoc.getLikeCount());
userPratilipiData.setCommentCount(userPratilipiDoc.getCommentCount());
userPratilipiData.setLiked(userPratilipiDoc.getLikedByUserIds().contains(AccessTokenFilter.getAccessToken().getUserId()));
return userPratilipiData;
}
use of com.pratilipi.data.client.UserPratilipiData 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() };
}
use of com.pratilipi.data.client.UserPratilipiData in project pratilipi by Pratilipi.
the class EmailDataUtil method _createDataModelForVoteReviewEmail.
private static Object[] _createDataModelForVoteReviewEmail(String voteId) throws UnexpectedServerException {
DataAccessor dataAccessor = DataAccessorFactory.getDataAccessor();
Vote vote = dataAccessor.getVote(voteId);
UserPratilipiData userPratilipi = UserPratilipiDataUtil.createUserPratilipiData(dataAccessor.getUserPratilipi(vote.getParentId()));
PratilipiData pratilipi = PratilipiDataUtil.createPratilipiData(dataAccessor.getPratilipi(userPratilipi.getPratilipiId()));
UserData voter = UserDataUtil.createUserData(dataAccessor.getUser(vote.getUserId()));
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_page_url", _getDomainName(userPratilipi.getUser().getLanguage()) + userPratilipi.getUser().getProfilePageUrl());
dataModel.put("reviewer_image_url", userPratilipi.getUser().getAuthor().getProfileImageUrl(64));
dataModel.put("reviewer_name", userPratilipi.getUser().getAuthor().getName() != null ? userPratilipi.getUser().getAuthor().getName() : userPratilipi.getUser().getAuthor().getNameEn());
dataModel.put("review_creation_date", _getDateFormat(userPratilipi.getReviewDate()));
dataModel.put("review_review", HtmlUtil.toPlainText(userPratilipi.getReview()));
if (userPratilipi.getRating() != null)
dataModel.put("rating", userPratilipi.getRating());
dataModel.put("voter_name", voter.getAuthor().getName() != null ? voter.getAuthor().getName() : voter.getAuthor().getNameEn());
return new Object[] { dataModel, pratilipi.getLanguage() };
}
Aggregations