FIXME
This commit is contained in:
parent
99949629a8
commit
e031ad203e
|
@ -213,9 +213,8 @@ public class BulkDataExportSvcImpl implements IBulkDataExportSvc {
|
||||||
|
|
||||||
ourLog.info("Bulk export assembling export of type {} for job {}", nextType, theJobUuid);
|
ourLog.info("Bulk export assembling export of type {} for job {}", nextType, theJobUuid);
|
||||||
|
|
||||||
ISearchBuilder sb = dao.newSearchBuilder();
|
|
||||||
Class<? extends IBaseResource> nextTypeClass = myContext.getResourceDefinition(nextType).getImplementingClass();
|
Class<? extends IBaseResource> nextTypeClass = myContext.getResourceDefinition(nextType).getImplementingClass();
|
||||||
sb.setType(nextTypeClass, nextType);
|
ISearchBuilder sb = dao.newSearchBuilder(nextType, nextTypeClass);
|
||||||
|
|
||||||
SearchParameterMap map = new SearchParameterMap();
|
SearchParameterMap map = new SearchParameterMap();
|
||||||
map.setLoadSynchronous(true);
|
map.setLoadSynchronous(true);
|
||||||
|
@ -225,8 +224,6 @@ public class BulkDataExportSvcImpl implements IBulkDataExportSvc {
|
||||||
|
|
||||||
IResultIterator resultIterator = sb.createQuery(map, new SearchRuntimeDetails(null, theJobUuid), null);
|
IResultIterator resultIterator = sb.createQuery(map, new SearchRuntimeDetails(null, theJobUuid), null);
|
||||||
storeResultsToFiles(nextCollection, sb, resultIterator, jobResourceCounter, jobStopwatch);
|
storeResultsToFiles(nextCollection, sb, resultIterator, jobResourceCounter, jobStopwatch);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
job.setStatus(BulkJobStatusEnum.COMPLETE);
|
job.setStatus(BulkJobStatusEnum.COMPLETE);
|
||||||
|
|
|
@ -456,8 +456,8 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> extends BaseStora
|
||||||
|
|
||||||
// TODO KHS inject a searchBuilderFactory into callers of this method and delete this method
|
// TODO KHS inject a searchBuilderFactory into callers of this method and delete this method
|
||||||
@Override
|
@Override
|
||||||
public SearchBuilder newSearchBuilder() {
|
public SearchBuilder newSearchBuilder(String theResourceName, Class<? extends IBaseResource> theResourceType) {
|
||||||
return mySearchBuilderFactory.newSearchBuilder(this);
|
return mySearchBuilderFactory.newSearchBuilder(this, theResourceName, theResourceType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void notifyInterceptors(RestOperationTypeEnum theOperationType, ActionRequestDetails theRequestDetails) {
|
public void notifyInterceptors(RestOperationTypeEnum theOperationType, ActionRequestDetails theRequestDetails) {
|
||||||
|
|
|
@ -1126,8 +1126,7 @@ public abstract class BaseHapiFhirResourceDao<T extends IBaseResource> extends B
|
||||||
@Override
|
@Override
|
||||||
public Set<ResourcePersistentId> searchForIds(SearchParameterMap theParams, RequestDetails theRequest) {
|
public Set<ResourcePersistentId> searchForIds(SearchParameterMap theParams, RequestDetails theRequest) {
|
||||||
|
|
||||||
SearchBuilder builder = newSearchBuilder();
|
SearchBuilder builder = newSearchBuilder(getResourceName(), getResourceType());
|
||||||
builder.setType(getResourceType(), getResourceName());
|
|
||||||
|
|
||||||
// FIXME: fail if too many results
|
// FIXME: fail if too many results
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ public interface IDao {
|
||||||
*/
|
*/
|
||||||
void injectDependenciesIntoBundleProvider(PersistedJpaBundleProvider theProvider);
|
void injectDependenciesIntoBundleProvider(PersistedJpaBundleProvider theProvider);
|
||||||
|
|
||||||
ISearchBuilder newSearchBuilder();
|
ISearchBuilder newSearchBuilder(String theResourceName, Class<? extends IBaseResource> theResourceType);
|
||||||
|
|
||||||
IBaseResource toResource(BaseHasResource theEntity, boolean theForHistoryOperation);
|
IBaseResource toResource(BaseHasResource theEntity, boolean theForHistoryOperation);
|
||||||
|
|
||||||
|
|
|
@ -54,8 +54,6 @@ public interface ISearchBuilder {
|
||||||
*/
|
*/
|
||||||
void setFetchSize(int theFetchSize);
|
void setFetchSize(int theFetchSize);
|
||||||
|
|
||||||
void setType(Class<? extends IBaseResource> theResourceType, String theResourceName);
|
|
||||||
|
|
||||||
void setPreviouslyAddedResourcePids(List<ResourcePersistentId> thePreviouslyAddedResourcePids);
|
void setPreviouslyAddedResourcePids(List<ResourcePersistentId> thePreviouslyAddedResourcePids);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,21 +127,23 @@ public class SearchBuilder implements ISearchBuilder {
|
||||||
private CriteriaBuilder myBuilder;
|
private CriteriaBuilder myBuilder;
|
||||||
private BaseHapiFhirDao<?> myCallingDao;
|
private BaseHapiFhirDao<?> myCallingDao;
|
||||||
private SearchParameterMap myParams;
|
private SearchParameterMap myParams;
|
||||||
private String myResourceName;
|
|
||||||
private Class<? extends IBaseResource> myResourceType;
|
|
||||||
private String mySearchUuid;
|
private String mySearchUuid;
|
||||||
private int myFetchSize;
|
private int myFetchSize;
|
||||||
private Integer myMaxResultsToFetch;
|
private Integer myMaxResultsToFetch;
|
||||||
private Set<ResourcePersistentId> myPidSet;
|
private Set<ResourcePersistentId> myPidSet;
|
||||||
private PredicateBuilder myPredicateBuilder;
|
private PredicateBuilder myPredicateBuilder;
|
||||||
private final QueryRoot myQueryRoot = new QueryRoot();
|
private final QueryRoot myQueryRoot = new QueryRoot();
|
||||||
|
private final String myResourceName;
|
||||||
|
private final Class<? extends IBaseResource> myResourceType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
SearchBuilder(BaseHapiFhirDao<?> theDao) {
|
SearchBuilder(BaseHapiFhirDao<?> theDao, String theResourceName, Class<? extends IBaseResource> theResourceType) {
|
||||||
myCallingDao = theDao;
|
myCallingDao = theDao;
|
||||||
myDaoConfig = theDao.getConfig();
|
myDaoConfig = theDao.getConfig();
|
||||||
|
myResourceName = theResourceName;
|
||||||
|
myResourceType = theResourceType;
|
||||||
myDontUseHashesForSearch = myDaoConfig.getDisableHashBasedSearches();
|
myDontUseHashesForSearch = myDaoConfig.getDisableHashBasedSearches();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -860,13 +862,6 @@ public class SearchBuilder implements ISearchBuilder {
|
||||||
myFetchSize = theFetchSize;
|
myFetchSize = theFetchSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME KHS move this into constructor and make these final
|
|
||||||
@Override
|
|
||||||
public void setType(Class<? extends IBaseResource> theResourceType, String theResourceName) {
|
|
||||||
myResourceType = theResourceType;
|
|
||||||
myResourceName = theResourceName;
|
|
||||||
}
|
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
void setParamsForUnitTest(SearchParameterMap theParams) {
|
void setParamsForUnitTest(SearchParameterMap theParams) {
|
||||||
myParams = theParams;
|
myParams = theParams;
|
||||||
|
|
|
@ -20,11 +20,12 @@ package ca.uhn.fhir.jpa.dao;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||||
import org.springframework.beans.factory.annotation.Lookup;
|
import org.springframework.beans.factory.annotation.Lookup;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public abstract class SearchBuilderFactory {
|
public abstract class SearchBuilderFactory {
|
||||||
@Lookup
|
@Lookup
|
||||||
public abstract SearchBuilder newSearchBuilder(BaseHapiFhirDao theBaseHapiFhirResourceDao);
|
public abstract SearchBuilder newSearchBuilder(BaseHapiFhirDao theBaseHapiFhirResourceDao, String theResourceName, Class<? extends IBaseResource> theResourceType);
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class PredicateBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
void addPredicateCoords(String theResourceName, String theParamName, List<? extends IQueryParameterType> theNextAnd) {
|
void addPredicateCoords(String theResourceName, String theParamName, List<? extends IQueryParameterType> theNextAnd) {
|
||||||
myPredicateBuilderCoords.addPredicate(theResourceName, theParamName, theNextAnd);
|
myPredicateBuilderCoords.addPredicate(theResourceName, theParamName, theNextAnd, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
Predicate addPredicateDate(String theResourceName, String theParamName, List<? extends IQueryParameterType> theNextAnd, SearchFilterParser.CompareOperation theOperation) {
|
Predicate addPredicateDate(String theResourceName, String theParamName, List<? extends IQueryParameterType> theNextAnd, SearchFilterParser.CompareOperation theOperation) {
|
||||||
|
|
|
@ -502,7 +502,6 @@ class PredicateBuilderReference extends BasePredicateBuilder {
|
||||||
// TODO: we clear the predicates below because the filter builds up
|
// TODO: we clear the predicates below because the filter builds up
|
||||||
// its own collection of predicates. It'd probably be good at some
|
// its own collection of predicates. It'd probably be good at some
|
||||||
// point to do something more fancy...
|
// point to do something more fancy...
|
||||||
// FIXME KHS
|
|
||||||
ArrayList<Predicate> holdPredicates = new ArrayList<>(myQueryRoot.getPredicates());
|
ArrayList<Predicate> holdPredicates = new ArrayList<>(myQueryRoot.getPredicates());
|
||||||
|
|
||||||
Predicate filterPredicate = processFilter(filter, theResourceName, theRequest);
|
Predicate filterPredicate = processFilter(filter, theResourceName, theRequest);
|
||||||
|
|
|
@ -4,6 +4,7 @@ import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamDate;
|
||||||
import ca.uhn.fhir.jpa.model.entity.ResourceTable;
|
import ca.uhn.fhir.jpa.model.entity.ResourceTable;
|
||||||
|
|
||||||
import javax.persistence.criteria.*;
|
import javax.persistence.criteria.*;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Stack;
|
import java.util.Stack;
|
||||||
|
|
||||||
|
@ -60,7 +61,6 @@ public class QueryRoot {
|
||||||
top().clearPredicates();
|
top().clearPredicates();
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME KHS don't leak
|
|
||||||
List<Predicate> getPredicates() {
|
List<Predicate> getPredicates() {
|
||||||
return top().getPredicates();
|
return top().getPredicates();
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import ca.uhn.fhir.jpa.model.entity.ResourceTable;
|
||||||
|
|
||||||
import javax.persistence.criteria.*;
|
import javax.persistence.criteria.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class QueryRootEntry {
|
public class QueryRootEntry {
|
||||||
|
@ -54,9 +55,8 @@ public class QueryRootEntry {
|
||||||
myPredicates.clear();
|
myPredicates.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME KHS don't leak
|
|
||||||
List<Predicate> getPredicates() {
|
List<Predicate> getPredicates() {
|
||||||
return myPredicates;
|
return Collections.unmodifiableList(myPredicates);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void where(Predicate theAnd) {
|
public void where(Predicate theAnd) {
|
||||||
|
|
|
@ -170,11 +170,9 @@ public class PersistedJpaBundleProvider implements IBundleProvider {
|
||||||
// No resources to fetch (e.g. we did a _summary=count search)
|
// No resources to fetch (e.g. we did a _summary=count search)
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
final ISearchBuilder sb = myDao.newSearchBuilder();
|
|
||||||
|
|
||||||
String resourceName = mySearchEntity.getResourceType();
|
String resourceName = mySearchEntity.getResourceType();
|
||||||
Class<? extends IBaseResource> resourceType = myContext.getResourceDefinition(resourceName).getImplementingClass();
|
Class<? extends IBaseResource> resourceType = myContext.getResourceDefinition(resourceName).getImplementingClass();
|
||||||
sb.setType(resourceType, resourceName);
|
final ISearchBuilder sb = myDao.newSearchBuilder(resourceName, resourceType);
|
||||||
|
|
||||||
final List<ResourcePersistentId> pidsSubList = mySearchCoordinatorSvc.getResources(myUuid, theFromIndex, theToIndex, myRequest);
|
final List<ResourcePersistentId> pidsSubList = mySearchCoordinatorSvc.getResources(myUuid, theFromIndex, theToIndex, myRequest);
|
||||||
|
|
||||||
|
|
|
@ -286,8 +286,7 @@ public class SearchCoordinatorSvcImpl implements ISearchCoordinatorSvc {
|
||||||
ourLog.debug("Registering new search {}", searchUuid);
|
ourLog.debug("Registering new search {}", searchUuid);
|
||||||
|
|
||||||
Class<? extends IBaseResource> resourceTypeClass = myContext.getResourceDefinition(theResourceType).getImplementingClass();
|
Class<? extends IBaseResource> resourceTypeClass = myContext.getResourceDefinition(theResourceType).getImplementingClass();
|
||||||
final ISearchBuilder sb = theCallingDao.newSearchBuilder();
|
final ISearchBuilder sb = theCallingDao.newSearchBuilder(theResourceType, resourceTypeClass);
|
||||||
sb.setType(resourceTypeClass, theResourceType);
|
|
||||||
sb.setFetchSize(mySyncSize);
|
sb.setFetchSize(mySyncSize);
|
||||||
|
|
||||||
final Integer loadSynchronousUpTo = getLoadSynchronousUpToOrNull(theCacheControlDirective);
|
final Integer loadSynchronousUpTo = getLoadSynchronousUpToOrNull(theCacheControlDirective);
|
||||||
|
@ -645,8 +644,7 @@ public class SearchCoordinatorSvcImpl implements ISearchCoordinatorSvc {
|
||||||
|
|
||||||
private ISearchBuilder newSearchBuilder() {
|
private ISearchBuilder newSearchBuilder() {
|
||||||
Class<? extends IBaseResource> resourceTypeClass = myContext.getResourceDefinition(myResourceType).getImplementingClass();
|
Class<? extends IBaseResource> resourceTypeClass = myContext.getResourceDefinition(myResourceType).getImplementingClass();
|
||||||
ISearchBuilder sb = myCallingDao.newSearchBuilder();
|
ISearchBuilder sb = myCallingDao.newSearchBuilder(myResourceType, resourceTypeClass);
|
||||||
sb.setType(resourceTypeClass, myResourceType);
|
|
||||||
|
|
||||||
return sb;
|
return sb;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class SearchBuilderTest {
|
||||||
public void testIncludeIterator() {
|
public void testIncludeIterator() {
|
||||||
BaseHapiFhirDao<?> mockDao = mock(BaseHapiFhirDao.class);
|
BaseHapiFhirDao<?> mockDao = mock(BaseHapiFhirDao.class);
|
||||||
when(mockDao.getConfig()).thenReturn(new DaoConfig());
|
when(mockDao.getConfig()).thenReturn(new DaoConfig());
|
||||||
SearchBuilder searchBuilder = new SearchBuilder(mockDao);
|
SearchBuilder searchBuilder = new SearchBuilder(mockDao, null, null);
|
||||||
|
|
||||||
searchBuilder.setParamsForUnitTest(new SearchParameterMap());
|
searchBuilder.setParamsForUnitTest(new SearchParameterMap());
|
||||||
EntityManager mockEntityManager = mock(EntityManager.class);
|
EntityManager mockEntityManager = mock(EntityManager.class);
|
||||||
|
|
|
@ -77,7 +77,7 @@ public class SearchCoordinatorSvcImplTest {
|
||||||
@After
|
@After
|
||||||
public void after() {
|
public void after() {
|
||||||
System.clearProperty(SearchCoordinatorSvcImpl.UNIT_TEST_CAPTURE_STACK);
|
System.clearProperty(SearchCoordinatorSvcImpl.UNIT_TEST_CAPTURE_STACK);
|
||||||
verify(myCallingDao, atMost(myExpectedNumberOfSearchBuildersCreated)).newSearchBuilder();
|
verify(myCallingDao, atMost(myExpectedNumberOfSearchBuildersCreated)).newSearchBuilder(any(), any());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
|
@ -97,7 +97,7 @@ public class SearchCoordinatorSvcImplTest {
|
||||||
DaoConfig daoConfig = new DaoConfig();
|
DaoConfig daoConfig = new DaoConfig();
|
||||||
mySvc.setDaoConfigForUnitTest(daoConfig);
|
mySvc.setDaoConfigForUnitTest(daoConfig);
|
||||||
|
|
||||||
when(myCallingDao.newSearchBuilder()).thenReturn(mySearchBuilder);
|
when(myCallingDao.newSearchBuilder(any(), any())).thenReturn(mySearchBuilder);
|
||||||
|
|
||||||
when(myTxManager.getTransaction(any())).thenReturn(mock(TransactionStatus.class));
|
when(myTxManager.getTransaction(any())).thenReturn(mock(TransactionStatus.class));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue