use of org.ambraproject.rhino.model.Article in project rhino by PLOS.
the class IngestionService method persistArticle.
private ArticleIngestion persistArticle(IngestPackage ingestPackage, Doi doi, ArticlePackage articlePackage) {
Article article = hibernatePersistenceService.persistArticle(doi);
ArticleIngestion ingestion = hibernatePersistenceService.persistIngestion(article, ingestPackage.getArticleMetadata(), ingestPackage.getArticleCustomMetadata());
hibernatePersistenceService.persistAssets(articlePackage, ingestion);
hibernateTemplate.flush();
// Pick up auto-persisted timestamp
hibernateTemplate.refresh(ingestion);
return ingestion;
}
use of org.ambraproject.rhino.model.Article in project rhino by PLOS.
the class IssueCrudServiceImpl method applyInput.
private Issue applyInput(Issue issue, IssueInputView input) {
String issueDoi = input.getDoi();
if (issueDoi != null) {
IssueIdentifier issueId = IssueIdentifier.create(issueDoi);
issue.setDoi(issueId.getDoi().getName());
}
String displayName = input.getDisplayName();
if (displayName != null) {
issue.setDisplayName(displayName);
} else if (issue.getDisplayName() == null) {
issue.setDisplayName("");
}
String imageDoi = input.getImageArticleDoi();
if (imageDoi != null) {
ArticleIdentifier imageArticleId = ArticleIdentifier.create(imageDoi);
Article imageArticle = articleCrudService.readArticle(imageArticleId);
issue.setImageArticle(imageArticle);
} else {
issue.setImageArticle(null);
}
List<String> inputArticleDois = input.getArticleOrder();
if (inputArticleDois != null) {
List<Article> inputArticles = inputArticleDois.stream().map(doi -> articleCrudService.readArticle(ArticleIdentifier.create(doi))).collect(Collectors.toList());
issue.setArticles(inputArticles);
}
return issue;
}
use of org.ambraproject.rhino.model.Article in project rhino by PLOS.
the class SolrIndexServiceImpl method updateSolrIndex.
@Override
public void updateSolrIndex(ArticleIdentifier articleId) {
Article article = articleCrudService.readArticle(articleId);
ArticleIngestion ingestion = articleCrudService.readLatestRevision(article).getIngestion();
Document doc = articleCrudService.getManuscriptXml(ingestion);
doc = appendJournals(doc, ingestion);
doc = appendStrikingImage(doc, ingestion);
String destination = runtimeConfiguration.getQueueConfiguration().getSolrUpdate();
if (destination == null) {
throw new RuntimeException("solrUpdate is not configured");
}
messageSender.sendBody(destination, doc);
}
use of org.ambraproject.rhino.model.Article in project rhino by PLOS.
the class TaxonomyServiceImpl method getArticleCategoryAssignmentFlags.
private List<ArticleCategoryAssignmentFlag> getArticleCategoryAssignmentFlags(Article article, Category category, Optional<Long> userProfileId) {
return hibernateTemplate.execute(session -> {
Query query = userProfileId.map(userProfileIdValue -> session.createQuery("" + "FROM ArticleCategoryAssignmentFlag " + "WHERE article = :article AND category = :category AND userProfileId = :userProfileId").setParameter("userProfileId", userProfileIdValue)).orElseGet(() -> session.createQuery("" + "FROM ArticleCategoryAssignmentFlag " + "WHERE article = :article AND category = :category AND userProfileId IS NULL"));
query.setParameter("article", article);
query.setParameter("category", category);
return (List<ArticleCategoryAssignmentFlag>) query.list();
});
}
use of org.ambraproject.rhino.model.Article in project rhino by PLOS.
the class CommentCrudServiceImpl method createView.
private CommentOutputView createView(Comment comment) {
Article article = comment.getArticle();
Collection<Comment> articleComments = fetchAllComments(article);
return new CommentOutputView.Factory(new CompetingInterestPolicy(runtimeConfiguration), articleComments, article).buildView(comment);
}
Aggregations