Search in sources :

Example 1 with VoteData

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;
}
Also used : VoteData(com.pratilipi.data.client.VoteData)

Example 2 with 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() };
}
Also used : HashMap(java.util.HashMap) DataAccessor(com.pratilipi.data.DataAccessor) UserPratilipiData(com.pratilipi.data.client.UserPratilipiData) PratilipiData(com.pratilipi.data.client.PratilipiData) CommentData(com.pratilipi.data.client.CommentData) UserPratilipiData(com.pratilipi.data.client.UserPratilipiData) VoteData(com.pratilipi.data.client.VoteData)

Example 3 with VoteData

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();
}
Also used : Task(com.pratilipi.taskqueue.Task) GenericResponse(com.pratilipi.api.shared.GenericResponse) VoteData(com.pratilipi.data.client.VoteData) Post(com.pratilipi.api.annotation.Post)

Aggregations

VoteData (com.pratilipi.data.client.VoteData)3 Post (com.pratilipi.api.annotation.Post)1 GenericResponse (com.pratilipi.api.shared.GenericResponse)1 DataAccessor (com.pratilipi.data.DataAccessor)1 CommentData (com.pratilipi.data.client.CommentData)1 PratilipiData (com.pratilipi.data.client.PratilipiData)1 UserPratilipiData (com.pratilipi.data.client.UserPratilipiData)1 Task (com.pratilipi.taskqueue.Task)1 HashMap (java.util.HashMap)1