Search in sources :

Example 1 with ArticleRevisionView

use of org.ambraproject.rhino.view.article.ArticleRevisionView in project rhino by PLOS.

the class ArticleListView method serialize.

@Override
public JsonObject serialize(JsonSerializationContext context) {
    JsonObject serialized = context.serialize(getIdentity()).getAsJsonObject();
    serialized.addProperty("title", articleList.getDisplayName());
    if (!excludeArticleMetadata) {
        List<ArticleRevisionView> articleViews = Lists.transform(articleList.getArticles(), articleFactory::getLatestRevisionView);
        serialized.add("articles", context.serialize(articleViews));
    }
    return serialized;
}
Also used : ArticleRevisionView(org.ambraproject.rhino.view.article.ArticleRevisionView) JsonObject(com.google.gson.JsonObject)

Example 2 with ArticleRevisionView

use of org.ambraproject.rhino.view.article.ArticleRevisionView in project rhino by PLOS.

the class IssueCrudController method readArticlesInIssue.

@Transactional(readOnly = true)
@RequestMapping(value = "/issues/{issueDoi:.+}/contents", method = RequestMethod.GET)
public ResponseEntity<?> readArticlesInIssue(@PathVariable("issueDoi") String issueDoi) throws IOException {
    IssueIdentifier issueId = getIssueId(issueDoi);
    Issue issue = issueCrudService.readIssue(issueId);
    List<ArticleRevisionView> views = issueOutputViewFactory.getIssueArticlesView(issue);
    return ServiceResponse.serveView(views).asJsonResponse(entityGson);
}
Also used : ArticleRevisionView(org.ambraproject.rhino.view.article.ArticleRevisionView) Issue(org.ambraproject.rhino.model.Issue) IssueIdentifier(org.ambraproject.rhino.identity.IssueIdentifier) Transactional(org.springframework.transaction.annotation.Transactional) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with ArticleRevisionView

use of org.ambraproject.rhino.view.article.ArticleRevisionView in project rhino by PLOS.

the class ArticleCrudServiceImpl method serveRevisions.

@Override
public ServiceResponse<List<ArticleRevisionView>> serveRevisions(ArticleIdentifier id) {
    Article article = readArticle(id);
    List<ArticleRevision> revisions = (List<ArticleRevision>) hibernateTemplate.find("FROM ArticleRevision WHERE ingestion.article = ? ORDER BY revisionNumber", article);
    List<ArticleRevisionView> views = Lists.transform(revisions, ArticleRevisionView::getView);
    return ServiceResponse.serveView(views);
}
Also used : ArticleRevision(org.ambraproject.rhino.model.ArticleRevision) ArticleRevisionView(org.ambraproject.rhino.view.article.ArticleRevisionView) Article(org.ambraproject.rhino.model.Article) List(java.util.List) ArrayList(java.util.ArrayList)

Aggregations

ArticleRevisionView (org.ambraproject.rhino.view.article.ArticleRevisionView)3 JsonObject (com.google.gson.JsonObject)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 IssueIdentifier (org.ambraproject.rhino.identity.IssueIdentifier)1 Article (org.ambraproject.rhino.model.Article)1 ArticleRevision (org.ambraproject.rhino.model.ArticleRevision)1 Issue (org.ambraproject.rhino.model.Issue)1 Transactional (org.springframework.transaction.annotation.Transactional)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1