use of org.ambraproject.rhino.content.xml.ArticleXml in project rhino by PLOS.
the class IngestionService method createIngestPackage.
private IngestPackage createIngestPackage(Archive archive, Optional<String> bucketName) throws IOException {
ManifestXml manifestXml = getManifestXml(archive);
ImmutableSet<String> entryNames = archive.getEntryNames();
manifestXml.validateManifestCompleteness(entryNames);
String manuscriptEntry = getManuscriptEntry(entryNames, manifestXml);
Document document = getDocument(archive, manuscriptEntry);
ArticleXml parsedArticle = new ArticleXml(document);
ArticleCustomMetadata customMetadata = customMetadataExtractorFactory.parse(document).build();
ArticlePackage articlePackage = new ArticlePackageBuilder(resolveBucketName(bucketName), archive, parsedArticle, manifestXml).build();
articlePackage.validateAssetCompleteness(parsedArticle.findAllAssetNodes().getDois());
ArticleMetadata articleMetadata = parsedArticle.build();
return new IngestPackage(articlePackage, articleMetadata, customMetadata);
}
use of org.ambraproject.rhino.content.xml.ArticleXml in project rhino by PLOS.
the class ArticleCrudServiceImpl method refreshArticleRelationships.
@Override
public void refreshArticleRelationships(ArticleRevision sourceArticleRev) {
ArticleXml sourceArticleXml = new ArticleXml(getManuscriptXml(sourceArticleRev.getIngestion()));
Article sourceArticle = sourceArticleRev.getIngestion().getArticle();
List<RelatedArticleLink> xmlRelationships = sourceArticleXml.parseRelatedArticles();
List<ArticleRelationship> dbRelationships = getRelationshipsFrom(ArticleIdentifier.create(sourceArticle.getDoi()));
dbRelationships.forEach(ar -> hibernateTemplate.delete(ar));
xmlRelationships.forEach(ar -> {
getArticle(ar.getArticleId()).ifPresent((Article relatedArticle) -> {
hibernateTemplate.save(fromRelatedArticleLink(sourceArticle, ar));
getLatestRevision(relatedArticle).ifPresent((ArticleRevision relatedArticleRev) -> {
ArticleXml relatedArticleXml = new ArticleXml(getManuscriptXml(relatedArticleRev.getIngestion()));
Set<ArticleRelationship> inboundDbRelationships = getRelationshipsTo(ArticleIdentifier.create(sourceArticle.getDoi())).stream().filter(dbAr -> dbAr.getSourceArticle().equals(relatedArticle)).collect(Collectors.toSet());
relatedArticleXml.parseRelatedArticles().stream().filter(ral -> ral.getArticleId().getDoiName().equals(sourceArticle.getDoi())).map(ral -> fromRelatedArticleLink(relatedArticle, ral)).filter(relatedAr -> !inboundDbRelationships.contains(relatedAr)).forEach(relatedAr -> hibernateTemplate.save(relatedAr));
});
});
});
}
Aggregations