Fixed and improved the recent activity manager

This commit is contained in:
George Kalampokis 2020-07-03 12:18:53 +03:00
parent 7197892352
commit acf8b58728
1 changed files with 13 additions and 5 deletions

View File

@ -224,25 +224,33 @@ public class DashBoardManager {
.withHint(HintedModelFactory.getHint(DataManagementPlanListingModel.class))
.orderBy((builder, root) -> builder.desc(root.get(tableRequest.getCriteria().getOrder())))
.skip(tableRequest.getOffset())
.take(tableRequest.getSize())
.take(tableRequest.getLength())
.selectAsync(item -> {
return new RecentDmpModel().fromEntity(item);
})
.whenComplete((dmpActivities, throwable) -> recentActivityModels.addAll(dmpActivities));
.whenComplete((dmpActivities, throwable) -> {
if (dmpActivities != null) {
recentActivityModels.addAll(dmpActivities);
}
});
CompletableFuture<List<RecentActivityModel>> datasets = datasetList
.withHint(HintedModelFactory.getHint(DatasetListingModel.class))
.orderBy((builder, root) -> builder.desc(root.get(tableRequest.getCriteria().getOrder())))
.skip(tableRequest.getOffset())
.take(tableRequest.getSize())
.take(tableRequest.getLength())
.selectAsync(item -> {
return new RecentDatasetModel().fromEntity(item);
})
.whenComplete((datasetActivities, throwable) -> recentActivityModels.addAll(datasetActivities));
.whenComplete((datasetActivities, throwable) -> {
if (datasetActivities != null) {
recentActivityModels.addAll(datasetActivities);
}
});
CompletableFuture.allOf(dmps, datasets).join();
return recentActivityModels.stream().sorted(this.comparators.get(tableRequest.getCriteria().getOrder())).collect(Collectors.toList());
return recentActivityModels.stream().sorted(this.comparators.get(tableRequest.getCriteria().getOrder())).limit(tableRequest.getLength()).collect(Collectors.toList());
}
public List<SearchBarItem> searchUserData(String like, Principal principal) {