Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
147 commits
Select commit Hold shift + click to select a range
a04b36e
Add todos
jloux-brapi Apr 22, 2026
b8444e9
Merge branch 'develop' into feature/BI-2806
jloux-brapi Apr 23, 2026
df7affd
Remove unused method from BrAPITrialDAO
jloux-brapi Apr 23, 2026
d1ae3d9
Fix first get method
jloux-brapi Apr 24, 2026
c1b0174
Update getTrials(UUID) method to use brapi directly
jloux-brapi Apr 28, 2026
6b6a695
Udpate remaining getMethods, fix enough exRef things to pass unit tests
jloux-brapi May 4, 2026
bb30594
Remove code setting brapiId to exRef
jloux-brapi May 4, 2026
a36229b
Merge branch 'develop' into fix_exrefs
jloux-brapi May 4, 2026
35cde9c
Changes to support ExperimentControllerIntegrationTest
jloux-brapi May 5, 2026
af7ceda
Fix remaining test failures and alter some code to support dbIds
jloux-brapi May 5, 2026
6854606
Remove cache from last get method
jloux-brapi May 5, 2026
1f18377
Remove cache from trial update
jloux-brapi May 5, 2026
c2083d8
Remove cache from post method and remove entirely for trials
jloux-brapi May 5, 2026
3b2b047
Remove unused imports, comments, refactor some function names in BrAP…
jloux-brapi May 6, 2026
3b081b8
Rename BrAPIStudyDAO method to reflect lookup on BrAPI Trial ExRef
jloux-brapi May 6, 2026
092c25b
Add comment on PendingImportObject id
jloux-brapi May 6, 2026
7425a6e
Update brapi java client version
jloux-brapi May 27, 2026
da3eeb2
Update TrialsController to support brapi side filter/sort/pagination
jloux-brapi May 29, 2026
174378a
Add pagination logic to use defaults if not provided
jloux-brapi May 29, 2026
7321804
Fix Trial collaborator use case
jloux-brapi May 29, 2026
4b9d345
Remove comment
jloux-brapi Jun 1, 2026
edd03fd
Update TODO comments with created tickets/epics
jloux-brapi Jun 10, 2026
5be89c6
Addtional comment edits to include created tasks/epics
jloux-brapi Jun 10, 2026
0f8a05d
Generalize sorting and filtering code for reusability for future cach…
jloux-brapi Jun 15, 2026
8067d5c
Create generalized brapi get method
jloux-brapi Jun 17, 2026
a470ef9
Update comments
jloux-brapi Jun 17, 2026
28378f0
Merge pull request #516 from Breeding-Insight/feature/BI-2806
jloux-brapi Jul 1, 2026
1f56711
Fix issues where bi-generated exref id used instead of trialDbId in b…
jloux-brapi Jul 2, 2026
2896356
Add TODOs for cache.get() path involving trial deletion
jloux-brapi Jul 6, 2026
2d3d39c
Remove cache.get calls from ObservationDAO
jloux-brapi Jul 6, 2026
e9099ea
Remove rest of cache code from ObservationDAO
jloux-brapi Jul 7, 2026
e0baa4a
Remove unused imports, comments on cache usage
jloux-brapi Jul 7, 2026
e07a755
Merge pull request #531 from Breeding-Insight/feature/BI-2908
humsika Jul 8, 2026
a5ef826
Fix unit test failures
jloux-brapi Jul 8, 2026
ae20e21
Merge branch 'bug/BI-2944' into feature/BI-2911
jloux-brapi Jul 8, 2026
7997122
Remove referenced to CachedDAO parent class, remove imports
jloux-brapi Jul 8, 2026
d293243
Remove cache.get() in ObservationUnitDAO
jloux-brapi Jul 9, 2026
bfa2e4b
Remove getObservationUnitByName from OUDAO
jloux-brapi Jul 9, 2026
87f00ec
Add TODO comments for future ticket work
jloux-brapi Jul 10, 2026
35cc359
First pass at external reference swapping
jloux-brapi Jul 16, 2026
66f5ebb
Remove unused runScheduledTasks from ObservationDAO constructor
jloux-brapi Jul 16, 2026
bdc4abd
Swap remaining essential ou exref usages to brapi ouDbId
jloux-brapi Jul 23, 2026
bc896de
Remove remaining CRUD operations and references to OU programCache
jloux-brapi Jul 23, 2026
c4509c3
Fix logging messages referencing exrefs for ous
jloux-brapi Jul 23, 2026
7afd4bd
BI-2918: Updated StudyDAO layer to remove cache reads and call BrAPI …
humsika Aug 13, 2026
d145660
BI-2919: Initial changes made to 2919 ticket.
humsika Aug 21, 2026
09543aa
Initial changes to remove cache get, address mass unit test failures
jloux-brapi Aug 21, 2026
9044db6
Use brapi pagination for all pagination attributes
jloux-brapi Aug 24, 2026
18ed8c9
Set BrapiQuery sort order to ASC by default on BI side
jloux-brapi Aug 24, 2026
7bc0c3d
Handle use case where no authorized IDs exist for collaborator
jloux-brapi Aug 24, 2026
a9179ff
Merge pull request #521 from Breeding-Insight/feature/BI-2861
jloux-brapi Aug 24, 2026
219b670
Remove cache get for rawGermplasm, fix unit tests
jloux-brapi Aug 24, 2026
526e2ec
Merge branch 'epic/BI-2862' into feature/BI-2932
jloux-brapi Aug 24, 2026
f0df78f
Merge branch 'feature/BI-2932' into bug/BI-2944
jloux-brapi Aug 25, 2026
b1b2160
Merge pull request #527 from Breeding-Insight/feature/BI-2932
jloux-brapi Aug 25, 2026
dbb4e86
Add comments for BrAPIGermplasmDAO implementation, link ticket
jloux-brapi Aug 25, 2026
b642037
Add TODO for created ticket [BI-3029]
jloux-brapi Aug 25, 2026
5144197
Merge branch 'bug/BI-2944' into feature/BI-2911
jloux-brapi Aug 25, 2026
6819f49
Merge pull request #530 from Breeding-Insight/bug/BI-2944
jloux-brapi Aug 25, 2026
fd73e5c
Merge pull request #532 from Breeding-Insight/feature/BI-2911
jloux-brapi Aug 25, 2026
c5aeb5f
Merge pull request #533 from Breeding-Insight/feature/BI-2913
jloux-brapi Aug 25, 2026
bce57fc
Merge pull request #536 from Breeding-Insight/feature/BI-2914
jloux-brapi Aug 25, 2026
14d0307
Add Germplasm search code, fix another cache get()
jloux-brapi Aug 25, 2026
19ae9d0
Merge pull request #537 from Breeding-Insight/feature/BI-2916
jloux-brapi Aug 25, 2026
f2ce3b6
Merge pull request #538 from Breeding-Insight/feature/BI-3004
jloux-brapi Aug 25, 2026
78c0863
BI-2919: Removed study external-reference ID overwrites.
humsika Aug 26, 2026
576683e
BI-2919: Added unit tests.
humsika Aug 26, 2026
37d3f9c
Merge pull request #541 from Breeding-Insight/feature/BI-2918
jloux-brapi Aug 26, 2026
2d3efd0
Merge remote-tracking branch 'origin/epic/BI-2862' into feature/BI-2919
humsika Aug 27, 2026
12d808b
BI-2919: Pulled latest from epic 2862.
humsika Aug 27, 2026
4b0c6d2
BI-2919: Formatted file.
humsika Aug 27, 2026
b56ac08
Fix BrAPIGermplasmController getCache usage
jloux-brapi Aug 27, 2026
1e1690d
Go after next BrAPIController cache usage, fix bug
jloux-brapi Aug 27, 2026
acef437
Remove remaining cache.get() usages
jloux-brapi Aug 27, 2026
d443f59
Merge pull request #549 from Breeding-Insight/feature/BI-2919
jloux-brapi Aug 31, 2026
40c5f71
Add comments to fix during BrAPI endpoint fixing
jloux-brapi Sep 1, 2026
54ada76
Untagnle pedigree male/female UUID setting, use brapiGermplasmDbIds f…
jloux-brapi Sep 2, 2026
0196eb7
Reverse changes to setting male/femaleParentUUID to germplasmDbId, im…
jloux-brapi Sep 4, 2026
2262274
Fix unit test
jloux-brapi Sep 4, 2026
b215bcc
Address review comments
jloux-brapi Sep 9, 2026
52b8674
Improvements to be based hack
jloux-brapi Sep 9, 2026
cc4bae0
Restrict pedigree string mutation usage to pulls size 200 and below
jloux-brapi Sep 10, 2026
6ce44fe
BI-2921: Removed remaining ProgramCache operations from BrAPIStudyDAO.
humsika Sep 11, 2026
5bef696
BI-2921: Formatted the file.
humsika Sep 14, 2026
67b7b79
Merge pull request #555 from Breeding-Insight/feature/BI-2921
jloux-brapi Sep 14, 2026
d9d6798
Remove rest of CRUD operations from BrAPIGermplasmDAO
jloux-brapi Sep 14, 2026
536cc8e
Resolve merge conflicts
jloux-brapi Sep 14, 2026
f9fd37d
Remove unused germplasmFetch
jloux-brapi Sep 17, 2026
3eda7eb
Remove imports
jloux-brapi Sep 17, 2026
c838dc5
BI-2922: Made the changes required to call the prod server directly w…
humsika Sep 22, 2026
58d65e6
Implement brapi side filtering, sorting, paging for germplasm
jloux-brapi Sep 25, 2026
2b7f7e6
BI-2922: Replaced the LinkedHashMap with List.
humsika Sep 28, 2026
0808dab
Merge pull request #560 from Breeding-Insight/feature/BI-2922
jloux-brapi Sep 28, 2026
eb7717f
Swap bi/brapi col names in GermplasmQuery
jloux-brapi Sep 30, 2026
1368eae
Merge branch 'epic/BI-2862' into feature/BI-2902
jloux-brapi Oct 2, 2026
012c9dd
BI-2963: Optimized observation retrieval using BrAPI search.
humsika Oct 2, 2026
e9b6cd3
BI-2963: Optimized ObservationDAO method and added test case.
humsika Oct 5, 2026
adbb9f0
Merge pull request #550 from Breeding-Insight/feature/BI-2902
jloux-brapi Oct 6, 2026
faa6303
Merge branch 'epic/BI-2862' into feature/BI-2904
jloux-brapi Oct 6, 2026
878392e
Merge pull request #553 from Breeding-Insight/feature/BI-2904
jloux-brapi Oct 6, 2026
a426b22
Merge pull request #557 from Breeding-Insight/feature/BI-2906
jloux-brapi Oct 6, 2026
cdc8bd9
Merge pull request #561 from Breeding-Insight/feature/BI-2907
jloux-brapi Oct 6, 2026
9e1f79e
Fix compile time issue, and missing injections
jloux-brapi Oct 6, 2026
d2c62d6
BI-3069: Fix observation unit filtering by studyDbId.
humsika Oct 7, 2026
b1f6dfc
Merge pull request #565 from Breeding-Insight/feature/BI-3069
jloux-brapi Oct 7, 2026
11562d8
Merge branch 'epic/BI-2862' into feature/BI-2963
jloux-brapi Oct 7, 2026
cfea7e7
Merge pull request #564 from Breeding-Insight/feature/BI-2963
jloux-brapi Oct 7, 2026
2f9ca55
BI-2964: Applied observation filtering and pagination on BrAPI side a…
humsika Oct 12, 2026
dce51f4
BI-2979: Optimized observation unit queries and add unit tests.
humsika Oct 14, 2026
9108636
Update src/main/java/org/breedinginsight/brapi/v2/dao/BrAPIObservatio…
jloux-brapi Oct 15, 2026
b8cd8fd
Merge pull request #566 from Breeding-Insight/feature/BI-2964
jloux-brapi Oct 15, 2026
14e1012
Utilize prod server changes to correctly sort/filter/paginate germs b…
jloux-brapi Oct 15, 2026
ece4f54
Force type parametrization serialization on the client
jloux-brapi Oct 16, 2026
8dc5c9e
Add comment
jloux-brapi Oct 19, 2026
3abd1a9
Fix broken unit test
jloux-brapi Oct 19, 2026
a5433ef
Set entry number sorting/filtering to correct brapi column name
jloux-brapi Oct 19, 2026
64d3da8
BI-2979: Modified unit tests.
humsika Oct 20, 2026
c5a3665
Continue support of original importEntryNumber, add support for listE…
jloux-brapi Oct 20, 2026
6f07532
Merge pull request #569 from Breeding-Insight/feature/BI-2979
jloux-brapi Oct 21, 2026
917a864
Merge pull request #567 from Breeding-Insight/feature/BI-3082
jloux-brapi Oct 23, 2026
ccbcf6e
Merge pull request #568 from Breeding-Insight/feature/BI-3089
jloux-brapi Oct 23, 2026
e09d8bf
BI-3028: Updated getGermplasmByRawName to use BrAPI germplasm search …
humsika Oct 26, 2026
537afe2
BI-3028: Added Unit test.
humsika Oct 26, 2026
86b6c19
Create obs vars with brapi programDbId, fetch using brapi id
jloux-brapi Oct 27, 2026
ac08461
Remove cache.get() in TraitDAOImpl
jloux-brapi Oct 28, 2026
3c7a06c
Fix revert back to reference_source
jloux-brapi Oct 29, 2026
e00c5aa
Preliminary exref swapping work on traits and observation variable dbIds
jloux-brapi Oct 29, 2026
f38827e
Fix unit test failures, add processing for ObservationVariables to st…
jloux-brapi Oct 29, 2026
d453287
Remove programKeys from other observation variable attributes
jloux-brapi Oct 29, 2026
240536b
Throw DoesNotExist, reuse and update getBrapiVariable method
jloux-brapi Nov 2, 2026
bc7fd39
Merge pull request #575 from Breeding-Insight/feature/BI-3028
jloux-brapi Nov 2, 2026
833fee9
Merge branch 'feature/BI-2924' into feature/BI-2925
jloux-brapi Nov 2, 2026
6036dc5
Address 404 use cases, fix program key stripping
jloux-brapi Nov 2, 2026
d5be47a
Return brapiDbIds for rest of entities in BrAPIObservationVariableCon…
jloux-brapi Nov 3, 2026
9490d56
Unify response data between single variableDbId get and general get
jloux-brapi Nov 3, 2026
ad4c030
Add clarifying comment
jloux-brapi Nov 3, 2026
c06b505
Remove trait cache and rest of CRUD operations
jloux-brapi Nov 5, 2026
3596977
Merge branch 'epic/BI-2862' into feature/BI-2923
jloux-brapi Nov 10, 2026
b3f6bda
Merge pull request #571 from Breeding-Insight/feature/BI-2923
jloux-brapi Nov 10, 2026
b378ed4
Merge branch 'epic/BI-2862' into feature/BI-2924
jloux-brapi Nov 10, 2026
d99eb91
Merge pull request #572 from Breeding-Insight/feature/BI-2924
jloux-brapi Nov 10, 2026
5fdc9cd
Merge branch 'epic/BI-2862' into feature/BI-2925
jloux-brapi Nov 10, 2026
d985309
Merge pull request #573 from Breeding-Insight/feature/BI-2925
jloux-brapi Nov 10, 2026
711a33e
Merge pull request #576 from Breeding-Insight/feature/BI-2927
jloux-brapi Nov 10, 2026
f5b9ca4
BI-2862: Pass observations search-results GET directly to BrAPIDAOUtil.
humsika Nov 12, 2026
27e8cb0
Merge branch 'develop' into epic/BI-2862
jloux-brapi Nov 16, 2026
a5f0168
Update brapi snapshot
jloux-brapi Nov 16, 2026
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
2 changes: 2 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,5 @@ TRIAL_START_DELAY=15s
TRAIT_START_DELAY=20s
OBSERVATION_START_DELAY=25s
OBSERVATION_UNIT_START_DELAY=30s

