-
Notifications
You must be signed in to change notification settings - Fork 0
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
Germplasm Search Optimizations #49
base: develop
Are you sure you want to change the base?
Changes from 8 commits
8316721
cc5d9c6
ec4055a
773b307
1b06e85
9ff25a5
2526b1e
0f56f73
d148e5d
55b1841
407242c
b59ec3e
2de845c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
import io.swagger.model.core.BatchDeletesListResponseResult; | ||
import org.brapi.test.BrAPITestServer.auth.AuthDetails; | ||
import org.brapi.test.BrAPITestServer.exceptions.BrAPIServerException; | ||
import org.brapi.test.BrAPITestServer.exceptions.InvalidPagingException; | ||
import org.brapi.test.BrAPITestServer.service.PagingUtility; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.http.HttpStatus; | ||
|
@@ -33,29 +33,14 @@ | |
|
||
public class BrAPIController { | ||
private static final Logger log = LoggerFactory.getLogger(ServerInfoApiController.class); | ||
|
||
protected Metadata generateMetaDataTemplateForSearch(Integer originalRequestedPage, Integer newRequestedPage, | ||
Integer originalRequestedPageSize, Integer newRequestedPageSize) throws BrAPIServerException { | ||
Integer page = newRequestedPage; | ||
Integer pageSize = newRequestedPageSize; | ||
|
||
if (page == null) { | ||
page = originalRequestedPage; | ||
} | ||
if (pageSize == null) { | ||
pageSize = originalRequestedPageSize; | ||
} | ||
|
||
return generateMetaDataTemplate(page, pageSize); | ||
} | ||
|
||
protected Metadata generateMetaDataTemplate(SearchRequest request) throws BrAPIServerException { | ||
return generateMetaDataTemplate(request.getPage(), request.getPageSize()); | ||
} | ||
|
||
protected Metadata generateMetaDataTemplate(String pageToken, Integer pageSize) { | ||
if (pageSize == null) { | ||
pageSize = 1000; | ||
pageSize = PagingUtility.getDefaultPageSize(); | ||
} | ||
|
||
Metadata metaData = generateEmptyMetadataToken(); | ||
|
@@ -65,14 +50,14 @@ protected Metadata generateMetaDataTemplate(String pageToken, Integer pageSize) | |
} | ||
|
||
protected Metadata generateMetaDataTemplate(Integer page, Integer pageSize) throws BrAPIServerException { | ||
validatePaging(page, pageSize); | ||
PagingUtility.validatePaging(page, pageSize); | ||
|
||
// defaults | ||
if (page == null) { | ||
page = 0; | ||
} | ||
if (pageSize == null) { | ||
pageSize = 1000; | ||
pageSize = PagingUtility.getDefaultPageSize(); | ||
} | ||
|
||
Metadata metaData = generateEmptyMetadata(); | ||
|
@@ -81,16 +66,6 @@ protected Metadata generateMetaDataTemplate(Integer page, Integer pageSize) thro | |
return metaData; | ||
} | ||
|
||
private void validatePaging(Integer page, Integer pageSize) throws BrAPIServerException { | ||
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. Moved to |
||
boolean pageValid = (page == null) || (page >= 0); | ||
if (!pageValid) | ||
throw new InvalidPagingException("page"); | ||
boolean pageSizeValid = (pageSize == null) || (pageSize >= 1); | ||
if (!pageSizeValid) | ||
throw new InvalidPagingException("pageSize"); | ||
|
||
} | ||
|
||
protected Metadata generateEmptyMetadata() { | ||
Metadata metaData = new Metadata(); | ||
metaData.setDatafiles(new ArrayList<>()); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,7 +66,7 @@ public ResponseEntity<SeedLotListResponse> seedlotsGet( | |
validateAcceptHeader(request); | ||
Metadata metadata = generateMetaDataTemplate(page, pageSize); | ||
List<SeedLot> data = seedLotService.findSeedLots(seedLotDbId, germplasmDbId, germplasmName, crossDbId, | ||
crossName, commonCropName, programDbId, externalReferenceId, externalReferenceID, | ||
crossName, commonCropName, programDbId, externalReferenceID, | ||
externalReferenceSource, metadata); | ||
return responseOK(new SeedLotListResponse(), new SeedLotListResponseResult(), data, metadata); | ||
} | ||
|
@@ -156,7 +156,7 @@ public ResponseEntity<SeedLotTransactionListResponse> seedlotsTransactionsGet( | |
validateAcceptHeader(request); | ||
Metadata metadata = generateMetaDataTemplate(page, pageSize); | ||
List<SeedLotTransaction> data = seedLotService.findSeedLotTransactions(transactionDbId, seedLotDbId, | ||
germplasmDbId, germplasmName, crossDbId, crossName, commonCropName, programDbId, externalReferenceId, | ||
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.
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. These were autofixes for params that were being unused in these sigs, I can rename to 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. I will use the right one here and other places, but think we should wait to fully delete from ApiControllers and data models, or do it in another commit/MR. 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. I would either continue to support the deprecated 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. Ok, I would rather this not be a sticking point then. These changes are pretty far removed and out of scope of the things we actually want. I will just revert these changes. If we actually want to remove those attributes from the codebase would rather that be done in a separate MR, bc it's a decent amount of changes to fully support. |
||
germplasmDbId, germplasmName, crossDbId, crossName, commonCropName, programDbId, | ||
externalReferenceID, externalReferenceSource, metadata); | ||
return responseOK(new SeedLotTransactionListResponse(), new SeedLotTransactionListResponseResult(), data, | ||
metadata); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,11 +4,12 @@ | |
import io.swagger.model.SearchRequest; | ||
import io.swagger.model.core.BatchDeleteTypes; | ||
import jakarta.validation.Valid; | ||
import org.brapi.test.BrAPITestServer.exceptions.BrAPIServerException; | ||
|
||
import java.util.List; | ||
|
||
public interface BrAPIComponent<T, R extends SearchRequest> { | ||
List<T> findEntities(@Valid R request, Metadata metadata); | ||
List<T> findEntities(@Valid R request, Metadata metadata) throws BrAPIServerException; | ||
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. All these |
||
BatchDeleteTypes getBatchDeleteType(); | ||
List<String> collectDbIds(List<T> entities); | ||
void deleteBatchDeleteData(List<String> dbIds); | ||
|
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 was unused.