From b6d65cc185ad1fd7dbe78ec408ce6d9458ba0fb8 Mon Sep 17 00:00:00 2001 From: himeshr Date: Fri, 13 Dec 2024 18:40:50 +0530 Subject: [PATCH] avniproject/avni-server#813 | Fix test failure --- .../java/org/avni/server/dao/SubjectSearchRepository.java | 5 +++-- .../org/avni/server/service/IndividualSearchService.java | 3 ++- .../avni/server/service/UserSubjectAssignmentService.java | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/avni-server-api/src/main/java/org/avni/server/dao/SubjectSearchRepository.java b/avni-server-api/src/main/java/org/avni/server/dao/SubjectSearchRepository.java index 7e6c79289..5e00c49f0 100644 --- a/avni-server-api/src/main/java/org/avni/server/dao/SubjectSearchRepository.java +++ b/avni-server-api/src/main/java/org/avni/server/dao/SubjectSearchRepository.java @@ -15,6 +15,7 @@ import org.springframework.stereotype.Repository; import org.springframework.util.StringUtils; +import java.math.BigInteger; import java.util.List; import java.util.Map; @@ -52,7 +53,7 @@ public List> search(SubjectSearchRequest searchRequest, Sear } @Transactional - public Long getTotalCount(SubjectSearchRequest searchRequest, SearchBuilder searchBuilder) { + public BigInteger getTotalCount(SubjectSearchRequest searchRequest, SearchBuilder searchBuilder) { SubjectType subjectType = StringUtils.isEmpty(searchRequest.getSubjectType()) ? null : subjectTypeRepository.findByUuid(searchRequest.getSubjectType()); SqlQuery query = searchBuilder.getSQLCountQuery(searchRequest, subjectType); try { @@ -62,7 +63,7 @@ public Long getTotalCount(SubjectSearchRequest searchRequest, SearchBuilder sear sql.setParameter(name, value); }); - return (Long) sql.getSingleResult(); + return (BigInteger) sql.getSingleResult(); } finally { setRoleBackToUser(); } diff --git a/avni-server-api/src/main/java/org/avni/server/service/IndividualSearchService.java b/avni-server-api/src/main/java/org/avni/server/service/IndividualSearchService.java index bc227dc6e..93f205c73 100644 --- a/avni-server-api/src/main/java/org/avni/server/service/IndividualSearchService.java +++ b/avni-server-api/src/main/java/org/avni/server/service/IndividualSearchService.java @@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.math.BigInteger; import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; @@ -40,7 +41,7 @@ public LinkedHashMap search(SubjectSearchRequest subjectSearchRe return constructIndividual(searchResults,totalCount); } - private LinkedHashMap constructIndividual(List> individualList,BigInteger totalCount) { + private LinkedHashMap constructIndividual(List> individualList, BigInteger totalCount) { LinkedHashMap recordsMap = new LinkedHashMap(); List individualIds = individualList.stream() .map(individualRecord -> Long.valueOf((Integer) individualRecord.get("id"))) diff --git a/avni-server-api/src/main/java/org/avni/server/service/UserSubjectAssignmentService.java b/avni-server-api/src/main/java/org/avni/server/service/UserSubjectAssignmentService.java index a569e0065..89f6dbfcc 100644 --- a/avni-server-api/src/main/java/org/avni/server/service/UserSubjectAssignmentService.java +++ b/avni-server-api/src/main/java/org/avni/server/service/UserSubjectAssignmentService.java @@ -17,6 +17,7 @@ import org.springframework.data.projection.SpelAwareProxyProjectionFactory; import org.springframework.stereotype.Service; +import java.math.BigInteger; import java.util.*; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -123,7 +124,7 @@ public LinkedHashMap searchSubjects(SubjectSearchRequest subject searchResult.put("addressLevel", titleLineages.get((Long) searchResult.get("addressId"))); } - Long totalCount = subjectSearchRepository.getTotalCount(subjectSearchRequest, new SubjectAssignmentSearchQueryBuilder()); + BigInteger totalCount = subjectSearchRepository.getTotalCount(subjectSearchRequest, new SubjectAssignmentSearchQueryBuilder()); LinkedHashMap recordsMap = new LinkedHashMap<>(); recordsMap.put("totalElements", totalCount);