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