-
Notifications
You must be signed in to change notification settings - Fork 2
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
record-manager-ui#36 Implement export filtered records to excel #52
record-manager-ui#36 Implement export filtered records to excel #52
Conversation
- add sparql query - add export related entities - add dao layer code to retrieve exported record data - add ExcelRecordExporter service exporting records to excel
src/main/java/cz/cvut/kbss/study/rest/PatientRecordController.java
Outdated
Show resolved
Hide resolved
src/main/java/cz/cvut/kbss/study/rest/PatientRecordController.java
Outdated
Show resolved
Hide resolved
@GetMapping(value = "/export", produces = MediaType.APPLICATION_JSON_VALUE) | ||
public List<PatientRecord> exportRecords( | ||
@GetMapping(value = "/export", produces = {MediaType.APPLICATION_JSON_VALUE, Constants.MEDIA_TYPE_EXCEL}) | ||
public ResponseEntity<?> exportRecords( |
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.
We just need to make sure that we did not change implementation of JSON export.
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.
@LaChope please test it when implementing UI
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.
I exported twice, before and after this PR, output JSON file is similar
/** | ||
* Maps the specified parameters to a new {@link RecordFilterParams} instance. | ||
* | ||
* @param params Request parameters to map | ||
* @return New {@code RecordFilterParams} instance | ||
*/ | ||
public static RecordFilterParams constructRecordFilter(MultiValueMap<String, String> params) { | ||
public static RecordFilterParams constructRecordFilter(final RecordFilterParams result, MultiValueMap<String, String> params) { |
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.
Not sure why we need this.
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 is here as we did not want to include into query MIN_MODIFIED_DATE and MAX_MODIFIED_DATE .. this should be modified to remove.
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.
DO NOT FIX NOW.
/** | ||
* Maps the specified parameters to a new {@link RecordFilterParams} instance. | ||
* | ||
* @param params Request parameters to map | ||
* @return New {@code RecordFilterParams} instance | ||
*/ | ||
public static RecordFilterParams constructRecordFilter(MultiValueMap<String, String> params) { | ||
public static RecordFilterParams constructRecordFilter(final RecordFilterParams result, MultiValueMap<String, String> params) { |
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 is here as we did not want to include into query MIN_MODIFIED_DATE and MAX_MODIFIED_DATE .. this should be modified to remove.
/** | ||
* Maps the specified parameters to a new {@link RecordFilterParams} instance. | ||
* | ||
* @param params Request parameters to map | ||
* @return New {@code RecordFilterParams} instance | ||
*/ | ||
public static RecordFilterParams constructRecordFilter(MultiValueMap<String, String> params) { | ||
public static RecordFilterParams constructRecordFilter(final RecordFilterParams result, MultiValueMap<String, String> params) { |
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.
DO NOT FIX NOW.
… when extracting exportType from request. exportType uri parameter takes precedence over Accept header.
…nstitution request parameter. - remove unnecessary annotations from method parameters
d4a230e
to
0b985cd
Compare
@blcham |
It should behave same as for export to JSON, so if it ignores it as well then it is ok. (you can even test on kbss :) |
…st parameters support for excel export
…emplate.xlsx file
@blcham |
UriComponentsBuilder uriBuilder, HttpServletResponse response) { | ||
@RequestParam(required = false) MultiValueMap<String, String> params, | ||
UriComponentsBuilder uriBuilder, HttpServletRequest request, HttpServletResponse response) { | ||
MediaType exportType = Stream.of( |
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.
@LaChope here the way how to differentiate between JSON and EXCEL
Either use accept header or parameter in the query string:
public static final String EXPORT_TYPE_PARAM = "exportType";
public static final String MEDIA_TYPE_EXCEL = "application/vnd.ms-excel"
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.
Thus you need to use alternatively following query parameters:
&exportType=application/vnd.ms-excel
&exportType=application/json
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.
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.
ok, I'm not sure why it does not work, but you can try the exportType
query parameter instead of the Accept header.
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.
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.
Removing the sort
parameter fixed it. I can try with the page
parameter but I do not know what does it represent? The number of sheet?
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.
@LaChope
The page parameter represents the index of the page. The page has size
number of records. (request parameter, default is 25 records per page).
I am not sure what are you trying to do. There are three two things that I think makes sense to implement.
- Export all records matching the filter specified by the user. I think the user specifies the filter using the table.
- In this case the request should contain the same filter, e.g. min max date, institution, as the one used to filter the records in the table.
page
,size
andsort
parameters should be omitted.
- Export the records on the current page.
- In this case the request should contain the filter parameters as well as the and the
page
,size
, andsort
parameters.
@blcham
Implements partially kbss-cvut/record-manager-ui#36