@@ -60,45 +60,59 @@ public class BrAPIDAOUtil {
6060 private final Duration searchTimeout ;
6161 private final int pageSize ;
6262 private final int postGroupSize ;
63+ private final int brapiFetchPageSize ;
6364 private final ProgramService programService ;
6465
6566 @ Inject
6667 public BrAPIDAOUtil (@ Property (name = "brapi.search.wait-time" ) int searchWaitTime ,
6768 @ Property (name = "brapi.read-timeout" ) Duration searchTimeout ,
6869 @ Property (name = "brapi.page-size" ) int pageSize ,
6970 @ Property (name = "brapi.post-group-size" ) int postGroupSize ,
71+ @ Property (name = "brapi.cache.fetch-page-size" ) int brapiFetchPageSize ,
7072 ProgramService programService ) {
7173 this .searchWaitTime = searchWaitTime ;
7274 this .searchTimeout = searchTimeout ;
7375 this .pageSize = pageSize ;
7476 this .postGroupSize = postGroupSize ;
77+ this .brapiFetchPageSize = brapiFetchPageSize ;
7578 this .programService = programService ;
7679 }
7780
7881 public <T , U extends BrAPISearchRequestParametersPaging , V > List <V > search (Function <U , ApiResponse <Pair <Optional <T >, Optional <BrAPIAcceptedSearchResponse >>>> searchMethod ,
7982 Function3 <String , Integer , Integer , ApiResponse <Pair <Optional <T >, Optional <BrAPIAcceptedSearchResponse >>>> searchGetMethod ,
8083 U searchBody
8184 ) throws ApiException {
82- return searchInternal (searchMethod , searchGetMethod , null , searchBody );
85+ return searchInternal (searchMethod , searchGetMethod , null , searchBody , true );
8386 }
8487
8588 public <T , U extends BrAPISearchRequestParametersPaging , V > List <V > search (Function <U , ApiResponse <Pair <Optional <T >, Optional <BrAPIAcceptedSearchResponse >>>> searchMethod ,
8689 Function4 <BrAPIWSMIMEDataTypes , String , Integer , Integer , ApiResponse <Pair <Optional <T >, Optional <BrAPIAcceptedSearchResponse >>>> searchGetMethod ,
8790 U searchBody
8891 ) throws ApiException {
89- return searchInternal (searchMethod , null , searchGetMethod , searchBody );
92+ return searchInternal (searchMethod , null , searchGetMethod , searchBody , true );
93+ }
94+
95+ public <T , U extends BrAPISearchRequestParametersPaging , V > List <V > searchNoPaging (Function <U , ApiResponse <Pair <Optional <T >, Optional <BrAPIAcceptedSearchResponse >>>> searchMethod ,
96+ Function3 <String , Integer , Integer , ApiResponse <Pair <Optional <T >, Optional <BrAPIAcceptedSearchResponse >>>> searchGetMethod ,
97+ U searchBody
98+ ) throws ApiException {
99+ return searchInternal (searchMethod , searchGetMethod , null , searchBody , false );
90100 }
91101
92102 private <T , U extends BrAPISearchRequestParametersPaging , V > List <V > searchInternal (Function <U , ApiResponse <Pair <Optional <T >, Optional <BrAPIAcceptedSearchResponse >>>> searchMethod ,
93103 Function3 <String , Integer , Integer , ApiResponse <Pair <Optional <T >, Optional <BrAPIAcceptedSearchResponse >>>> searchGetMethod ,
94104 Function4 <BrAPIWSMIMEDataTypes , String , Integer , Integer , ApiResponse <Pair <Optional <T >, Optional <BrAPIAcceptedSearchResponse >>>> searchGetMethodWithMimeType ,
95- U searchBody ) throws ApiException {
105+ U searchBody , boolean sendPaging ) throws ApiException {
96106 try {
97107 List <V > listResult = new ArrayList <>();
98- //NOTE: Because of the way Breedbase implements BrAPI searches, the page size is initially set to an
99- //arbitrary, large value to ensure that in the event that a 202 response is returned, the searchDbId
100- //stored will refer to all records of the BrAPI variable.
101- searchBody .pageSize (10000000 );
108+
109+ if (sendPaging ) {
110+ // This should be set to whatever the maximum allowable value is configured in the brapi test server,
111+ // perhaps it should be configurable on bi side as well.
112+ // For reference, that prop name is paging.page-size.max-allowed
113+ searchBody .pageSize (brapiFetchPageSize );
114+ }
115+
102116 ApiResponse <Pair <Optional <T >, Optional <BrAPIAcceptedSearchResponse >>> response = searchMethod .apply (searchBody );
103117 if (response .getBody ().getLeft ().isPresent ()) {
104118 BrAPIResponse listResponse = (BrAPIResponse ) response .getBody ().getLeft ().get ();
@@ -108,7 +122,7 @@ private <T, U extends BrAPISearchRequestParametersPaging, V> List<V> searchInter
108122 pagination params are handled for POST search endpoints or the corresponding endpoints in Breedbase are
109123 changed or updated
110124 */
111- if (hasMorePages (listResponse )) {
125+ if (sendPaging && hasMorePages (listResponse )) {
112126 int currentPage = listResponse .getMetadata ().getPagination ().getCurrentPage () + 1 ;
113127 int totalPages = listResponse .getMetadata ().getPagination ().getTotalPages ();
114128
@@ -137,7 +151,7 @@ private <T, U extends BrAPISearchRequestParametersPaging, V> List<V> searchInter
137151 BrAPIResponse listResponse = (BrAPIResponse ) searchGetResponse .getBody ().getLeft ().get ();
138152 listResult = getListResult (searchGetResponse );
139153
140- if (hasMorePages (listResponse )) {
154+ if (sendPaging && hasMorePages (listResponse )) {
141155 currentPage ++;
142156 int totalPages = listResponse .getMetadata ()
143157 .getPagination ()
0 commit comments