DATA_TABLE_MAX_SIZE=200
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
<guava.version>31.0.1-jre</guava.version>
<okhttp.version>4.9.3</okhttp.version>
<mockito.version>4.3.1</mockito.version>
<brapi-java-client.version>2.2-SNAPSHOT</brapi-java-client.version>
<brapi-java-client.version>2.2.2-SNAPSHOT</brapi-java-client.version>
<commons-io.version>2.11.0</commons-io.version>
<tika-app.version>2.2.1</tika-app.version>
<!-- Version of apache-poi depends on version of tika. Tika uses these. -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,15 @@
@Secured(SecurityRule.IS_AUTHENTICATED)
public class ExperimentController {
private final BrAPITrialService experimentService;
private final ExperimentQueryMapper experimentQueryMapper;
private final ProgramService programService;
private final ExperimentalCollaboratorService experimentalCollaboratorService;
private final SecurityService securityService;
private final ProgramUserService programUserService;
private final RoleService roleService;

@Inject
public ExperimentController(BrAPITrialService experimentService, ExperimentQueryMapper experimentQueryMapper, ProgramService programService, ExperimentalCollaboratorService experimentalCollaboratorService, SecurityService securityService, ProgramUserService programUserService, RoleService roleService) {
public ExperimentController(BrAPITrialService experimentService, ProgramService programService, ExperimentalCollaboratorService experimentalCollaboratorService, SecurityService securityService, ProgramUserService programUserService, RoleService roleService) {
this.experimentService = experimentService;
this.experimentQueryMapper = experimentQueryMapper;
this.programService = programService;
this.experimentalCollaboratorService = experimentalCollaboratorService;
this.securityService = securityService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import javax.validation.constraints.Positive;
import javax.validation.constraints.PositiveOrZero;
import java.util.Map;

@Getter
@Setter
Expand All @@ -42,7 +43,7 @@ public class BrapiQuery implements PaginationParams {
private Integer page;

private String sortField;
private SortOrder sortOrder;
private SortOrder sortOrder = SortOrder.ASC;

public Integer getDefaultPage() {
return DEFAULT_PAGE;
Expand All @@ -58,4 +59,26 @@ protected FilterRequest constructFilterRequest(String field, String value) {
.value(value)
.build();
}

/**
* For BrapiQuery objects that have implemented this method, this map is used by the BrAPIDAOUtil
* to iterate through all valid filter columns and their associated values that are submitted from the fe.
*
* See @ExperimentQuery for example implementation
*/
public Map<String, String> getFilterValuesByBrAPIColumnName() {
throw new UnsupportedOperationException(
String.format("Server side BrAPI filtering not implemented for class [%s]", this.getClass().getSimpleName())
);
}

/**
* For BrapiQuery objects that have implemented this method, this map is used by the BrAPIDAOUtil
* to match submitted sortField column names to the associated brapi column name for sorting.
*
* See @ExperimentQuery for example implementation
*/
public Map<String, String> getBrAPIColumnNamesByBiColumnName() {
throw new UnsupportedOperationException(String.format("Server side BrAPI sorting not implemented for class [%s]", this.getClass().getSimpleName()));
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.breedinginsight.brapi.v2;

import com.drew.lang.annotations.Nullable;
import io.micronaut.context.annotation.Property;
import io.micronaut.http.HttpHeaders;
import io.micronaut.http.HttpResponse;
Expand All @@ -27,7 +26,6 @@
import org.brapi.v2.model.germ.response.BrAPIGermplasmProgenyResponse;
import org.breedinginsight.api.auth.ProgramSecured;
import org.breedinginsight.api.auth.ProgramSecuredRoleGroup;
import org.breedinginsight.api.model.v1.request.query.SearchRequest;
import org.breedinginsight.api.model.v1.response.DataResponse;
import org.breedinginsight.api.model.v1.response.Response;
import org.breedinginsight.api.model.v1.validators.QueryValid;
Expand Down Expand Up @@ -108,17 +106,8 @@ public HttpResponse<Object> searchGermplasm(
return HttpResponse.notFound();
}

// Can't use BrAPI server programDbId filtering, think germplasm are linked to program through observation
// units and doesn't work if don't have any loaded, use external refs instead for now
// Just use DeltaBreed program UUID
String extRefId = program.get().getId().toString();
body.externalReferenceIds(List.of(extRefId));

// convert request filter dbIds from DeltaBreed UUID to BrAPI service dbIds
if (body.getGermplasmDbIds() != null && !body.getGermplasmDbIds().isEmpty()) {
List<String> convertedDbIds = germplasmService.getGermplasmDbIdsForUUIDs(program.get().getId(), body.getGermplasmDbIds());
body.setGermplasmDbIds(convertedDbIds);
}
String brapiProgramDbId = programService.getBrAPIProgramDbId(program.get().getId());
body.setProgramDbIds(List.of(brapiProgramDbId));

ApiResponse<Pair<Optional<BrAPIGermplasmListResponse>, Optional<BrAPIAcceptedSearchResponse>>> brapiGermplasm;
brapiGermplasm = brAPIEndpointProvider
Expand Down Expand Up @@ -179,10 +168,6 @@ private void batchProcessGermplasm(List<BrAPIGermplasm> germplasmList, String pr
// Prepare a regex pattern for program key removal
Pattern programKeyPattern = Utilities.getRegexPatternMatchAllProgramKeysAnyAccession(programKey);
germplasmList.parallelStream().forEach(germplasm -> {
// Set dbId
germplasm.germplasmDbId(Utilities.getExternalReference(germplasm.getExternalReferences(), "breedinginsight.org")
.orElseThrow(() -> new IllegalStateException("No BI external reference found"))
.getReferenceId());
// Process synonyms
if (germplasm.getSynonyms() != null) {
germplasm.getSynonyms().forEach(synonym -> {
Expand All @@ -199,7 +184,7 @@ private void batchProcessGermplasm(List<BrAPIGermplasm> germplasmList, String pr
@Get("/programs/{programId}" + BrapiVersion.BRAPI_V2 + "/germplasm{?queryParams*}")
@Produces(MediaType.APPLICATION_JSON)
@ProgramSecured(roleGroups = {ProgramSecuredRoleGroup.PROGRAM_SCOPED_ROLES})
public HttpResponse<Response<DataResponse<List<BrAPIGermplasm>>>> getGermplasm(
public HttpResponse<Response<DataResponse<BrAPIGermplasm>>> getGermplasm(
@PathVariable("programId") UUID programId,
@QueryValue @QueryValid(using = GermplasmQueryMapper.class) @Valid GermplasmQuery queryParams) {
try {
Expand All @@ -212,15 +197,19 @@ public HttpResponse<Response<DataResponse<List<BrAPIGermplasm>>>> getGermplasm(
}

// Fetch all germplasm in the program unless a list id is supplied to return only germplasm in that collection
List<BrAPIGermplasm> germplasm = queryParams.getListDbId() == null ? germplasmService.getGermplasm(programId) : germplasmService.getGermplasmByList(programId, queryParams.getListDbId());
SearchRequest searchRequest = queryParams.constructSearchRequest();
return ResponseUtils.getBrapiQueryResponse(germplasm, germplasmQueryMapper, queryParams, searchRequest);
BrAPIGermplasmListResponse brapiResponse = queryParams.getListDbId() == null ? germplasmService.searchGermplasm(programId, queryParams) : germplasmService.getGermplasmByList(programId, queryParams);

List<BrAPIGermplasm> foundGermplasm = brapiResponse.getResult().getData();
return ResponseUtils.getBrapiQueryResponse(foundGermplasm, brapiResponse);
} catch (ApiException e) {
log.info(e.getMessage(), e);
return HttpResponse.status(HttpStatus.INTERNAL_SERVER_ERROR, "Error retrieving germplasm");
} catch (IllegalArgumentException e) {
log.info(e.getMessage(), e);
return HttpResponse.status(HttpStatus.UNPROCESSABLE_ENTITY, "Error parsing requested date format");
} catch (DoesNotExistException e) {
log.info(e.getMessage(), e);
return HttpResponse.status(HttpStatus.NOT_FOUND, "Supplied programId does not exist");
}
}

Expand Down Expand Up @@ -322,8 +311,7 @@ public HttpResponse<BrAPIGermplasmPedigreeResponse> getGermplasmPedigreeInfo(
metadata.setPagination(pagination);
response = new BrAPIGermplasmPedigreeResponse();
} else {
BrAPIGermplasm germplasm = germplasmService.getGermplasmByDBID(programId, germplasmId)
.orElseThrow(() -> new DoesNotExistException("DBID for this germplasm does not exist"));
BrAPIGermplasm germplasm = germplasmService.getGermplasmByUUID(programId, germplasmId);

//Forward the pedigree call to the backing BrAPI system of the program passing the germplasmDbId that came in the request
GermplasmApi api = brAPIEndpointProvider.get(programDAO.getCoreClient(programId), GermplasmApi.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,13 @@
import org.brapi.client.v2.modules.phenotype.ObservationUnitsApi;
import org.brapi.v2.model.BrAPIIndexPagination;
import org.brapi.v2.model.BrAPIMetadata;
import org.brapi.v2.model.core.BrAPIStudy;
import org.brapi.v2.model.core.BrAPITrial;
import org.brapi.v2.model.pheno.BrAPIObservationUnitHierarchyLevel;
import org.brapi.v2.model.pheno.response.BrAPIObservationLevelListResponse;
import org.brapi.v2.model.pheno.response.BrAPIObservationLevelListResponseResult;
import org.breedinginsight.api.auth.ProgramSecured;
import org.breedinginsight.api.auth.ProgramSecuredRoleGroup;
import org.breedinginsight.brapi.v1.controller.BrapiVersion;
import org.breedinginsight.brapi.v2.dao.BrAPIStudyDAO;
import org.breedinginsight.brapi.v2.dao.BrAPITrialDAO;
import org.breedinginsight.daos.ProgramDAO;
import org.breedinginsight.model.BrAPIConstants;
Expand All @@ -65,15 +63,13 @@ public class BrAPIObservationLevelsController {
private final ProgramDAO programDAO;
private final ProgramService programService;
private final BrAPITrialDAO trialDAO;
private final BrAPIStudyDAO studyDAO;

@Inject
public BrAPIObservationLevelsController(BrAPIEndpointProvider brAPIEndpointProvider, ProgramDAO programDAO, ProgramService programService, BrAPITrialDAO trialDAO, BrAPIStudyDAO studyDAO) {
public BrAPIObservationLevelsController(BrAPIEndpointProvider brAPIEndpointProvider, ProgramDAO programDAO, ProgramService programService, BrAPITrialDAO trialDAO) {
this.brAPIEndpointProvider = brAPIEndpointProvider;
this.programDAO = programDAO;
this.programService = programService;
this.trialDAO = trialDAO;
this.studyDAO = studyDAO;
}

@Get("/observationlevels")
Expand All @@ -93,25 +89,13 @@ public HttpResponse<BrAPIObservationLevelListResponse> observationlevelsGet(@Pat
}

String programDbId = program.get().getBrapiProgram().getProgramDbId();
String studyDbId = null;
String studyDbId = environmentId;
String trialDbId = null;

if(environmentId != null) {
try {
Optional<BrAPIStudy> study = studyDAO.getStudyByEnvironmentId(UUID.fromString(environmentId), program.get());
if(study.isPresent()) {
studyDbId = study.get().getStudyDbId();
} else {
studyDbId = environmentId;
}
} catch (ApiException e) {
log.error(Utilities.generateApiExceptionLogMessage(e), "Error fetching environment");
return HttpResponse.status(HttpStatus.INTERNAL_SERVER_ERROR, "Error finding observation levels");
}
} else if(experimentId != null) {
if(environmentId == null && experimentId != null) {
try {
List<BrAPITrial> trial = trialDAO.getTrialsByExperimentIds(List.of(UUID.fromString(experimentId)), program.get());
if(trial.size() == 1) {
if (trial.size() == 1) {
trialDbId = trial.get(0).getTrialDbId();
} else {
trialDbId = experimentId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public HttpResponse<BrAPIObservationUnitListResponse> observationunitsGet(@PathV
@Get("/observationunits/{observationUnitDbId}")
@ProgramSecured(roleGroups = {ProgramSecuredRoleGroup.PROGRAM_SCOPED_ROLES})
public HttpResponse<BrAPIObservationUnitSingleResponse> observationunitsObservationUnitDbIdGet(@PathVariable("programId") UUID programId, @PathVariable("observationUnitDbId") String observationUnitDbId) {
log.debug("observationunitsObservationUnitDbIdGet: fetching ou by externalReferenceId: " + observationUnitDbId);
log.debug("observationunitsObservationUnitDbIdGet: fetching ou by dbId: " + observationUnitDbId);
Optional<Program> program = programService.getById(programId);
if(program.isEmpty()) {
log.warn("Program id: " + programId + " not found");
Expand All @@ -158,7 +158,7 @@ public HttpResponse<BrAPIObservationUnitSingleResponse> observationunitsObservat
try {
List<BrAPIObservationUnit> ous = observationUnitDAO.getObservationUnitsById(List.of(observationUnitDbId), program.get());
if(ous.size() != 1) {
log.warn("did not find a single ou with externalReferenceId: " + observationUnitDbId);
log.warn("did not find a single ou with dbId: " + observationUnitDbId);
return HttpResponse.notFound();
}
setDbIds(ous.get(0));
Expand Down Expand Up @@ -220,18 +220,10 @@ public HttpResponse<?> observationunitsTableGet(@PathVariable("programId") UUID
}

private void setDbIds(BrAPIObservationUnit ou) {
ou.observationUnitDbId(Utilities.getExternalReference(ou.getExternalReferences(), Utilities.generateReferenceSource(referenceSource, ExternalReferenceSource.OBSERVATION_UNITS))
.orElseThrow(() -> new IllegalStateException("No BI external reference found"))
.getReferenceID());
ou.studyDbId(Utilities.getExternalReference(ou.getExternalReferences(), Utilities.generateReferenceSource(referenceSource, ExternalReferenceSource.STUDIES))
.orElseThrow(() -> new IllegalStateException("No BI external reference found"))
.getReferenceID());
ou.trialDbId(Utilities.getExternalReference(ou.getExternalReferences(), Utilities.generateReferenceSource(referenceSource, ExternalReferenceSource.TRIALS))
.orElseThrow(() -> new IllegalStateException("No BI external reference found"))
.getReferenceID());
ou.programDbId(Utilities.getExternalReference(ou.getExternalReferences(), Utilities.generateReferenceSource(referenceSource, ExternalReferenceSource.PROGRAMS))
.orElseThrow(() -> new IllegalStateException("No BI external reference found"))
.getReferenceID());
// TODO: Remove this as part of [BI-3006]
if (ou.getAdditionalInfo().has(BrAPIAdditionalInfoFields.GERMPLASM_UUID)) {
ou.setGermplasmDbId(ou.getAdditionalInfo()
.get(BrAPIAdditionalInfoFields.GERMPLASM_UUID)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,23 +150,25 @@ public HttpResponse<BrAPIObservationVariableListResponse> variablesGet(@PathVari
public HttpResponse<BrAPIObservationVariableSingleResponse> variablesObservationVariableDbIdGet(@PathVariable("programId") UUID programId,
@PathVariable("observationVariableDbId") String observationVariableDbId) {
log.debug("fetching variable: " + observationVariableDbId);
UUID traitId;
try {
traitId = UUID.fromString(observationVariableDbId);
// Check if submitted ID is valid UUID
UUID.fromString(observationVariableDbId);
} catch (IllegalArgumentException e) {
return HttpResponse.notFound();
}

try {
Optional<Trait> trait = traitService.getById(programId, traitId);
List<Trait> programTraits = traitService.getByProgramId(programId, true);

if(trait.isEmpty()) {
if(programTraits.isEmpty()) {
return HttpResponse.notFound();
}

BrAPIObservationVariable observationVariable = observationVariableService.filterVariableById(programTraits, observationVariableDbId);

BrAPIObservationVariableSingleResponse response = new BrAPIObservationVariableSingleResponse()
.metadata(new BrAPIMetadata())
.result(observationVariableService.convertToBrAPI(trait.get()));
.result(observationVariable);

return HttpResponse.ok(response);
} catch (DoesNotExistException e) {
Expand Down
Loading
Loading