From 949e26bd0a075a3340d6330c93d75432f40dd977 Mon Sep 17 00:00:00 2001 From: carlosjepard Date: Wed, 2 Aug 2023 10:31:35 +0100 Subject: [PATCH] Fixed empty reports --- .../org/roda/wui/api/controllers/Browser.java | 2 +- .../wui/api/controllers/BrowserHelper.java | 35 +++++++++++++------ 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/controllers/Browser.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/controllers/Browser.java index efa52658b4..4b0fe9abc4 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/controllers/Browser.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/controllers/Browser.java @@ -3234,7 +3234,7 @@ public static Notification acknowledgeNotification(User user, String notificatio } public static Reports listReports(User user, String id, String resourceOrSip, int start, int limit, - String acceptFormat) throws AuthorizationDeniedException, GenericException, RequestNotValidException { + String acceptFormat) throws AuthorizationDeniedException, GenericException, RequestNotValidException, NotFoundException { final ControllerAssistant controllerAssistant = new ControllerAssistant() {}; // validate input diff --git a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/controllers/BrowserHelper.java b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/controllers/BrowserHelper.java index a9764419f0..45c016c4a0 100644 --- a/roda-ui/roda-wui/src/main/java/org/roda/wui/api/controllers/BrowserHelper.java +++ b/roda-ui/roda-wui/src/main/java/org/roda/wui/api/controllers/BrowserHelper.java @@ -2829,17 +2829,20 @@ public static void updateRiskIncidence(RiskIncidence incidence) RodaCoreFactory.getModelService().updateRiskIncidence(incidence, true); } - protected static Reports listReports(int start, int limit) throws RequestNotValidException, GenericException { + protected static Reports listReports(int start, int limit) throws RequestNotValidException, GenericException, AuthorizationDeniedException, NotFoundException { Sorter sorter = new Sorter(new SortParameter(RodaConstants.JOB_REPORT_DATE_UPDATED, true)); IndexResult indexReports = RodaCoreFactory.getIndexService().find(IndexedReport.class, Filter.ALL, sorter, new Sublist(start, limit), new ArrayList<>()); - List results = indexReports.getResults().stream().map(ireport -> (Report) ireport) - .collect(Collectors.toList()); + List results = new ArrayList<>(); + for (IndexedReport val: indexReports.getResults()) { + val.setReports(RodaCoreFactory.getModelService().retrieveJobReport(val.getJobId(), val.getId()).getReports()); + results.add(val); + } return new Reports(results); } protected static Reports listTransferredResourcesReports(String resourceId, int start, int limit) - throws RequestNotValidException, GenericException { + throws RequestNotValidException, GenericException, AuthorizationDeniedException, NotFoundException { Filter filter = new Filter(); filter.add( new SimpleFilterParameter(RodaConstants.JOB_REPORT_SOURCE_OBJECT_CLASS, TransferredResource.class.getName())); @@ -2850,12 +2853,16 @@ protected static Reports listTransferredResourcesReports(String resourceId, int Sorter sorter = new Sorter(new SortParameter(RodaConstants.JOB_REPORT_DATE_UPDATED, true)); IndexResult reports = RodaCoreFactory.getIndexService().find(IndexedReport.class, filter, sorter, new Sublist(start, limit), new ArrayList<>()); - List results = reports.getResults().stream().map(ireport -> (Report) ireport).collect(Collectors.toList()); + List results = new ArrayList<>(); + for (IndexedReport val: reports.getResults()) { + val.setReports(RodaCoreFactory.getModelService().retrieveJobReport(val.getJobId(), val.getId()).getReports()); + results.add(val); + } return new Reports(results); } protected static Reports listTransferredResourcesReportsWithSIP(String sipId, int start, int limit) - throws RequestNotValidException, GenericException { + throws RequestNotValidException, GenericException, AuthorizationDeniedException, NotFoundException { Filter filter = new Filter(); filter.add(new OneOfManyFilterParameter(RodaConstants.JOB_REPORT_OUTCOME_OBJECT_CLASS, Arrays.asList(AIP.class.getName(), IndexedAIP.class.getName()))); @@ -2864,13 +2871,16 @@ protected static Reports listTransferredResourcesReportsWithSIP(String sipId, in Sorter sorter = new Sorter(new SortParameter(RodaConstants.JOB_REPORT_DATE_UPDATED, true)); IndexResult indexReports = RodaCoreFactory.getIndexService().find(IndexedReport.class, filter, sorter, new Sublist(start, limit), new ArrayList<>()); - List results = indexReports.getResults().stream().map(ireport -> (Report) ireport) - .collect(Collectors.toList()); + List results = new ArrayList<>(); + for (IndexedReport val: indexReports.getResults()) { + val.setReports(RodaCoreFactory.getModelService().retrieveJobReport(val.getJobId(), val.getId()).getReports()); + results.add(val); + } return new Reports(results); } protected static Reports listTransferredResourcesReportsWithSourceOriginalName(String sourceName, int start, - int limit) throws RequestNotValidException, GenericException { + int limit) throws RequestNotValidException, GenericException, AuthorizationDeniedException, NotFoundException { Filter filter = new Filter(); filter.add(new OneOfManyFilterParameter(RodaConstants.JOB_REPORT_OUTCOME_OBJECT_CLASS, Arrays.asList(AIP.class.getName(), IndexedAIP.class.getName()))); @@ -2879,8 +2889,11 @@ protected static Reports listTransferredResourcesReportsWithSourceOriginalName(S Sorter sorter = new Sorter(new SortParameter(RodaConstants.JOB_REPORT_DATE_UPDATED, true)); IndexResult indexReports = RodaCoreFactory.getIndexService().find(IndexedReport.class, filter, sorter, new Sublist(start, limit), new ArrayList<>()); - List results = indexReports.getResults().stream().map(ireport -> (Report) ireport) - .collect(Collectors.toList()); + List results = new ArrayList<>(); + for (IndexedReport val: indexReports.getResults()) { + val.setReports(RodaCoreFactory.getModelService().retrieveJobReport(val.getJobId(), val.getId()).getReports()); + results.add(val); + } return new Reports(results); }