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 a4ecc18..31ba95c 100644 --- a/src/main/java/io/github/genomicdatainfrastructure/discovery/utils/PackageShowMapper.java +++ b/src/main/java/io/github/genomicdatainfrastructure/discovery/utils/PackageShowMapper.java @@ -43,6 +43,7 @@ public RetrievedDataset from(CkanPackage ckanPackage) { .url(ckanPackage.getUrl()) .languages(values(ckanPackage.getLanguage())) .contact(value(ckanPackage.getContactUri())) + .creators(creator(ckanPackage)) .hasVersions(values(ckanPackage.getHasVersion())) .accessRights(value(ckanPackage.getAccessRights())) .conformsTo(values(ckanPackage.getConformsTo())) @@ -90,6 +91,14 @@ private ContactPoint contactPointEntry(CkanContactPoint value) { .build(); } + private List creator(CkanPackage ckanPackage) { + return ofNullable(ckanPackage.getCreators()) + .orElseGet(List::of) + .stream() + .map(PackageShowMapper::creator) + .toList(); + } + private DatasetRelationEntry relation(CkanDatasetRelationEntry value) { return DatasetRelationEntry.builder() .relation(value.getRelation()) @@ -134,6 +143,13 @@ private ValueLabel value(CkanValueLabel value) { } + private ValueLabel creator(CkanCreator creator) { + return ValueLabel.builder() + .label(creator.getCreatorName()) + .value(creator.getCreatorIdentifier()) + .build(); + } + private LocalDateTime parse(String date) { return ofNullable(date) .map(it -> LocalDateTime.parse(it, DATE_FORMATTER)) diff --git a/src/main/openapi/ckan.yaml b/src/main/openapi/ckan.yaml index 63cd4aa..d36f5e9 100644 --- a/src/main/openapi/ckan.yaml +++ b/src/main/openapi/ckan.yaml @@ -225,6 +225,10 @@ components: items: $ref: "#/components/schemas/CkanContactPoint" title: Contacts + creators: + type: array + items: + $ref: "#/components/schemas/CkanCreator" datasetRelationships: type: array items: @@ -285,6 +289,16 @@ components: required: - name - email + CkanCreator: + type: object + properties: + creator_name: + type: string + creator_identifier: + type: string + required: + - creator_name + - creator_identifier CkanDatasetRelationEntry: properties: relation: diff --git a/src/main/openapi/discovery.yaml b/src/main/openapi/discovery.yaml index e5cb5d2..fb87e30 100644 --- a/src/main/openapi/discovery.yaml +++ b/src/main/openapi/discovery.yaml @@ -314,6 +314,10 @@ components: contact: $ref: "#/components/schemas/ValueLabel" title: Contact + creators: + type: array + items: + $ref: "#/components/schemas/ValueLabel" hasVersions: type: array items: 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 5a505b0..5fc3120 100644 --- a/src/test/java/io/github/genomicdatainfrastructure/discovery/services/PackageShowMapperTest.java +++ b/src/test/java/io/github/genomicdatainfrastructure/discovery/services/PackageShowMapperTest.java @@ -6,6 +6,7 @@ import io.github.genomicdatainfrastructure.discovery.model.*; import io.github.genomicdatainfrastructure.discovery.remote.ckan.model.CkanContactPoint; +import io.github.genomicdatainfrastructure.discovery.remote.ckan.model.CkanCreator; 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; @@ -41,6 +42,7 @@ void accepts_empty_package() { .themes(List.of()) .keywords(List.of()) .contacts(List.of()) + .creators(List.of()) .organization(DatasetOrganization.builder().build()) .datasetRelationships(List.of()) .dataDictionary(List.of()) @@ -121,6 +123,12 @@ void can_parse() { CkanContactPoint.builder().name("Contact 2").email("contact2@example.com") .build() )) + .creators(List.of( + CkanCreator.builder() + .creatorName("creatorName") + .creatorIdentifier("creatorIdentifier") + .build() + )) .datasetRelationships(List.of( CkanDatasetRelationEntry.builder().target("Dataset 1").relation( "Relation 1").build(), @@ -168,6 +176,12 @@ void can_parse() { .label("version") .build() )) + .creators(List.of( + ValueLabel.builder() + .label("creatorName") + .value("creatorIdentifier") + .build() + )) .accessRights(ValueLabel.builder() .value("public") .label("accessRights")