From 9dbc47f09291e95ad19d0a510d59e6870013d314 Mon Sep 17 00:00:00 2001 From: Sondre Vestad Date: Tue, 29 Oct 2024 12:53:09 +0100 Subject: [PATCH] New response model --- .../search/resource/response/Affiliation.java | 12 ++++++ .../search/resource/response/Contributor.java | 25 +++++++++++ .../search/resource/response/Identity.java | 15 +++++++ .../resource/response/OtherIdentifiers.java | 23 ++++++++++ .../resource/response/PublishingDetails.java | 30 +++++++++++++ .../resource/response/RecordMetadata.java | 18 ++++++++ .../response/ResourceSearchResponse.java | 43 +++++++++++++++++++ 7 files changed, 166 insertions(+) create mode 100644 search-commons/src/main/java/no/unit/nva/search/resource/response/Affiliation.java create mode 100644 search-commons/src/main/java/no/unit/nva/search/resource/response/Contributor.java create mode 100644 search-commons/src/main/java/no/unit/nva/search/resource/response/Identity.java create mode 100644 search-commons/src/main/java/no/unit/nva/search/resource/response/OtherIdentifiers.java create mode 100644 search-commons/src/main/java/no/unit/nva/search/resource/response/PublishingDetails.java create mode 100644 search-commons/src/main/java/no/unit/nva/search/resource/response/RecordMetadata.java create mode 100644 search-commons/src/main/java/no/unit/nva/search/resource/response/ResourceSearchResponse.java diff --git a/search-commons/src/main/java/no/unit/nva/search/resource/response/Affiliation.java b/search-commons/src/main/java/no/unit/nva/search/resource/response/Affiliation.java new file mode 100644 index 000000000..24b72b2e2 --- /dev/null +++ b/search-commons/src/main/java/no/unit/nva/search/resource/response/Affiliation.java @@ -0,0 +1,12 @@ +package no.unit.nva.search.resource.response; + +import com.fasterxml.jackson.annotation.JsonProperty; + +class Affiliation { + + @JsonProperty("id") + private String id; + + @JsonProperty("type") + private String type; +} diff --git a/search-commons/src/main/java/no/unit/nva/search/resource/response/Contributor.java b/search-commons/src/main/java/no/unit/nva/search/resource/response/Contributor.java new file mode 100644 index 000000000..28c968350 --- /dev/null +++ b/search-commons/src/main/java/no/unit/nva/search/resource/response/Contributor.java @@ -0,0 +1,25 @@ +package no.unit.nva.search.resource.response; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +class Contributor { + + @JsonProperty("affiliations") + private List affiliations; + + @JsonProperty("correspondingAuthor") + private boolean correspondingAuthor; + + @JsonProperty("identity") + private Identity identity; + + @JsonProperty("role") + private String role; + + @JsonProperty("sequence") + private int sequence; + + @JsonProperty("type") + private String type; +} diff --git a/search-commons/src/main/java/no/unit/nva/search/resource/response/Identity.java b/search-commons/src/main/java/no/unit/nva/search/resource/response/Identity.java new file mode 100644 index 000000000..931a5005f --- /dev/null +++ b/search-commons/src/main/java/no/unit/nva/search/resource/response/Identity.java @@ -0,0 +1,15 @@ +package no.unit.nva.search.resource.response; + +import com.fasterxml.jackson.annotation.JsonProperty; + +class Identity { + + @JsonProperty("id") + private String id; + + @JsonProperty("type") + private String type; + + @JsonProperty("name") + private String name; +} diff --git a/search-commons/src/main/java/no/unit/nva/search/resource/response/OtherIdentifiers.java b/search-commons/src/main/java/no/unit/nva/search/resource/response/OtherIdentifiers.java new file mode 100644 index 000000000..e1b049a3d --- /dev/null +++ b/search-commons/src/main/java/no/unit/nva/search/resource/response/OtherIdentifiers.java @@ -0,0 +1,23 @@ +package no.unit.nva.search.resource.response; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +public class OtherIdentifiers { + + @JsonProperty("scopus") + private List scopus; + + @JsonProperty("scopus") + private List cristin; + + @JsonProperty("scopus") + private List handle; + + @JsonProperty("scopus") + private List issn; + + @JsonProperty("scopus") + private List isbn; + +} diff --git a/search-commons/src/main/java/no/unit/nva/search/resource/response/PublishingDetails.java b/search-commons/src/main/java/no/unit/nva/search/resource/response/PublishingDetails.java new file mode 100644 index 000000000..68efbff4b --- /dev/null +++ b/search-commons/src/main/java/no/unit/nva/search/resource/response/PublishingDetails.java @@ -0,0 +1,30 @@ +package no.unit.nva.search.resource.response; + +import com.fasterxml.jackson.annotation.JsonProperty; + +class PublishingDetails { + + @JsonProperty("id") + private String id; + + @JsonProperty("type") + private String type; + + @JsonProperty("series") + private Series series; + + @JsonProperty("name") + private String name; + + @JsonProperty("doi") + private String doi; + + private class Series { + + @JsonProperty("id") + private String id; + + @JsonProperty("name") + private String name; + } +} diff --git a/search-commons/src/main/java/no/unit/nva/search/resource/response/RecordMetadata.java b/search-commons/src/main/java/no/unit/nva/search/resource/response/RecordMetadata.java new file mode 100644 index 000000000..4679bdc47 --- /dev/null +++ b/search-commons/src/main/java/no/unit/nva/search/resource/response/RecordMetadata.java @@ -0,0 +1,18 @@ +package no.unit.nva.search.resource.response; + +import com.fasterxml.jackson.annotation.JsonProperty; + +class RecordMetadata { + + @JsonProperty("status") + private String status; + + @JsonProperty("createdDate") + private String createdDate; + + @JsonProperty("modifiedDate") + private String modifiedDate; + + @JsonProperty("publishedDate") + private String publishedDate; +} 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 new file mode 100644 index 000000000..c2257a9aa --- /dev/null +++ b/search-commons/src/main/java/no/unit/nva/search/resource/response/ResourceSearchResponse.java @@ -0,0 +1,43 @@ +package no.unit.nva.search.resource.response; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +public class ResourceSearchResponse { + + @JsonProperty("id") + private String id; + + @JsonProperty("type") + private String type; + + @JsonProperty("otherIdentifiers") + private OtherIdentifiers otherIdentifiers; + + @JsonProperty("recordMetadata") + private RecordMetadata recordMetadata; + + @JsonProperty("mainTitle") + private String mainTitle; + + @JsonProperty("abstract") + private String mainLanguageAbstract; + + @JsonProperty("description") + private String description; + + @JsonProperty("alternativeTitles") + private List alternativeTitles; + + @JsonProperty("publicationDate") + private String publicationDate; + + @JsonProperty("contributorsPreview") + private List contributorsPreview; + + @JsonProperty("contributorsCount") + private int contributorsCount; + + @JsonProperty("publishingDetails") + private PublishingDetails publishingDetails; +}