Repository navigation
[BI-3082] Implement generalized list item search endpoint, targeting DeltaBreed germplasm use case - #33
Conversation
- Addtional changes to processGermplasmForDisplay that was not occuring before. This was breaking features in the Lists tab
| List<GermplasmEntity> synonyms = germplasmRepository.findAllBySearch(searchQuery); | ||
|
|
||
| Map<String, List<ExternalReferenceEntity>> synonymsByEntity = new HashMap<>(); | ||
| synonyms.forEach(entity -> synonymsByEntity.put(entity.getId().toString(), entity.getExternalReferences())); |
There was a problem hiding this comment.
The synonyms block reads getExternalReferences() and calls setExternalReferences(), so synonyms are never set in findGermplasmEntitiesWithoutPaging.
I think it should be getSynonyms() / setSynonyms(), with the map typed Map<String, List<GermplasmSynonymEntity>>.
| "synonyms"); | ||
| // Because the join was overwritten above, the original synonym join was removed with the replace. This extra join restores it so | ||
| // queries with join in the where clause can continue to work. | ||
| searchQuery.join("synonyms", "synonyms"); |
There was a problem hiding this comment.
join("synonyms", "synonyms") adds an INNER JOIN, and it stays in place for the xref, attribute, donor, and later queries. Germplasm without synonyms drop out of those results and come back with null external references, attributes, and so on. bi-api depends on those external references.
Can we add this join only when a synonyms filter is present, or use a LEFT JOIN?
There was a problem hiding this comment.
I opted for a check on the filter instead of a left join, less code.
I also noticed the where clause was wrong for instituteCodes, so fixed that as well.
|
|
||
| if (entityColumnNameAndType.getEntityColumnName().startsWith("*")) { | ||
| joinCollectionColumn(entityColumnNameAndType.getEntityColumnName()); | ||
| if (sortAndFilterEntityColumnInfo.isCollectionOnEntity() && !sortAndFilterEntityColumnInfo.isJoinOnUnrelatedEntity()) { |
There was a problem hiding this comment.
This used to check startsWith("*"), and it now checks isCollectionOnEntity(). But the * columns in StudySearchRequest (externalReferenceId, externalReferenceSource, germplasmDbId, observationVariableDbId, seasonDbId) and TrialSearchRequest (locationDbId) still use the 2-arg constructor, so the flag is false for them.
joinCollectionColumn is skipped, and the WHERE clause refers to an alias that was never joined, so the query fails with a 500.
bi-api’s StudyQuery filters on externalReferenceId, so this affects a path bi-api actually uses. Sorting on these columns also no longer returns a 400. Those entries need the 4-arg constructor with isCollectionOnEntity = true.
Description
Story: BI-3082
Supporting changes:
New Lists API endpoint
/search/lists/{listDbId}/itemsadded to allow list type entity search requests. In particular, this search request will be used bybi-apito support the requirement of sorting, filtering, and paginating germplasm data that belongs in lists. Previously issues were found with the cache-removal implementation of germplasm lists, and this body should work should address all of these issues. To support a generalized approach to this endpoint, the following features were implemented:ListItemSearchRequestHandlerfor all ListTypeSearchRequests to implement. Only Germplasm implements this right now, if BrAPI wants to support all list types we (or them) can implement the rest at that timeListItemWithFullItem<T>responses added. In particular, this new model object providesListIteminformation, as well as the full BrAPI model object that is represented by . In the case of DeltaBreed, this isgermplasm, but if other list types are implemented, this generalized approach will allow for different models to use this object.EntityColumnNameAndTypetoSortAndFilterEntityColumnInfoafter new support requirements caused more attributes to be added to this model. These new attributes, supplied on creation, tell theSearchQueryBuilderabout special use cases that were previously being overwritten or ignored with existing features. These new attributes make this more explicit.BrAPIRepositry/Implsupport to search on multiple entities which is required for this new endpoint's use case. This code has been generalized to support any such use case.SearchQueryBuildersupport for multiple entity search requestsBrAPIGermplasmService.buildGermplasmSearchQuery()to prevent fetching thesynonymscollection in the initial query. This was seen as a problem for using on the list query in general because it would have required the usage ofBrAPIRespository.findAllBySearchPaginatingWithFetches(), which utilizes a difficult to edit subquery. It was found through these changes in fact that this method can likely be removed in favor of simply not fetching the first collection, then iterating through all the collections you need to fetch to populate before conversion. It's the subject of this new ticketDependencies
Testing
Testing for this bi-api PR is sufficient for the testing of this ticket.
Supplemental testing can be done on the new
/search/lists/{listDbId}/itemsendpoint as well to test corner cases as well, but not required.Checklist: