Search in sources :

Example 11 with Article

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;
}
Also used : ArticleIngestion(org.ambraproject.rhino.model.ArticleIngestion) Article(org.ambraproject.rhino.model.Article)

Example 12 with Article

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;
}
Also used : Article(org.ambraproject.rhino.model.Article) IssueInputView(org.ambraproject.rhino.view.journal.IssueInputView) Journal(org.ambraproject.rhino.model.Journal) CacheableResponse(org.ambraproject.rhino.rest.response.CacheableResponse) RestClientException(org.ambraproject.rhino.rest.RestClientException) Session(org.hibernate.Session) Autowired(org.springframework.beans.factory.annotation.Autowired) IssueOutputView(org.ambraproject.rhino.view.journal.IssueOutputView) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) ArticleIdentifier(org.ambraproject.rhino.identity.ArticleIdentifier) IssueIdentifier(org.ambraproject.rhino.identity.IssueIdentifier) HttpStatus(org.springframework.http.HttpStatus) ArticleCrudService(org.ambraproject.rhino.service.ArticleCrudService) List(java.util.List) Issue(org.ambraproject.rhino.model.Issue) VolumeIdentifier(org.ambraproject.rhino.identity.VolumeIdentifier) Volume(org.ambraproject.rhino.model.Volume) VolumeCrudService(org.ambraproject.rhino.service.VolumeCrudService) Query(org.hibernate.Query) Optional(java.util.Optional) Preconditions(com.google.common.base.Preconditions) IssueCrudService(org.ambraproject.rhino.service.IssueCrudService) ArticleIdentifier(org.ambraproject.rhino.identity.ArticleIdentifier) IssueIdentifier(org.ambraproject.rhino.identity.IssueIdentifier) Article(org.ambraproject.rhino.model.Article)

Example 13 with Article

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);
}
Also used : ArticleIngestion(org.ambraproject.rhino.model.ArticleIngestion) Article(org.ambraproject.rhino.model.Article) Document(org.w3c.dom.Document)

Example 14 with Article

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();
    });
}
Also used : AmbraService(org.ambraproject.rhino.service.impl.AmbraService) Article(org.ambraproject.rhino.model.Article) Collection(java.util.Collection) Autowired(org.springframework.beans.factory.annotation.Autowired) IOException(java.io.IOException) TaxonomyClassificationService(org.ambraproject.rhino.service.taxonomy.TaxonomyClassificationService) ArticleCategoryAssignment(org.ambraproject.rhino.model.ArticleCategoryAssignment) WeightedTerm(org.ambraproject.rhino.service.taxonomy.WeightedTerm) ArticleCategoryAssignmentFlag(org.ambraproject.rhino.model.ArticleCategoryAssignmentFlag) List(java.util.List) ArticleRevision(org.ambraproject.rhino.model.ArticleRevision) Category(org.ambraproject.rhino.model.Category) Document(org.w3c.dom.Document) LocalDate(java.time.LocalDate) TaxonomyService(org.ambraproject.rhino.service.taxonomy.TaxonomyService) Query(org.hibernate.Query) Optional(java.util.Optional) Query(org.hibernate.Query) List(java.util.List)

Example 15 with Article

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);
}
Also used : Comment(org.ambraproject.rhino.model.Comment) Article(org.ambraproject.rhino.model.Article) CommentOutputView(org.ambraproject.rhino.view.comment.CommentOutputView) CompetingInterestPolicy(org.ambraproject.rhino.view.comment.CompetingInterestPolicy)

Aggregations

Article (org.ambraproject.rhino.model.Article)31 ArticleRevision (org.ambraproject.rhino.model.ArticleRevision)10 ArticleIdentifier (org.ambraproject.rhino.identity.ArticleIdentifier)9 List (java.util.List)8 ArticleIngestion (org.ambraproject.rhino.model.ArticleIngestion)8 RestClientException (org.ambraproject.rhino.rest.RestClientException)7 Document (org.w3c.dom.Document)7 IOException (java.io.IOException)6 Optional (java.util.Optional)6 Query (org.hibernate.Query)6 Autowired (org.springframework.beans.factory.annotation.Autowired)6 Collection (java.util.Collection)5 Collectors (java.util.stream.Collectors)5 ArticleCrudService (org.ambraproject.rhino.service.ArticleCrudService)5 LocalDate (java.time.LocalDate)4 ArrayList (java.util.ArrayList)4 Doi (org.ambraproject.rhino.identity.Doi)4 ArticleCategoryAssignment (org.ambraproject.rhino.model.ArticleCategoryAssignment)4 CacheableResponse (org.ambraproject.rhino.rest.response.CacheableResponse)4 HttpStatus (org.springframework.http.HttpStatus)4