Search in sources :

Example 6 with Article

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

the class ArticleCrudServiceImpl method populateCategories.

@Override
public void populateCategories(ArticleIdentifier articleId) throws IOException {
    Article article = readArticle(articleId);
    ArticleRevision revision = readLatestRevision(article);
    taxonomyService.populateCategories(revision);
}
Also used : ArticleRevision(org.ambraproject.rhino.model.ArticleRevision) Article(org.ambraproject.rhino.model.Article)

Example 7 with Article

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

the class SolrIndexServiceTest method testPublication.

@Test(enabled = false)
public void testPublication() throws Exception {
    Archive archive = Archive.readZipFileIntoMemory(new File(TEST_DATA_DIR + "pone.0056489.zip"));
    //    Article article = articleCrudService.writeArchive(archive,
    //        Optional.empty(), DoiBasedCrudService.WriteMode.CREATE_ONLY, OptionalInt.empty());
    Article article = new Article();
    ArticleIdentifier articleId = ArticleIdentifier.create(article.getDoi());
    SolrIndexServiceImpl impl = (SolrIndexServiceImpl) solrIndexService;
    DummyMessageSender dummySender = (DummyMessageSender) impl.messageSender;
    assertEquals(dummySender.messagesSent.size(), 5);
    List<String> solrMessages = dummySender.messagesSent.get("activemq:fake.indexing.queue");
    assertEquals(solrMessages.size(), 1);
    XMLUnit.compareXML(IOUtils.toString(new FileInputStream(TEST_DATA_DIR + "pone.0056489_solr_decorated.xml")), solrMessages.get(0));
    String expectedSyndication = "<ambraMessage><doi>info:doi/10.1371/journal.pone.0056489</doi><archive>pone.0056489.zip</archive></ambraMessage>";
    List<String> crossRefMessages = dummySender.messagesSent.get("activemq:fake.crossref.queue");
    assertEquals(crossRefMessages.size(), 1);
    XMLUnit.compareXML(expectedSyndication, crossRefMessages.get(0));
    List<String> pmcMessages = dummySender.messagesSent.get("activemq:fake.pmc.queue");
    assertEquals(pmcMessages.size(), 1);
    XMLUnit.compareXML(expectedSyndication, pmcMessages.get(0));
    List<String> pubmedMessages = dummySender.messagesSent.get("activemq:fake.pubmed.queue");
    assertEquals(pubmedMessages.size(), 1);
    XMLUnit.compareXML(expectedSyndication, pubmedMessages.get(0));
    solrIndexService.removeSolrIndex(articleId);
    assertEquals(dummySender.messagesSent.size(), 6);
    List<String> deletionMessages = dummySender.messagesSent.get("activemq:fake.delete.queue");
    assertEquals(deletionMessages.size(), 1);
    assertEquals(deletionMessages.get(0), article.getDoi());
}
Also used : Archive(org.ambraproject.rhino.util.Archive) ArticleIdentifier(org.ambraproject.rhino.identity.ArticleIdentifier) SolrIndexServiceImpl(org.ambraproject.rhino.service.impl.SolrIndexServiceImpl) Article(org.ambraproject.rhino.model.Article) File(java.io.File) FileInputStream(java.io.FileInputStream) Test(org.testng.annotations.Test) BaseRhinoTest(org.ambraproject.rhino.BaseRhinoTest)

Example 8 with Article

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

the class IssueOutputView method serialize.

@Override
public JsonElement serialize(JsonSerializationContext context) {
    JsonObject serialized = new JsonObject();
    serialized.addProperty("doi", issue.getDoi());
    serialized.addProperty("displayName", issue.getDisplayName());
    serialized.add("parentVolume", context.serialize(factory.volumeOutputViewFactory.getView(parentVolume)));
    Article imageArticle = issue.getImageArticle();
    if (imageArticle != null) {
        JsonObject serializedImageArticle = new JsonObject();
        String figureImageDoi = getIssueImageFigureDoi(factory.articleCrudService, imageArticle);
        serializedImageArticle.addProperty("doi", imageArticle.getDoi());
        serializedImageArticle.addProperty("figureImageDoi", figureImageDoi);
        serialized.add("imageArticle", serializedImageArticle);
    }
    return serialized;
}
Also used : Article(org.ambraproject.rhino.model.Article) JsonObject(com.google.gson.JsonObject)

Example 9 with Article

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

the class ArticleCrudServiceTest method testListDois.

@Test
public void testListDois() throws IOException {
    Article a1 = new Article();
    a1.setDoi("info:doi/10.0/test1");
//    a1.seteIssn("1932-6203");
//    hibernateTemplate.save(a1);
//
//    Article a2 = new Article();
//    a2.setDoi("info:doi/10.0/test2");
//    a2.seteIssn(a1.geteIssn());
//    hibernateTemplate.save(a2);
//
//    Transceiver response = articleCrudService.listDois(ArticleCriteria.create(null, null, false));
//    Map<?, ?> doiList = entityGson.fromJson(response.readJson(entityGson), Map.class);
//
//    // Kludge! Extract DOI values from object bodies
//    ImmutableSet<String> dois = ImmutableSet.copyOf(Collections2.transform(doiList.values(), new Function<Object, String>() {
//      @Override
//      public String apply(Object input) {
//        return (String) ((Map) input).get("doi");
//      }
//    }));
//
//    assertEquals(dois, ImmutableSet.of(a1.getDoi(), a2.getDoi()));
}
Also used : Article(org.ambraproject.rhino.model.Article) BaseRhinoTransactionalTest(org.ambraproject.rhino.BaseRhinoTransactionalTest) Test(org.testng.annotations.Test)

Example 10 with Article

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

the class CommentOutputViewTest method createStubComment.

private Comment createStubComment() {
    Comment comment = new Comment();
    Article article = new Article();
    article.setDoi("test");
    comment.setArticle(article);
    comment.setBody("test body");
    comment.setCommentId(0L);
    comment.setCreated(Date.from(Instant.now()));
    return comment;
}
Also used : Comment(org.ambraproject.rhino.model.Comment) Article(org.ambraproject.rhino.model.Article)

Aggregations

Article (org.ambraproject.rhino.model.Article)31 ArticleRevision (org.ambraproject.rhino.model.ArticleRevision)10 ArticleIdentifier (org.ambraproject.rhino.identity.ArticleIdentifier)9 List (java.util.List)8 ArticleIngestion (org.ambraproject.rhino.model.ArticleIngestion)8 RestClientException (org.ambraproject.rhino.rest.RestClientException)7 Document (org.w3c.dom.Document)7 IOException (java.io.IOException)6 Optional (java.util.Optional)6 Query (org.hibernate.Query)6 Autowired (org.springframework.beans.factory.annotation.Autowired)6 Collection (java.util.Collection)5 Collectors (java.util.stream.Collectors)5 ArticleCrudService (org.ambraproject.rhino.service.ArticleCrudService)5 LocalDate (java.time.LocalDate)4 ArrayList (java.util.ArrayList)4 Doi (org.ambraproject.rhino.identity.Doi)4 ArticleCategoryAssignment (org.ambraproject.rhino.model.ArticleCategoryAssignment)4 CacheableResponse (org.ambraproject.rhino.rest.response.CacheableResponse)4 HttpStatus (org.springframework.http.HttpStatus)4