use of org.ambraproject.rhino.model.Journal in project rhino by PLOS.
the class SolrIndexServiceTest method addJournal.
@BeforeMethod
public void addJournal() {
final ImmutableSet<String> testCaseEissns = ImmutableSet.of("1932-6203");
for (String eissn : testCaseEissns) {
List<?> existing = hibernateTemplate.findByCriteria(DetachedCriteria.forClass(Journal.class).add(Restrictions.eq("eIssn", eissn)));
if (!existing.isEmpty())
continue;
Journal journal = RhinoTestHelper.createDummyJournal(eissn);
// hibernateTemplate.save(journal);
}
}
use of org.ambraproject.rhino.model.Journal in project rhino by PLOS.
the class VolumeCrudServiceTest method testCreate.
@Test(enabled = false)
public void testCreate() {
Doi volumeId = Doi.create("10.1371/volume.pmed.v05");
String displayName = "volumeDisplay";
String json = String.format("{\"volumeUri\": \"%s\", \"displayName\": \"%s\"}", volumeId.getName(), displayName);
VolumeInputView input = entityGson.fromJson(json, VolumeInputView.class);
Journal testJournal = createTestJournal();
volumeCrudService.create(testJournal.getJournalKey(), input);
testJournal = getTestJournal();
List<Volume> testJournalVolumes = testJournal.getVolumes();
assertFalse(testJournalVolumes.isEmpty());
}
use of org.ambraproject.rhino.model.Journal in project rhino by PLOS.
the class VolumeCrudServiceTest method createTestJournal.
private Journal createTestJournal() {
Journal testJournal = new Journal();
testJournal.setJournalKey(TEST_JOURNAL_KEY);
hibernateTemplate.save(testJournal);
return testJournal;
}
use of org.ambraproject.rhino.model.Journal in project rhino by PLOS.
the class RhinoTestHelper method addExpectedJournals.
public static void addExpectedJournals(HibernateTemplate hibernateTemplate) {
final ImmutableSet<String> testCaseEissns = ImmutableSet.of("1932-6203");
for (String eissn : testCaseEissns) {
List<?> existing = hibernateTemplate.findByCriteria(DetachedCriteria.forClass(Journal.class).add(Restrictions.eq("eIssn", eissn)));
if (!existing.isEmpty()) {
continue;
}
Journal journal = createDummyJournal(eissn);
// hibernateTemplate.save(journal);
}
}
use of org.ambraproject.rhino.model.Journal in project rhino by PLOS.
the class HibernatePersistenceServiceImpl method persistIngestion.
@Override
public ArticleIngestion persistIngestion(Article article, ArticleMetadata articleMetadata, ArticleCustomMetadata customMetadata) {
Journal journal = fetchJournal(articleMetadata);
int nextIngestionNumber = hibernateTemplate.execute(session -> {
Query findNextIngestionNumber = session.createQuery("SELECT MAX(ingestionNumber) FROM ArticleIngestion WHERE article = :article");
findNextIngestionNumber.setParameter("article", article);
Number maxIngestionNumber = (Number) findNextIngestionNumber.uniqueResult();
return (maxIngestionNumber == null) ? FIRST_INGESTION_NUMBER : maxIngestionNumber.intValue() + 1;
});
ArticleIngestion ingestion = new ArticleIngestion();
ingestion.setArticle(article);
ingestion.setIngestionNumber(nextIngestionNumber);
ingestion.setTitle(articleMetadata.getTitle());
ingestion.setPublicationDate(java.sql.Date.valueOf(articleMetadata.getPublicationDate()));
ingestion.setArticleType(articleMetadata.getArticleType());
ingestion.setJournal(journal);
ingestion.setRevisionDate((customMetadata.getRevisionDate() == null ? null : java.sql.Date.valueOf(customMetadata.getRevisionDate())));
ingestion.setPublicationStage(customMetadata.getPublicationStage());
hibernateTemplate.save(ingestion);
return ingestion;
}
Aggregations