[BI-617] - Sort/paginate/filter for trait upload#49
Conversation
| @Setter | ||
| @Accessors(chain=true) | ||
| @ToString | ||
| @SuperBuilder |
There was a problem hiding this comment.
Guessing this was removed because there was an ambiguous "builder()" method? If so, the name of the builder for this class can be changed by updating the @Superbuilder annotation to something like: @SuperBuilder(builderMethodName = "uploadBuilder")
The use of the builder will need to be typed given that ProgramUpload now has generic support for the parsedData field. An example of how to do this would be: ProgramUpload.<T>uploadBuilder()...
There was a problem hiding this comment.
Perfect! Yeah the type ProgramUpload was messing things up and not liking ProgramUpload.<Trait>builder().... I'll try out the named builder and see how that goes.
There was a problem hiding this comment.
Changed and pushed
| public static <T> HttpResponse<Response<ProgramUpload>> getQueryResponse( | ||
| ProgramUpload upload, AbstractQueryMapper mapper, SearchRequest searchRequest, QueryParams queryParams) { | ||
| return processSearchResponse(upload, searchRequest, queryParams, mapper, new Metadata()); | ||
| } | ||
|
|
||
| // Pagination and sort only | ||
| public static <T> HttpResponse<Response<ProgramUpload>> getQueryResponse( | ||
| ProgramUpload upload, AbstractQueryMapper mapper, QueryParams queryParams) { | ||
| return processSearchResponse(upload, null, queryParams, mapper, new Metadata()); | ||
| } |
There was a problem hiding this comment.
I think it'd be helpful to have the names of these methods reflect that they are for uploads instead of overloading the method name of getQueryResponse
There was a problem hiding this comment.
How so? I plan on changing the names, but still wondering your thoughts as to the benefits of changing the method name instead of overloading?
There was a problem hiding this comment.
Changed and pushed
There was a problem hiding this comment.
My main reason for saying that is because of this HttpResponse<Response<ProgramUpload>> being specifically typed to ProgramUpload, and the overloaded method has it as generice <T>
There was a problem hiding this comment.
Created new methods for ProgramUpload and removed the generic typing from those methods.
| return HttpResponse.ok(new Response(metadata, new DataResponse(paginationResult.getLeft()))); | ||
| } | ||
|
|
||
| private static <T> HttpResponse<Response<ProgramUpload>> processSearchResponse( |
There was a problem hiding this comment.
Same thing goes here for the method name
There was a problem hiding this comment.
Changed and pushed
45d1cbd to
6716cac
Compare
Updated trait upload services to parse the JSONB data from the database before returning to controller. For the sorting/filtering/pagination we needed something we could read and act on, so that seemed like the most logically course. It doesn't change the way the data is returned.
There is one more point of failure in the upload process though. If for some reason the data was not stored properly during the file upload, there will be a failure when parsing this. But, that should never happen since the JSONB being stored in the database is rendered from Trait objects to begin with.