Search in sources :

Example 11 with PratilipiData

use of com.pratilipi.data.client.PratilipiData in project pratilipi by Pratilipi.

the class PratilipiSite method createDataModelForLibraryPage.

private Map<String, Object> createDataModelForLibraryPage(boolean basicMode, Language filterLanguage) throws UnexpectedServerException {
    DataListCursorTuple<PratilipiData> pratilipiDataListCursorTuple = UserPratilipiDataUtil.getUserLibrary(AccessTokenFilter.getAccessToken().getUserId(), null, null, null);
    Map<String, Object> dataModel = new HashMap<String, Object>();
    dataModel.put("title", SEOTitleUtil.getLibraryPageTitle(filterLanguage));
    if (basicMode) {
        dataModel.put("pratilipiList", toListResponseObject(pratilipiDataListCursorTuple.getDataList()));
    } else {
        Gson gson = new Gson();
        dataModel.put("pratilipiListJson", gson.toJson(toListResponseObject(pratilipiDataListCursorTuple.getDataList())));
        dataModel.put("pratilipiListCursor", pratilipiDataListCursorTuple.getCursor());
    }
    return dataModel;
}
Also used : HashMap(java.util.HashMap) PratilipiData(com.pratilipi.data.client.PratilipiData) Gson(com.google.gson.Gson) JsonObject(com.google.gson.JsonObject)

Example 12 with PratilipiData

use of com.pratilipi.data.client.PratilipiData in project pratilipi by Pratilipi.

the class PratilipiV1Api method get.

@Get
public Response get(GetRequest request) throws UnexpectedServerException {
    DataAccessor dataAccessor = DataAccessorFactory.getDataAccessor();
    Pratilipi pratilipi = dataAccessor.getPratilipi(request.pratilipiId);
    Author author = pratilipi.getAuthorId() == null ? null : dataAccessor.getAuthor(pratilipi.getAuthorId());
    PratilipiData pratilipiData = PratilipiDataUtil.createPratilipiData(pratilipi, author);
    if (UxModeFilter.isAndroidApp()) {
        DocAccessor docAccessor = DataAccessorFactory.getDocAccessor();
        PratilipiContentDoc pcDoc = docAccessor.getPratilipiContentDoc(request.pratilipiId);
        pratilipiData.setIndex(pcDoc == null ? null : pcDoc.getIndex());
    }
    return new Response(pratilipiData);
}
Also used : GenericResponse(com.pratilipi.api.shared.GenericResponse) DataAccessor(com.pratilipi.data.DataAccessor) PratilipiData(com.pratilipi.data.client.PratilipiData) DocAccessor(com.pratilipi.data.DocAccessor) Author(com.pratilipi.data.type.Author) Pratilipi(com.pratilipi.data.type.Pratilipi) PratilipiContentDoc(com.pratilipi.data.type.PratilipiContentDoc) Get(com.pratilipi.api.annotation.Get)

Example 13 with PratilipiData

use of com.pratilipi.data.client.PratilipiData in project pratilipi by Pratilipi.

the class EmailDataUtil method _createDataModelForPratilipiPublishedEmail.

private static Object[] _createDataModelForPratilipiPublishedEmail(Long pratilipiId) throws UnexpectedServerException {
    DataAccessor dataAccessor = DataAccessorFactory.getDataAccessor();
    PratilipiData pratilipi = PratilipiDataUtil.createPratilipiData(dataAccessor.getPratilipi(pratilipiId));
    Map<String, Object> dataModel = new HashMap<>();
    dataModel.put("pratilipi_title", pratilipi.getTitle() != null ? pratilipi.getTitle() : pratilipi.getTitleEn());
    dataModel.put("pratilipi_cover_image_url", pratilipi.getCoverImageUrl(150));
    dataModel.put("pratilipi_listing_date", _getDateFormat(pratilipi.getListingDate()));
    dataModel.put("pratilipi_summary", HtmlUtil.truncateText(pratilipi.getSummary(), 250));
    dataModel.put("pratilipi_page_url", _getDomainName(pratilipi.getLanguage()) + pratilipi.getPageUrl());
    dataModel.put("author_name", pratilipi.getAuthor().getName() != null ? pratilipi.getAuthor().getName() : pratilipi.getAuthor().getNameEn());
    dataModel.put("author_page_url", _getDomainName(pratilipi.getLanguage()) + pratilipi.getAuthor().getPageUrl());
    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)

Example 14 with PratilipiData

use of com.pratilipi.data.client.PratilipiData 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 15 with PratilipiData

use of com.pratilipi.data.client.PratilipiData 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() };
}
Also used : Vote(com.pratilipi.data.type.Vote) UserData(com.pratilipi.data.client.UserData) HashMap(java.util.HashMap) DataAccessor(com.pratilipi.data.DataAccessor) UserPratilipiData(com.pratilipi.data.client.UserPratilipiData) PratilipiData(com.pratilipi.data.client.PratilipiData) UserPratilipiData(com.pratilipi.data.client.UserPratilipiData)

Aggregations

PratilipiData (com.pratilipi.data.client.PratilipiData)20 DataAccessor (com.pratilipi.data.DataAccessor)15 HashMap (java.util.HashMap)9 Get (com.pratilipi.api.annotation.Get)5 UserPratilipiData (com.pratilipi.data.client.UserPratilipiData)5 Pratilipi (com.pratilipi.data.type.Pratilipi)5 LinkedList (java.util.LinkedList)5 Gson (com.google.gson.Gson)4 GenericResponse (com.pratilipi.api.shared.GenericResponse)4 PratilipiFilter (com.pratilipi.common.util.PratilipiFilter)4 PratilipiContentDoc (com.pratilipi.data.type.PratilipiContentDoc)4 JsonObject (com.google.gson.JsonObject)3 DocAccessor (com.pratilipi.data.DocAccessor)3 UserData (com.pratilipi.data.client.UserData)3 Author (com.pratilipi.data.type.Author)3 UserPratilipi (com.pratilipi.data.type.UserPratilipi)3 ArrayList (java.util.ArrayList)3 InsufficientAccessException (com.pratilipi.common.exception.InsufficientAccessException)2 CommentData (com.pratilipi.data.client.CommentData)2 Event (com.pratilipi.data.type.Event)2