Search in sources :

Example 6 with Issue

use of org.ambraproject.rhino.model.Issue in project rhino by PLOS.

the class DoiController method findDoiTarget.

private ResolvedDoiView findDoiTarget(Doi doi) throws IOException {
    // Look for the DOI in the corpus of articles
    Optional<ResolvedDoiView> itemOverview = articleCrudService.getItemOverview(doi);
    if (itemOverview.isPresent()) {
        return itemOverview.get();
    }
    // Not found as an Article or ArticleItem. Check other object types that use DOIs.
    Optional<Comment> comment = commentCrudService.getComment(CommentIdentifier.create(doi));
    if (comment.isPresent()) {
        ArticleOverview article = articleCrudService.buildOverview(comment.get().getArticle());
        return ResolvedDoiView.createForArticle(doi, ResolvedDoiView.DoiWorkType.COMMENT, article);
    }
    Optional<Issue> issue = issueCrudService.getIssue(IssueIdentifier.create(doi));
    if (issue.isPresent()) {
        Journal journal = issueCrudService.getJournalOf(issue.get());
        return ResolvedDoiView.create(doi, ResolvedDoiView.DoiWorkType.ISSUE, journal);
    }
    Optional<Volume> volume = volumeCrudService.getVolume(VolumeIdentifier.create(doi));
    if (volume.isPresent()) {
        Journal journal = volumeCrudService.getJournalOf(volume.get());
        return ResolvedDoiView.create(doi, ResolvedDoiView.DoiWorkType.VOLUME, journal);
    }
    throw new RestClientException("DOI not found: " + doi.getName(), HttpStatus.NOT_FOUND);
}
Also used : Comment(org.ambraproject.rhino.model.Comment) ResolvedDoiView(org.ambraproject.rhino.view.ResolvedDoiView) Issue(org.ambraproject.rhino.model.Issue) Volume(org.ambraproject.rhino.model.Volume) RestClientException(org.ambraproject.rhino.rest.RestClientException) ArticleOverview(org.ambraproject.rhino.view.article.ArticleOverview) Journal(org.ambraproject.rhino.model.Journal)

Example 7 with Issue

use of org.ambraproject.rhino.model.Issue in project rhino by PLOS.

the class IssueCrudServiceImpl method update.

@Override
public void update(IssueIdentifier issueId, IssueInputView input) {
    Preconditions.checkNotNull(input);
    Issue issue = readIssue(issueId);
    issue = applyInput(issue, input);
    hibernateTemplate.update(issue);
}
Also used : Issue(org.ambraproject.rhino.model.Issue)

Example 8 with Issue

use of org.ambraproject.rhino.model.Issue in project rhino by PLOS.

the class JournalCrudServiceImpl method applyInput.

private Journal applyInput(Journal journal, JournalInputView input) {
    String currentIssueDoi = input.getCurrentIssueDoi();
    if (currentIssueDoi != null) {
        Issue currentIssue = issueCrudService.readIssue(IssueIdentifier.create(currentIssueDoi));
        validateIssueInJournal(currentIssue, journal);
        journal.setCurrentIssue(currentIssue);
    }
    return journal;
}
Also used : Issue(org.ambraproject.rhino.model.Issue)

Aggregations

Issue (org.ambraproject.rhino.model.Issue)8 RestClientException (org.ambraproject.rhino.rest.RestClientException)5 IssueIdentifier (org.ambraproject.rhino.identity.IssueIdentifier)3 Volume (org.ambraproject.rhino.model.Volume)3 VolumeIdentifier (org.ambraproject.rhino.identity.VolumeIdentifier)2 Journal (org.ambraproject.rhino.model.Journal)2 IssueInputView (org.ambraproject.rhino.view.journal.IssueInputView)2 Query (org.hibernate.Query)2 Session (org.hibernate.Session)2 Transactional (org.springframework.transaction.annotation.Transactional)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 Preconditions (com.google.common.base.Preconditions)1 ApiImplicitParam (com.wordnik.swagger.annotations.ApiImplicitParam)1 IOException (java.io.IOException)1 List (java.util.List)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 ArticleIdentifier (org.ambraproject.rhino.identity.ArticleIdentifier)1 Article (org.ambraproject.rhino.model.Article)1 Comment (org.ambraproject.rhino.model.Comment)1