use of org.ambraproject.rhino.model.Journal in project rhino by PLOS.
the class RhinoTestHelper method createDummyJournal.
/**
* Create a dummy journal with required non-null fields filled in.
*
* @param eissn the dummy journal's eIssn
* @return a new dummy journal object
*/
public static Journal createDummyJournal(String eissn) {
Preconditions.checkNotNull(eissn);
Journal journal = new Journal();
String title = "Test Journal " + eissn;
journal.setTitle(title);
journal.setJournalKey(title.replaceAll("\\s|-", ""));
journal.seteIssn(eissn);
return journal;
}
use of org.ambraproject.rhino.model.Journal in project rhino by PLOS.
the class VolumeCrudServiceImpl method getJournalOf.
@Override
public Journal getJournalOf(Volume volume) {
return hibernateTemplate.execute(session -> {
Query query = session.createQuery("FROM Journal WHERE :volume IN ELEMENTS(volumes)");
query.setParameter("volume", volume);
return (Journal) query.uniqueResult();
});
}
use of org.ambraproject.rhino.model.Journal in project rhino by PLOS.
the class JournalCrudServiceImpl method readJournalByVolume.
@Override
public Journal readJournalByVolume(Volume volume) {
return hibernateTemplate.execute(session -> {
Query query = session.createQuery("FROM Journal j WHERE :volume IN ELEMENTS(volumes)");
query.setParameter("volume", volume);
return (Journal) query.uniqueResult();
});
}
use of org.ambraproject.rhino.model.Journal in project rhino by PLOS.
the class SyndicationCrudServiceImpl method getSyndications.
@Transactional
@Override
public Collection<Syndication> getSyndications(final String journalKey, final List<String> statuses) {
int numDaysInPast = runtimeConfiguration.getQueueConfiguration().getSyndicationRange();
LocalDate startDate = LocalDate.now().minus(numDaysInPast, ChronoUnit.DAYS);
Instant startTime = startDate.atStartOfDay(ZoneId.systemDefault()).toInstant();
final Journal journal = journalService.readJournal(journalKey);
if (journal == null) {
throw new RuntimeException("Could not find journal for journal key: " + journalKey);
}
return hibernateTemplate.execute(session -> {
Query query = session.createQuery("" + "SELECT s " + "FROM Syndication s " + "JOIN s.articleVersion av " + "JOIN av.journals j " + "WHERE j.journalKey = :journalKey " + "AND s.status in (:statuses)" + "AND s.lastModified > :startTime");
query.setParameter("journalKey", journalKey);
query.setParameterList("statuses", statuses);
query.setDate("startTime", Date.from(startTime));
return (Collection<Syndication>) query.list();
});
}
Aggregations