RED-5049 - Allow reports to be downloaded in all document states

- use the dossier reports/ download types in case the lists provided are empty
This commit is contained in:
devplant 2022-11-14 14:18:54 +02:00
parent fd2aa4e876
commit 495bbcb08f

View File

@ -70,6 +70,13 @@ public class DownloadController implements DownloadResource {
public JSONPrimitive<String> prepareDownload(@RequestBody DownloadWithOptionRequest request) {
var existingFileStatuses = fileStatusPersistenceService.getStatusesForDossier(request.getDossierId());
var dossier = dossierPersistenceService.getActiveOrArchivedDossier(request.getDossierId());
// check reports list and download types
if (request.getReportTemplateIds() == null || request.getReportTemplateIds().isEmpty()) {
request.setReportTemplateIds(dossier.getReportTemplates().stream().map(ReportTemplateEntity::getTemplateId).collect(Collectors.toList()));
}
if (request.getDownloadFileTypes() == null || request.getDownloadFileTypes().isEmpty()) {
request.setDownloadFileTypes(dossier.getDownloadFileTypes());
}
return this.startPrepareDownload(request, dossier, existingFileStatuses);
}