use of com.pratilipi.data.client.VoteData in project pratilipi by Pratilipi.
the class VoteDataUtil method createVoteData.
public static VoteData createVoteData(Vote vote) {
VoteData voteData = new VoteData(vote.getId());
voteData.setUserId(vote.getUserId());
voteData.setParentType(vote.getParentType());
voteData.setParentId(vote.getParentId());
voteData.setReferenceType(vote.getReferenceType());
voteData.setReferenceId(vote.getReferenceId());
voteData.setType(vote.getType());
voteData.setCreationDate(vote.getCreationDate());
voteData.setLastUpdated(vote.getLastUpdated());
return voteData;
}
use of com.pratilipi.data.client.VoteData 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.VoteData in project pratilipi by Pratilipi.
the class VoteApi method post.
@Post
public GenericResponse post(PostRequest request) throws InvalidArgumentException, InsufficientAccessException {
VoteData voteData = VoteDataUtil.saveVoteData(AccessTokenFilter.getAccessToken().getUserId(), request.parentType, request.parentId, request.type);
if (voteData.getReferenceType() == ReferenceType.PRATILIPI) {
Task task = TaskQueueFactory.newTask().setUrl("/pratilipi/process").addParam("pratilipiId", voteData.getReferenceId()).addParam("updateReviewsDoc", "true");
TaskQueueFactory.getPratilipiTaskQueue().add(task);
}
return new GenericResponse();
}
Aggregations