Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(openchallenges): update OC data model and API specs #2399

Merged
merged 23 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ src/main/java/org/sagebionetworks/openchallenges/challenge/service/model/dto/Cha
src/main/java/org/sagebionetworks/openchallenges/challenge/service/model/dto/ChallengeContributionDto.java
src/main/java/org/sagebionetworks/openchallenges/challenge/service/model/dto/ChallengeContributionRoleDto.java
src/main/java/org/sagebionetworks/openchallenges/challenge/service/model/dto/ChallengeContributionsPageDto.java
src/main/java/org/sagebionetworks/openchallenges/challenge/service/model/dto/ChallengeDifficultyDto.java
src/main/java/org/sagebionetworks/openchallenges/challenge/service/model/dto/ChallengeDirectionDto.java
src/main/java/org/sagebionetworks/openchallenges/challenge/service/model/dto/ChallengeDto.java
src/main/java/org/sagebionetworks/openchallenges/challenge/service/model/dto/ChallengeIncentiveDto.java
Expand Down
4 changes: 0 additions & 4 deletions apps/openchallenges/challenge-service/requests.http
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ GET {{basePath}}/challenges?status=active,upcoming

GET {{basePath}}/challenges?platforms=synapse

### List the challenges with intermediate difficulty.

GET {{basePath}}/challenges?difficulties=intermediate

### List the challenges with a container image submissions.

