diff --git a/src/main/java/org/breedinginsight/brapi/v2/dao/BrAPIGermplasmDAO.java b/src/main/java/org/breedinginsight/brapi/v2/dao/BrAPIGermplasmDAO.java index fabf2bd70..8ad1413c9 100644 --- a/src/main/java/org/breedinginsight/brapi/v2/dao/BrAPIGermplasmDAO.java +++ b/src/main/java/org/breedinginsight/brapi/v2/dao/BrAPIGermplasmDAO.java @@ -49,7 +49,6 @@ import org.breedinginsight.utilities.Utilities; import javax.inject.Inject; -import javax.inject.Named; import javax.inject.Singleton; import java.util.*; import java.util.stream.Collectors; @@ -72,57 +71,21 @@ public class BrAPIGermplasmDAO { private final BrAPIEndpointProvider brAPIEndpointProvider; - private final int brapiMaxPageSize; - @Inject public BrAPIGermplasmDAO(ProgramDAO programDAO, ImportDAO importDAO, BrAPIDAOUtil brAPIDAOUtil, BrAPIEndpointProvider brAPIEndpointProvider, - @Property(name = "brapi.cache.fetch-page-size") int brapiFetchPageSize, ObjectMapper objectMapper, BrAPIListDAO brAPIListDAO) { this.programDAO = programDAO; this.importDAO = importDAO; this.brAPIDAOUtil = brAPIDAOUtil; this.brAPIEndpointProvider = brAPIEndpointProvider; - this.brapiMaxPageSize = brapiFetchPageSize; this.objectMapper = objectMapper; this.brAPIListDAO = brAPIListDAO; } - /** - * Fetch the germplasm for this program, and process it to remove storage specific values - * @param programId - * @return this program's germplasm - * @throws ApiException - */ - public List getGermplasm(UUID programId) throws ApiException { - Program program = programDAO.get(programId) - .stream() - .findFirst() - .orElseThrow(); - - if (program.getId() == null) { - throw new InternalServerException("BI-API Program or Program ID is null"); - } - - String brapiProgramDbId = Optional.of(program) - .map(Program::getBrapiProgram) - .map(BrAPIProgram::getProgramDbId) - .orElse(null); - - if (brapiProgramDbId == null) { - brapiProgramDbId = programDAO.getProgramBrAPI(program).getProgramDbId(); - } - - GermplasmQueryParams germplasmQueryParams = GermplasmQueryParams.builder() - .programDbId(brapiProgramDbId) - .build(); - - return getBrAPIGermplasmUsingBrAPIProgramId(germplasmQueryParams, program); - } - /** * Fetch the germplasm for this program as it was stored in the program's BrAPI server * @param programId @@ -130,9 +93,9 @@ public List getGermplasm(UUID programId) throws ApiException { * @throws ApiException */ public List getRawGermplasm(UUID programId) throws ApiException { - // TODO: This method is used for checking if germplasm already exist in the system. Once a generalized BrAPI exists check is made, we should update this method [BI-2938] + // TODO: This method is used for checking if germplasm already exist in the system. Once a generalized BrAPI exists check is made, we should update this method to optimize it [BI-2938] Program program = new Program(programDAO.fetchOneById(programId)); - List programGermplasm = getGermplasm(programId); + List programGermplasm = brapiGermplasmSearchReturnList(program, new BrAPIGermplasmSearchRequest()); return programGermplasm.stream().map(germplasm -> { germplasm.setGermplasmName(Utilities.appendProgramKey(germplasm.getDefaultDisplayName(), program.getKey(), germplasm.getAccessionNumber())); if(germplasm.getAdditionalInfo() != null && germplasm.getAdditionalInfo().has(BrAPIAdditionalInfoFields.GERMPLASM_RAW_PEDIGREE) @@ -334,7 +297,7 @@ private Map getPedigreeGermplasmDbIdByBICreatedExRef(List germplasmSearchedWithExRef = brAPIDAOUtil.searchNoPaging( + List germplasmSearchedWithExRef = brAPIDAOUtil.searchNoPageThru( api::searchGermplasmPost, api::searchGermplasmSearchResultsDbIdGet, searchRequest); @@ -352,27 +315,6 @@ private Map getPedigreeGermplasmDbIdByBICreatedExRef(List getBrAPIGermplasmUsingBrAPIProgramId(GermplasmQueryParams germplasmQueryParams, Program program) throws ApiException { - if (germplasmQueryParams.page() == null) { - germplasmQueryParams.setPage(0); - } - - if (germplasmQueryParams.pageSize() == null) { - germplasmQueryParams.setPageSize(brapiMaxPageSize); - } - - GermplasmApi api = brAPIEndpointProvider.get(programDAO.getCoreClient(program.getId()), GermplasmApi.class); - - List result = brAPIDAOUtil.get(api::germplasmGet, germplasmQueryParams); - - // TODO: Once cache is removed for this class, fix processGermplasmForDisplay to return List [BI-2906] - return processGermplasmForDisplay(result, program); - } - // TODO: hack for now, probably should update breedbase // Made a JIRA card BI-1883 for this // Breedbase will return NA/NA for no pedigree or NA/father, mother/NA @@ -481,8 +423,9 @@ public BrAPIGermplasmListResponse brapiGermplasmSearchReturnResponse(Program pro BrAPIGermplasmSearchRequest brAPIGermplasmSearchRequest = buildSearchRequest(program, searchRequest, germplasmQuery); BrAPIGermplasmListResponse brAPIResponse = - brAPIDAOUtil.simpleSearch( + brAPIDAOUtil.searchReturnResponse( api::searchGermplasmPost, + api::searchGermplasmSearchResultsDbIdGet, brAPIGermplasmSearchRequest ); @@ -527,7 +470,7 @@ public BrAPIGermplasm getGermplasmByUUID(String germplasmId, UUID programId) thr } public List getGermplasmsByDBID(Collection germplasmDbIds, UUID programId) throws ApiException { - // TODO: This method is mainly used by the download experiment export tool. This method will fail until we address the parameter limit for async Germplasm requests for germplasmDbIds > 4. Return to this use case during [BI-3021] + // This method is mainly used by the download experiment export tool. Program program = new Program(programDAO.fetchOneById(programId)); BrAPIGermplasmSearchRequest searchRequest = new BrAPIGermplasmSearchRequest(); diff --git a/src/main/java/org/breedinginsight/brapi/v2/dao/BrAPIObservationDAO.java b/src/main/java/org/breedinginsight/brapi/v2/dao/BrAPIObservationDAO.java index 2026f2ac5..42c753d22 100644 --- a/src/main/java/org/breedinginsight/brapi/v2/dao/BrAPIObservationDAO.java +++ b/src/main/java/org/breedinginsight/brapi/v2/dao/BrAPIObservationDAO.java @@ -188,19 +188,19 @@ public List getObservationsByObservationUnits(Collection observations = brAPIDAOUtil.getListResult(brAPIResponse); processObservations(program.getKey(), observations); @@ -223,37 +223,6 @@ public List createBrAPIObservations(List brA } } - private List getBrAPIObservationsUsingBrAPIProgramId(Program program) throws ApiException { - - if (program == null || program.getId() == null) { - throw new InternalServerException("BI-API Program or Program ID is null"); - } - - String brapiProgramDbId = Optional.of(program) - .map(Program::getBrapiProgram) - .map(BrAPIProgram::getProgramDbId) - .orElse(null); - - if (brapiProgramDbId == null) { - brapiProgramDbId = programDAO.getProgramBrAPI(program).getProgramDbId(); - } - - ObservationQueryParams observationQueryParams = - ObservationQueryParams.builder() - .programDbId(brapiProgramDbId) - .pageSize(brapiMaxPageSize) - .page(0) - .build(); - - ObservationsApi api = brAPIEndpointProvider.get(programDAO.getCoreClient(program.getId()), ObservationsApi.class); - - List result = brAPIDAOUtil.get(api::observationsGet, observationQueryParams); - - processObservations(program.getKey(), result); - - return result; - } - public List updateBrAPIObservation(Map mutatedObservationByDbId, UUID programId) throws ApiException { ObservationsApi api = brAPIEndpointProvider.get(programDAO.getCoreClient(programId), ObservationsApi.class); var program = programDAO.fetchOneById(programId); diff --git a/src/main/java/org/breedinginsight/brapi/v2/dao/BrAPIObservationUnitDAO.java b/src/main/java/org/breedinginsight/brapi/v2/dao/BrAPIObservationUnitDAO.java index 1d1bab246..fb6a33876 100644 --- a/src/main/java/org/breedinginsight/brapi/v2/dao/BrAPIObservationUnitDAO.java +++ b/src/main/java/org/breedinginsight/brapi/v2/dao/BrAPIObservationUnitDAO.java @@ -85,62 +85,19 @@ public BrAPIObservationUnitDAO(ProgramDAO programDAO, this.brapiMaxPageSize = brapiFetchPageSize; } - /** - * Get all observation units for a program from the cache. - */ - public List getProgramObservationUnits(UUID programId) throws ApiException { - Program program = programDAO.get(programId) - .stream() - .findFirst() - .orElseThrow(); - - if (program.getId() == null) { - throw new InternalServerException("BI-API Program or Program ID is null"); - } - - String brapiProgramDbId = Optional.of(program) - .map(Program::getBrapiProgram) - .map(BrAPIProgram::getProgramDbId) - .orElse(null); - - if (brapiProgramDbId == null) { - brapiProgramDbId = programDAO.getProgramBrAPI(program).getProgramDbId(); - } - - ObservationUnitQueryParams observationUnitQueryParams = ObservationUnitQueryParams.builder() - .programDbId(brapiProgramDbId) - .build(); - - return getBrAPIObservationUnitsUsingQueryParams(observationUnitQueryParams, program); - } - - private List getBrAPIObservationUnitsUsingQueryParams(ObservationUnitQueryParams observationUnitQueryParams, - Program program) throws ApiException { - - if (observationUnitQueryParams.page() == null) { - observationUnitQueryParams.setPage(0); - } - - if (observationUnitQueryParams.pageSize() == null) { - observationUnitQueryParams.setPageSize(brapiMaxPageSize); - } - - ObservationUnitsApi api = brAPIEndpointProvider.get(programDAO.getCoreClient(program.getId()), ObservationUnitsApi.class); - - List result = brAPIDAOUtil.get(api::observationunitsGet, observationUnitQueryParams); - - processObservationUnits(program, result, true); - - return result; - } - - private List searchBrapiObservationUnits(BrAPIObservationUnitSearchRequest observationUnitSearchRequest, + public List searchBrapiObservationUnits(BrAPIObservationUnitSearchRequest observationUnitSearchRequest, Program program) throws ApiException { ObservationUnitsApi api = brAPIEndpointProvider.get(programDAO.getCoreClient(program.getId()), ObservationUnitsApi.class); + if (observationUnitSearchRequest.getProgramDbIds() == null || observationUnitSearchRequest.getProgramDbIds().isEmpty()) { + String brapiProgramDbId = brAPIDAOUtil.getBrAPIProgramDbId(program.getId()); + observationUnitSearchRequest.setProgramDbIds(List.of(brapiProgramDbId)); + } + BrAPIObservationUnitListResponse brAPIResponse = - brAPIDAOUtil.simpleSearch( + brAPIDAOUtil.searchReturnResponse( api::searchObservationunitsPost, + api::searchObservationunitsSearchResultsDbIdGet, observationUnitSearchRequest ); @@ -194,7 +151,7 @@ public List getObservationUnitsById(Collection obs } // TODO: Optimize and change to search/get on observationUnitDbId. This will cause sample submission tests to fail until we have a better solution for exists checks for tabular errors. [BI-2987] - return getProgramObservationUnits(program.getId()).stream() + return searchBrapiObservationUnits(new BrAPIObservationUnitSearchRequest(), program).stream() .filter(ou -> observationUnitDbIds.contains(ou.getObservationUnitDbId())) .collect(Collectors.toList()); } @@ -224,7 +181,7 @@ public List getObservationUnitsForTrialDbId(@NotNull UUID public List getObservationUnitsForDataset(@NotNull String datasetId, @NotNull Program program) throws ApiException { String datasetReferenceSource = Utilities.generateReferenceSource(referenceSource, ExternalReferenceSource.DATASET); // TODO: Optimize and change this to search/get on dataset id once a solution is in place to relate ous to datasets [BI-2961] - return getProgramObservationUnits(program.getId()).stream() + return searchBrapiObservationUnits(new BrAPIObservationUnitSearchRequest(), program).stream() .filter(ou -> { Optional exRef = Utilities.getExternalReference(ou.getExternalReferences(), datasetReferenceSource); return exRef.map(brAPIExternalReference -> brAPIExternalReference.getReferenceId().equals(datasetId)).orElse(false); @@ -234,8 +191,8 @@ public List getObservationUnitsForDataset(@NotNull String public List getObservationUnitsForDatasetAndEnvs(@NotNull String datasetId, Collection envIds, @NotNull Program program) throws ApiException { String datasetReferenceSource = Utilities.generateReferenceSource(referenceSource, ExternalReferenceSource.DATASET); - - return getProgramObservationUnits(program.getId()) + // TODO: Optimize and change this to search/get on dataset id once a solution is in place to relate ous to datasets [BI-2961] + return searchBrapiObservationUnits(new BrAPIObservationUnitSearchRequest(), program) .stream() .filter(ou -> { Optional datasetExRef = @@ -353,7 +310,7 @@ private void processObservationUnits(Program program, List HashMap germplasmByDbId = new HashMap<>(); if( withGID ){ - // TODO: Optimize this to use germplasm information directly in BrAPIObservationUnit by searching on ou.germplasmDbIds in a GermplasmSearchRequest [BI-3006] + // TODO: Optimize this to use germplasm information directly in BrAPIObservationUnit by searching on ou.germplasmDbIds in a GermplasmSearchRequest [BI-3105] this.germplasmService.getGermplasm(program.getId()).forEach((germplasm -> germplasmByDbId.put(germplasm.getGermplasmDbId(), germplasm))); } diff --git a/src/main/java/org/breedinginsight/brapi/v2/dao/BrAPIStudyDAO.java b/src/main/java/org/breedinginsight/brapi/v2/dao/BrAPIStudyDAO.java index 424a17339..3af82e91d 100644 --- a/src/main/java/org/breedinginsight/brapi/v2/dao/BrAPIStudyDAO.java +++ b/src/main/java/org/breedinginsight/brapi/v2/dao/BrAPIStudyDAO.java @@ -23,7 +23,6 @@ import org.brapi.client.v2.model.exceptions.ApiException; import org.brapi.client.v2.model.queryParams.core.StudyQueryParams; import org.brapi.client.v2.modules.core.StudiesApi; -import org.brapi.v2.model.BrAPIExternalReference; import org.brapi.v2.model.core.BrAPIProgram; import org.brapi.v2.model.core.BrAPIStudy; import org.brapi.v2.model.core.request.BrAPIStudySearchRequest; @@ -95,7 +94,7 @@ public BrAPIStudyListResponse brapiStudySearch(Program program, List brapi BrAPIStudySearchRequest brAPIStudySearchRequest = buildSearchRequest(program, brapiTrialIds, studyQuery); - BrAPIStudyListResponse brAPIResponse = brAPIDAOUtil.simpleSearch(api::searchStudiesPost, brAPIStudySearchRequest); + BrAPIStudyListResponse brAPIResponse = brAPIDAOUtil.searchReturnResponse(api::searchStudiesPost, api::searchStudiesSearchResultsDbIdGet, brAPIStudySearchRequest); List processedStudies = processStudyForDisplay(brAPIDAOUtil.getListResult(brAPIResponse), program.getKey()); diff --git a/src/main/java/org/breedinginsight/brapi/v2/dao/impl/BrAPITrialDAOImpl.java b/src/main/java/org/breedinginsight/brapi/v2/dao/impl/BrAPITrialDAOImpl.java index 96d7e9ff7..6a178cbae 100644 --- a/src/main/java/org/breedinginsight/brapi/v2/dao/impl/BrAPITrialDAOImpl.java +++ b/src/main/java/org/breedinginsight/brapi/v2/dao/impl/BrAPITrialDAOImpl.java @@ -21,13 +21,9 @@ import lombok.extern.slf4j.Slf4j; import okhttp3.HttpUrl; import okhttp3.Request; -import org.apache.commons.lang3.StringUtils; -import org.brapi.client.v2.ApiResponse; import org.brapi.client.v2.model.exceptions.ApiException; import org.brapi.client.v2.model.queryParams.core.TrialQueryParams; import org.brapi.client.v2.modules.core.TrialsApi; -import org.brapi.v2.model.BrAPIFilterBy; -import org.brapi.v2.model.BrAPISortBy; import org.brapi.v2.model.core.BrAPIProgram; import org.brapi.v2.model.core.BrAPITrial; import org.brapi.v2.model.core.request.BrAPITrialSearchRequest; @@ -227,8 +223,9 @@ public BrAPITrialListResponse brapiTrialSearch(Program program, BrAPITrialSearchRequest brAPITrialSearchRequest = buildSearchRequest(program, brapiTrialIds, experimentQuery); BrAPITrialListResponse brAPIResponse = - brAPIDAOUtil.simpleSearch( + brAPIDAOUtil.searchReturnResponse( api::searchTrialsPost, + api::searchTrialsSearchResultsDbIdGet, brAPITrialSearchRequest ); diff --git a/src/main/java/org/breedinginsight/brapi/v2/services/BrAPIGermplasmService.java b/src/main/java/org/breedinginsight/brapi/v2/services/BrAPIGermplasmService.java index 03d7ddfc5..0e592c879 100644 --- a/src/main/java/org/breedinginsight/brapi/v2/services/BrAPIGermplasmService.java +++ b/src/main/java/org/breedinginsight/brapi/v2/services/BrAPIGermplasmService.java @@ -14,6 +14,7 @@ import org.brapi.v2.model.core.response.BrAPIListsSingleResponse; import org.brapi.v2.model.germ.BrAPIGermplasm; import org.brapi.v2.model.germ.BrAPIGermplasmSynonyms; +import org.brapi.v2.model.germ.request.BrAPIGermplasmSearchRequest; import org.brapi.v2.model.germ.response.BrAPIGermplasmListResponse; import org.brapi.v2.model.germ.response.BrAPIGermplasmListResponseResult; import org.breedinginsight.brapi.v2.constants.BrAPIAdditionalInfoFields; @@ -59,10 +60,12 @@ public BrAPIGermplasmService(BrAPIListDAO brAPIListDAO, ProgramService programSe this.germplasmDAO = germplasmDAO; } - public List getGermplasm(UUID programId) throws ApiException { + public List getGermplasm(UUID programId) throws ApiException{ try { - return germplasmDAO.getGermplasm(programId); - } catch (ApiException e) { + Program program = programService.getById(programId).orElseThrow(() -> new DoesNotExistException( String.format("No program user found for program %s", programId))); + + return germplasmDAO.brapiGermplasmSearchReturnList(program, new BrAPIGermplasmSearchRequest()); + } catch (ApiException | DoesNotExistException e) { throw new InternalServerException(e.getMessage(), e); } } @@ -212,25 +215,30 @@ public BrAPIGermplasmListResponse getGermplasmByList(UUID programId, GermplasmQu public DownloadFile exportGermplasm(UUID programId, FileType fileExtension) throws IllegalArgumentException, ApiException, IOException, DoesNotExistException { List columns = GermplasmFileColumns.getOrderedColumns(); + Optional optionalProgram = programService.getById(programId); + + if (optionalProgram.isEmpty()) { + throw new DoesNotExistException("BI Program with id " + programId + " does not exist"); + } + + Program program = optionalProgram.get(); + //Retrieve germplasm list data - List germplasm = germplasmDAO.getGermplasm(programId); + List germplasm = germplasmDAO.brapiGermplasmSearchReturnList(program, new BrAPIGermplasmSearchRequest()); germplasm.sort(Comparator.comparingInt(germ -> Integer.parseInt(germ.getAccessionNumber()))); // make file Name DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd:hh-mm-ssZ"); String timestamp = formatter.format(OffsetDateTime.now()); StringBuilder fileNameSB = new StringBuilder(); - Optional optionalProgram = programService.getById(programId); - if (optionalProgram.isPresent()) { - Program program = optionalProgram.get(); - fileNameSB.append( program.getName() ); - fileNameSB.append("_"); - } + + fileNameSB.append( program.getName() ); + fileNameSB.append("_"); + String fileName = fileNameSB.append("germplasm").append("_").append(timestamp).toString(); StreamedFile downloadFile; - //Convert list data to List> data to pass into file writer - Program program = programService.getById(programId).orElseThrow(() -> new DoesNotExistException("Could not find program: " + programId)); + List> processedData = processListData(germplasm, null, program); if (fileExtension == FileType.CSV){ diff --git a/src/main/java/org/breedinginsight/brapps/importer/services/processors/SampleSubmissionProcessor.java b/src/main/java/org/breedinginsight/brapps/importer/services/processors/SampleSubmissionProcessor.java index d946d9175..c0c0608b8 100644 --- a/src/main/java/org/breedinginsight/brapps/importer/services/processors/SampleSubmissionProcessor.java +++ b/src/main/java/org/breedinginsight/brapps/importer/services/processors/SampleSubmissionProcessor.java @@ -27,6 +27,7 @@ import org.brapi.v2.model.geno.BrAPIPlate; import org.brapi.v2.model.geno.BrAPISample; import org.brapi.v2.model.germ.BrAPIGermplasm; +import org.brapi.v2.model.germ.request.BrAPIGermplasmSearchRequest; import org.brapi.v2.model.pheno.BrAPIObservationUnit; import org.breedinginsight.api.model.v1.response.ValidationError; import org.breedinginsight.api.model.v1.response.ValidationErrors; @@ -97,7 +98,8 @@ public void getExistingBrapiData(List importRows, Program program) .map(row -> ((SampleSubmissionImport) row).getGid()) .collect(Collectors.toSet()); - List germplasm = germplasmDAO.getGermplasm(program.getId()); + // TODO: Optimize this method with a lookup on germplasm by DbId, or an exists check once [BI-2938] is complete. + List germplasm = germplasmDAO.brapiGermplasmSearchReturnList(program, new BrAPIGermplasmSearchRequest()); List obsUnitIds = importRows.stream() .filter((row -> StringUtils.isNotBlank(((SampleSubmissionImport) row).getObsUnitId()))) diff --git a/src/main/java/org/breedinginsight/brapps/importer/services/processors/experiment/create/workflow/steps/PopulateExistingPendingImportObjectsStep.java b/src/main/java/org/breedinginsight/brapps/importer/services/processors/experiment/create/workflow/steps/PopulateExistingPendingImportObjectsStep.java index e4d6d93cc..b24930924 100644 --- a/src/main/java/org/breedinginsight/brapps/importer/services/processors/experiment/create/workflow/steps/PopulateExistingPendingImportObjectsStep.java +++ b/src/main/java/org/breedinginsight/brapps/importer/services/processors/experiment/create/workflow/steps/PopulateExistingPendingImportObjectsStep.java @@ -29,6 +29,7 @@ import org.brapi.v2.model.core.BrAPITrial; import org.brapi.v2.model.core.response.BrAPIListDetails; import org.brapi.v2.model.germ.BrAPIGermplasm; +import org.brapi.v2.model.germ.request.BrAPIGermplasmSearchRequest; import org.brapi.v2.model.pheno.BrAPIObservation; import org.brapi.v2.model.pheno.BrAPIObservationUnit; import org.breedinginsight.brapi.v2.constants.BrAPIAdditionalInfoFields; @@ -43,6 +44,7 @@ import org.breedinginsight.brapps.importer.services.processors.experiment.create.model.ProcessContext; import org.breedinginsight.brapps.importer.services.processors.experiment.services.ExperimentStudyService; import org.breedinginsight.brapps.importer.services.processors.experiment.services.ExperimentTrialService; +import org.breedinginsight.daos.ProgramDAO; import org.breedinginsight.model.Program; import org.breedinginsight.model.ProgramLocation; import org.breedinginsight.services.ProgramLocationService; @@ -308,7 +310,7 @@ private Map> initializeExistingGermp .collect(Collectors.toList()); try { - existingGermplasms = new ArrayList<>(getGermplasmByAccessionNumber(uniqueGermplasmGIDs, program.getId())); + existingGermplasms = new ArrayList<>(getGermplasmByAccessionNumber(uniqueGermplasmGIDs, program)); } catch (ApiException e) { log.error("Error fetching germplasm: " + Utilities.generateApiExceptionLogMessage(e), e); throw new InternalServerException(e.toString(), e); @@ -326,14 +328,15 @@ private Map> initializeExistingGermp * Retrieves a list of germplasm with the specified accession numbers. * * @param germplasmAccessionNumbers The list of accession numbers to search for. - * @param programId The ID of the program. + * @param program The program to lookup germplasm against * @return An ArrayList of BrAPIGermplasm objects that match the accession numbers. * @throws ApiException if there is an error retrieving the germplasm. */ private ArrayList getGermplasmByAccessionNumber( List germplasmAccessionNumbers, - UUID programId) throws ApiException { - List germplasmList = brAPIGermplasmDAO.getGermplasm(programId); + Program program) throws ApiException { + // TODO: Optimize with an exists check on accession number, or a filter brapi lookup on accession number. Revisit once BI-2938 is complete + List germplasmList = brAPIGermplasmDAO.brapiGermplasmSearchReturnList(program, new BrAPIGermplasmSearchRequest()); ArrayList resultGermplasm = new ArrayList<>(); // Search for accession number matches for (BrAPIGermplasm germplasm : germplasmList) { diff --git a/src/main/java/org/breedinginsight/brapps/importer/services/processors/germplasm/GermplasmProcessor.java b/src/main/java/org/breedinginsight/brapps/importer/services/processors/germplasm/GermplasmProcessor.java index 4ea4d7963..13ee47e76 100644 --- a/src/main/java/org/breedinginsight/brapps/importer/services/processors/germplasm/GermplasmProcessor.java +++ b/src/main/java/org/breedinginsight/brapps/importer/services/processors/germplasm/GermplasmProcessor.java @@ -157,6 +157,7 @@ public void getExistingBrapiData(List importRows, Program program) // Get existing germplasm names. This should be used ONLY to identify duplicate germplasm names. // In general you should look up germplasm by GID. + // TODO: Revisit and optimize once a way to check if certain data already exists in brapi is created [BI-2938] List dbGermplasm = brAPIGermplasmService.getGermplasmByDisplayName(new ArrayList<>(fileGermplasmByName.keySet()), program.getId()); dbGermplasm.forEach(germplasm -> { dbGermplasmByName.put(germplasm.getDefaultDisplayName(), germplasm); diff --git a/src/main/java/org/breedinginsight/services/impl/BreedingMethodServiceImpl.java b/src/main/java/org/breedinginsight/services/impl/BreedingMethodServiceImpl.java index 19e880309..9b96588ba 100644 --- a/src/main/java/org/breedinginsight/services/impl/BreedingMethodServiceImpl.java +++ b/src/main/java/org/breedinginsight/services/impl/BreedingMethodServiceImpl.java @@ -2,6 +2,7 @@ import org.apache.commons.lang3.StringUtils; import org.brapi.client.v2.model.exceptions.ApiException; +import org.brapi.v2.model.germ.BrAPIGermplasm; import org.breedinginsight.brapi.v2.services.BrAPIGermplasmService; import org.breedinginsight.dao.db.tables.pojos.ProgramBreedingMethodEntity; import org.breedinginsight.daos.BreedingMethodDAO; @@ -46,7 +47,7 @@ public List fetchBreedingMethodsInUse(UUID programI .stream() .collect(Collectors.toMap(ProgramBreedingMethodEntity::getId, o -> o)); - //TODO retest with new germplasm after updating the DAO to return the correct ID for a method + // TODO: Optimize this lookup by searching on the breeding method name on germplasm. This could be further optimized with an exists check. Revisit after [BI-2938] germplasmService.getGermplasm(programId).forEach(germplasm -> { UUID id = UUID.fromString(germplasm.getBreedingMethodDbId()); if(programMethods.containsKey(id)) { diff --git a/src/main/java/org/breedinginsight/utilities/BrAPIDAOUtil.java b/src/main/java/org/breedinginsight/utilities/BrAPIDAOUtil.java index 07d012b06..c1c727d2f 100644 --- a/src/main/java/org/breedinginsight/utilities/BrAPIDAOUtil.java +++ b/src/main/java/org/breedinginsight/utilities/BrAPIDAOUtil.java @@ -76,8 +76,8 @@ public BrAPIDAOUtil(@Property(name = "brapi.search.wait-time") int searchWaitTim this.programService = programService; } - public List get(Function> getMethod, - U queryParams) throws ApiException { + public , U extends BrAPIResponseResult, V, W extends BrAPIQueryParams> List get(Function> getMethod, + W queryParams) throws ApiException { T brapiResponseResult; boolean paginationSet = queryParams.page() != null && queryParams.pageSize() != null; @@ -115,7 +115,7 @@ public List get(Func // Size of BrAPI entity GET data can not exceed configured pageSize. // If it does, it is recommended the GET method not be used for this purpose. // If you are trying to utilize this method to get a large amount of data for an entity, you can use - // searchInternal for now. In the future, we need a more robust way of transmitting this data using + // searchInternalReturnList for now. In the future, we need a more robust way of transmitting this data using // compression client techniques to reduce strain on the server and avoid keeping all the database data // in java memory. throw new InternalServerException(String.format("More than one page found, meaning there is more data to be returned " + @@ -125,79 +125,88 @@ public List get(Func return getListResult(brapiResponseResult); } - // Performs a POST brapi search on an entity without looping paging logic, utilizing filters and pagination provided in the searchBody. - // Also verifies response paging matches requested paging - public T simpleSearch(Function, Optional>>> searchMethod, - U searchBody) throws ApiException { - T brapiResponseResult; + public , U extends BrAPIResponseResult, V, W extends BrAPISearchRequestParametersPaging> List search(Function, Optional>>> searchMethod, + Function3, Optional>>> searchGetMethod, + W searchBody + ) throws ApiException { + return searchInternalReturnList(searchMethod, searchGetMethod, null, searchBody, true); + } - try { - // Traverse response with an optional to allow for free null checking with .map() - brapiResponseResult = Optional.ofNullable(searchMethod.apply(searchBody)) - .map(ApiResponse::getBody) - .map(Pair::getLeft) - // Deal with wrapped Optionals - .flatMap(optional -> optional) - .orElseThrow(); - } catch (ApiException e) { - log.warn(Utilities.generateApiExceptionLogMessage(e)); - throw e; - } catch (NoSuchElementException e) { - log.debug("Unable to retrieve BrAPIResponse from POST search request", e); - throw new InternalServerException(e.toString(), e); - } catch (Exception e) { - log.debug("error", e); - throw new InternalServerException(e.toString(), e); - } + public , U extends BrAPIResponseResult, V, W extends BrAPISearchRequestParametersPaging> List search(Function, Optional>>> searchMethod, + Function4, Optional>>> searchMimedGetMethod, + W searchBody + ) throws ApiException { + return searchInternalReturnList(searchMethod, null, searchMimedGetMethod, searchBody, true); + } - BrAPIPagination responsePagination = Optional.of(brapiResponseResult) - .map(BrAPIResponse::getMetadata) - .map(BrAPIMetadata::getPagination) - .orElse(null); + // Sends a boolean to prevent paging through the entire response to retrieve all data. Necessary in cases where specific paging is required. + public , U extends BrAPIResponseResult, V, W extends BrAPISearchRequestParametersPaging> List searchNoPageThru(Function, Optional>>> searchMethod, + Function3, Optional>>> searchGetMethod, + W searchBody + ) throws ApiException { + return searchInternalReturnList(searchMethod, searchGetMethod, null, searchBody, false); + } - if (responsePagination == null) { - throw new InternalServerException("Expected pagination metadata in BrAPI search response not present"); - } + private , U extends BrAPIResponseResult, V, W extends BrAPISearchRequestParametersPaging> List searchInternalReturnList(Function, Optional>>> searchMethod, + Function3, Optional>>> searchGetMethod, + Function4, Optional>>> searchGetMethodWithMimeType, + W searchBody, boolean pageThru) throws ApiException { + return getListResult(searchInternalReturnResponse(searchMethod, searchGetMethod, searchGetMethodWithMimeType, searchBody, pageThru)); + } - var requestPageNumber = searchBody.getPage(); - var requestPageSize = searchBody.getPageSize(); + public , U extends BrAPIResponseResult, V, W extends BrAPISearchRequestParametersPaging> T searchReturnResponse(Function, Optional>>> searchMethod, + Function3, Optional>>> searchGetMethod, + W searchBody + ) throws ApiException { - if (!responsePagination.getCurrentPage().equals(requestPageNumber) || !responsePagination.getPageSize().equals(requestPageSize)) { - throw new InternalServerException("Page number and/or page size do not match between BrAPI search request and response"); - } + boolean pageThru = (searchBody.getPage() == null || searchBody.getPage() == 0) && (searchBody.getPageSize() == null || searchBody.getPageSize() == 0); - return brapiResponseResult; + return searchInternalReturnResponse(searchMethod, searchGetMethod, null, searchBody, pageThru); } - public List search(Function, Optional>>> searchMethod, - Function3, Optional>>> searchGetMethod, - U searchBody + public , U extends BrAPIResponseResult, V, W extends BrAPISearchRequestParametersPaging> T searchReturnResponse(Function, Optional>>> searchMethod, + Function4, Optional>>> searchMimedGetMethod, + W searchBody ) throws ApiException { - return searchInternal(searchMethod, searchGetMethod, null, searchBody, true); - } + boolean pageThru = (searchBody.getPage() == null || searchBody.getPage() == 0) && (searchBody.getPageSize() == null || searchBody.getPageSize() == 0); - public List search(Function, Optional>>> searchMethod, - Function4, Optional>>> searchGetMethod, - U searchBody - ) throws ApiException { - return searchInternal(searchMethod, null, searchGetMethod, searchBody, true); + return searchInternalReturnResponse(searchMethod, null, searchMimedGetMethod, searchBody, pageThru); } - public List searchNoPaging(Function, Optional>>> searchMethod, - Function3, Optional>>> searchGetMethod, - U searchBody - ) throws ApiException { - return searchInternal(searchMethod, searchGetMethod, null, searchBody, false); - } + /** + * @param searchMethod The BrAPI API search post method, e.g. ObservationUnitsApi.searchObservationsPost() + * + * For the following two params, it should be noted some BrAPI APIs only support one of the following GET methods (e.g. ObservationUnitsApi) In those cases, BI passes in the existing GET method. + * @param searchGetMethod The BrAPI API search GET by searchDbId method. This is used when async search is triggered by > 5 params in BrAPI search method. + * The searchDbId is returned by the original postMethod if it is triggered. e.g. ObservationsApi.searchObservationsSearchResultsDbIdGet() + * @param searchGetMethodWithMimeType The BrAPI API search GET method that triggers an async response. This is used when async search is triggered by > 5 params in BrAPI search method, and no searchGetMethod exists. + * The searchDbId is returned by the original postMethod if it is triggered. e.g. ObservationUnitsApi.searchObservationunitsSearchResultsDbIdGet. + * + * @param searchBody The BrAPI entity search request being supplied for this search + * @param pageThru Determines whether all existing data related to the request should be retrieved, ignoring pagination. + * For this method and all callers above, the parameters are described as follows: + * @param A BrAPIResponse object + * @param A BrAPIResponseResult object + * @param The BrAPI model object contained in list returned by U.getData() + * @param The specific BrAPI search request type + * An example in action, say GermplasmApi.searchGermplasmPost() is supplied as the search method. This returns a BrAPIGermplasmListResponse class, which is T. + * The U then, is BrAPIGermplasmListResponseResult, and V is BrAPIGermplasm. + * In this example, W should be a BrAPIGermplasmSearchRequest + * @return The full BrAPIResponse object from a completed BrAPI search request + */ + private , U extends BrAPIResponseResult, V, W extends BrAPISearchRequestParametersPaging> T searchInternalReturnResponse(Function, Optional>>> searchMethod, + Function3, Optional>>> searchGetMethod, + Function4, Optional>>> searchGetMethodWithMimeType, + W searchBody, boolean pageThru) throws ApiException { + if (searchBody.getPageSize() != null && searchBody.getPageSize() > brapiFetchPageSize) { + // Currently support for pages over 65k is not supported, which at the time of writing is the configured size of brapiFetchPageSize, which in .env is paging.page-size.max-allowed + throw new ApiException(HttpStatus.BAD_REQUEST.getCode(), String.format("Maximum allowable pageSize for a BrAPI request is [%s]. If more data than this is required, send request without specifying page or page size to retrieve all of it.", brapiFetchPageSize)); + } - private List searchInternal(Function, Optional>>> searchMethod, - Function3, Optional>>> searchGetMethod, - Function4, Optional>>> searchGetMethodWithMimeType, - U searchBody, boolean sendPaging) throws ApiException { try { - List listResult = new ArrayList<>(); + T listResponse = null; - if (sendPaging) { + if (pageThru) { // This should be set to whatever the maximum allowable value is configured in the brapi test server, // perhaps it should be configurable on bi side as well. // For reference, that prop name is paging.page-size.max-allowed @@ -206,14 +215,13 @@ private List searchInter ApiResponse, Optional>> response = searchMethod.apply(searchBody); if (response.getBody().getLeft().isPresent()) { - BrAPIResponse listResponse = (BrAPIResponse) response.getBody().getLeft().get(); - listResult = getListResult(response); + listResponse = response.getBody().getLeft().get(); /* NOTE: may want to check for additional pages depending on whether BrAPI standard specifies how pagination params are handled for POST search endpoints or the corresponding endpoints in Breedbase are changed or updated */ - if(sendPaging && hasMorePages(listResponse)) { + if (pageThru && hasMorePages(listResponse)) { int currentPage = listResponse.getMetadata().getPagination().getCurrentPage() + 1; int totalPages = listResponse.getMetadata().getPagination().getTotalPages(); @@ -221,7 +229,7 @@ private List searchInter searchBody.setPage(currentPage); response = searchMethod.apply(searchBody); if (response.getBody().getLeft().isPresent()) { - listResult.addAll(getListResult(response)); + listResponse.getResult().getData().addAll(getListResult(response)); } currentPage++; @@ -239,10 +247,9 @@ private List searchInter searchGetResponse(searchGetMethod, searchGetMethodWithMimeType, searchResult, currentPage); if (searchGetResponse.getBody().getLeft().isPresent()) { searchFinished = true; - BrAPIResponse listResponse = (BrAPIResponse) searchGetResponse.getBody().getLeft().get(); - listResult = getListResult(searchGetResponse); + listResponse = searchGetResponse.getBody().getLeft().get(); - if(sendPaging && hasMorePages(listResponse)) { + if(pageThru && hasMorePages(listResponse)) { currentPage++; int totalPages = listResponse.getMetadata() .getPagination() @@ -251,7 +258,7 @@ private List searchInter while (currentPage < totalPages) { searchGetResponse = searchGetResponse(searchGetMethod, searchGetMethodWithMimeType, searchResult, currentPage); if (searchGetResponse.getBody().getLeft().isPresent()) { - listResult.addAll(getListResult(searchGetResponse)); + listResponse.getResult().getData().addAll(getListResult(searchGetResponse)); } currentPage++; @@ -268,7 +275,20 @@ private List searchInter } } - return listResult; + if (pageThru) { + BrAPIPagination pagination = listResponse.getMetadata().getPagination(); + + // If pageThru is true, all the data found with the search request was retrieved, rendering paging info useless. + // To accommodate for this, re-assign some of the metadata params. + // TODO: In this use case, align bi/brapi-server/client to return all nulls. + pagination.setPageSize(pagination.getTotalCount()); + pagination.setTotalPages(1); + pagination.setCurrentPage(0); + + listResponse.getMetadata().setPagination(pagination); + } + + return listResponse; } catch (ApiException e) { log.warn(Utilities.generateApiExceptionLogMessage(e)); throw e; @@ -579,9 +599,10 @@ private BrAPISortBy constructSortBy(String sortOn, String sortOrder) { public void setGenericSearchParameters(T brapiSearchRequest, U biSearchQuery) { if (biSearchQuery == null) { - // If the search query is not available, assume maximum size fetch is required and break out of this method. - brapiSearchRequest.setPage(0); - brapiSearchRequest.setPageSize(brapiFetchPageSize); + // If the search query is not available, assume we want all data retrieved using the search request. + // This is accomplished by setting the page and pageSize to null. + brapiSearchRequest.setPage(null); + brapiSearchRequest.setPageSize(null); return; } diff --git a/src/test/java/org/breedinginsight/brapi/v2/BrAPIObservationsControllerIntegrationTest.java b/src/test/java/org/breedinginsight/brapi/v2/BrAPIObservationsControllerIntegrationTest.java index 8ba8580b0..3077658eb 100644 --- a/src/test/java/org/breedinginsight/brapi/v2/BrAPIObservationsControllerIntegrationTest.java +++ b/src/test/java/org/breedinginsight/brapi/v2/BrAPIObservationsControllerIntegrationTest.java @@ -452,7 +452,7 @@ private void checkPagination(Integer page, Integer pageSize, HttpStatus expected JsonObject responseObj = gson.fromJson(response.body(), JsonObject.class); // Get metadata. JsonObject pagination = responseObj.getAsJsonObject("metadata").getAsJsonObject("pagination"); - int expectedPageSize = pageSize == null ? 1000 : pageSize; + int expectedPageSize = pageSize == null ? expectedTotalCount : pageSize; assertEquals(expectedPageSize, pagination.get("pageSize").getAsInt()); int expectedPage = page == null ? 0 : page; assertEquals(expectedPage, pagination.get("currentPage").getAsInt()); diff --git a/src/test/java/org/breedinginsight/brapi/v2/dao/BrAPIGermplasmDAOUnitTest.java b/src/test/java/org/breedinginsight/brapi/v2/dao/BrAPIGermplasmDAOUnitTest.java index 038fdbfaf..1e3bfed61 100644 --- a/src/test/java/org/breedinginsight/brapi/v2/dao/BrAPIGermplasmDAOUnitTest.java +++ b/src/test/java/org/breedinginsight/brapi/v2/dao/BrAPIGermplasmDAOUnitTest.java @@ -68,7 +68,6 @@ void setup() { germplasmDAO = new BrAPIGermplasmDAO(programDAO, mock(ImportDAO.class), brAPIDAOUtil, new BrAPIEndpointProvider(), - 65000, new ObjectMapper(), mock(BrAPIListDAO.class) ); diff --git a/src/test/java/org/breedinginsight/brapi/v2/dao/BrAPIObservationDAOUnitTest.java b/src/test/java/org/breedinginsight/brapi/v2/dao/BrAPIObservationDAOUnitTest.java index ab4cbd794..5253f7dfb 100644 --- a/src/test/java/org/breedinginsight/brapi/v2/dao/BrAPIObservationDAOUnitTest.java +++ b/src/test/java/org/breedinginsight/brapi/v2/dao/BrAPIObservationDAOUnitTest.java @@ -213,7 +213,7 @@ void getObservationsByFiltersUsesDefaultsWithoutStudyFilter() { BrAPIObservationListResponse brAPIResponse = new BrAPIObservationListResponse().result(new BrAPIObservationListResponseResult().data(observations)); - when(brAPIDAOUtil.simpleSearch(any(Function.class), any(BrAPIObservationSearchRequest.class))).thenReturn(brAPIResponse); + when(brAPIDAOUtil.searchReturnResponse(any(Function.class), any(Function4.class), any(BrAPIObservationSearchRequest.class))).thenReturn(brAPIResponse); doReturn(observations).when(brAPIDAOUtil).getListResult(brAPIResponse); @@ -223,14 +223,14 @@ void getObservationsByFiltersUsesDefaultsWithoutStudyFilter() { ArgumentCaptor requestCaptor = ArgumentCaptor.forClass(BrAPIObservationSearchRequest.class); - verify(brAPIDAOUtil).simpleSearch(any(Function.class), requestCaptor.capture()); + verify(brAPIDAOUtil).searchReturnResponse(any(Function.class), any(Function4.class), requestCaptor.capture()); BrAPIObservationSearchRequest request = requestCaptor.getValue(); assertEquals(List.of(BRAPI_PROGRAM_DB_ID), request.getProgramDbIds()); assertEquals(null, request.getStudyDbIds()); - assertEquals(0, request.getPage()); - assertEquals(1000, request.getPageSize()); + assertEquals(null, request.getPage()); + assertEquals(null, request.getPageSize()); } @Test @@ -247,7 +247,7 @@ void getObservationsByFiltersUsesBrAPISearchPagination() { List brapiObservations = List.of(observation); BrAPIObservationListResponse brAPIResponse = new BrAPIObservationListResponse().result(new BrAPIObservationListResponseResult().data(brapiObservations)); - when(brAPIDAOUtil.simpleSearch(any(Function.class), any(BrAPIObservationSearchRequest.class))).thenReturn(brAPIResponse); + when(brAPIDAOUtil.searchReturnResponse(any(Function.class), any(Function4.class), any(BrAPIObservationSearchRequest.class))).thenReturn(brAPIResponse); doReturn(brapiObservations).when(brAPIDAOUtil).getListResult(brAPIResponse); @@ -261,7 +261,7 @@ void getObservationsByFiltersUsesBrAPISearchPagination() { ArgumentCaptor requestCaptor = ArgumentCaptor.forClass(BrAPIObservationSearchRequest.class); - verify(brAPIDAOUtil).simpleSearch(any(Function.class), requestCaptor.capture()); + verify(brAPIDAOUtil).searchReturnResponse(any(Function.class), any(Function4.class), requestCaptor.capture()); BrAPIObservationSearchRequest request = requestCaptor.getValue(); diff --git a/src/test/java/org/breedinginsight/brapi/v2/dao/BrAPIStudyDAOUnitTest.java b/src/test/java/org/breedinginsight/brapi/v2/dao/BrAPIStudyDAOUnitTest.java index 58806202e..5cf594011 100644 --- a/src/test/java/org/breedinginsight/brapi/v2/dao/BrAPIStudyDAOUnitTest.java +++ b/src/test/java/org/breedinginsight/brapi/v2/dao/BrAPIStudyDAOUnitTest.java @@ -190,14 +190,14 @@ void brapiStudySearchSendsServerSideQueryAndPreservesPagedResponseOrder() { study("2", "Environment 2 [TEST-2]"), study("1", "Environment 1 [TEST-1]")); - when(brAPIDAOUtil.simpleSearch(any(Function.class), any(BrAPIStudySearchRequest.class))).thenReturn(brAPIResponse); + when(brAPIDAOUtil.searchReturnResponse(any(Function.class), any(Function3.class), any(BrAPIStudySearchRequest.class))).thenReturn(brAPIResponse); doReturn(serverOrderedStudies).when(brAPIDAOUtil).getListResult(brAPIResponse); BrAPIStudyListResponse result = studyDAO.brapiStudySearch(program, List.of(authorizedTrialId), studyQuery); ArgumentCaptor requestCaptor = ArgumentCaptor.forClass(BrAPIStudySearchRequest.class); - verify(brAPIDAOUtil).simpleSearch(any(Function.class), requestCaptor.capture()); + verify(brAPIDAOUtil).searchReturnResponse(any(Function.class), any(Function3.class), requestCaptor.capture()); BrAPIStudySearchRequest request = requestCaptor.getValue(); assertEquals(List.of("brapi-program-1"), request.getProgramDbIds()); diff --git a/src/test/java/org/breedinginsight/brapps/importer/daos/BrAPIObservationUnitDAOTest.java b/src/test/java/org/breedinginsight/brapps/importer/daos/BrAPIObservationUnitDAOTest.java index eb071b652..cabef6342 100644 --- a/src/test/java/org/breedinginsight/brapps/importer/daos/BrAPIObservationUnitDAOTest.java +++ b/src/test/java/org/breedinginsight/brapps/importer/daos/BrAPIObservationUnitDAOTest.java @@ -11,11 +11,11 @@ import org.brapi.v2.model.BrAPIExternalReference; import org.brapi.v2.model.pheno.BrAPIObservationTreatment; import org.brapi.v2.model.pheno.BrAPIObservationUnit; +import org.brapi.v2.model.pheno.request.BrAPIObservationUnitSearchRequest; import org.breedinginsight.BrAPITest; import org.breedinginsight.api.model.v1.request.ProgramRequest; import org.breedinginsight.api.model.v1.request.SpeciesRequest; import org.breedinginsight.api.v1.controller.TestTokenValidator; -import org.breedinginsight.brapi.v2.constants.BrAPIAdditionalInfoFields; import org.breedinginsight.brapi.v2.dao.BrAPIObservationUnitDAO; import org.breedinginsight.brapps.importer.model.ImportProgress; import org.breedinginsight.brapps.importer.model.ImportUpload; @@ -143,7 +143,7 @@ public void testCreateObservationUnitAdditionalInfoSingleTreatmentFactor() { @SneakyThrows @Order(2) public void testGetObservationUnitAdditionalInfoSingleTreatmentFactor() { - List createdOus = obsUnitDAO.getProgramObservationUnits(validProgram.getId()); + List createdOus = obsUnitDAO.searchBrapiObservationUnits(new BrAPIObservationUnitSearchRequest(), validProgram); singleTreatmentAsserts(createdOus, testTreatment); } diff --git a/src/test/java/org/breedinginsight/services/BrAPIGermplasmServiceUnitTest.java b/src/test/java/org/breedinginsight/services/BrAPIGermplasmServiceUnitTest.java index 4211bb419..1e2bd1b8c 100644 --- a/src/test/java/org/breedinginsight/services/BrAPIGermplasmServiceUnitTest.java +++ b/src/test/java/org/breedinginsight/services/BrAPIGermplasmServiceUnitTest.java @@ -60,7 +60,7 @@ void setup() { listDAO = mock(BrAPIListDAO.class); programDAO = mock(ProgramDAO.class); brAPIDAOUtil = mock(BrAPIDAOUtil.class); - germplasmDAO = new BrAPIGermplasmDAO(programDAO, mock(ImportDAO.class), brAPIDAOUtil, new BrAPIEndpointProvider(), 65000, new ObjectMapper(), listDAO); + germplasmDAO = new BrAPIGermplasmDAO(programDAO, mock(ImportDAO.class), brAPIDAOUtil, new BrAPIEndpointProvider(), new ObjectMapper(), listDAO); programService = mock(ProgramService.class); Field externalReferenceSource = BrAPIGermplasmDAO.class.getDeclaredField("referenceSource");