From 299cf5b230b1dee4b9848747bfcc7dcb95ef7863 Mon Sep 17 00:00:00 2001 From: frankjtao <38163583+frankjtao@users.noreply.github.com> Date: Sat, 16 Jun 2018 22:37:12 -0400 Subject: [PATCH] Changed retval to resource id instead of SearchResult in SearchResultDao --- .../ca/uhn/fhir/jpa/dao/data/ISearchResultDao.java | 4 ++-- .../uhn/fhir/jpa/search/SearchCoordinatorSvcImpl.java | 6 +++--- .../fhir/jpa/search/SearchCoordinatorSvcImplTest.java | 10 +++++----- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/data/ISearchResultDao.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/data/ISearchResultDao.java index 12649857f48..4f7e05d9131 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/data/ISearchResultDao.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/data/ISearchResultDao.java @@ -38,8 +38,8 @@ public interface ISearchResultDao extends JpaRepository { @Query(value="SELECT r FROM SearchResult r WHERE r.mySearch = :search") Collection findWithSearchUuid(@Param("search") Search theSearch); - @Query(value="SELECT r FROM SearchResult r WHERE r.mySearch = :search ORDER BY r.myOrder ASC") - Page findWithSearchUuid(@Param("search") Search theSearch, Pageable thePage); + @Query(value="SELECT r.myResourcePid FROM SearchResult r WHERE r.mySearch = :search ORDER BY r.myOrder ASC") + Page findWithSearchUuid(@Param("search") Search theSearch, Pageable thePage); @Modifying @Query(value="DELETE FROM SearchResult r WHERE r.mySearchPid = :search") diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/SearchCoordinatorSvcImpl.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/SearchCoordinatorSvcImpl.java index dcace7b4fc2..1dcd22462f0 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/SearchCoordinatorSvcImpl.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/SearchCoordinatorSvcImpl.java @@ -178,9 +178,9 @@ public class SearchCoordinatorSvcImpl implements ISearchCoordinatorSvc { @Override public List doInTransaction(TransactionStatus theStatus) { final List resultPids = new ArrayList(); - Page searchResults = mySearchResultDao.findWithSearchUuid(foundSearch, page); - for (SearchResult next : searchResults) { - resultPids.add(next.getResourcePid()); + Page searchResultPids = mySearchResultDao.findWithSearchUuid(foundSearch, page); + for (Long next : searchResultPids) { + resultPids.add(next); } return resultPids; } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/SearchCoordinatorSvcImplTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/SearchCoordinatorSvcImplTest.java index 9126cec246a..07316c53160 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/SearchCoordinatorSvcImplTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/SearchCoordinatorSvcImplTest.java @@ -323,18 +323,18 @@ public class SearchCoordinatorSvcImplTest { // ignore } - when(mySearchResultDao.findWithSearchUuid(any(Search.class), any(Pageable.class))).thenAnswer(new Answer>() { + when(mySearchResultDao.findWithSearchUuid(any(Search.class), any(Pageable.class))).thenAnswer(new Answer>() { @Override - public Page answer(InvocationOnMock theInvocation) throws Throwable { + public Page answer(InvocationOnMock theInvocation) throws Throwable { Pageable page = (Pageable) theInvocation.getArguments()[1]; - ArrayList results = new ArrayList(); + ArrayList results = new ArrayList(); int max = (page.getPageNumber() * page.getPageSize()) + page.getPageSize(); for (int i = page.getOffset(); i < max; i++) { - results.add(new SearchResult().setResourcePid(i + 10L)); + results.add(i + 10L); } - return new PageImpl(results); + return new PageImpl(results); } }); search.setStatus(SearchStatusEnum.FINISHED);