use of org.ambraproject.rhino.identity.Doi 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.identity.Doi in project rhino by PLOS.
the class IngestionService method processIngestPackage.
private ArticleIngestion processIngestPackage(IngestPackage ingestPackage) {
Doi doi = ArticleIdentifier.create(ingestPackage.getArticleMetadata().getDoi()).getDoi();
ArticlePackage articlePackage = ingestPackage.getArticlePackage();
for (ManifestXml.Asset asset : articlePackage.getManifest().getAssets()) {
Doi assetDoi = Doi.create(asset.getUri());
validateAssetUniqueness(doi, articleCrudService.getAllArticleItems(assetDoi));
}
validateManuscript(doi, articlePackage.getManifest().getArticleAsset().getUri());
return persistArticle(ingestPackage, doi, articlePackage);
}
use of org.ambraproject.rhino.identity.Doi in project rhino by PLOS.
the class CommentCrudServiceImpl method createComment.
@Override
public ServiceResponse<CommentOutputView> createComment(Optional<ArticleIdentifier> articleId, CommentInputView input) {
final Optional<String> parentCommentUri = Optional.ofNullable(input.getParentCommentId());
final Article article;
final Comment parentComment;
if (parentCommentUri.isPresent()) {
parentComment = readComment(CommentIdentifier.create(parentCommentUri.get()));
if (parentComment == null) {
throw new RestClientException("Parent comment not found: " + parentCommentUri, HttpStatus.BAD_REQUEST);
}
article = parentComment.getArticle();
ArticleIdentifier articleDoiFromDb = ArticleIdentifier.create(parentComment.getArticle().getDoi());
if (!articleId.isPresent()) {
articleId = Optional.of(articleDoiFromDb);
} else if (!articleId.get().equals(articleDoiFromDb)) {
String message = String.format("Parent comment (%s) not from declared article (%s).", parentCommentUri.get(), articleId.get());
throw new RestClientException(message, HttpStatus.BAD_REQUEST);
}
} else {
// The comment is a root-level reply to an article (no parent comment).
if (!articleId.isPresent()) {
throw new RestClientException("Must provide articleId or parentCommentUri", HttpStatus.BAD_REQUEST);
}
article = articleCrudService.readArticle(articleId.get());
parentComment = null;
}
// comment receives same DOI prefix as article
String doiPrefix = extractDoiPrefix(articleId.get());
// generate a new DOI out of a random UUID
UUID uuid = UUID.randomUUID();
Doi createdCommentUri = Doi.create(doiPrefix + "annotation/" + uuid);
Comment created = new Comment();
created.setArticle(article);
created.setParent(parentComment);
created.setCommentUri(createdCommentUri.getName());
created.setUserProfileID(Long.valueOf(Strings.nullToEmpty(input.getCreatorUserId())));
created.setTitle(Strings.nullToEmpty(input.getTitle()));
created.setBody(Strings.nullToEmpty(input.getBody()));
created.setHighlightedText(Strings.nullToEmpty(input.getHighlightedText()));
created.setCompetingInterestBody(Strings.nullToEmpty(input.getCompetingInterestStatement()));
created.setIsRemoved(Boolean.valueOf(Strings.nullToEmpty(input.getIsRemoved())));
hibernateTemplate.save(created);
// the new comment can't have any children yet
List<Comment> childComments = ImmutableList.of();
CompetingInterestPolicy competingInterestPolicy = new CompetingInterestPolicy(runtimeConfiguration);
CommentOutputView.Factory viewFactory = new CommentOutputView.Factory(competingInterestPolicy, childComments, article);
CommentOutputView view = viewFactory.buildView(created);
return ServiceResponse.reportCreated(view);
}
use of org.ambraproject.rhino.identity.Doi in project rhino by PLOS.
the class ArticleXml method setFromXml.
private void setFromXml(final ArticleMetadata.Builder article) throws XmlContentException {
Doi doi = readDoi();
article.setDoi(doi.getName());
article.setTitle(getXmlFromNode(readNode("/article/front/article-meta/title-group/article-title")));
String eissn = readString("/article/front/journal-meta/issn[@pub-type=\"epub\"]");
if (Strings.isNullOrEmpty(eissn)) {
eissn = readString("/article/front/journal-meta/issn");
}
article.seteIssn(checkEissn(eissn));
article.setDescription(getXmlFromNode(findAbstractNode()));
String rights = readString("/article/front/article-meta/permissions/copyright-statement");
if (rights == null) {
rights = buildRights(readString("/article/front/article-meta/permissions/copyright-holder"), readString("/article/front/article-meta/permissions/license/license-p"));
}
article.setRights(rights);
article.setPageCount(parsePageCount(readString("/article/front/article-meta/counts/page-count/@count")));
article.seteLocationId(readString("/article/front/article-meta/elocation-id"));
article.setVolume(readString("/article/front/article-meta/volume"));
article.setIssue(readString("/article/front/article-meta/issue"));
article.setPublisherName(readString("/article/front/journal-meta/publisher/publisher-name"));
article.setPublisherLocation(readString("/article/front/journal-meta/publisher/publisher-loc"));
article.setLanguage(parseLanguage(readString("/article/@xml:lang")));
Node dateNode = readNode("/article/front/article-meta/pub-date[@pub-type=\"epub\"]");
if (dateNode == null) {
dateNode = readNode("/article/front/article-meta/pub-date[@publication-format=\"electronic\"]");
}
article.setPublicationDate(parseDate(dateNode));
article.setNlmArticleType(readString("/article/@article-type"));
article.setArticleType(parseArticleHeading());
article.setEditors(readPersons(readNodeList("/article/front/article-meta/contrib-group/contrib[@contrib-type=\"editor\"]/name")));
article.setUrl(buildUrl(doi));
article.setRelatedArticles(parseRelatedArticles());
article.setAssets(parseAssets());
}
use of org.ambraproject.rhino.identity.Doi in project rhino by PLOS.
the class ArticleCrudServiceImpl method getManuscriptMetadata.
@Override
public RepoObjectMetadata getManuscriptMetadata(ArticleIngestion ingestion) {
Doi articleDoi = Doi.create(ingestion.getArticle().getDoi());
ArticleIngestionIdentifier ingestionId = ArticleIngestionIdentifier.create(articleDoi, ingestion.getIngestionNumber());
ArticleItemIdentifier articleItemId = ingestionId.getItemFor();
ArticleFileIdentifier manuscriptId = ArticleFileIdentifier.create(articleItemId, "manuscript");
RepoObjectMetadata objectMetadata = assetCrudService.getArticleItemFile(manuscriptId);
return objectMetadata;
}
Aggregations