GET {{basePath}}/challenges?submissionTypes=container_image
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ default ResponseEntity<ChallengeDto> getChallenge(Long challengeId) {
for (MediaType mediaType : MediaType.parseMediaTypes(request.getHeader("Accept"))) {
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
String exampleString =
"{ \"avatarUrl\" : \"http://example.com/aeiou\", \"endDate\" : \"2017-07-21T00:00:00.000+00:00\", \"description\" : \"This is an example description of the challenge.\", \"platform\" : { \"name\" : \"name\", \"id\" : 1, \"slug\" : \"example-challenge-platform\" }, \"starredCount\" : 0, \"difficulty\" : \"intermediate\", \"createdAt\" : \"2022-07-04T22:19:11Z\", \"incentives\" : [ \"publication\", \"publication\" ], \"submissionTypes\" : [ \"container_image\", \"container_image\" ], \"websiteUrl\" : \"http://example.com/aeiou\", \"name\" : \"name\", \"id\" : 1, \"headline\" : \"Example challenge headline\", \"slug\" : \"awesome-challenge\", \"startDate\" : \"2017-07-21T00:00:00.000+00:00\", \"doi\" : \"doi\", \"status\" : \"active\", \"inputDataTypes\" : [ { \"name\" : \"gene expression\", \"id\" : 1, \"slug\" : \"gene-expression\" }, { \"name\" : \"gene expression\", \"id\" : 1, \"slug\" : \"gene-expression\" } ], \"updatedAt\" : \"2022-07-04T22:19:11Z\" }";
"{ \"avatarUrl\" : \"https://openchallenges.io\", \"endDate\" : \"2017-07-21T00:00:00.000+00:00\", \"description\" : \"This is an example description of the challenge.\", \"platform\" : { \"name\" : \"name\", \"id\" : 1, \"slug\" : \"example-challenge-platform\" }, \"starredCount\" : 100, \"createdAt\" : \"2022-07-04T22:19:11Z\", \"incentives\" : [ \"publication\", \"publication\" ], \"submissionTypes\" : [ \"container_image\", \"container_image\" ], \"websiteUrl\" : \"https://openchallenges.io\", \"name\" : \"name\", \"id\" : 1, \"headline\" : \"Example challenge headline\", \"slug\" : \"awesome-challenge\", \"startDate\" : \"2017-07-21T00:00:00.000+00:00\", \"doi\" : \"https://doi.org/123/abc\", \"status\" : \"active\", \"inputDataTypes\" : [ { \"name\" : \"gene expression\", \"id\" : 1, \"slug\" : \"gene-expression\" }, { \"name\" : \"gene expression\", \"id\" : 1, \"slug\" : \"gene-expression\" } ], \"updatedAt\" : \"2022-07-04T22:19:11Z\" }";
ApiUtil.setExampleResponse(request, "application/json", exampleString);
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import org.sagebionetworks.openchallenges.challenge.service.model.dto.ChallengeCategoryDto;
import org.sagebionetworks.openchallenges.challenge.service.model.dto.ChallengeContributionRoleDto;
import org.sagebionetworks.openchallenges.challenge.service.model.dto.ChallengeDifficultyDto;
import org.sagebionetworks.openchallenges.challenge.service.model.dto.ChallengeDirectionDto;
import org.sagebionetworks.openchallenges.challenge.service.model.dto.ChallengeIncentiveDto;
import org.sagebionetworks.openchallenges.challenge.service.model.dto.ChallengeInputDataTypeDirectionDto;
Expand Down Expand Up @@ -39,16 +38,6 @@ public ChallengeContributionRoleDto convert(String source) {
};
}

@Bean
Converter<String, ChallengeDifficultyDto> challengeDifficultyConverter() {
return new Converter<String, ChallengeDifficultyDto>() {
@Override
public ChallengeDifficultyDto convert(String source) {
return ChallengeDifficultyDto.fromValue(source);
}
};
}

@Bean
Converter<String, ChallengeDirectionDto> challengeDirectionConverter() {
return new Converter<String, ChallengeDirectionDto>() {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,25 @@ public class ChallengeDto {
private String name;

@JsonProperty("headline")
private String headline;
private String headline = null;

@JsonProperty("description")
private String description;

@JsonProperty("doi")
private String doi;
private String doi = null;

@JsonProperty("status")
private ChallengeStatusDto status;

@JsonProperty("difficulty")
private ChallengeDifficultyDto difficulty;

@JsonProperty("platform")
private SimpleChallengePlatformDto platform;
private SimpleChallengePlatformDto platform = null;

@JsonProperty("websiteUrl")
private String websiteUrl;
private String websiteUrl = null;

@JsonProperty("avatarUrl")
private String avatarUrl;
private String avatarUrl = null;

@JsonProperty("incentives")
@Valid
Expand Down Expand Up @@ -115,7 +112,7 @@ public ChallengeDto slug(String slug) {
}

/**
* The slug of the challenge.
* The unique slug of the challenge.
*
* @return slug
*/
Expand All @@ -125,7 +122,7 @@ public ChallengeDto slug(String slug) {
@Schema(
name = "slug",
example = "awesome-challenge",
description = "The slug of the challenge.",
description = "The unique slug of the challenge.",
required = true)
public String getSlug() {
return slug;
Expand Down Expand Up @@ -211,11 +208,16 @@ public ChallengeDto doi(String doi) {
}

/**
* Get doi
* The DOI of the challenge.
*
* @return doi
*/
@Schema(name = "doi", required = false)
@Size(max = 120)
@Schema(
name = "doi",
example = "https://doi.org/123/abc",
description = "The DOI of the challenge.",
required = false)
public String getDoi() {
return doi;
}
Expand Down Expand Up @@ -245,27 +247,6 @@ public void setStatus(ChallengeStatusDto status) {
this.status = status;
}

public ChallengeDto difficulty(ChallengeDifficultyDto difficulty) {
this.difficulty = difficulty;
return this;
}

/**
* Get difficulty
*
* @return difficulty
*/
@NotNull
@Valid
@Schema(name = "difficulty", required = true)
public ChallengeDifficultyDto getDifficulty() {
return difficulty;
}

public void setDifficulty(ChallengeDifficultyDto difficulty) {
this.difficulty = difficulty;
}

public ChallengeDto platform(SimpleChallengePlatformDto platform) {
this.platform = platform;
return this;
Expand All @@ -276,9 +257,8 @@ public ChallengeDto platform(SimpleChallengePlatformDto platform) {
*
* @return platform
*/
@NotNull
@Valid
@Schema(name = "platform", required = true)
@Schema(name = "platform", required = false)
public SimpleChallengePlatformDto getPlatform() {
return platform;
}
Expand All @@ -293,11 +273,16 @@ public ChallengeDto websiteUrl(String websiteUrl) {
}

/**
* Get websiteUrl
* A URL to the website or image.
*
* @return websiteUrl
*/
@Schema(name = "websiteUrl", required = false)
@Size(max = 500)
@Schema(
name = "websiteUrl",
example = "https://openchallenges.io",
description = "A URL to the website or image.",
required = false)
public String getWebsiteUrl() {
return websiteUrl;
}
Expand All @@ -312,11 +297,16 @@ public ChallengeDto avatarUrl(String avatarUrl) {
}

/**
* Get avatarUrl
* A URL to the website or image.
*
* @return avatarUrl
*/
@Schema(name = "avatarUrl", required = false)
@Size(max = 500)
@Schema(
name = "avatarUrl",
example = "https://openchallenges.io",
description = "A URL to the website or image.",
required = false)
public String getAvatarUrl() {
return avatarUrl;
}
Expand Down Expand Up @@ -465,13 +455,15 @@ public ChallengeDto starredCount(Integer starredCount) {
}

/**
* The number of times the challenge has been starred by users.
* The number of times the challenge has been starred by users. minimum: 0
*
* @return starredCount
*/
@NotNull
@Min(0)
@Schema(
name = "starredCount",
example = "100",
description = "The number of times the challenge has been starred by users.",
required = true)
public Integer getStarredCount() {
Expand All @@ -488,13 +480,17 @@ public ChallengeDto createdAt(OffsetDateTime createdAt) {
}

/**
* Get createdAt
* Datetime when metadata was added to the OC database.
*
* @return createdAt
*/
@NotNull
@Valid
@Schema(name = "createdAt", example = "2022-07-04T22:19:11Z", required = true)
@Schema(
name = "createdAt",
example = "2022-07-04T22:19:11Z",
description = "Datetime when metadata was added to the OC database.",
required = true)
public OffsetDateTime getCreatedAt() {
return createdAt;
}
Expand All @@ -509,13 +505,17 @@ public ChallengeDto updatedAt(OffsetDateTime updatedAt) {
}

/**
* Get updatedAt
* Datetime when metadata was last modified in the OC database.
*
* @return updatedAt
*/
@NotNull
@Valid
@Schema(name = "updatedAt", example = "2022-07-04T22:19:11Z", required = true)
@Schema(
name = "updatedAt",
example = "2022-07-04T22:19:11Z",
description = "Datetime when metadata was last modified in the OC database.",
required = true)
public OffsetDateTime getUpdatedAt() {
return updatedAt;
}
Expand All @@ -540,7 +540,6 @@ public boolean equals(Object o) {
&& Objects.equals(this.description, challenge.description)
&& Objects.equals(this.doi, challenge.doi)
&& Objects.equals(this.status, challenge.status)
&& Objects.equals(this.difficulty, challenge.difficulty)
&& Objects.equals(this.platform, challenge.platform)
&& Objects.equals(this.websiteUrl, challenge.websiteUrl)
&& Objects.equals(this.avatarUrl, challenge.avatarUrl)
Expand All @@ -564,7 +563,6 @@ public int hashCode() {
description,
doi,
status,
difficulty,
platform,
websiteUrl,
avatarUrl,
Expand All @@ -589,7 +587,6 @@ public String toString() {
sb.append(" description: ").append(toIndentedString(description)).append("\n");
sb.append(" doi: ").append(toIndentedString(doi)).append("\n");
sb.append(" status: ").append(toIndentedString(status)).append("\n");
sb.append(" difficulty: ").append(toIndentedString(difficulty)).append("\n");
sb.append(" platform: ").append(toIndentedString(platform)).append("\n");
sb.append(" websiteUrl: ").append(toIndentedString(websiteUrl)).append("\n");
sb.append(" avatarUrl: ").append(toIndentedString(avatarUrl)).append("\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ public class ChallengeSearchQueryDto {
@JsonProperty("direction")
private ChallengeDirectionDto direction = null;

@JsonProperty("difficulties")
@Valid
private List<ChallengeDifficultyDto> difficulties = null;

@JsonProperty("incentives")
@Valid
private List<ChallengeIncentiveDto> incentives = null;
Expand Down Expand Up @@ -185,37 +181,6 @@ public void setDirection(ChallengeDirectionDto direction) {
this.direction = direction;
}

public ChallengeSearchQueryDto difficulties(List<ChallengeDifficultyDto> difficulties) {
this.difficulties = difficulties;
return this;
}

public ChallengeSearchQueryDto addDifficultiesItem(ChallengeDifficultyDto difficultiesItem) {
if (this.difficulties == null) {
this.difficulties = new ArrayList<>();
}
this.difficulties.add(difficultiesItem);
return this;
}

/**
* An array of challenge difficulty levels used to filter the results.
*
* @return difficulties
*/
@Valid
@Schema(
name = "difficulties",
description = "An array of challenge difficulty levels used to filter the results.",
required = false)
public List<ChallengeDifficultyDto> getDifficulties() {
return difficulties;
}

public void setDifficulties(List<ChallengeDifficultyDto> difficulties) {
this.difficulties = difficulties;
}

public ChallengeSearchQueryDto incentives(List<ChallengeIncentiveDto> incentives) {
this.incentives = incentives;
return this;
Expand Down Expand Up @@ -516,7 +481,6 @@ public boolean equals(Object o) {
&& Objects.equals(this.sort, challengeSearchQuery.sort)
&& Objects.equals(this.sortSeed, challengeSearchQuery.sortSeed)
&& Objects.equals(this.direction, challengeSearchQuery.direction)
&& Objects.equals(this.difficulties, challengeSearchQuery.difficulties)
&& Objects.equals(this.incentives, challengeSearchQuery.incentives)
&& Objects.equals(this.minStartDate, challengeSearchQuery.minStartDate)
&& Objects.equals(this.maxStartDate, challengeSearchQuery.maxStartDate)
Expand All @@ -537,7 +501,6 @@ public int hashCode() {
sort,
sortSeed,
direction,
difficulties,
incentives,
minStartDate,
maxStartDate,
Expand All @@ -559,7 +522,6 @@ public String toString() {
sb.append(" sort: ").append(toIndentedString(sort)).append("\n");
sb.append(" sortSeed: ").append(toIndentedString(sortSeed)).append("\n");
sb.append(" direction: ").append(toIndentedString(direction)).append("\n");
sb.append(" difficulties: ").append(toIndentedString(difficulties)).append("\n");
sb.append(" incentives: ").append(toIndentedString(incentives)).append("\n");
sb.append(" minStartDate: ").append(toIndentedString(minStartDate)).append("\n");
sb.append(" maxStartDate: ").append(toIndentedString(maxStartDate)).append("\n");
Expand Down
Loading