Search in sources :

Example 6 with Journal

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

the class IssueCrudServiceImpl method getJournalOf.

@Override
public Journal getJournalOf(Issue issue) {
    return hibernateTemplate.execute(session -> {
        Query query = session.createQuery("" + "SELECT j FROM Journal j, Volume v " + "WHERE v IN ELEMENTS(j.volumes) AND :issue IN ELEMENTS(v.issues)");
        query.setParameter("issue", issue);
        return (Journal) query.uniqueResult();
    });
}
Also used : Query(org.hibernate.Query) Journal(org.ambraproject.rhino.model.Journal)

Example 7 with Journal

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

the class JournalCrudServiceImpl method update.

@Override
public void update(String journalKey, JournalInputView input) {
    Preconditions.checkNotNull(input);
    Journal journal = readJournal(journalKey);
    hibernateTemplate.update(applyInput(journal, input));
}
Also used : Journal(org.ambraproject.rhino.model.Journal)

Example 8 with Journal

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

the class SolrIndexServiceImpl method appendJournals.

/**
   * Attaches additional XML info to an article document specifying the journals it is published in.
   * <p/>
   * This is largely copied from org.ambraproject.article.service.ArticleDocumentServiceImpl in the old admin codebase.
   *
   * @param doc       article XML
   * @param ingestion encodes DOI
   * @return doc
   */
private Document appendJournals(Document doc, ArticleIngestion ingestion) {
    Element additionalInfoElement = doc.createElementNS(XML_NAMESPACE, "ambra");
    Element journalsElement = doc.createElementNS(XML_NAMESPACE, "journals");
    doc.getDocumentElement().appendChild(additionalInfoElement);
    additionalInfoElement.appendChild(journalsElement);
    Journal journal = ingestion.getJournal();
    Element journalElement = doc.createElementNS(XML_NAMESPACE, "journal");
    Element eIssn = doc.createElementNS(XML_NAMESPACE, "eIssn");
    eIssn.appendChild(doc.createTextNode(journal.geteIssn()));
    journalElement.appendChild(eIssn);
    Element key = doc.createElementNS(XML_NAMESPACE, "key");
    key.appendChild(doc.createTextNode(journal.getJournalKey()));
    journalElement.appendChild(key);
    Element name = doc.createElementNS(XML_NAMESPACE, "name");
    name.appendChild(doc.createTextNode(journal.getTitle()));
    journalElement.appendChild(name);
    journalsElement.appendChild(journalElement);
    return doc;
}
Also used : Element(org.w3c.dom.Element) Journal(org.ambraproject.rhino.model.Journal)

Example 9 with Journal

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

the class CommentCrudServiceImpl method getAllFlags.

private Collection<Flag> getAllFlags(String journalKey) {
    Journal journal = journalCrudService.readJournal(journalKey);
    return hibernateTemplate.execute(session -> {
        Query query = session.createQuery("SELECT DISTINCT f FROM ArticleIngestion i, Flag f " + "WHERE f.flaggedComment.article = i.article " + "AND i.journal = :journal ");
        query.setParameter("journal", journal);
        return (Collection<Flag>) query.list();
    });
}
Also used : Query(org.hibernate.Query) Collection(java.util.Collection) Journal(org.ambraproject.rhino.model.Journal)

Example 10 with Journal

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

the class VolumeCrudServiceImpl method create.

@Override
public Volume create(String journalKey, VolumeInputView input) {
    Preconditions.checkNotNull(journalKey);
    VolumeIdentifier volumeId = VolumeIdentifier.create(input.getDoi());
    if (getVolume(volumeId).isPresent()) {
        throw new RestClientException("Volume already exists with DOI: " + volumeId.getDoi(), HttpStatus.BAD_REQUEST);
    }
    Volume volume = new Volume();
    volume.setIssues(new ArrayList<>(0));
    volume = applyInput(volume, input);
    Journal journal = journalCrudService.readJournal(journalKey);
    journal.getVolumes().add(volume);
    hibernateTemplate.save(journal);
    return volume;
}
Also used : Volume(org.ambraproject.rhino.model.Volume) RestClientException(org.ambraproject.rhino.rest.RestClientException) Journal(org.ambraproject.rhino.model.Journal) VolumeIdentifier(org.ambraproject.rhino.identity.VolumeIdentifier)

Aggregations

Journal (org.ambraproject.rhino.model.Journal)19 Query (org.hibernate.Query)6 RestClientException (org.ambraproject.rhino.rest.RestClientException)4 Volume (org.ambraproject.rhino.model.Volume)3 Transactional (org.springframework.transaction.annotation.Transactional)3 Collection (java.util.Collection)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ImmutableList (com.google.common.collect.ImmutableList)1 Instant (java.time.Instant)1 LocalDate (java.time.LocalDate)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 BaseRhinoTest (org.ambraproject.rhino.BaseRhinoTest)1 Doi (org.ambraproject.rhino.identity.Doi)1 VolumeIdentifier (org.ambraproject.rhino.identity.VolumeIdentifier)1 ArticleIngestion (org.ambraproject.rhino.model.ArticleIngestion)1 ArticleList (org.ambraproject.rhino.model.ArticleList)1 Comment (org.ambraproject.rhino.model.Comment)1 Issue (org.ambraproject.rhino.model.Issue)1 ResolvedDoiView (org.ambraproject.rhino.view.ResolvedDoiView)1