Removed redundant code that calculated count on queries, already implemented on the data tools package

This commit is contained in:
Thomas Georgios Giannos 2023-10-16 12:22:41 +03:00
parent 234aa359c0
commit b537810406
2 changed files with 11 additions and 3 deletions

View File

@ -49,6 +49,11 @@ public class DescriptionTemplateTypeService {
return builderFactory.builder(DescriptionTemplateTypeBuilder.class).build(lookup.getProject(), data); 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) { public DescriptionTemplateType get(UUID id) {
DescriptionTemplateTypeQuery query = applicationContext.getBean(DescriptionTemplateTypeQuery.class); DescriptionTemplateTypeQuery query = applicationContext.getBean(DescriptionTemplateTypeQuery.class);

View File

@ -15,6 +15,7 @@ import gr.cite.tools.exception.MyNotFoundException;
import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry; import gr.cite.tools.logging.MapLogEntry;
import org.opensaml.xml.signature.Q;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.context.MessageSource; import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.context.i18n.LocaleContextHolder;
@ -25,11 +26,10 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.AbstractMap; import java.util.AbstractMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import static eu.eudat.controllers.v2.BaseController.extractQueryResultWithCount;
@RestController @RestController
@CrossOrigin @CrossOrigin
@Transactional @Transactional
@ -59,9 +59,12 @@ public class DescriptionTemplateTypeV2Controller {
censorFactory.censor(DescriptionTemplateTypeCensor.class).censor(lookup.getProject()); censorFactory.censor(DescriptionTemplateTypeCensor.class).censor(lookup.getProject());
List<DescriptionTemplateType> models = descriptionTemplateTypeService.query(lookup);
long count = (lookup.getMetadata() != null && lookup.getMetadata().getCountAll()) ? descriptionTemplateTypeService.count(lookup) : models.size();
auditService.track(AuditableAction.DescriptionTemplateType_Query, "lookup", lookup); auditService.track(AuditableAction.DescriptionTemplateType_Query, "lookup", lookup);
return extractQueryResultWithCount(descriptionTemplateTypeService::query, lookup); return new QueryResult<>(models, count);
} }
@GetMapping("{id}") @GetMapping("{id}")