From b537810406d0a0fbfc63b00b07edf28166ca7b57 Mon Sep 17 00:00:00 2001 From: Thomas Georgios Giannos Date: Mon, 16 Oct 2023 12:22:41 +0300 Subject: [PATCH] Removed redundant code that calculated count on queries, already implemented on the data tools package --- .../eu/eudat/service/DescriptionTemplateTypeService.java | 5 +++++ .../v2/DescriptionTemplateTypeV2Controller.java | 9 ++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/DescriptionTemplateTypeService.java b/dmp-backend/core/src/main/java/eu/eudat/service/DescriptionTemplateTypeService.java index 90e52d0bd..a7fab06fb 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/DescriptionTemplateTypeService.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/DescriptionTemplateTypeService.java @@ -49,6 +49,11 @@ public class DescriptionTemplateTypeService { return builderFactory.builder(DescriptionTemplateTypeBuilder.class).build(lookup.getProject(), data); } + public long count(DescriptionTemplateTypeLookup lookup) { + DescriptionTemplateTypeQuery query = lookup.enrich(queryFactory); + return query.count(); + } + public DescriptionTemplateType get(UUID id) { DescriptionTemplateTypeQuery query = applicationContext.getBean(DescriptionTemplateTypeQuery.class); diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/DescriptionTemplateTypeV2Controller.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/DescriptionTemplateTypeV2Controller.java index 4eaae2942..d063e46f4 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/DescriptionTemplateTypeV2Controller.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/DescriptionTemplateTypeV2Controller.java @@ -15,6 +15,7 @@ import gr.cite.tools.exception.MyNotFoundException; import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.MapLogEntry; +import org.opensaml.xml.signature.Q; import org.slf4j.LoggerFactory; import org.springframework.context.MessageSource; import org.springframework.context.i18n.LocaleContextHolder; @@ -25,11 +26,10 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import java.util.AbstractMap; +import java.util.List; import java.util.Map; import java.util.UUID; -import static eu.eudat.controllers.v2.BaseController.extractQueryResultWithCount; - @RestController @CrossOrigin @Transactional @@ -59,9 +59,12 @@ public class DescriptionTemplateTypeV2Controller { censorFactory.censor(DescriptionTemplateTypeCensor.class).censor(lookup.getProject()); + List models = descriptionTemplateTypeService.query(lookup); + long count = (lookup.getMetadata() != null && lookup.getMetadata().getCountAll()) ? descriptionTemplateTypeService.count(lookup) : models.size(); + auditService.track(AuditableAction.DescriptionTemplateType_Query, "lookup", lookup); - return extractQueryResultWithCount(descriptionTemplateTypeService::query, lookup); + return new QueryResult<>(models, count); } @GetMapping("{id}")