-
Notifications
You must be signed in to change notification settings - Fork 1
Feature/bi 1716 #254
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
Merged
Merged
Feature/bi 1716 #254
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5015133
[BI-1716] WIP
davedrp 23ccce6
[BI-1716] WIP
davedrp bfd4bb2
[BI-1716] clean up code (remove debug statements)
davedrp f83d116
[BI-1716] Clean code (reomove unused imports and variables, etc...)
davedrp ddcb5b7
remove the program-key from the trial name before returning the trait
davedrp 244cbc9
[BI-1716] impliment Tim's PR change request
davedrp ddf5385
Merge branch 'develop' into feature/BI-1716
davedrp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,14 @@ | ||
| package org.breedinginsight.brapi.v2.services; | ||
|
|
||
| import io.micronaut.context.annotation.Property; | ||
| import io.micronaut.http.server.exceptions.InternalServerException; | ||
| import org.brapi.client.v2.model.exceptions.ApiException; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.brapi.v2.model.core.BrAPITrial; | ||
| import org.brapi.v2.model.pheno.BrAPIObservationUnit; | ||
| import org.breedinginsight.brapps.importer.daos.BrAPIObservationUnitDAO; | ||
| import org.breedinginsight.brapps.importer.daos.BrAPITrialDAO; | ||
| import org.breedinginsight.services.ProgramService; | ||
| import org.breedinginsight.services.exceptions.DoesNotExistException; | ||
| import org.breedinginsight.utilities.Utilities; | ||
|
|
||
| import javax.inject.Inject; | ||
| import javax.inject.Singleton; | ||
|
|
@@ -17,19 +18,38 @@ | |
| @Singleton | ||
| public class BrAPITrialService { | ||
|
|
||
| @Property(name = "brapi.server.reference-source") | ||
| private String referenceSource; | ||
|
|
||
| private final BrAPITrialDAO trialDAO; | ||
| private final ProgramService programService; | ||
| private final BrAPIObservationUnitDAO ouDAO; | ||
|
|
||
| @Inject | ||
| public BrAPITrialService(ProgramService programService, BrAPITrialDAO trialDAO) { | ||
| this.programService = programService; | ||
| public BrAPITrialService( BrAPITrialDAO trialDAO,BrAPIObservationUnitDAO ouDAO) { | ||
| this.trialDAO = trialDAO; | ||
| this.ouDAO = ouDAO; | ||
| } | ||
|
|
||
| public List<BrAPITrial> getExperiments(UUID programId) throws ApiException, DoesNotExistException { | ||
| return trialDAO.getTrials(programId); | ||
| } | ||
|
|
||
| public BrAPITrial getTrialDataByUUID(UUID programId, UUID trialId, boolean stats) throws DoesNotExistException { | ||
| try { | ||
| BrAPITrial trial = trialDAO.getTrialById(programId,trialId).orElseThrow(() -> new DoesNotExistException("Trial does not exist")); | ||
| //Remove the [program key] from the trial name | ||
| trial.setTrialName( Utilities.removeUnknownProgramKey( trial.getTrialName()) ); | ||
| if( stats ){ | ||
| int environmentsCount = 1; // For now this is hardcoded to 1, because we are only supporting one environment per experiment | ||
| long germplasmCount = countGermplasm(programId, trial.getTrialDbId()); | ||
| trial.putAdditionalInfoItem("environmentsCount", environmentsCount); | ||
| trial.putAdditionalInfoItem("germplasmCount", germplasmCount); | ||
| } | ||
| return trial; | ||
| } catch (ApiException e) { | ||
| throw new InternalServerException(e.getMessage(), e); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you add a error log message here. You can use |
||
| } | ||
| } | ||
|
|
||
| private long countGermplasm(UUID programId, String trialDbId) throws ApiException, DoesNotExistException{ | ||
| List<BrAPIObservationUnit> obUnits = ouDAO.getObservationUnitsForTrialDbId(programId, trialDbId); | ||
| return obUnits.stream().map(BrAPIObservationUnit::getGermplasmDbId).distinct().count(); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This import statement isn't needed