From b07cbd1b51a9ac19b76a2712fee8e204790277b6 Mon Sep 17 00:00:00 2001 From: zia alborzi Date: Fri, 26 Jul 2024 09:24:54 +0200 Subject: [PATCH 1/8] add dataset relations and dictionary --- .../discovery/utils/PackageShowMapper.java | 67 +++++++++++++++++-- src/main/openapi/ckan.yaml | 55 ++++++++++++--- src/main/openapi/discovery.yaml | 62 ++++++++++++++--- 3 files changed, 161 insertions(+), 23 deletions(-) diff --git a/src/main/java/io/github/genomicdatainfrastructure/discovery/utils/PackageShowMapper.java b/src/main/java/io/github/genomicdatainfrastructure/discovery/utils/PackageShowMapper.java index a6bb54a..3664c4b 100644 --- a/src/main/java/io/github/genomicdatainfrastructure/discovery/utils/PackageShowMapper.java +++ b/src/main/java/io/github/genomicdatainfrastructure/discovery/utils/PackageShowMapper.java @@ -7,9 +7,7 @@ import java.util.List; import java.util.Objects; -import io.github.genomicdatainfrastructure.discovery.model.RetrievedDataset; -import io.github.genomicdatainfrastructure.discovery.model.RetrievedDistribution; -import io.github.genomicdatainfrastructure.discovery.model.ValueLabel; +import io.github.genomicdatainfrastructure.discovery.model.*; import io.github.genomicdatainfrastructure.discovery.remote.ckan.model.*; import lombok.experimental.UtilityClass; @@ -44,16 +42,75 @@ public RetrievedDataset from(CkanPackage ckanPackage) { .url(ckanPackage.getUrl()) .languages(values(ckanPackage.getLanguage())) .contact(value(ckanPackage.getContactUri())) - .hasVersions(values(ckanPackage.getHasVersion())) .accessRights(value(ckanPackage.getAccessRights())) - .conformsTo(values(ckanPackage.getConformsTo())) .provenance(ckanPackage.getProvenance()) .spatial(value(ckanPackage.getSpatialUri())) .distributions(distributions(ckanPackage)) .keywords(keywords(ckanPackage)) + .contacts(contactPoints(ckanPackage.getContacts())) + .datasetRelationships(relations(ckanPackage.getDatasetRelationships())) + .dataDictionary(dictionary(ckanPackage.getDataDictionary())) .build(); } + private List contactPoints(List values) { + return ofNullable(values) + .orElseGet(List::of) + .stream() + .map(PackageShowMapper::contactPoint) + .filter(Objects::nonNull) + .toList(); + } + + private List relations(List values) { + return ofNullable(values) + .orElseGet(List::of) + .stream() + .map(PackageShowMapper::relation) + .filter(Objects::nonNull) + .toList(); + } + + private List dictionary(List values) { + return ofNullable(values) + .orElseGet(List::of) + .stream() + .map(PackageShowMapper::dictionaryEntry) + .filter(Objects::nonNull) + .toList(); + } + + private ContactPoints contactPoint(CkanContactPoints value) { + return ofNullable(value) + .filter(Objects::nonNull) + .map(it -> ContactPoints.builder() + .name(it.getName()) + .email(it.getEmail()) + .build()) + .orElse(null); + } + + private DatasetRelationEntry relation(CkanDatasetRelationEntry value) { + return ofNullable(value) + .filter(Objects::nonNull) + .map(it -> DatasetRelationEntry.builder() + .relation(it.getRelation()) + .target(it.getTarget()) + .build()) + .orElse(null); + } + + private DatasetDictionaryEntry dictionaryEntry(CkanDatasetDictionaryEntry value) { + return ofNullable(value) + .filter(Objects::nonNull) + .map(it -> DatasetDictionaryEntry.builder() + .name(it.getName()) + .type(it.getType()) + .description(it.getDescription()) + .build()) + .orElse(null); + } + private List values(List values) { return ofNullable(values) .orElseGet(List::of) diff --git a/src/main/openapi/ckan.yaml b/src/main/openapi/ckan.yaml index 28e77e9..8255fda 100644 --- a/src/main/openapi/ckan.yaml +++ b/src/main/openapi/ckan.yaml @@ -159,6 +159,21 @@ components: type: array items: $ref: "#/components/schemas/CkanTag" + contacts: + type: array + items: + $ref: "#/components/schemas/CkanContactPoints" + title: Contacts + datasetRelationships: + type: array + items: + $ref: "#/components/schemas/CkanDatasetRelationEntry" + title: Dataset Relationships + dataDictionary: + type: array + items: + $ref: "#/components/schemas/CkanDatasetDictionaryEntry" + title: Data Dictionary publisher_name: type: string organization: @@ -175,16 +190,8 @@ components: $ref: "#/components/schemas/CkanValueLabel" contact_uri: type: string - has_version: - type: array - items: - $ref: "#/components/schemas/CkanValueLabel" access_rights: $ref: "#/components/schemas/CkanValueLabel" - conforms_to: - type: array - items: - $ref: "#/components/schemas/CkanValueLabel" provenance: type: string spatial_uri: @@ -196,6 +203,38 @@ components: required: - id - title + CkanContactPoints: + properties: + name: + type: string + title: name + email: + type: string + title: email + required: + - name + - email + CkanDatasetRelationEntry: + properties: + relation: + type: string + target: + type: string + required: + - target + - relation + CkanDatasetDictionaryEntry: + properties: + name: + type: string + type: + type: string + description: + type: string + required: + - name + - type + - description CkanOrganization: type: object properties: diff --git a/src/main/openapi/discovery.yaml b/src/main/openapi/discovery.yaml index 0396540..cba59f5 100644 --- a/src/main/openapi/discovery.yaml +++ b/src/main/openapi/discovery.yaml @@ -210,6 +210,21 @@ components: items: $ref: "#/components/schemas/ValueLabel" title: Themes + contacts: + type: array + items: + $ref: "#/components/schemas/ContactPoints" + title: Contacts + datasetRelationships: + type: array + items: + $ref: "#/components/schemas/DatasetRelationEntry" + title: Dataset Relationships + dataDictionary: + type: array + items: + $ref: "#/components/schemas/DatasetDictionaryEntry" + title: Data Dictionary publisherName: type: string title: Publisher Name @@ -235,19 +250,9 @@ components: contact: $ref: "#/components/schemas/ValueLabel" title: Contact - hasVersions: - type: array - items: - $ref: "#/components/schemas/ValueLabel" - title: Has Versions accessRights: $ref: "#/components/schemas/ValueLabel" title: Access Rights - conformsTo: - type: array - items: - $ref: "#/components/schemas/ValueLabel" - title: Conforms to keywords: type: array items: @@ -312,6 +317,43 @@ components: required: - value - label + ContactPoints: + properties: + name: + type: string + title: name + email: + type: string + title: email + required: + - name + - email + DatasetRelationEntry: + properties: + relation: + type: string + title: relation + target: + type: string + title: target + required: + - target + - relation + DatasetDictionaryEntry: + properties: + name: + type: string + title: name + type: + type: string + title: type + description: + type: string + title: description + required: + - name + - type + - description FacetGroup: properties: key: From 3729a8021a20f321f830a3e5cea5179c65b61518 Mon Sep 17 00:00:00 2001 From: zia alborzi Date: Fri, 26 Jul 2024 09:32:18 +0200 Subject: [PATCH 2/8] remove tests for conform and hasversion --- .../services/PackageShowMapperTest.java | 24 ------------------- 1 file changed, 24 deletions(-) diff --git a/src/test/java/io/github/genomicdatainfrastructure/discovery/services/PackageShowMapperTest.java b/src/test/java/io/github/genomicdatainfrastructure/discovery/services/PackageShowMapperTest.java index a9b1d74..05cf9a7 100644 --- a/src/test/java/io/github/genomicdatainfrastructure/discovery/services/PackageShowMapperTest.java +++ b/src/test/java/io/github/genomicdatainfrastructure/discovery/services/PackageShowMapperTest.java @@ -29,9 +29,7 @@ void accepts_empty_package() { var actual = PackageShowMapper.from(ckanPackage); var expected = RetrievedDataset.builder() - .conformsTo(List.of()) .distributions(List.of()) - .hasVersions(List.of()) .languages(List.of()) .themes(List.of()) .keywords(List.of()) @@ -71,20 +69,10 @@ void can_parse() { .name("en") .build())) .contactUri("contactUri") - .hasVersion(List.of( - CkanValueLabel.builder() - .displayName("version") - .name("1") - .build())) .accessRights(CkanValueLabel.builder() .displayName("accessRights") .name("public") .build()) - .conformsTo(List.of( - CkanValueLabel.builder() - .displayName("conformsTo") - .name("conforms") - .build())) .provenance("provenance") .spatialUri(CkanValueLabel.builder() .displayName("spatial") @@ -133,22 +121,10 @@ void can_parse() { .value("contactUri") .label("contactUri") .build()) - .hasVersions(List.of( - ValueLabel.builder() - .value("1") - .label("version") - .build() - )) .accessRights(ValueLabel.builder() .value("public") .label("accessRights") .build()) - .conformsTo(List.of( - ValueLabel.builder() - .value("conforms") - .label("conformsTo") - .build() - )) .provenance("provenance") .keywords(List.of(ValueLabel.builder() .label("key-tag") From e9a9c20fd9c0dd81505cd108cad8c306787f9094 Mon Sep 17 00:00:00 2001 From: zia alborzi Date: Fri, 26 Jul 2024 09:57:19 +0200 Subject: [PATCH 3/8] fix test --- .../discovery/services/PackageShowMapperTest.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/test/java/io/github/genomicdatainfrastructure/discovery/services/PackageShowMapperTest.java b/src/test/java/io/github/genomicdatainfrastructure/discovery/services/PackageShowMapperTest.java index 05cf9a7..841da3f 100644 --- a/src/test/java/io/github/genomicdatainfrastructure/discovery/services/PackageShowMapperTest.java +++ b/src/test/java/io/github/genomicdatainfrastructure/discovery/services/PackageShowMapperTest.java @@ -148,6 +148,9 @@ void can_parse() { .modifiedAt(parse("2024-03-19T13:37:05.472970", DATE_FORMATTER)) .build() )) + .contacts(List.of()) + .datasetRelationships(List.of()) + .dataDictionary(List.of()) .build(); assertThat(actual) From 17f659adaa45b5a97555a1b0b45e68b3c0a70a0f Mon Sep 17 00:00:00 2001 From: zia alborzi Date: Fri, 26 Jul 2024 10:07:42 +0200 Subject: [PATCH 4/8] fix test --- .../discovery/services/PackageShowMapperTest.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/test/java/io/github/genomicdatainfrastructure/discovery/services/PackageShowMapperTest.java b/src/test/java/io/github/genomicdatainfrastructure/discovery/services/PackageShowMapperTest.java index 841da3f..026f326 100644 --- a/src/test/java/io/github/genomicdatainfrastructure/discovery/services/PackageShowMapperTest.java +++ b/src/test/java/io/github/genomicdatainfrastructure/discovery/services/PackageShowMapperTest.java @@ -33,6 +33,9 @@ void accepts_empty_package() { .languages(List.of()) .themes(List.of()) .keywords(List.of()) + .contacts(List.of()) + .datasetRelationships(List.of()) + .dataDictionary(List.of()) .build(); assertThat(actual) From 00d86962be698ec68b802c0c0912bafbc335a57a Mon Sep 17 00:00:00 2001 From: zia alborzi Date: Fri, 26 Jul 2024 10:28:21 +0200 Subject: [PATCH 5/8] fix sonar by adding test going through new codes. --- .../services/PackageShowMapperTest.java | 51 +++++++++++++++++-- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/src/test/java/io/github/genomicdatainfrastructure/discovery/services/PackageShowMapperTest.java b/src/test/java/io/github/genomicdatainfrastructure/discovery/services/PackageShowMapperTest.java index 026f326..0d00ab8 100644 --- a/src/test/java/io/github/genomicdatainfrastructure/discovery/services/PackageShowMapperTest.java +++ b/src/test/java/io/github/genomicdatainfrastructure/discovery/services/PackageShowMapperTest.java @@ -4,10 +4,20 @@ package io.github.genomicdatainfrastructure.discovery.services; +import io.github.genomicdatainfrastructure.discovery.model.ContactPoints; +import io.github.genomicdatainfrastructure.discovery.model.DatasetDictionaryEntry; +import io.github.genomicdatainfrastructure.discovery.model.DatasetRelationEntry; import io.github.genomicdatainfrastructure.discovery.model.RetrievedDataset; import io.github.genomicdatainfrastructure.discovery.model.RetrievedDistribution; import io.github.genomicdatainfrastructure.discovery.model.ValueLabel; -import io.github.genomicdatainfrastructure.discovery.remote.ckan.model.*; +import io.github.genomicdatainfrastructure.discovery.remote.ckan.model.CkanContactPoints; +import io.github.genomicdatainfrastructure.discovery.remote.ckan.model.CkanDatasetDictionaryEntry; +import io.github.genomicdatainfrastructure.discovery.remote.ckan.model.CkanDatasetRelationEntry; +import io.github.genomicdatainfrastructure.discovery.remote.ckan.model.CkanOrganization; +import io.github.genomicdatainfrastructure.discovery.remote.ckan.model.CkanPackage; +import io.github.genomicdatainfrastructure.discovery.remote.ckan.model.CkanResource; +import io.github.genomicdatainfrastructure.discovery.remote.ckan.model.CkanTag; +import io.github.genomicdatainfrastructure.discovery.remote.ckan.model.CkanValueLabel; import io.github.genomicdatainfrastructure.discovery.utils.PackageShowMapper; import org.junit.jupiter.api.Test; @@ -95,6 +105,24 @@ void can_parse() { .lastModified("2024-03-19T13:37:05.472970") .build() )) + .contacts(List.of( + CkanContactPoints.builder().name("Contact 1").email("contact1@example.com") + .build(), + CkanContactPoints.builder().name("Contact 2").email("contact2@example.com") + .build() + )) + .datasetRelationships(List.of( + CkanDatasetRelationEntry.builder().target("Dataset 1").relation( + "Relation 1").build(), + CkanDatasetRelationEntry.builder().target("Dataset 2").relation( + "Relation 2").build() + )) + .dataDictionary(List.of( + CkanDatasetDictionaryEntry.builder().name("Entry 1").type("Type 1") + .description("Description 1").build(), + CkanDatasetDictionaryEntry.builder().name("Entry 2").type("Type 2") + .description("Description 2").build() + )) .build(); var actual = PackageShowMapper.from(ckanPackage); @@ -151,9 +179,24 @@ void can_parse() { .modifiedAt(parse("2024-03-19T13:37:05.472970", DATE_FORMATTER)) .build() )) - .contacts(List.of()) - .datasetRelationships(List.of()) - .dataDictionary(List.of()) + .contacts(List.of( + ContactPoints.builder().name("Contact 1").email("contact1@example.com") + .build(), + ContactPoints.builder().name("Contact 2").email("contact2@example.com") + .build() + )) + .datasetRelationships(List.of( + DatasetRelationEntry.builder().relation("Relation 1").target("Dataset 1") + .build(), + DatasetRelationEntry.builder().relation("Relation 2").target("Dataset 2") + .build() + )) + .dataDictionary(List.of( + DatasetDictionaryEntry.builder().name("Entry 1").type("Type 1").description( + "Description 1").build(), + DatasetDictionaryEntry.builder().name("Entry 2").type("Type 2").description( + "Description 2").build() + )) .build(); assertThat(actual) From fcbd860fd5b0d4dac41412532017025163eac23f Mon Sep 17 00:00:00 2001 From: zia alborzi Date: Fri, 26 Jul 2024 14:28:08 +0200 Subject: [PATCH 6/8] answer comments --- .../discovery/utils/PackageShowMapper.java | 60 ++++++++----------- src/main/openapi/ckan.yaml | 4 +- src/main/openapi/discovery.yaml | 4 +- 3 files changed, 28 insertions(+), 40 deletions(-) diff --git a/src/main/java/io/github/genomicdatainfrastructure/discovery/utils/PackageShowMapper.java b/src/main/java/io/github/genomicdatainfrastructure/discovery/utils/PackageShowMapper.java index 3664c4b..40fe93f 100644 --- a/src/main/java/io/github/genomicdatainfrastructure/discovery/utils/PackageShowMapper.java +++ b/src/main/java/io/github/genomicdatainfrastructure/discovery/utils/PackageShowMapper.java @@ -47,18 +47,18 @@ public RetrievedDataset from(CkanPackage ckanPackage) { .spatial(value(ckanPackage.getSpatialUri())) .distributions(distributions(ckanPackage)) .keywords(keywords(ckanPackage)) - .contacts(contactPoints(ckanPackage.getContacts())) + .contacts(contactPoint(ckanPackage.getContacts())) .datasetRelationships(relations(ckanPackage.getDatasetRelationships())) .dataDictionary(dictionary(ckanPackage.getDataDictionary())) .build(); } - private List contactPoints(List values) { + private List contactPoint(List values) { return ofNullable(values) .orElseGet(List::of) .stream() - .map(PackageShowMapper::contactPoint) .filter(Objects::nonNull) + .map(PackageShowMapper::contactPointEntry) .toList(); } @@ -66,8 +66,8 @@ private List relations(List valu return ofNullable(values) .orElseGet(List::of) .stream() - .map(PackageShowMapper::relation) .filter(Objects::nonNull) + .map(PackageShowMapper::relation) .toList(); } @@ -75,48 +75,39 @@ private List dictionary(List return ofNullable(values) .orElseGet(List::of) .stream() - .map(PackageShowMapper::dictionaryEntry) .filter(Objects::nonNull) + .map(PackageShowMapper::dictionaryEntry) .toList(); } - private ContactPoints contactPoint(CkanContactPoints value) { - return ofNullable(value) - .filter(Objects::nonNull) - .map(it -> ContactPoints.builder() - .name(it.getName()) - .email(it.getEmail()) - .build()) - .orElse(null); + private ContactPoint contactPointEntry(CkanContactPoint value) { + return ContactPoint.builder() + .name(value.getName()) + .email(value.getEmail()) + .build(); } private DatasetRelationEntry relation(CkanDatasetRelationEntry value) { - return ofNullable(value) - .filter(Objects::nonNull) - .map(it -> DatasetRelationEntry.builder() - .relation(it.getRelation()) - .target(it.getTarget()) - .build()) - .orElse(null); + return DatasetRelationEntry.builder() + .relation(value.getRelation()) + .target(value.getTarget()) + .build(); } private DatasetDictionaryEntry dictionaryEntry(CkanDatasetDictionaryEntry value) { - return ofNullable(value) - .filter(Objects::nonNull) - .map(it -> DatasetDictionaryEntry.builder() - .name(it.getName()) - .type(it.getType()) - .description(it.getDescription()) - .build()) - .orElse(null); + return DatasetDictionaryEntry.builder() + .name(value.getName()) + .type(value.getType()) + .description(value.getDescription()) + .build(); } private List values(List values) { return ofNullable(values) .orElseGet(List::of) .stream() - .map(PackageShowMapper::value) .filter(Objects::nonNull) + .map(PackageShowMapper::value) .toList(); } @@ -132,13 +123,10 @@ private ValueLabel value(String value) { } private ValueLabel value(CkanValueLabel value) { - return ofNullable(value) - .filter(Objects::nonNull) - .map(it -> ValueLabel.builder() - .value(it.getName()) - .label(it.getDisplayName()) - .build()) - .orElse(null); + return ValueLabel.builder() + .value(value.getName()) + .label(value.getDisplayName()) + .build(); } private LocalDateTime parse(String date) { diff --git a/src/main/openapi/ckan.yaml b/src/main/openapi/ckan.yaml index 8255fda..061ca12 100644 --- a/src/main/openapi/ckan.yaml +++ b/src/main/openapi/ckan.yaml @@ -162,7 +162,7 @@ components: contacts: type: array items: - $ref: "#/components/schemas/CkanContactPoints" + $ref: "#/components/schemas/CkanContactPoint" title: Contacts datasetRelationships: type: array @@ -203,7 +203,7 @@ components: required: - id - title - CkanContactPoints: + CkanContactPoint: properties: name: type: string diff --git a/src/main/openapi/discovery.yaml b/src/main/openapi/discovery.yaml index cba59f5..41f7ca8 100644 --- a/src/main/openapi/discovery.yaml +++ b/src/main/openapi/discovery.yaml @@ -213,7 +213,7 @@ components: contacts: type: array items: - $ref: "#/components/schemas/ContactPoints" + $ref: "#/components/schemas/ContactPoint" title: Contacts datasetRelationships: type: array @@ -317,7 +317,7 @@ components: required: - value - label - ContactPoints: + ContactPoint: properties: name: type: string From 455cf7940ae72e5adcaf83e85f1360fb28fd4924 Mon Sep 17 00:00:00 2001 From: zia alborzi Date: Fri, 26 Jul 2024 14:50:25 +0200 Subject: [PATCH 7/8] fix test --- .../discovery/services/PackageShowMapperTest.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/test/java/io/github/genomicdatainfrastructure/discovery/services/PackageShowMapperTest.java b/src/test/java/io/github/genomicdatainfrastructure/discovery/services/PackageShowMapperTest.java index 0d00ab8..9cb61ad 100644 --- a/src/test/java/io/github/genomicdatainfrastructure/discovery/services/PackageShowMapperTest.java +++ b/src/test/java/io/github/genomicdatainfrastructure/discovery/services/PackageShowMapperTest.java @@ -4,13 +4,13 @@ package io.github.genomicdatainfrastructure.discovery.services; -import io.github.genomicdatainfrastructure.discovery.model.ContactPoints; +import io.github.genomicdatainfrastructure.discovery.model.ContactPoint; import io.github.genomicdatainfrastructure.discovery.model.DatasetDictionaryEntry; import io.github.genomicdatainfrastructure.discovery.model.DatasetRelationEntry; import io.github.genomicdatainfrastructure.discovery.model.RetrievedDataset; import io.github.genomicdatainfrastructure.discovery.model.RetrievedDistribution; import io.github.genomicdatainfrastructure.discovery.model.ValueLabel; -import io.github.genomicdatainfrastructure.discovery.remote.ckan.model.CkanContactPoints; +import io.github.genomicdatainfrastructure.discovery.remote.ckan.model.CkanContactPoint; import io.github.genomicdatainfrastructure.discovery.remote.ckan.model.CkanDatasetDictionaryEntry; import io.github.genomicdatainfrastructure.discovery.remote.ckan.model.CkanDatasetRelationEntry; import io.github.genomicdatainfrastructure.discovery.remote.ckan.model.CkanOrganization; @@ -106,9 +106,9 @@ void can_parse() { .build() )) .contacts(List.of( - CkanContactPoints.builder().name("Contact 1").email("contact1@example.com") + CkanContactPoint.builder().name("Contact 1").email("contact1@example.com") .build(), - CkanContactPoints.builder().name("Contact 2").email("contact2@example.com") + CkanContactPoint.builder().name("Contact 2").email("contact2@example.com") .build() )) .datasetRelationships(List.of( @@ -180,9 +180,9 @@ void can_parse() { .build() )) .contacts(List.of( - ContactPoints.builder().name("Contact 1").email("contact1@example.com") + ContactPoint.builder().name("Contact 1").email("contact1@example.com") .build(), - ContactPoints.builder().name("Contact 2").email("contact2@example.com") + ContactPoint.builder().name("Contact 2").email("contact2@example.com") .build() )) .datasetRelationships(List.of( From 10d94d08a4f4f798cec0af137651da413179220e Mon Sep 17 00:00:00 2001 From: zia alborzi Date: Fri, 26 Jul 2024 15:10:05 +0200 Subject: [PATCH 8/8] fix test --- .../discovery/utils/PackageShowMapper.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/io/github/genomicdatainfrastructure/discovery/utils/PackageShowMapper.java b/src/main/java/io/github/genomicdatainfrastructure/discovery/utils/PackageShowMapper.java index 40fe93f..37ad586 100644 --- a/src/main/java/io/github/genomicdatainfrastructure/discovery/utils/PackageShowMapper.java +++ b/src/main/java/io/github/genomicdatainfrastructure/discovery/utils/PackageShowMapper.java @@ -106,14 +106,13 @@ private List values(List values) { return ofNullable(values) .orElseGet(List::of) .stream() - .filter(Objects::nonNull) .map(PackageShowMapper::value) + .filter(Objects::nonNull) .toList(); } private ValueLabel value(String value) { return ofNullable(value) - .filter(Objects::nonNull) .filter(not(String::isBlank)) .map(it -> ValueLabel.builder() .value(it) @@ -123,10 +122,13 @@ private ValueLabel value(String value) { } private ValueLabel value(CkanValueLabel value) { - return ValueLabel.builder() - .value(value.getName()) - .label(value.getDisplayName()) - .build(); + return ofNullable(value) + .map(it -> ValueLabel.builder() + .value(value.getName()) + .label(value.getDisplayName()) + .build()) + .orElse(null); + } private LocalDateTime parse(String date) {