Search in sources :

Example 1 with Journal

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);
    }
}
Also used : Journal(org.ambraproject.rhino.model.Journal) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 2 with 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());
}
Also used : Volume(org.ambraproject.rhino.model.Volume) VolumeInputView(org.ambraproject.rhino.view.journal.VolumeInputView) Journal(org.ambraproject.rhino.model.Journal) Doi(org.ambraproject.rhino.identity.Doi) Test(org.testng.annotations.Test) BaseRhinoTest(org.ambraproject.rhino.BaseRhinoTest)

Example 3 with Journal

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;
}
Also used : Journal(org.ambraproject.rhino.model.Journal)

Example 4 with Journal

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);
    }
}
Also used : Journal(org.ambraproject.rhino.model.Journal)

Example 5 with 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;
}
Also used : ArticleIngestion(org.ambraproject.rhino.model.ArticleIngestion) Query(org.hibernate.Query) Journal(org.ambraproject.rhino.model.Journal)

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