Skip to content

Commit

Permalink
fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
StigNorland committed Jan 9, 2025
1 parent 04bc2f5 commit ebe785b
Showing 1 changed file with 43 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;

Expand Down Expand Up @@ -172,36 +173,7 @@ private Map<String, String> jsonNodeMapToMap(JsonNode source) {
}

private OtherIdentifiers mutateOtherIdentifiers(JsonNode source) throws IOException {
var issns =
Stream.of(
source
.path(ENTITY_DESCRIPTION)
.path(REFERENCE)
.path(PUBLICATION_CONTEXT)
.path(ONLINE_ISSN)
.textValue(),
source
.path(ENTITY_DESCRIPTION)
.path(REFERENCE)
.path(PUBLICATION_CONTEXT)
.path(PRINT_ISSN)
.textValue(),
source
.path(ENTITY_DESCRIPTION)
.path(REFERENCE)
.path(PUBLICATION_CONTEXT)
.path(SERIES)
.path(ONLINE_ISSN)
.textValue(),
source
.path(ENTITY_DESCRIPTION)
.path(REFERENCE)
.path(PUBLICATION_CONTEXT)
.path(SERIES)
.path(PRINT_ISSN)
.textValue())
.filter(Objects::nonNull)
.collect(Collectors.toSet());
var issns = getIssns(source);

var isbnsInSourceNode =
source.path(ENTITY_DESCRIPTION).path(REFERENCE).path(PUBLICATION_CONTEXT).path(ISBN_LIST);
Expand All @@ -219,16 +191,11 @@ private OtherIdentifiers mutateOtherIdentifiers(JsonNode source) throws IOExcept
.iterator()
.forEachRemaining(
manifest -> {
if (!manifest.get(ISBN_LIST).isMissingNode()) {
List<String> isbns =
(List<String>)
attempt(
() ->
objectMapper
.readerForListOf(String.class)
.readValue(manifest.get(ISBN_LIST)))
.orElseThrow();
isbnsInManifestations.addAll(isbns);
if (!manifest.path(ISBN_LIST).isMissingNode()) {
manifest
.get(ISBN_LIST)
.elements()
.forEachRemaining(isbn -> isbnsInManifestations.add(isbn.textValue()));
}
});
}
Expand All @@ -249,17 +216,10 @@ private OtherIdentifiers mutateOtherIdentifiers(JsonNode source) throws IOExcept
.forEachRemaining(
i -> {
switch (i.path(TYPE).textValue()) {
case HANDLE_IDENTIFIER:
handleIdentifiers.add(i.path(VALUE).textValue());
break;
case SCOPUS_IDENTIFIER:
scopusIdentifiers.add(i.path(VALUE).textValue());
break;
case CRISTIN_IDENTIFIER:
cristinIdentifiers.add(i.path(VALUE).textValue());
break;
default:
break;
case HANDLE_IDENTIFIER -> handleIdentifiers.add(i.path(VALUE).textValue());
case SCOPUS_IDENTIFIER -> scopusIdentifiers.add(i.path(VALUE).textValue());
case CRISTIN_IDENTIFIER -> cristinIdentifiers.add(i.path(VALUE).textValue());
default -> {}
}
});

Expand All @@ -271,6 +231,38 @@ private OtherIdentifiers mutateOtherIdentifiers(JsonNode source) throws IOExcept
new HashSet<>(isbns));
}

private Set<String> getIssns(JsonNode source) {
return Stream.of(
source
.path(ENTITY_DESCRIPTION)
.path(REFERENCE)
.path(PUBLICATION_CONTEXT)
.path(ONLINE_ISSN)
.textValue(),
source
.path(ENTITY_DESCRIPTION)
.path(REFERENCE)
.path(PUBLICATION_CONTEXT)
.path(PRINT_ISSN)
.textValue(),
source
.path(ENTITY_DESCRIPTION)
.path(REFERENCE)
.path(PUBLICATION_CONTEXT)
.path(SERIES)
.path(ONLINE_ISSN)
.textValue(),
source
.path(ENTITY_DESCRIPTION)
.path(REFERENCE)
.path(PUBLICATION_CONTEXT)
.path(SERIES)
.path(PRINT_ISSN)
.textValue())
.filter(Objects::nonNull)
.collect(Collectors.toSet());
}

private RecordMetadata mutateRecordMetadata(JsonNode source) {
return new RecordMetadata(
source.path(STATUS).textValue(), source.path(CREATED_DATE).textValue(),
Expand Down

0 comments on commit ebe785b

Please sign in to comment.