From 234aa359c04aa0d705903b34171dcd218ea3c30b Mon Sep 17 00:00:00 2001 From: Thomas Georgios Giannos Date: Mon, 16 Oct 2023 12:21:58 +0300 Subject: [PATCH] Removed redundant code that calculated count on queries, already implemented on the data tools package --- .../eudat/controllers/v2/BaseController.java | 36 ------------------- 1 file changed, 36 deletions(-) delete mode 100644 dmp-backend/web/src/main/java/eu/eudat/controllers/v2/BaseController.java diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/BaseController.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/BaseController.java deleted file mode 100644 index cb3b26a4f..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/BaseController.java +++ /dev/null @@ -1,36 +0,0 @@ -package eu.eudat.controllers.v2; - -import eu.eudat.model.result.QueryResult; -import gr.cite.tools.data.query.Lookup; - -import java.util.List; -import java.util.function.BiFunction; -import java.util.function.Function; - -public class BaseController { - - public static QueryResult extractQueryResultWithCount(Function> service, L lookup) { - return extractQueryResultWithCountWhen(service, lookup, null); - } - - public static QueryResult extractQueryResultWithCountWhen(Function> service, L lookup, Function when) { - List result = service.apply(lookup); - lookup.setPage(null); - List all = service.apply(lookup); - long count = all.size(); - if (when == null) return new QueryResult<>(result, count); - long countOverride = count; - for (T item : all) { - if (!when.apply(item)) countOverride--; - } - return new QueryResult<>(result, count, countOverride); - } - - public static QueryResult extractQueryResultWithCount(BiFunction> service, String name, L lookup) { - List result = service.apply(name, lookup); - lookup.setPage(null); - long count = service.apply(name, lookup).size(); - return new QueryResult<>(result, count); - } - -}