Skip to content

Commit

Permalink
add missing identifier in simplified resource model (#619)
Browse files Browse the repository at this point in the history
  • Loading branch information
sondrev authored Dec 13, 2024
1 parent f0531e6 commit 695ef66
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -90,6 +91,7 @@ public static String path(String... path) {
public static List<String> getIncludedFields() {
return List.of(
ID,
IDENTIFIER,
STATUS,
CREATED_DATE,
MODIFIED_DATE,
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -103,6 +111,7 @@ public Builder withPublishingDetails(PublishingDetails publishingDetails) {
public ResourceSearchResponse build() {
return new ResourceSearchResponse(
id,
identifier,
type,
otherIdentifiers,
recordMetadata,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 695ef66

Please sign in to comment.