Skip to content

Commit

Permalink
Fixed empty reports
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosjepard authored and hmiguim committed Aug 2, 2023
1 parent 8e328fb commit 949e26b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<IndexedReport> indexReports = RodaCoreFactory.getIndexService().find(IndexedReport.class, Filter.ALL,
sorter, new Sublist(start, limit), new ArrayList<>());
List<Report> results = indexReports.getResults().stream().map(ireport -> (Report) ireport)
.collect(Collectors.toList());
List<Report> 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()));
Expand All @@ -2850,12 +2853,16 @@ protected static Reports listTransferredResourcesReports(String resourceId, int
Sorter sorter = new Sorter(new SortParameter(RodaConstants.JOB_REPORT_DATE_UPDATED, true));
IndexResult<IndexedReport> reports = RodaCoreFactory.getIndexService().find(IndexedReport.class, filter, sorter,
new Sublist(start, limit), new ArrayList<>());
List<Report> results = reports.getResults().stream().map(ireport -> (Report) ireport).collect(Collectors.toList());
List<Report> 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())));
Expand All @@ -2864,13 +2871,16 @@ protected static Reports listTransferredResourcesReportsWithSIP(String sipId, in
Sorter sorter = new Sorter(new SortParameter(RodaConstants.JOB_REPORT_DATE_UPDATED, true));
IndexResult<IndexedReport> indexReports = RodaCoreFactory.getIndexService().find(IndexedReport.class, filter,
sorter, new Sublist(start, limit), new ArrayList<>());
List<Report> results = indexReports.getResults().stream().map(ireport -> (Report) ireport)
.collect(Collectors.toList());
List<Report> 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())));
Expand All @@ -2879,8 +2889,11 @@ protected static Reports listTransferredResourcesReportsWithSourceOriginalName(S
Sorter sorter = new Sorter(new SortParameter(RodaConstants.JOB_REPORT_DATE_UPDATED, true));
IndexResult<IndexedReport> indexReports = RodaCoreFactory.getIndexService().find(IndexedReport.class, filter,
sorter, new Sublist(start, limit), new ArrayList<>());
List<Report> results = indexReports.getResults().stream().map(ireport -> (Report) ireport)
.collect(Collectors.toList());
List<Report> 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);
}

Expand Down

0 comments on commit 949e26b

Please sign in to comment.