diff --git a/search-commons/src/main/java/no/unit/nva/search/resource/SimplifiedResourceModelMutator.java b/search-commons/src/main/java/no/unit/nva/search/resource/SimplifiedResourceModelMutator.java index ee48f21da..926db0fbe 100644 --- a/search-commons/src/main/java/no/unit/nva/search/resource/SimplifiedResourceModelMutator.java +++ b/search-commons/src/main/java/no/unit/nva/search/resource/SimplifiedResourceModelMutator.java @@ -39,6 +39,7 @@ public class SimplifiedResourceModelMutator implements JsonNodeMutator { public static final String ID = "id"; + public static final String IDENTIFIER = "identifier"; public static final String AFFILIATIONS = "affiliations"; public static final String PUBLICATION_INSTANCE = "publicationInstance"; public static final String TYPE = "type"; @@ -90,6 +91,7 @@ public static String path(String... path) { public static List getIncludedFields() { return List.of( ID, + IDENTIFIER, STATUS, CREATED_DATE, MODIFIED_DATE, @@ -140,7 +142,8 @@ private static PublicationDate mutatePublicationDate(JsonNode source) { private ResourceSearchResponse transformToDto(JsonNode source) throws IOException { return new Builder() - .withId(source.path(ID).textValue()) + .withId(uriFromText(source.path(ID).textValue())) + .withIdentifier(source.path(IDENTIFIER).textValue()) .withType( source.path(ENTITY_DESCRIPTION) .path(REFERENCE) diff --git a/search-commons/src/main/java/no/unit/nva/search/resource/response/ResourceSearchResponse.java b/search-commons/src/main/java/no/unit/nva/search/resource/response/ResourceSearchResponse.java index e602437dd..af78b994d 100644 --- a/search-commons/src/main/java/no/unit/nva/search/resource/response/ResourceSearchResponse.java +++ b/search-commons/src/main/java/no/unit/nva/search/resource/response/ResourceSearchResponse.java @@ -2,11 +2,13 @@ import com.fasterxml.jackson.annotation.JsonProperty; +import java.net.URI; import java.util.List; import java.util.Map; public record ResourceSearchResponse( - String id, + URI id, + String identifier, String type, OtherIdentifiers otherIdentifiers, RecordMetadata recordMetadata, @@ -21,7 +23,8 @@ public record ResourceSearchResponse( public static final class Builder { - private String id; + private URI id; + private String identifier; private String type; private OtherIdentifiers otherIdentifiers; private RecordMetadata recordMetadata; @@ -40,11 +43,16 @@ public static Builder aResourceSearchResponse() { return new Builder(); } - public Builder withId(String id) { + public Builder withId(URI id) { this.id = id; return this; } + public Builder withIdentifier(String identifier) { + this.identifier = identifier; + return this; + } + public Builder withType(String type) { this.type = type; return this; @@ -103,6 +111,7 @@ public Builder withPublishingDetails(PublishingDetails publishingDetails) { public ResourceSearchResponse build() { return new ResourceSearchResponse( id, + identifier, type, otherIdentifiers, recordMetadata, diff --git a/search-handlers/src/test/java/no/unit/nva/search/SearchResource20241201HandlerTest.java b/search-handlers/src/test/java/no/unit/nva/search/SearchResource20241201HandlerTest.java index 943adce11..f383fad1b 100644 --- a/search-handlers/src/test/java/no/unit/nva/search/SearchResource20241201HandlerTest.java +++ b/search-handlers/src/test/java/no/unit/nva/search/SearchResource20241201HandlerTest.java @@ -33,6 +33,7 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; +import java.net.URI; import java.nio.file.Path; import java.util.Map; @@ -83,7 +84,10 @@ public void shouldReturnAResponseThatCanBeMappedToModelDto() throws IOException assertThat( firstHitDto.id(), - is(equalTo("http://localhost/publication/f367b260-c15e-4d0f-b197-e1dc0e9eb0e8"))); + is( + equalTo( + URI.create( + "http://localhost/publication/f367b260-c15e-4d0f-b197-e1dc0e9eb0e8")))); } private InputStream getInputStream() throws JsonProcessingException {