diff --git a/pass-deposit-services/deposit-core/src/main/java/org/eclipse/pass/deposit/provider/nihms/NihmsMetadataSerializer.java b/pass-deposit-services/deposit-core/src/main/java/org/eclipse/pass/deposit/provider/nihms/NihmsMetadataSerializer.java index cc420733..67700fd6 100644 --- a/pass-deposit-services/deposit-core/src/main/java/org/eclipse/pass/deposit/provider/nihms/NihmsMetadataSerializer.java +++ b/pass-deposit-services/deposit-core/src/main/java/org/eclipse/pass/deposit/provider/nihms/NihmsMetadataSerializer.java @@ -108,23 +108,41 @@ private void write_metadata(Document doc) { LocalDate now = LocalDate.now(); if (lift.isAfter(now)) { - Period period = Period.between(LocalDate.now(), lift); - root.setAttribute("embargo-months", "" + period.getMonths()); + long months = Period.between(LocalDate.now(), lift).toTotalMonths(); + + // The max embargo time is 12 months + if (months > 12) { + months = 12; + } + + root.setAttribute("embargo-months", "" + months); } } + if (article != null && article.getDoi() != null) { + // DOI may not include UTI's scheme or host, only path + String path = article.getDoi().getPath(); + if (path.startsWith("/")) { + path = path.substring(1); + } + + root.setAttribute("doi", path); + } + + // There is an optional agency attribute. + // Should only be used for non-NIH funders when grant information is also given + if (journal != null) { Element journal_meta = doc.createElement("journal-meta"); root.appendChild(journal_meta); add_text_element(doc, journal_meta, "nlm-ta", journal.getJournalId()); + // If the IssnPubType is incomplete (either the pubType or issn is null or + // empty), we should omit it from the metadata, per NIH's requirements. + // See https://github.com/OA-PASS/metadata-schemas/pull/28 and + // https://github.com/OA-PASS/jhu-package-providers/issues/16 journal.getIssnPubTypes().values().forEach(issnPubType -> { - // if the IssnPubType is incomplete (either the pubType or issn is null or - // empty), we should - // omit it from the metadata, per NIH's requirements - // See https://github.com/OA-PASS/metadata-schemas/pull/28 and - // https://github.com/OA-PASS/jhu-package-providers/issues/16 if (issnPubType.pubType == null || issnPubType.issn == null || issnPubType.issn.trim().isEmpty()) { LOG.debug("Discarding incomplete ISSN: {}", issnPubType); return; @@ -139,27 +157,13 @@ private void write_metadata(Document doc) { }); add_text_element(doc, journal_meta, "journal-title", journal.getJournalTitle()); - - // TODO No place for journal.getJournalType } - if (manuscript != null) { + if (manuscript != null && manuscript.title != null) { add_text_element(doc, root, "manuscript-title", manuscript.title); } - // TODO No place to put manuscript.getManuscriptUrl() - // TODO Add citation element? - - if (article != null && article.getDoi() != null) { - // DOI may not include UTI's scheme or host, only path - // TODO Cannot find any documentation about this - String path = article.getDoi().getPath(); - if (path.startsWith("/")) { - path = path.substring(1); - } - - root.setAttribute("doi", path); - } + // Could add a citation element if we had all the information List persons = metadata.getPersons(); @@ -205,5 +209,8 @@ private void write_metadata(Document doc) { } } } + + // Could add grant information here if it was useful. + // Can only be used for a set list of funders } } diff --git a/pass-deposit-services/deposit-core/src/test/java/org/eclipse/pass/deposit/provider/nihms/NihmsAssemblerTest.java b/pass-deposit-services/deposit-core/src/test/java/org/eclipse/pass/deposit/provider/nihms/NihmsAssemblerTest.java index 7686d3b9..12572bd5 100644 --- a/pass-deposit-services/deposit-core/src/test/java/org/eclipse/pass/deposit/provider/nihms/NihmsAssemblerTest.java +++ b/pass-deposit-services/deposit-core/src/test/java/org/eclipse/pass/deposit/provider/nihms/NihmsAssemblerTest.java @@ -55,7 +55,7 @@ public void setUp() throws Exception { mdBuilder = mock(MetadataBuilder.class); String expectedSubmissionUuid = UUID.randomUUID().toString(); - when(submission.getId()).thenReturn("http://example.org/" + expectedSubmissionUuid); + when(submission.getId()).thenReturn(expectedSubmissionUuid); when(mdBuilder.build()).thenReturn(metadata);