use of org.ambraproject.rhino.model.ingest.ArticleFileInput in project rhino by PLOS.
the class ContentRepoPersistenceServiceImpl method createItem.
@Override
public ArticleItem createItem(ArticleItemInput itemInput, ArticleIngestion ingestion) {
ArticleItem item = new ArticleItem();
item.setIngestion(ingestion);
item.setDoi(itemInput.getDoi().getName());
item.setItemType(itemInput.getType());
Collection<ArticleFile> files = new ArrayList<>(itemInput.getFiles().entrySet().size());
for (Map.Entry<String, ArticleFileInput> entry : itemInput.getFiles().entrySet()) {
ArticleFileInput fileInput = entry.getValue();
RepoVersion repoVersion = contentRepoService.autoCreateRepoObject(fileInput.getObject()).getVersion();
ArticleFile file = new ArticleFile();
file.setIngestion(ingestion);
file.setItem(item);
file.setFileType(entry.getKey());
RepoId repoId = repoVersion.getId();
file.setBucketName(repoId.getBucketName());
file.setCrepoKey(repoId.getKey());
file.setCrepoUuid(repoVersion.getUuid().toString());
file.setFileSize(contentRepoService.getRepoObjectMetadata(repoVersion).getSize());
file.setIngestedFileName(fileInput.getFilename());
files.add(file);
}
item.setFiles(files);
return item;
}
use of org.ambraproject.rhino.model.ingest.ArticleFileInput in project rhino by PLOS.
the class ContentRepoPersistenceServiceImpl method persistAncillaryFiles.
// TODO: 12/9/16 merge some of the shared logic between these two methods
@Override
public Collection<ArticleFile> persistAncillaryFiles(ArticlePackage articlePackage, ArticleIngestion ingestion) {
Collection<ArticleFile> files = new ArrayList<>();
for (ArticleFileInput ancillaryFile : articlePackage.getAncillaryFiles()) {
RepoVersion repoVersion = contentRepoService.autoCreateRepoObject(ancillaryFile.getObject()).getVersion();
ArticleFile file = new ArticleFile();
file.setIngestion(ingestion);
file.setFileSize(contentRepoService.getRepoObjectMetadata(repoVersion).getSize());
file.setIngestedFileName(ancillaryFile.getFilename());
RepoId repoId = repoVersion.getId();
file.setBucketName(repoId.getBucketName());
file.setCrepoKey(repoId.getKey());
file.setCrepoUuid(repoVersion.getUuid().toString());
files.add(file);
}
return files;
}
Aggregations