use of org.ambraproject.rhino.service.ArticleCrudService in project rhino by PLOS.
the class IssueOutputView method getIssueImageFigureDoi.
private static String getIssueImageFigureDoi(ArticleCrudService articleCrudService, Article imageArticle) {
ArticleRevision latestArticleRevision = articleCrudService.getLatestRevision(imageArticle).orElseThrow(() -> new RuntimeException("Image article has no published revisions. " + imageArticle.getDoi()));
ArticleIngestion ingestion = latestArticleRevision.getIngestion();
Collection<ArticleItem> allArticleItems = articleCrudService.getAllArticleItems(ingestion);
List<ArticleItem> figureImageItems = allArticleItems.stream().filter(item -> FIGURE_IMAGE_TYPES.contains(item.getItemType())).collect(Collectors.toList());
if (figureImageItems.size() != 1) {
throw new RuntimeException("Image article does not contain exactly one image file. " + imageArticle.getDoi());
}
return figureImageItems.get(0).getDoi();
}
Aggregations