Conversation
…into feature/BI-1339 � Conflicts: � src/main/java/org/breedinginsight/brapi/v2/dao/BrAPIGermplasmDAO.java
| @Get("/${micronaut.bi.api.version}/programs/{programId}" + BrapiVersion.BRAPI_V2 + "/germplasm/{germplasmId}") | ||
| @Produces(MediaType.APPLICATION_JSON) | ||
| @ProgramSecured(roleGroups = {ProgramSecuredRoleGroup.ALL}) | ||
| public HttpResponse<BrAPIGermplasm> getSingleGermplasm( |
There was a problem hiding this comment.
Should be HttpResponse<Response<BrAPIGermplasm>> to get the right return type.
| public class ProgramCache<K, R> { | ||
|
|
||
| private final FetchFunction<UUID, List<R>> fetchMethod; | ||
| private final FetchFunction<UUID, Map<K, R>> fetchMethod; |
There was a problem hiding this comment.
Not clearly explained that K should be the object id, it took me a bit to figure out what K was supposed to be. Maybe a class header comment for explanation?
src/test/java/org/breedinginsight/services/BrAPIGermplasmServiceUnitTest.java
Show resolved
Hide resolved
| } | ||
|
|
||
| public BrAPIGermplasm getGermplasmByUUID(String germplasmId, UUID programId) throws ApiException { | ||
| return programGermplasmCache.get(programId).get(germplasmId); |
There was a problem hiding this comment.
What if the germplasmId doesn't exist in the returned map?
| public BrAPIGermplasm getGermplasmByUUID(String germplasmId, UUID programId) throws ApiException { | ||
| return programGermplasmCache.get(programId).get(germplasmId); | ||
| public BrAPIGermplasm getGermplasmByUUID(String germplasmId, UUID programId) throws ApiException, DoesNotExistException { | ||
| BrAPIGermplasm germplasm = programGermplasmCache.get(programId).get(germplasmId); |
There was a problem hiding this comment.
Did you test this out? I thought in java the exception is thrown here on the map access if the key doesn't exist rather than it returning a null.
There was a problem hiding this comment.
There probably should be a null check for what's returned from programGermplasmCache.get(programId) as there could be some programs don't have germplasm in the cache...either they don't have any in the system yet, or the cache loading failed, or is in progress.
| try { | ||
| return germplasmDAO.getGermplasmByUUID(germplasmId, programId); | ||
| } catch (ApiException e) { | ||
| } catch (ApiException | DoesNotExistException e) { |
There was a problem hiding this comment.
If a germplasm is requested that doesn't exist it seems like that is a 404 rather than a 500.
timparsons
left a comment
There was a problem hiding this comment.
Testing passed. Have a few code changes, however
| germplasm.setPedigree(newPedigreeString); | ||
| } | ||
|
|
||
| BrAPIExternalReference extRef = germplasm.getExternalReferences().stream().filter(reference -> referenceSource.equals(reference.getReferenceSource())).findFirst().orElseThrow(); |
There was a problem hiding this comment.
I think you should specify the error to throw in the .orElseThrow method call, for example: .orElseThrow(() -> new IllegalStateException("No BI external reference found"))
| import io.micronaut.context.annotation.Context; | ||
| import io.micronaut.context.annotation.Property; | ||
| import io.micronaut.http.server.exceptions.InternalServerException; | ||
| import it.unimi.dsi.fastutil.Hash; |
There was a problem hiding this comment.
This import is not used and can be removed
| public BrAPIGermplasm getGermplasmByUUID(String germplasmId, UUID programId) throws ApiException { | ||
| return programGermplasmCache.get(programId).get(germplasmId); | ||
| public BrAPIGermplasm getGermplasmByUUID(String germplasmId, UUID programId) throws ApiException, DoesNotExistException { | ||
| BrAPIGermplasm germplasm = programGermplasmCache.get(programId).get(germplasmId); |
There was a problem hiding this comment.
There probably should be a null check for what's returned from programGermplasmCache.get(programId) as there could be some programs don't have germplasm in the cache...either they don't have any in the system yet, or the cache loading failed, or is in progress.
| } | ||
| } | ||
|
|
||
| public BrAPIGermplasm getGermplasmByUUID(UUID programId, String germplasmId) throws ApiException, DoesNotExistException { |
There was a problem hiding this comment.
Given that you're catching an ApiException, you don't need to specify that an ApiException will be thrown.
| } catch (DoesNotExistException e) { | ||
| throw e; | ||
| } |
There was a problem hiding this comment.
This is redundant and can be removed as the method declares it can throw a DoesNotExistException
Description
Story: BI-1339 - Germplasm Details page
Updates to enable display of individual germplasm details
Dependencies
bi-web/feature/BI-1339
Testing
See testing for bi-web
Checklist: