Search in sources :

Example 1 with ArticleFileInput

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;
}
Also used : ArticleItem(org.ambraproject.rhino.model.ArticleItem) ArticleFileInput(org.ambraproject.rhino.model.ingest.ArticleFileInput) ArrayList(java.util.ArrayList) ArticleFile(org.ambraproject.rhino.model.ArticleFile) RepoId(org.plos.crepo.model.identity.RepoId) Map(java.util.Map) RepoVersion(org.plos.crepo.model.identity.RepoVersion)

Example 2 with ArticleFileInput

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;
}
Also used : ArticleFileInput(org.ambraproject.rhino.model.ingest.ArticleFileInput) ArrayList(java.util.ArrayList) ArticleFile(org.ambraproject.rhino.model.ArticleFile) RepoId(org.plos.crepo.model.identity.RepoId) RepoVersion(org.plos.crepo.model.identity.RepoVersion)

Aggregations

ArrayList (java.util.ArrayList)2 ArticleFile (org.ambraproject.rhino.model.ArticleFile)2 ArticleFileInput (org.ambraproject.rhino.model.ingest.ArticleFileInput)2 RepoId (org.plos.crepo.model.identity.RepoId)2 RepoVersion (org.plos.crepo.model.identity.RepoVersion)2 Map (java.util.Map)1 ArticleItem (org.ambraproject.rhino.model.ArticleItem)1