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();
});
}
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));
}
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;
}
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();
});
}
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;
}
Aggregations