Skip to content

BI-1845 - add listType parameter to GET /lists calls#284

Merged
mlm483 merged 9 commits intodevelopfrom
feature/BI-1845
Sep 14, 2023
Merged

BI-1845 - add listType parameter to GET /lists calls#284
mlm483 merged 9 commits intodevelopfrom
feature/BI-1845

Conversation

@mlm483
Copy link
Contributor

@mlm483 mlm483 commented Aug 15, 2023

Description

Story: https://breedinginsight.atlassian.net/browse/BI-1845

Instead of defaulting to Germplasm if listType is not provided, the list controller now responds with 400 BAD REQUEST responds with all lists of all types if listType is missing in GET calls to /lists. This only applies to the /lists endpoint, and not, for example to the /lists/{listDbId} endpoint.

In order to reuse some code in ListControllerIntegrationTest.java, I moved createTraits and writeDataToFile methods from ExperimentFileImportTest.java to ImportTestUtils.java.

Dependencies

Breeding-Insight/bi-web#324

Testing

Authenticated calls to {bi-api}/v1/programs/{programId}/brapi/v2/lists should get a 400 response get a 200 response with all lists of all types for the program. Authenticated calls to {bi-api}/v1/programs/{programId}/brapi/v2/lists?listType={type} should get a 200 response with only Germplasm lists for the program.

Checklist:

  • I have performed a self-review of my own code
  • I have tested my code and ensured it meets the acceptance criteria of the story
  • I have tested that my code works with both the brapi-java-server and BreedBase
  • I have create/modified unit tests to cover this change
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to documentation
  • I have run TAF: https://github.com/Breeding-Insight/taf/actions/runs/5931132862

@mlm483 mlm483 changed the title [BI-1845] - add listType parameter to GET /lists calls BI-1845 - add listType parameter to GET /lists calls Aug 17, 2023
@mlm483 mlm483 marked this pull request as ready for review August 22, 2023 12:23
@mlm483 mlm483 requested review from davedrp and timparsons August 22, 2023 12:25
// get germplasm lists by default
BrAPIListTypes type = BrAPIListTypes.fromValue(queryParams.getListType());
if (type == null) {
type = BrAPIListTypes.GERMPLASM;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this goes against the BrAPI spec. I think we should probably return all lists if the type parameter is null. Worth confirming with @BrapiCoordinatorSelby

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The BrAPI Spec does not specifically define what should happen if listType is null.
I would expect it to return all lists of all types, in line with other GET query parameters. You might also make listType a required parameter for your implementation.
Defaulting listType to germplasm is unusual, and might cause some confusion if it is not well documented, but it is not technically against the BrAPI spec.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the input @BrapiCoordinatorSelby, all lists of all types are now returned.

Comment on lines +75 to +76
if (type != null) {
switch (type) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prevents NullPointerException for switch on null object.

@mlm483 mlm483 requested a review from timparsons August 23, 2023 18:06
Copy link
Member

@timparsons timparsons left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One suggested change to existing code, but doesn't need to stop my approval of the main change.

Comment on lines +80 to +87
default:
String createdBy = germplasmDAO.getGermplasmByRawName(listItemNames, program.getId()).get(0)
.getAdditionalInfo()
.getAsJsonObject("createdBy")
.get("userName")
.getAsString();
list.setListOwnerName(createdBy);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this wasn't a change you made, but this code should probably be moved inside the GERMPLASM case

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, d029f0d.

A switch doesn't really make sense at the moment, but I assume it will get more use in the future.

@mlm483 mlm483 merged commit 330497f into develop Sep 14, 2023
@mlm483 mlm483 deleted the feature/BI-1845 branch September 14, 2023 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants