Skip to content

Commit

Permalink
Merge pull request #80 from Markus92/add_creator
Browse files Browse the repository at this point in the history
Added creator field to discovery service
  • Loading branch information
PatrickDekkerHealthRI authored Aug 5, 2024
2 parents 5de0d1c + afa5e08 commit 9aa714b
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand Down Expand Up @@ -90,6 +91,14 @@ private ContactPoint contactPointEntry(CkanContactPoint value) {
.build();
}

private List<ValueLabel> 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())
Expand Down Expand Up @@ -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))
Expand Down
14 changes: 14 additions & 0 deletions src/main/openapi/ckan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@ components:
items:
$ref: "#/components/schemas/CkanContactPoint"
title: Contacts
creators:
type: array
items:
$ref: "#/components/schemas/CkanCreator"
datasetRelationships:
type: array
items:
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 4 additions & 0 deletions src/main/openapi/discovery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,10 @@ components:
contact:
$ref: "#/components/schemas/ValueLabel"
title: Contact
creators:
type: array
items:
$ref: "#/components/schemas/ValueLabel"
hasVersions:
type: array
items:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -121,6 +123,12 @@ void can_parse() {
CkanContactPoint.builder().name("Contact 2").email("[email protected]")
.build()
))
.creators(List.of(
CkanCreator.builder()
.creatorName("creatorName")
.creatorIdentifier("creatorIdentifier")
.build()
))
.datasetRelationships(List.of(
CkanDatasetRelationEntry.builder().target("Dataset 1").relation(
"Relation 1").build(),
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 9aa714b

Please sign in to comment.