diff --git a/examples/src/main/java/example/PagingPatientProvider.java b/examples/src/main/java/example/PagingPatientProvider.java index ce70e046e76..0d6ae45aea2 100644 --- a/examples/src/main/java/example/PagingPatientProvider.java +++ b/examples/src/main/java/example/PagingPatientProvider.java @@ -39,7 +39,7 @@ public class PagingPatientProvider implements IResourceProvider { return new IBundleProvider() { @Override - public int size() { + public Integer size() { return matchingResourceIds.size(); } diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/HistoryMethodBinding.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/HistoryMethodBinding.java index 77fd2f2ec57..dd130cd74ae 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/HistoryMethodBinding.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/HistoryMethodBinding.java @@ -196,7 +196,7 @@ public class HistoryMethodBinding extends BaseResourceReturningMethodBinding { } @Override - public int size() { + public Integer size() { return resources.size(); } diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/BundleProviders.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/BundleProviders.java index 32027e57bde..ff60792a46c 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/BundleProviders.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/BundleProviders.java @@ -51,7 +51,7 @@ public class BundleProviders { } @Override - public int size() { + public Integer size() { return 0; } diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/SimpleBundleProvider.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/SimpleBundleProvider.java index d457d86c972..ab281fde003 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/SimpleBundleProvider.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/SimpleBundleProvider.java @@ -52,7 +52,7 @@ public class SimpleBundleProvider implements IBundleProvider { } @Override - public int size() { + public Integer size() { return myList.size(); } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDao.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDao.java index 84e2358a42e..f5cb9bff7be 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDao.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDao.java @@ -942,15 +942,6 @@ public abstract class BaseHapiFhirResourceDao extends B ourLog.info("Processed remove tag {}/{} on {} in {}ms", new Object[] { theScheme, theTerm, theId.getValue(), w.getMillisAndRestart() }); } - @Override - public IBundleProvider search(Map theParams) { - SearchParameterMap map = new SearchParameterMap(); - for (Entry nextEntry : theParams.entrySet()) { - map.add(nextEntry.getKey(), (nextEntry.getValue())); - } - return search(map); - } - @Override public IBundleProvider search(final SearchParameterMap theParams) { return search(theParams, null); @@ -959,20 +950,17 @@ public abstract class BaseHapiFhirResourceDao extends B @Override public IBundleProvider search(final SearchParameterMap theParams, RequestDetails theRequestDetails) { // Notify interceptors - ActionRequestDetails requestDetails = new ActionRequestDetails(theRequestDetails, getContext(), getResourceName(), null); - notifyInterceptors(RestOperationTypeEnum.SEARCH_TYPE, requestDetails); - + if (theRequestDetails != null) { + ActionRequestDetails requestDetails = new ActionRequestDetails(theRequestDetails, getContext(), getResourceName(), null); + notifyInterceptors(RestOperationTypeEnum.SEARCH_TYPE, requestDetails); + } + SearchBuilder builder = newSearchBuilder(); builder.setType(getResourceType(), getResourceName()); return builder.search(theParams); } - @Override - public IBundleProvider search(String theParameterName, IQueryParameterType theValue) { - return search(Collections.singletonMap(theParameterName, theValue)); - } - @Override public Set searchForIds(Map theParams) { SearchParameterMap map = new SearchParameterMap(); diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoValueSetDstu2.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoValueSetDstu2.java index 511a1b98f03..9905cd282dc 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoValueSetDstu2.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoValueSetDstu2.java @@ -110,7 +110,10 @@ public class FhirResourceDaoValueSetDstu2 extends FhirResourceDaoDstu2 if (defaultValueSet != null) { source = getContext().newJsonParser().parseResource(ValueSet.class, myRiCtx.newJsonParser().encodeResourceToString(defaultValueSet)); } else { - IBundleProvider ids = search(ValueSet.SP_URL, new UriParam(theUri)); + SearchParameterMap params = new SearchParameterMap(); + params.setLoadSynchronousUpTo(1); + params.add(ValueSet.SP_URL, new UriParam(theUri)); + IBundleProvider ids = search(params); if (ids.size() == 0) { throw new InvalidRequestException("Unknown ValueSet URI: " + theUri); } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/JpaValidationSupportDstu2.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/JpaValidationSupportDstu2.java index aceb318bd7b..37060cf2bfe 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/JpaValidationSupportDstu2.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/JpaValidationSupportDstu2.java @@ -70,7 +70,7 @@ public class JpaValidationSupportDstu2 implements IJpaValidationSupportDstu2 { params.setLoadSynchronousUpTo(10); search = myValueSetDao.search(params); } else if ("StructureDefinition".equals(resourceName)) { - search = myStructureDefinitionDao.search(ca.uhn.fhir.model.dstu2.resource.StructureDefinition.SP_URL, new UriParam(theUri)); + search = myStructureDefinitionDao.search(new SearchParameterMap().setLoadSynchronous(true).add(ca.uhn.fhir.model.dstu2.resource.StructureDefinition.SP_URL, new UriParam(theUri))); } else { throw new IllegalArgumentException("Can't fetch resource type: " + resourceName); } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchBuilder.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchBuilder.java index 046628214c0..de9af235817 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchBuilder.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchBuilder.java @@ -38,6 +38,7 @@ import javax.persistence.criteria.*; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.SerializationUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.Validate; import org.apache.commons.lang3.tuple.Pair; import org.hl7.fhir.instance.model.api.IAnyResource; import org.hl7.fhir.instance.model.api.IBaseResource; @@ -1438,7 +1439,6 @@ public class SearchBuilder { mySearchEntity.setUuid(UUID.randomUUID().toString()); mySearchEntity.setCreated(new Date()); mySearchEntity.setTotalCount(-1); - mySearchEntity.setSearchParamMap(SerializationUtils.serialize(myParams)); mySearchEntity.setPreferredPageSize(myParams.getCount()); mySearchEntity.setSearchType(myParams.getEverythingMode() != null ? SearchTypeEnum.EVERYTHING : SearchTypeEnum.SEARCH); mySearchEntity.setLastUpdated(myParams.getLastUpdated()); @@ -1457,43 +1457,8 @@ public class SearchBuilder { } } - public IBundleProvider search(final SearchParameterMap theParams) { + public Iterator createQuery(SearchParameterMap theParams) { myParams = theParams; - StopWatch w = new StopWatch(); - - mySearchEntity = new Search(); - mySearchEntity.setUuid(UUID.randomUUID().toString()); - mySearchEntity.setCreated(new Date()); - mySearchEntity.setTotalCount(-1); - mySearchEntity.setSearchParamMap(SerializationUtils.serialize(myParams)); - mySearchEntity.setPreferredPageSize(myParams.getCount()); - mySearchEntity.setSearchType(myParams.getEverythingMode() != null ? SearchTypeEnum.EVERYTHING : SearchTypeEnum.SEARCH); - mySearchEntity.setLastUpdated(myParams.getLastUpdated()); - mySearchEntity.setResourceType(myResourceName); - - for (Include next : myParams.getIncludes()) { - mySearchEntity.getIncludes().add(new SearchInclude(mySearchEntity, next.getValue(), false, next.isRecurse())); - } - for (Include next : myParams.getRevIncludes()) { - mySearchEntity.getIncludes().add(new SearchInclude(mySearchEntity, next.getValue(), true, next.isRecurse())); - } - - List firstPage = loadSearchPage(theParams, 0, 999); - mySearchEntity.setTotalCount(firstPage.size()); - - myEntityManager.persist(mySearchEntity); - for (SearchInclude next : mySearchEntity.getIncludes()) { - myEntityManager.persist(next); - } - - IBundleProvider retVal = doReturnProvider(); - - ourLog.info("Search initial phase completed in {}ms", w); - return retVal; - } - - public List loadSearchPage(SearchParameterMap theParams, int theFromIndex, int theToIndex) { - myBuilder = myEntityManager.getCriteriaBuilder(); CriteriaQuery outerQuery = null; @@ -1503,7 +1468,7 @@ public class SearchBuilder { * If we have a sort, we wrap the criteria search (the search that actually * finds the appropriate resources) in an outer search which is then sorted */ - if (theParams.getSort() != null) { + if (myParams.getSort() != null) { outerQuery = myBuilder.createQuery(Long.class); Root outerQueryFrom = outerQuery.from(ResourceTable.class); @@ -1511,7 +1476,7 @@ public class SearchBuilder { List orders = Lists.newArrayList(); List predicates = Lists.newArrayList(); - createSort(myBuilder, outerQueryFrom, theParams.getSort(), orders, predicates); + createSort(myBuilder, outerQueryFrom, myParams.getSort(), orders, predicates); if (orders.size() > 0) { outerQuery.orderBy(orders); } @@ -1542,20 +1507,20 @@ public class SearchBuilder { myResourceTableQuery.distinct(true); myPredicates = new ArrayList(); - if (theParams.getEverythingMode() == null) { + if (myParams.getEverythingMode() == null) { myPredicates.add(myBuilder.equal(myResourceTableRoot.get("myResourceType"), myResourceName)); } myPredicates.add(myBuilder.isNull(myResourceTableRoot.get("myDeleted"))); - DateRangeParam lu = theParams.getLastUpdated(); + DateRangeParam lu = myParams.getLastUpdated(); List lastUpdatedPredicates = createLastUpdatedPredicates(lu, myBuilder, myResourceTableRoot); myPredicates.addAll(lastUpdatedPredicates); - if (theParams.getEverythingMode() != null) { + if (myParams.getEverythingMode() != null) { Join join = myResourceTableRoot.join("myResourceLinks", JoinType.LEFT); - if (theParams.get(BaseResource.SP_RES_ID) != null) { - StringParam idParm = (StringParam) theParams.get(BaseResource.SP_RES_ID).get(0).get(0); + if (myParams.get(BaseResource.SP_RES_ID) != null) { + StringParam idParm = (StringParam) myParams.get(BaseResource.SP_RES_ID).get(0).get(0); Long pid = BaseHapiFhirDao.translateForcedIdToPid(myResourceName, idParm.getValue(), myForcedIdDao); myPredicates.add(myBuilder.equal(join.get("myTargetResourcePid").as(Long.class), pid)); } else { @@ -1566,21 +1531,21 @@ public class SearchBuilder { } else { // Normal search - searchForIdsWithAndOr(theParams); + searchForIdsWithAndOr(myParams); } /* * Fulltext search */ - if (theParams.containsKey(Constants.PARAM_CONTENT) || theParams.containsKey(Constants.PARAM_TEXT)) { + if (myParams.containsKey(Constants.PARAM_CONTENT) || myParams.containsKey(Constants.PARAM_TEXT)) { if (myFulltextSearchSvc == null) { - if (theParams.containsKey(Constants.PARAM_TEXT)) { + if (myParams.containsKey(Constants.PARAM_TEXT)) { throw new InvalidRequestException("Fulltext search is not enabled on this service, can not process parameter: " + Constants.PARAM_TEXT); - } else if (theParams.containsKey(Constants.PARAM_CONTENT)) { + } else if (myParams.containsKey(Constants.PARAM_CONTENT)) { throw new InvalidRequestException("Fulltext search is not enabled on this service, can not process parameter: " + Constants.PARAM_CONTENT); } } - List pids = myFulltextSearchSvc.everything(myResourceName, theParams); + List pids = myFulltextSearchSvc.everything(myResourceName, myParams); if (pids.isEmpty()) { // Will never match pids = Collections.singletonList((Long) null); @@ -1595,19 +1560,89 @@ public class SearchBuilder { * Now perform the search */ TypedQuery query = myEntityManager.createQuery(outerQuery); - query.setFirstResult(theFromIndex); - query.setMaxResults(theToIndex - theFromIndex); - - List pids = new ArrayList(); - Set pidSet = new HashSet(); + final Iterator results = query.getResultList().iterator(); + final Set pidSet = new HashSet(); - for (Long next : query.getResultList()) { - if (next != null && pidSet.add(next)) { - pids.add(next); + return new Iterator() { + private Long myNext; + + @Override + public boolean hasNext() { + if (myNext == null) { + fetchNext(); + } + if (myNext == NO_MORE) { + return false; + } + return true; } + + private void fetchNext() { + if (myNext == null) { + while (results.hasNext()) { + Long next = results.next(); + if (next != null && pidSet.add(next)) { + myNext = next; + break; + } + } + if (myNext == null) { + myNext = NO_MORE; + } + } + } + + @Override + public Long next() { + fetchNext(); + Validate.isTrue(myNext != NO_MORE, "No more elements"); + return myNext; + } + }; + + } + private static Long NO_MORE = Long.valueOf(-1); + + public IBundleProvider search(final SearchParameterMap theParams) { + myParams = theParams; + StopWatch w = new StopWatch(); + + if (theParams.isLoadSynchronous()) { + + } + + mySearchEntity = new Search(); + mySearchEntity.setUuid(UUID.randomUUID().toString()); + mySearchEntity.setCreated(new Date()); + mySearchEntity.setTotalCount(-1); + mySearchEntity.setPreferredPageSize(myParams.getCount()); + mySearchEntity.setSearchType(myParams.getEverythingMode() != null ? SearchTypeEnum.EVERYTHING : SearchTypeEnum.SEARCH); + mySearchEntity.setLastUpdated(myParams.getLastUpdated()); + mySearchEntity.setResourceType(myResourceName); + + for (Include next : myParams.getIncludes()) { + mySearchEntity.getIncludes().add(new SearchInclude(mySearchEntity, next.getValue(), false, next.isRecurse())); + } + for (Include next : myParams.getRevIncludes()) { + mySearchEntity.getIncludes().add(new SearchInclude(mySearchEntity, next.getValue(), true, next.isRecurse())); } - return pids; + List firstPage = loadSearchPage(theParams, 0, 999); + mySearchEntity.setTotalCount(firstPage.size()); + + myEntityManager.persist(mySearchEntity); + for (SearchInclude next : mySearchEntity.getIncludes()) { + myEntityManager.persist(next); + } + + IBundleProvider retVal = doReturnProvider(); + + ourLog.info("Search initial phase completed in {}ms", w); + return retVal; + } + + public List loadSearchPage(SearchParameterMap theParams, int theFromIndex, int theToIndex) { + } // public IBundleProvider loadPage(SearchParameterMap theParams, int theFromIndex, int theToIndex) { diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/dstu3/JpaValidationSupportDstu3.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/dstu3/JpaValidationSupportDstu3.java index e1a248cad0a..2e913f3a5cf 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/dstu3/JpaValidationSupportDstu3.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/dstu3/JpaValidationSupportDstu3.java @@ -38,6 +38,7 @@ import org.springframework.beans.factory.annotation.Qualifier; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.jpa.dao.IFhirResourceDao; +import ca.uhn.fhir.jpa.dao.SearchParameterMap; import ca.uhn.fhir.rest.param.StringParam; import ca.uhn.fhir.rest.param.UriParam; import ca.uhn.fhir.rest.server.IBundleProvider; @@ -92,22 +93,40 @@ public class JpaValidationSupportDstu3 implements IJpaValidationSupportDstu3 { IBundleProvider search; if ("ValueSet".equals(resourceName)) { if (localReference) { - search = myValueSetDao.search(IAnyResource.SP_RES_ID, new StringParam(theUri)); + SearchParameterMap params = new SearchParameterMap(); + params.setLoadSynchronousUpTo(1); + params.add(IAnyResource.SP_RES_ID, new StringParam(theUri)); + search = myValueSetDao.search(params); if (search.size() == 0) { - search = myValueSetDao.search(ValueSet.SP_URL, new UriParam(theUri)); + params = new SearchParameterMap(); + params.setLoadSynchronousUpTo(1); + params.add(ValueSet.SP_URL, new UriParam(theUri)); + search = myValueSetDao.search(params); } } else { - search = myValueSetDao.search(ValueSet.SP_URL, new UriParam(theUri)); + SearchParameterMap params = new SearchParameterMap(); + params.setLoadSynchronousUpTo(1); + params.add(ValueSet.SP_URL, new UriParam(theUri)); + search = myValueSetDao.search(params); } } else if ("StructureDefinition".equals(resourceName)) { if (theUri.startsWith("http://hl7.org/fhir/StructureDefinition/")) { return null; } - search = myStructureDefinitionDao.search(StructureDefinition.SP_URL, new UriParam(theUri)); + SearchParameterMap params = new SearchParameterMap(); + params.setLoadSynchronousUpTo(1); + params.add(StructureDefinition.SP_URL, new UriParam(theUri)); + search = myStructureDefinitionDao.search(params); } else if ("Questionnaire".equals(resourceName)) { - search = myQuestionnaireDao.search(IAnyResource.SP_RES_ID, new StringParam(id.getIdPart())); + SearchParameterMap params = new SearchParameterMap(); + params.setLoadSynchronousUpTo(1); + params.add(IAnyResource.SP_RES_ID, new StringParam(id.getIdPart())); + search = myQuestionnaireDao.search(params); } else if ("CodeSystem".equals(resourceName)) { - search = myCodeSystemDao.search(CodeSystem.SP_URL, new UriParam(theUri)); + SearchParameterMap params = new SearchParameterMap(); + params.setLoadSynchronousUpTo(1); + params.add(CodeSystem.SP_URL, new UriParam(theUri)); + search = myCodeSystemDao.search(params); } else { throw new IllegalArgumentException("Can't fetch resource type: " + resourceName); } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/PersistedJpaBundleProvider.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/PersistedJpaBundleProvider.java index 21aaff6f1e2..cc827427431 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/PersistedJpaBundleProvider.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/PersistedJpaBundleProvider.java @@ -121,8 +121,9 @@ public final class PersistedJpaBundleProvider implements IBundleProvider { Class resourceType = myContext.getResourceDefinition(resourceName).getImplementingClass(); sb.setType(resourceType, resourceName); - SearchParameterMap parameterMap = SerializationUtils.deserialize(mySearchEntity.getSearchParamMap()); - List pidsSubList = sb.loadSearchPage(parameterMap, theFromIndex, theToIndex); +// SearchParameterMap parameterMap = SerializationUtils.deserialize(mySearchEntity.getSearchParamMap()); +// List pidsSubList = sb.loadSearchPage(parameterMap, theFromIndex, theToIndex);()); + List pidsSubList = null; Set revIncludedPids = new HashSet(); if (mySearchEntity.getSearchType() == SearchTypeEnum.SEARCH) { @@ -236,7 +237,7 @@ public final class PersistedJpaBundleProvider implements IBundleProvider { } @Override - public int size() { + public Integer size() { ensureSearchEntityLoaded(); return Math.max(0, mySearchEntity.getTotalCount()); } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirSystemDaoDstu1Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirSystemDaoDstu1Test.java index a84c9d3c1c1..4a1302546e4 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirSystemDaoDstu1Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirSystemDaoDstu1Test.java @@ -172,10 +172,10 @@ public class FhirSystemDaoDstu1Test extends BaseJpaTest { // Try to search - IBundleProvider obsResults = ourObservationDao.search(Observation.SP_NAME, new IdentifierDt("urn:system", "testPersistWithSimpleLinkO01")); + IBundleProvider obsResults = ourObservationDao.search(new SearchParameterMap().setLoadSynchronous(true).add(Observation.SP_NAME, new IdentifierDt("urn:system", "testPersistWithSimpleLinkO01"))); assertEquals(1, obsResults.size().intValue()); - IBundleProvider patResults = ourPatientDao.search(Patient.SP_IDENTIFIER, new IdentifierDt("urn:system", "testPersistWithSimpleLinkP01")); + IBundleProvider patResults = ourPatientDao.search(new SearchParameterMap().setLoadSynchronous(true).add(Patient.SP_IDENTIFIER, new IdentifierDt("urn:system", "testPersistWithSimpleLinkP01"))); assertEquals(1, obsResults.size().intValue()); IIdType foundPatientId = patResults.getResources(0, 1).get(0).getIdElement(); @@ -446,8 +446,8 @@ public class FhirSystemDaoDstu1Test extends BaseJpaTest { * Verify */ - IBundleProvider results = ourPatientDao.search(Patient.SP_IDENTIFIER, new TokenParam("urn:system", "testTransactionWithDelete")); - assertEquals(3, results.size()); + IBundleProvider results = ourPatientDao.search(new SearchParameterMap().setLoadSynchronous(true).add(Patient.SP_IDENTIFIER, new TokenParam("urn:system", "testTransactionWithDelete"))); + assertEquals(3, results.size().intValue()); /* * Now delete 2 @@ -472,8 +472,8 @@ public class FhirSystemDaoDstu1Test extends BaseJpaTest { * Verify */ - IBundleProvider results2 = ourPatientDao.search(Patient.SP_IDENTIFIER, new TokenParam("urn:system", "testTransactionWithDelete")); - assertEquals(1, results2.size()); + IBundleProvider results2 = ourPatientDao.search(new SearchParameterMap().setLoadSynchronous(true).add(Patient.SP_IDENTIFIER, new TokenParam("urn:system", "testTransactionWithDelete"))); + assertEquals(1, results2.size().intValue()); List existing2 = results2.getResources(0, 1); assertEquals(existing2.get(0).getIdElement(), existing.get(2).getIdElement()); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirSystemDaoDstu2Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirSystemDaoDstu2Test.java index bd77c162878..4c867b74941 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirSystemDaoDstu2Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirSystemDaoDstu2Test.java @@ -875,7 +875,7 @@ public class FhirSystemDaoDstu2Test extends BaseJpaDstu2SystemTest { } IBundleProvider history = myPatientDao.history(id, null, null, mySrd); - assertEquals(2, history.size()); + assertEquals(2, history.size().intValue()); assertNotNull(ResourceMetadataKeyEnum.DELETED_AT.get((IResource) history.getResources(0, 1).get(0))); assertNotNull(ResourceMetadataKeyEnum.DELETED_AT.get((IResource) history.getResources(0, 1).get(0)).getValue()); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirSystemDaoDstu3Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirSystemDaoDstu3Test.java index fe4555ea0a3..02a980ac2b5 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirSystemDaoDstu3Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirSystemDaoDstu3Test.java @@ -126,7 +126,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest { ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(outputBundle)); IBundleProvider allPatients = myPatientDao.search(new SearchParameterMap()); - assertEquals(1, allPatients.size()); + assertEquals(1, allPatients.size().intValue()); } @Test @@ -696,13 +696,13 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest { SearchParameterMap map = new SearchParameterMap(); map.add(Organization.SP_PARTOF, new ReferenceParam(id1.toUnqualifiedVersionless().getValue())); IBundleProvider res = myOrganizationDao.search(map); - assertEquals(1, res.size()); + assertEquals(1, res.size().intValue()); assertEquals(id2.toUnqualifiedVersionless().getValue(), res.getResources(0, 1).get(0).getIdElement().toUnqualifiedVersionless().getValue()); map = new SearchParameterMap(); map.add(Organization.SP_PARTOF, new ReferenceParam(id2.toUnqualifiedVersionless().getValue())); res = myOrganizationDao.search(map); - assertEquals(1, res.size()); + assertEquals(1, res.size().intValue()); assertEquals(id1.toUnqualifiedVersionless().getValue(), res.getResources(0, 1).get(0).getIdElement().toUnqualifiedVersionless().getValue()); /* @@ -735,13 +735,13 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest { map = new SearchParameterMap(); map.add(Organization.SP_PARTOF, new ReferenceParam(id1.toUnqualifiedVersionless().getValue())); res = myOrganizationDao.search(map); - assertEquals(1, res.size()); + assertEquals(1, res.size().intValue()); assertEquals(id1.toUnqualifiedVersionless().getValue(), res.getResources(0, 1).get(0).getIdElement().toUnqualifiedVersionless().getValue()); map = new SearchParameterMap(); map.add(Organization.SP_PARTOF, new ReferenceParam(id2.toUnqualifiedVersionless().getValue())); res = myOrganizationDao.search(map); - assertEquals(1, res.size()); + assertEquals(1, res.size().intValue()); assertEquals(id2.toUnqualifiedVersionless().getValue(), res.getResources(0, 1).get(0).getIdElement().toUnqualifiedVersionless().getValue()); } @@ -1139,7 +1139,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest { } IBundleProvider history = myPatientDao.history(id, null, null, mySrd); - assertEquals(2, history.size()); + assertEquals(2, history.size().intValue()); assertNotNull(ResourceMetadataKeyEnum.DELETED_AT.get((IAnyResource) history.getResources(0, 1).get(0))); assertNotNull(ResourceMetadataKeyEnum.DELETED_AT.get((IAnyResource) history.getResources(0, 1).get(0)).getValue()); diff --git a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/SearchDstu2Test.java b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/SearchDstu2Test.java index ab2c58431df..91fdfe2b127 100644 --- a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/SearchDstu2Test.java +++ b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/SearchDstu2Test.java @@ -572,7 +572,7 @@ public class SearchDstu2Test { } @Override - public int size() { + public Integer size() { return 0; } diff --git a/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/rest/server/SearchHl7OrgDstu2Test.java b/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/rest/server/SearchHl7OrgDstu2Test.java index a5170173a49..23eafb86174 100644 --- a/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/rest/server/SearchHl7OrgDstu2Test.java +++ b/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/rest/server/SearchHl7OrgDstu2Test.java @@ -157,7 +157,7 @@ public class SearchHl7OrgDstu2Test { } @Override - public int size() { + public Integer size() { return 0; }