first pass at converting to generic ResourcePersistentId
This commit is contained in:
parent
bb4f31d250
commit
d3a1780a05
|
@ -37,6 +37,7 @@ import ca.uhn.fhir.jpa.dao.IResultIterator;
|
|||
import ca.uhn.fhir.jpa.dao.ISearchBuilder;
|
||||
import ca.uhn.fhir.jpa.dao.SearchBuilderFactory;
|
||||
import ca.uhn.fhir.jpa.dao.mdm.MdmExpansionCacheSvc;
|
||||
import ca.uhn.fhir.jpa.model.dao.JpaPid;
|
||||
import ca.uhn.fhir.jpa.model.search.SearchRuntimeDetails;
|
||||
import ca.uhn.fhir.jpa.partition.SystemRequestDetails;
|
||||
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
|
||||
|
@ -47,7 +48,6 @@ import ca.uhn.fhir.mdm.model.MdmPidTuple;
|
|||
import ca.uhn.fhir.model.api.Include;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.rest.api.server.bulk.BulkDataExportOptions;
|
||||
import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId;
|
||||
import ca.uhn.fhir.rest.param.HasOrListParam;
|
||||
import ca.uhn.fhir.rest.param.HasParam;
|
||||
import ca.uhn.fhir.rest.param.ReferenceOrListParam;
|
||||
|
@ -82,7 +82,7 @@ import java.util.stream.Collectors;
|
|||
import static ca.uhn.fhir.rest.api.Constants.PARAM_HAS;
|
||||
import static ca.uhn.fhir.rest.api.Constants.PARAM_ID;
|
||||
|
||||
public class JpaBulkExportProcessor implements IBulkExportProcessor {
|
||||
public class JpaBulkExportProcessor implements IBulkExportProcessor<JpaPid> {
|
||||
private static final Logger ourLog = LoggerFactory.getLogger(JpaBulkExportProcessor.class);
|
||||
|
||||
public static final int QUERY_CHUNK_SIZE = 100;
|
||||
|
@ -101,10 +101,10 @@ public class JpaBulkExportProcessor implements IBulkExportProcessor {
|
|||
private DaoRegistry myDaoRegistry;
|
||||
|
||||
@Autowired
|
||||
protected SearchBuilderFactory mySearchBuilderFactory;
|
||||
protected SearchBuilderFactory<JpaPid> mySearchBuilderFactory;
|
||||
|
||||
@Autowired
|
||||
private IIdHelperService myIdHelperService;
|
||||
private IIdHelperService<JpaPid> myIdHelperService;
|
||||
|
||||
@Autowired
|
||||
private IMdmLinkDao myMdmLinkDao;
|
||||
|
@ -119,12 +119,12 @@ public class JpaBulkExportProcessor implements IBulkExportProcessor {
|
|||
|
||||
@Transactional
|
||||
@Override
|
||||
public Iterator<ResourcePersistentId> getResourcePidIterator(ExportPIDIteratorParameters theParams) {
|
||||
public Iterator<JpaPid> getResourcePidIterator(ExportPIDIteratorParameters theParams) {
|
||||
String resourceType = theParams.getResourceType();
|
||||
String jobId = theParams.getJobId();
|
||||
RuntimeResourceDefinition def = myContext.getResourceDefinition(resourceType);
|
||||
|
||||
LinkedHashSet<ResourcePersistentId> pids;
|
||||
LinkedHashSet<JpaPid> pids;
|
||||
if (theParams.getExportStyle() == BulkDataExportOptions.ExportStyle.PATIENT) {
|
||||
pids = getPidsForPatientStyleExport(theParams, resourceType, jobId, def);
|
||||
} else if (theParams.getExportStyle() == BulkDataExportOptions.ExportStyle.GROUP) {
|
||||
|
@ -137,8 +137,8 @@ public class JpaBulkExportProcessor implements IBulkExportProcessor {
|
|||
return pids.iterator();
|
||||
}
|
||||
|
||||
private LinkedHashSet<ResourcePersistentId> getPidsForPatientStyleExport(ExportPIDIteratorParameters theParams, String resourceType, String jobId, RuntimeResourceDefinition def) {
|
||||
LinkedHashSet<ResourcePersistentId> pids = new LinkedHashSet<>();
|
||||
private LinkedHashSet<JpaPid> getPidsForPatientStyleExport(ExportPIDIteratorParameters theParams, String resourceType, String jobId, RuntimeResourceDefinition def) {
|
||||
LinkedHashSet<JpaPid> pids = new LinkedHashSet<>();
|
||||
// Patient
|
||||
if (myDaoConfig.getIndexMissingFields() == DaoConfig.IndexEnabledEnum.DISABLED) {
|
||||
String errorMessage = "You attempted to start a Patient Bulk Export, but the system has `Index Missing Fields` disabled. It must be enabled for Patient Bulk Export";
|
||||
|
@ -153,12 +153,12 @@ public class JpaBulkExportProcessor implements IBulkExportProcessor {
|
|||
//Ensure users did not monkey with the patient compartment search parameter.
|
||||
validateSearchParametersForPatient(map, theParams);
|
||||
|
||||
ISearchBuilder searchBuilder = getSearchBuilderForResourceType(theParams.getResourceType());
|
||||
ISearchBuilder<JpaPid> searchBuilder = getSearchBuilderForResourceType(theParams.getResourceType());
|
||||
|
||||
filterBySpecificPatient(theParams, resourceType, patientSearchParam, map);
|
||||
|
||||
SearchRuntimeDetails searchRuntime = new SearchRuntimeDetails(null, jobId);
|
||||
IResultIterator resultIterator = searchBuilder.createQuery(map, searchRuntime, null, RequestPartitionId.allPartitions());
|
||||
IResultIterator<JpaPid> resultIterator = searchBuilder.createQuery(map, searchRuntime, null, RequestPartitionId.allPartitions());
|
||||
while (resultIterator.hasNext()) {
|
||||
pids.add(resultIterator.next());
|
||||
}
|
||||
|
@ -191,15 +191,15 @@ public class JpaBulkExportProcessor implements IBulkExportProcessor {
|
|||
return referenceOrListParam;
|
||||
}
|
||||
|
||||
private LinkedHashSet<ResourcePersistentId> getPidsForSystemStyleExport(ExportPIDIteratorParameters theParams, String theJobId, RuntimeResourceDefinition theDef) {
|
||||
LinkedHashSet<ResourcePersistentId> pids = new LinkedHashSet<>();
|
||||
private LinkedHashSet<JpaPid> getPidsForSystemStyleExport(ExportPIDIteratorParameters theParams, String theJobId, RuntimeResourceDefinition theDef) {
|
||||
LinkedHashSet<JpaPid> pids = new LinkedHashSet<>();
|
||||
// System
|
||||
List<SearchParameterMap> maps = myBulkExportHelperSvc.createSearchParameterMapsForResourceType(theDef, theParams);
|
||||
ISearchBuilder searchBuilder = getSearchBuilderForResourceType(theParams.getResourceType());
|
||||
ISearchBuilder<JpaPid> searchBuilder = getSearchBuilderForResourceType(theParams.getResourceType());
|
||||
|
||||
for (SearchParameterMap map : maps) {
|
||||
// requires a transaction
|
||||
IResultIterator resultIterator = searchBuilder.createQuery(map,
|
||||
IResultIterator<JpaPid> resultIterator = searchBuilder.createQuery(map,
|
||||
new SearchRuntimeDetails(null, theJobId),
|
||||
null,
|
||||
RequestPartitionId.allPartitions());
|
||||
|
@ -210,8 +210,8 @@ public class JpaBulkExportProcessor implements IBulkExportProcessor {
|
|||
return pids;
|
||||
}
|
||||
|
||||
private LinkedHashSet<ResourcePersistentId> getPidsForGroupStyleExport(ExportPIDIteratorParameters theParams, String theResourceType, RuntimeResourceDefinition theDef) {
|
||||
LinkedHashSet<ResourcePersistentId> pids;
|
||||
private LinkedHashSet<JpaPid> getPidsForGroupStyleExport(ExportPIDIteratorParameters theParams, String theResourceType, RuntimeResourceDefinition theDef) {
|
||||
LinkedHashSet<JpaPid> pids;
|
||||
|
||||
if (theResourceType.equalsIgnoreCase("Patient")) {
|
||||
ourLog.info("Expanding Patients of a Group Bulk Export.");
|
||||
|
@ -225,9 +225,9 @@ public class JpaBulkExportProcessor implements IBulkExportProcessor {
|
|||
return pids;
|
||||
}
|
||||
|
||||
private LinkedHashSet<ResourcePersistentId> getRelatedResourceTypePids(ExportPIDIteratorParameters theParams, RuntimeResourceDefinition theDef) {
|
||||
LinkedHashSet<ResourcePersistentId> pids = new LinkedHashSet<>();
|
||||
Set<ResourcePersistentId> expandedMemberResourceIds = expandAllPatientPidsFromGroup(theParams);
|
||||
private LinkedHashSet<JpaPid> getRelatedResourceTypePids(ExportPIDIteratorParameters theParams, RuntimeResourceDefinition theDef) {
|
||||
LinkedHashSet<JpaPid> pids = new LinkedHashSet<>();
|
||||
Set<JpaPid> expandedMemberResourceIds = expandAllPatientPidsFromGroup(theParams);
|
||||
assert expandedMemberResourceIds != null && !expandedMemberResourceIds.isEmpty();
|
||||
if (ourLog.isDebugEnabled()) {
|
||||
ourLog.debug("{} has been expanded to members:[{}]", theParams.getGroupId(), expandedMemberResourceIds);
|
||||
|
@ -235,17 +235,17 @@ public class JpaBulkExportProcessor implements IBulkExportProcessor {
|
|||
|
||||
//Next, let's search for the target resources, with their correct patient references, chunked.
|
||||
//The results will be jammed into myReadPids
|
||||
QueryChunker<ResourcePersistentId> queryChunker = new QueryChunker<>();
|
||||
QueryChunker<JpaPid> queryChunker = new QueryChunker<>();
|
||||
queryChunker.chunk(expandedMemberResourceIds, QUERY_CHUNK_SIZE, (idChunk) -> {
|
||||
queryResourceTypeWithReferencesToPatients(pids, idChunk, theParams, theDef);
|
||||
});
|
||||
return pids;
|
||||
}
|
||||
|
||||
private LinkedHashSet<ResourcePersistentId> getSingletonGroupList(ExportPIDIteratorParameters theParams) {
|
||||
private LinkedHashSet<JpaPid> getSingletonGroupList(ExportPIDIteratorParameters theParams) {
|
||||
IBaseResource group = myDaoRegistry.getResourceDao("Group").read(new IdDt(theParams.getGroupId()), SystemRequestDetails.newSystemRequestAllPartitions());
|
||||
ResourcePersistentId pidOrNull = myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), group);
|
||||
LinkedHashSet<ResourcePersistentId> pids = new LinkedHashSet<>();
|
||||
JpaPid pidOrNull = (JpaPid) myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), group);
|
||||
LinkedHashSet<JpaPid> pids = new LinkedHashSet<>();
|
||||
pids.add(pidOrNull);
|
||||
return pids;
|
||||
}
|
||||
|
@ -253,7 +253,7 @@ public class JpaBulkExportProcessor implements IBulkExportProcessor {
|
|||
/**
|
||||
* Get a ISearchBuilder for the given resource type this partition is responsible for.
|
||||
*/
|
||||
protected ISearchBuilder getSearchBuilderForResourceType(String theResourceType) {
|
||||
protected ISearchBuilder<JpaPid> getSearchBuilderForResourceType(String theResourceType) {
|
||||
IFhirResourceDao<?> dao = myDaoRegistry.getResourceDao(theResourceType);
|
||||
RuntimeResourceDefinition def = myContext.getResourceDefinition(theResourceType);
|
||||
Class<? extends IBaseResource> typeClass = def.getImplementingClass();
|
||||
|
@ -308,21 +308,21 @@ public class JpaBulkExportProcessor implements IBulkExportProcessor {
|
|||
* In case we are doing a Group Bulk Export and resourceType `Patient` is requested, we can just return the group members,
|
||||
* possibly expanded by MDM, and don't have to go and fetch other resource DAOs.
|
||||
*/
|
||||
private LinkedHashSet<ResourcePersistentId> getExpandedPatientList(ExportPIDIteratorParameters theParameters) {
|
||||
List<ResourcePersistentId> members = getMembersFromGroupWithFilter(theParameters);
|
||||
private LinkedHashSet<JpaPid> getExpandedPatientList(ExportPIDIteratorParameters theParameters) {
|
||||
List<JpaPid> members = getMembersFromGroupWithFilter(theParameters);
|
||||
List<IIdType> ids = members.stream().map(member -> new IdDt("Patient/" + member)).collect(Collectors.toList());
|
||||
ourLog.info("While extracting patients from a group, we found {} patients.", ids.size());
|
||||
ourLog.info("Found patients: {}", ids.stream().map(id -> id.getValue()).collect(Collectors.joining(", ")));
|
||||
// Are bulk exports partition aware or care about partition at all? This does
|
||||
|
||||
List<ResourcePersistentId> pidsOrThrowException = members;
|
||||
LinkedHashSet<ResourcePersistentId> patientPidsToExport = new LinkedHashSet<>(pidsOrThrowException);
|
||||
List<JpaPid> pidsOrThrowException = members;
|
||||
LinkedHashSet<JpaPid> patientPidsToExport = new LinkedHashSet<>(pidsOrThrowException);
|
||||
|
||||
if (theParameters.isExpandMdm()) {
|
||||
SystemRequestDetails srd = SystemRequestDetails.newSystemRequestAllPartitions();
|
||||
IBaseResource group = myDaoRegistry.getResourceDao("Group").read(new IdDt(theParameters.getGroupId()), srd);
|
||||
ResourcePersistentId pidOrNull = myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), group);
|
||||
List<MdmPidTuple> goldenPidSourcePidTuple = myMdmLinkDao.expandPidsFromGroupPidGivenMatchResult(pidOrNull, MdmMatchResultEnum.MATCH);
|
||||
JpaPid pidOrNull = (JpaPid) myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), group);
|
||||
List<MdmPidTuple<JpaPid>> goldenPidSourcePidTuple = myMdmLinkDao.expandPidsFromGroupPidGivenMatchResult(pidOrNull, MdmMatchResultEnum.MATCH);
|
||||
goldenPidSourcePidTuple.forEach(tuple -> {
|
||||
patientPidsToExport.add(tuple.getGoldenPid());
|
||||
patientPidsToExport.add(tuple.getSourcePid());
|
||||
|
@ -337,19 +337,19 @@ public class JpaBulkExportProcessor implements IBulkExportProcessor {
|
|||
*
|
||||
* @return A list of strings representing the Patient IDs of the members (e.g. ["P1", "P2", "P3"]
|
||||
*/
|
||||
private List<ResourcePersistentId> getMembersFromGroupWithFilter(ExportPIDIteratorParameters theParameters) {
|
||||
private List<JpaPid> getMembersFromGroupWithFilter(ExportPIDIteratorParameters theParameters) {
|
||||
RuntimeResourceDefinition def = myContext.getResourceDefinition("Patient");
|
||||
List<String> pids = new ArrayList<>();
|
||||
List<ResourcePersistentId> resPids = new ArrayList<>();
|
||||
List<JpaPid> resPids = new ArrayList<>();
|
||||
|
||||
List<SearchParameterMap> maps = myBulkExportHelperSvc.createSearchParameterMapsForResourceType(def, theParameters);
|
||||
|
||||
maps.forEach(map -> addMembershipToGroupClause(map, theParameters.getGroupId()));
|
||||
|
||||
for (SearchParameterMap map : maps) {
|
||||
ISearchBuilder searchBuilder = getSearchBuilderForResourceType("Patient");
|
||||
ISearchBuilder<JpaPid> searchBuilder = getSearchBuilderForResourceType("Patient");
|
||||
ourLog.debug("Searching for members of group {} with job id {} with map {}", theParameters.getGroupId(), theParameters.getJobId(), map);
|
||||
IResultIterator resultIterator = searchBuilder.createQuery(map,
|
||||
IResultIterator<JpaPid> resultIterator = searchBuilder.createQuery(map,
|
||||
new SearchRuntimeDetails(null, theParameters.getJobId()),
|
||||
null,
|
||||
RequestPartitionId.allPartitions());
|
||||
|
@ -377,7 +377,7 @@ public class JpaBulkExportProcessor implements IBulkExportProcessor {
|
|||
/**
|
||||
* @param thePidTuples
|
||||
*/
|
||||
private void populateMdmResourceCache(List<MdmPidTuple> thePidTuples) {
|
||||
private void populateMdmResourceCache(List<MdmPidTuple<JpaPid>> thePidTuples) {
|
||||
if (myMdmExpansionCacheSvc.hasBeenPopulated()) {
|
||||
return;
|
||||
}
|
||||
|
@ -386,7 +386,7 @@ public class JpaBulkExportProcessor implements IBulkExportProcessor {
|
|||
// patient/gold-1 -> [patient/1, patient/2]
|
||||
// patient/gold-2 -> [patient/3, patient/4]
|
||||
//}
|
||||
Map<ResourcePersistentId, Set<ResourcePersistentId>> goldenResourceToSourcePidMap = new HashMap<>();
|
||||
Map<JpaPid, Set<JpaPid>> goldenResourceToSourcePidMap = new HashMap<>();
|
||||
extract(thePidTuples, goldenResourceToSourcePidMap);
|
||||
|
||||
//Next, lets convert it to an inverted index for fast lookup
|
||||
|
@ -411,21 +411,21 @@ public class JpaBulkExportProcessor implements IBulkExportProcessor {
|
|||
myMdmExpansionCacheSvc.setCacheContents(sourceResourceIdToGoldenResourceIdMap);
|
||||
}
|
||||
|
||||
private void extract(List<MdmPidTuple> theGoldenPidTargetPidTuples, Map<ResourcePersistentId, Set<ResourcePersistentId>> theGoldenResourceToSourcePidMap) {
|
||||
for (MdmPidTuple goldenPidTargetPidTuple : theGoldenPidTargetPidTuples) {
|
||||
ResourcePersistentId goldenPid = goldenPidTargetPidTuple.getGoldenPid();
|
||||
ResourcePersistentId sourcePid = goldenPidTargetPidTuple.getSourcePid();
|
||||
private void extract(List<MdmPidTuple<JpaPid>> theGoldenPidTargetPidTuples, Map<JpaPid, Set<JpaPid>> theGoldenResourceToSourcePidMap) {
|
||||
for (MdmPidTuple<JpaPid> goldenPidTargetPidTuple : theGoldenPidTargetPidTuples) {
|
||||
JpaPid goldenPid = goldenPidTargetPidTuple.getGoldenPid();
|
||||
JpaPid sourcePid = goldenPidTargetPidTuple.getSourcePid();
|
||||
theGoldenResourceToSourcePidMap.computeIfAbsent(goldenPid, key -> new HashSet<>()).add(sourcePid);
|
||||
}
|
||||
}
|
||||
|
||||
private void queryResourceTypeWithReferencesToPatients(Set<ResourcePersistentId> myReadPids,
|
||||
List<ResourcePersistentId> resourcePersistentIdChunk,
|
||||
private void queryResourceTypeWithReferencesToPatients(Set<JpaPid> theReadPids,
|
||||
List<JpaPid> JpaPidChunk,
|
||||
ExportPIDIteratorParameters theParams,
|
||||
RuntimeResourceDefinition theDef) {
|
||||
|
||||
//Convert Resource Persistent IDs to actual client IDs.
|
||||
Set<ResourcePersistentId> pidSet = new HashSet<>(resourcePersistentIdChunk);
|
||||
Set<JpaPid> pidSet = new HashSet<>(JpaPidChunk);
|
||||
Set<String> resourceIds = myIdHelperService.translatePidsToFhirResourceIds(pidSet);
|
||||
|
||||
//Build SP map
|
||||
|
@ -437,7 +437,7 @@ public class JpaBulkExportProcessor implements IBulkExportProcessor {
|
|||
validateSearchParametersForGroup(expandedSpMap, theParams.getResourceType());
|
||||
|
||||
// Fetch and cache a search builder for this resource type
|
||||
ISearchBuilder searchBuilder = getSearchBuilderForResourceType(theParams.getResourceType());
|
||||
ISearchBuilder<JpaPid> searchBuilder = getSearchBuilderForResourceType(theParams.getResourceType());
|
||||
|
||||
// Now, further filter the query with patient references defined by the chunk of IDs we have.
|
||||
if (PATIENT_BULK_EXPORT_FORWARD_REFERENCE_RESOURCE_TYPES.contains(theParams.getResourceType())) {
|
||||
|
@ -447,20 +447,20 @@ public class JpaBulkExportProcessor implements IBulkExportProcessor {
|
|||
}
|
||||
|
||||
//Execute query and all found pids to our local iterator.
|
||||
IResultIterator resultIterator = searchBuilder.createQuery(expandedSpMap,
|
||||
IResultIterator<JpaPid> resultIterator = searchBuilder.createQuery(expandedSpMap,
|
||||
new SearchRuntimeDetails(null, theParams.getJobId()),
|
||||
null,
|
||||
RequestPartitionId.allPartitions());
|
||||
while (resultIterator.hasNext()) {
|
||||
myReadPids.add(resultIterator.next());
|
||||
theReadPids.add(resultIterator.next());
|
||||
}
|
||||
|
||||
// add _include to results to support ONC
|
||||
Set<Include> includes = Collections.singleton(new Include("*", true));
|
||||
SystemRequestDetails requestDetails = SystemRequestDetails.newSystemRequestAllPartitions();
|
||||
Set<ResourcePersistentId> includeIds = searchBuilder.loadIncludes(myContext, myEntityManager, myReadPids, includes, false, expandedSpMap.getLastUpdated(), theParams.getJobId(), requestDetails, null);
|
||||
Set<JpaPid> includeIds = searchBuilder.loadIncludes(myContext, myEntityManager, theReadPids, includes, false, expandedSpMap.getLastUpdated(), theParams.getJobId(), requestDetails, null);
|
||||
// gets rid of the Patient duplicates
|
||||
myReadPids.addAll(includeIds.stream().filter((id) -> !id.getResourceType().equals("Patient")).collect(Collectors.toSet()));
|
||||
theReadPids.addAll(includeIds.stream().filter((id) -> !id.getResourceType().equals("Patient")).collect(Collectors.toSet()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -505,11 +505,11 @@ public class JpaBulkExportProcessor implements IBulkExportProcessor {
|
|||
*
|
||||
* @return a Set of Strings representing the resource IDs of all members of a group.
|
||||
*/
|
||||
private Set<ResourcePersistentId> expandAllPatientPidsFromGroup(ExportPIDIteratorParameters theParams) {
|
||||
Set<ResourcePersistentId> expandedIds = new HashSet<>();
|
||||
private Set<JpaPid> expandAllPatientPidsFromGroup(ExportPIDIteratorParameters theParams) {
|
||||
Set<JpaPid> expandedIds = new HashSet<>();
|
||||
SystemRequestDetails requestDetails = SystemRequestDetails.newSystemRequestAllPartitions();
|
||||
IBaseResource group = myDaoRegistry.getResourceDao("Group").read(new IdDt(theParams.getGroupId()), requestDetails);
|
||||
ResourcePersistentId pidOrNull = myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), group);
|
||||
JpaPid pidOrNull = (JpaPid) myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), group);
|
||||
|
||||
//Attempt to perform MDM Expansion of membership
|
||||
if (theParams.isExpandMdm()) {
|
||||
|
@ -518,24 +518,24 @@ public class JpaBulkExportProcessor implements IBulkExportProcessor {
|
|||
|
||||
//Now manually add the members of the group (its possible even with mdm expansion that some members dont have MDM matches,
|
||||
//so would be otherwise skipped
|
||||
List<ResourcePersistentId> membersFromGroupWithFilter = getMembersFromGroupWithFilter(theParams);
|
||||
List<JpaPid> membersFromGroupWithFilter = getMembersFromGroupWithFilter(theParams);
|
||||
ourLog.debug("Group with ID [{}] has been expanded to: {}", theParams.getGroupId(), membersFromGroupWithFilter);
|
||||
expandedIds.addAll(membersFromGroupWithFilter);
|
||||
|
||||
return expandedIds;
|
||||
}
|
||||
|
||||
private Set<ResourcePersistentId> performMembershipExpansionViaMdmTable(ResourcePersistentId pidOrNull) {
|
||||
List<MdmPidTuple> goldenPidTargetPidTuples = myMdmLinkDao.expandPidsFromGroupPidGivenMatchResult(pidOrNull, MdmMatchResultEnum.MATCH);
|
||||
private Set<JpaPid> performMembershipExpansionViaMdmTable(JpaPid pidOrNull) {
|
||||
List<MdmPidTuple<JpaPid>> goldenPidTargetPidTuples = myMdmLinkDao.expandPidsFromGroupPidGivenMatchResult(pidOrNull, MdmMatchResultEnum.MATCH);
|
||||
//Now lets translate these pids into resource IDs
|
||||
Set<ResourcePersistentId> uniquePids = new HashSet<>();
|
||||
Set<JpaPid> uniquePids = new HashSet<>();
|
||||
goldenPidTargetPidTuples.forEach(tuple -> {
|
||||
uniquePids.add(tuple.getGoldenPid());
|
||||
uniquePids.add(tuple.getSourcePid());
|
||||
});
|
||||
PersistentIdToForcedIdMap pidToForcedIdMap = myIdHelperService.translatePidsToForcedIds(uniquePids);
|
||||
|
||||
Map<ResourcePersistentId, Set<ResourcePersistentId>> goldenResourceToSourcePidMap = new HashMap<>();
|
||||
Map<JpaPid, Set<JpaPid>> goldenResourceToSourcePidMap = new HashMap<>();
|
||||
extract(goldenPidTargetPidTuples, goldenResourceToSourcePidMap);
|
||||
populateMdmResourceCache(goldenPidTargetPidTuples);
|
||||
|
||||
|
|
|
@ -24,13 +24,12 @@ import ca.uhn.fhir.interceptor.model.RequestPartitionId;
|
|||
import ca.uhn.fhir.jpa.api.dao.DaoRegistry;
|
||||
import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao;
|
||||
import ca.uhn.fhir.jpa.api.svc.IIdHelperService;
|
||||
import ca.uhn.fhir.jpa.model.dao.JpaPid;
|
||||
import ca.uhn.fhir.jpa.dao.data.IResourceTableDao;
|
||||
import ca.uhn.fhir.jpa.model.dao.JpaPid;
|
||||
import ca.uhn.fhir.jpa.model.entity.ResourceTable;
|
||||
import ca.uhn.fhir.jpa.partition.SystemRequestDetails;
|
||||
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
|
||||
import ca.uhn.fhir.jpa.util.QueryChunker;
|
||||
import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.slf4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -60,7 +59,7 @@ public class ResourceVersionSvcDaoImpl implements IResourceVersionSvc {
|
|||
@Autowired
|
||||
IResourceTableDao myResourceTableDao;
|
||||
@Autowired
|
||||
IIdHelperService myIdHelperService;
|
||||
IIdHelperService<JpaPid> myIdHelperService;
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
|
@ -137,8 +136,7 @@ public class ResourceVersionSvcDaoImpl implements IResourceVersionSvc {
|
|||
return retval;
|
||||
}
|
||||
|
||||
List<JpaPid> jpaPids = myIdHelperService.resolveResourcePersistentIdsWithCache(thePartitionId,
|
||||
new ArrayList<>(theIds)).stream().map(id -> (JpaPid) id).collect(Collectors.toList());
|
||||
List<JpaPid> jpaPids = myIdHelperService.resolveResourcePersistentIdsWithCache(thePartitionId, new ArrayList<>(theIds));
|
||||
|
||||
// we'll use this map to fetch pids that require versions
|
||||
HashMap<Long, JpaPid> pidsToVersionToResourcePid = new HashMap<>();
|
||||
|
|
|
@ -37,7 +37,7 @@ import ca.uhn.fhir.jpa.dao.expunge.ExpungeOperation;
|
|||
import ca.uhn.fhir.jpa.dao.expunge.ExpungeService;
|
||||
import ca.uhn.fhir.jpa.dao.expunge.IExpungeEverythingService;
|
||||
import ca.uhn.fhir.jpa.dao.expunge.IResourceExpungeService;
|
||||
import ca.uhn.fhir.jpa.dao.expunge.ResourceExpungeService;
|
||||
import ca.uhn.fhir.jpa.dao.expunge.JpaResourceExpungeService;
|
||||
import ca.uhn.fhir.jpa.dao.expunge.ResourceTableFKProvider;
|
||||
import ca.uhn.fhir.jpa.dao.index.DaoResourceLinkResolver;
|
||||
import ca.uhn.fhir.jpa.dao.index.DaoSearchParamSynchronizer;
|
||||
|
@ -690,7 +690,7 @@ public class JpaConfig {
|
|||
|
||||
@Bean
|
||||
public IResourceExpungeService resourceExpungeService() {
|
||||
return new ResourceExpungeService();
|
||||
return new JpaResourceExpungeService();
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
|
|
@ -27,7 +27,6 @@ import ca.uhn.fhir.jpa.api.dao.DaoRegistry;
|
|||
import ca.uhn.fhir.jpa.api.dao.IDao;
|
||||
import ca.uhn.fhir.jpa.api.svc.IIdHelperService;
|
||||
import ca.uhn.fhir.jpa.api.svc.ISearchCoordinatorSvc;
|
||||
import ca.uhn.fhir.jpa.dao.IFulltextSearchSvc;
|
||||
import ca.uhn.fhir.jpa.dao.ISearchBuilder;
|
||||
import ca.uhn.fhir.jpa.dao.SearchBuilderFactory;
|
||||
import ca.uhn.fhir.jpa.dao.data.IResourceSearchViewDao;
|
||||
|
@ -47,7 +46,6 @@ import ca.uhn.fhir.jpa.search.builder.tasks.SearchTask;
|
|||
import ca.uhn.fhir.jpa.search.builder.tasks.SearchTaskParameters;
|
||||
import ca.uhn.fhir.jpa.search.cache.ISearchCacheSvc;
|
||||
import ca.uhn.fhir.jpa.search.cache.ISearchResultCacheSvc;
|
||||
import ca.uhn.fhir.jpa.search.lastn.IElasticsearchSvc;
|
||||
import ca.uhn.fhir.rest.server.IPagingProvider;
|
||||
import ca.uhn.fhir.rest.server.util.ISearchParamRegistry;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
@ -164,8 +162,7 @@ public class SearchConfig {
|
|||
return new SearchTask(theParams,
|
||||
myManagedTxManager,
|
||||
myContext,
|
||||
mySearchStrategyFactory,
|
||||
myInterceptorBroadcaster,
|
||||
myInterceptorBroadcaster,
|
||||
mySearchBuilderFactory,
|
||||
mySearchResultCacheSvc,
|
||||
myDaoConfig,
|
||||
|
@ -181,7 +178,6 @@ public class SearchConfig {
|
|||
return new SearchContinuationTask(theParams,
|
||||
myManagedTxManager,
|
||||
myContext,
|
||||
mySearchStrategyFactory,
|
||||
myInterceptorBroadcaster,
|
||||
mySearchBuilderFactory,
|
||||
mySearchResultCacheSvc,
|
||||
|
|
|
@ -164,9 +164,9 @@ public abstract class BaseHapiFhirResourceDao<T extends IBaseResource> extends B
|
|||
@Autowired
|
||||
protected HapiTransactionService myTransactionService;
|
||||
@Autowired
|
||||
private MatchResourceUrlService myMatchResourceUrlService;
|
||||
private MatchResourceUrlService<JpaPid> myMatchResourceUrlService;
|
||||
@Autowired
|
||||
private SearchBuilderFactory mySearchBuilderFactory;
|
||||
private SearchBuilderFactory<JpaPid> mySearchBuilderFactory;
|
||||
@Autowired
|
||||
private DaoRegistry myDaoRegistry;
|
||||
@Autowired
|
||||
|
@ -289,7 +289,7 @@ public abstract class BaseHapiFhirResourceDao<T extends IBaseResource> extends B
|
|||
entity.setVersion(1);
|
||||
|
||||
if (isNotBlank(theMatchUrl) && theProcessMatchUrl) {
|
||||
Set<ResourcePersistentId> match = myMatchResourceUrlService.processMatchUrl(theMatchUrl, myResourceType, theTransactionDetails, theRequest);
|
||||
Set<JpaPid> match = myMatchResourceUrlService.processMatchUrl(theMatchUrl, myResourceType, theTransactionDetails, theRequest);
|
||||
if (match.size() > 1) {
|
||||
String msg = getContext().getLocalizer().getMessageSanitized(BaseStorageDao.class, "transactionOperationWithMultipleMatchFailure", "CREATE", theMatchUrl, match.size());
|
||||
throw new PreconditionFailedException(Msg.code(958) + msg);
|
||||
|
@ -640,7 +640,7 @@ public abstract class BaseHapiFhirResourceDao<T extends IBaseResource> extends B
|
|||
SearchParameterMap paramMap = resourceSearch.getSearchParameterMap();
|
||||
paramMap.setLoadSynchronous(true);
|
||||
|
||||
Set<ResourcePersistentId> resourceIds = myMatchResourceUrlService.search(paramMap, myResourceType, theRequest, null);
|
||||
Set<JpaPid> resourceIds = myMatchResourceUrlService.search(paramMap, myResourceType, theRequest, null);
|
||||
|
||||
if (resourceIds.size() > 1) {
|
||||
if (!getConfig().isAllowMultipleDelete()) {
|
||||
|
@ -671,11 +671,11 @@ public abstract class BaseHapiFhirResourceDao<T extends IBaseResource> extends B
|
|||
|
||||
@Nonnull
|
||||
@Override
|
||||
public DeleteMethodOutcome deletePidList(String theUrl, Collection<ResourcePersistentId> theResourceIds, DeleteConflictList theDeleteConflicts, RequestDetails theRequest) {
|
||||
public <P extends ResourcePersistentId> DeleteMethodOutcome deletePidList(String theUrl, Collection<P> theResourceIds, DeleteConflictList theDeleteConflicts, RequestDetails theRequest) {
|
||||
StopWatch w = new StopWatch();
|
||||
TransactionDetails transactionDetails = new TransactionDetails();
|
||||
List<ResourceTable> deletedResources = new ArrayList<>();
|
||||
for (ResourcePersistentId pid : theResourceIds) {
|
||||
for (P pid : theResourceIds) {
|
||||
ResourceTable entity = myEntityManager.find(ResourceTable.class, ((JpaPid) pid).getId());
|
||||
deletedResources.add(entity);
|
||||
|
||||
|
@ -1230,10 +1230,10 @@ public abstract class BaseHapiFhirResourceDao<T extends IBaseResource> extends B
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void reindex(ResourcePersistentId theResourcePersistentId, RequestDetails theRequest, TransactionDetails theTransactionDetails) {
|
||||
Optional<ResourceTable> entityOpt = myResourceTableDao.findById(((JpaPid) theResourcePersistentId).getId());
|
||||
public void reindex(ResourcePersistentId theJpaPid, RequestDetails theRequest, TransactionDetails theTransactionDetails) {
|
||||
Optional<ResourceTable> entityOpt = myResourceTableDao.findById(((JpaPid) theJpaPid).getId());
|
||||
if (!entityOpt.isPresent()) {
|
||||
ourLog.warn("Unable to find entity with PID: {}", ((JpaPid) theResourcePersistentId).getId());
|
||||
ourLog.warn("Unable to find entity with PID: {}", ((JpaPid) theJpaPid).getId());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1519,7 +1519,7 @@ public abstract class BaseHapiFhirResourceDao<T extends IBaseResource> extends B
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<ResourcePersistentId> searchForIds(SearchParameterMap theParams, RequestDetails theRequest, @Nullable IBaseResource theConditionalOperationTargetOrNull) {
|
||||
public List<JpaPid> searchForIds(SearchParameterMap theParams, RequestDetails theRequest, @Nullable IBaseResource theConditionalOperationTargetOrNull) {
|
||||
TransactionDetails transactionDetails = new TransactionDetails();
|
||||
|
||||
return myTransactionService.execute(theRequest, transactionDetails, tx -> {
|
||||
|
@ -1532,13 +1532,13 @@ public abstract class BaseHapiFhirResourceDao<T extends IBaseResource> extends B
|
|||
|
||||
ISearchBuilder builder = mySearchBuilderFactory.newSearchBuilder(this, getResourceName(), getResourceType());
|
||||
|
||||
List<ResourcePersistentId> ids = new ArrayList<>();
|
||||
List<JpaPid> ids = new ArrayList<>();
|
||||
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
RequestPartitionId requestPartitionId = myRequestPartitionHelperService.determineReadPartitionForRequestForSearchType(theRequest, getResourceName(), theParams, theConditionalOperationTargetOrNull);
|
||||
|
||||
SearchRuntimeDetails searchRuntimeDetails = new SearchRuntimeDetails(theRequest, uuid);
|
||||
try (IResultIterator iter = builder.createQuery(theParams, searchRuntimeDetails, theRequest, requestPartitionId)) {
|
||||
try (IResultIterator<JpaPid> iter = builder.createQuery(theParams, searchRuntimeDetails, theRequest, requestPartitionId)) {
|
||||
while (iter.hasNext()) {
|
||||
ids.add(iter.next());
|
||||
}
|
||||
|
@ -1669,7 +1669,7 @@ public abstract class BaseHapiFhirResourceDao<T extends IBaseResource> extends B
|
|||
|
||||
// Pre-cache the match URL
|
||||
if (outcome.getPersistentId() != null) {
|
||||
myMatchResourceUrlService.matchUrlResolved(theTransactionDetails, getResourceName(), theMatchUrl, outcome.getPersistentId());
|
||||
myMatchResourceUrlService.matchUrlResolved(theTransactionDetails, getResourceName(), theMatchUrl, (JpaPid) outcome.getPersistentId());
|
||||
}
|
||||
|
||||
return outcome;
|
||||
|
|
|
@ -7,12 +7,10 @@ import ca.uhn.fhir.jpa.api.config.DaoConfig;
|
|||
import ca.uhn.fhir.jpa.api.dao.IFhirSystemDao;
|
||||
import ca.uhn.fhir.jpa.api.model.ExpungeOptions;
|
||||
import ca.uhn.fhir.jpa.api.model.ExpungeOutcome;
|
||||
import ca.uhn.fhir.jpa.model.dao.JpaPid;
|
||||
import ca.uhn.fhir.jpa.dao.data.IResourceSearchViewDao;
|
||||
import ca.uhn.fhir.jpa.dao.data.IResourceTableDao;
|
||||
import ca.uhn.fhir.jpa.dao.data.IResourceTagDao;
|
||||
import ca.uhn.fhir.jpa.dao.expunge.ExpungeService;
|
||||
import ca.uhn.fhir.jpa.model.config.PartitionSettings;
|
||||
import ca.uhn.fhir.jpa.model.dao.JpaPid;
|
||||
import ca.uhn.fhir.jpa.model.entity.ResourceHistoryTable;
|
||||
import ca.uhn.fhir.jpa.model.entity.ResourceTable;
|
||||
import ca.uhn.fhir.jpa.search.PersistedJpaBundleProviderFactory;
|
||||
|
@ -26,7 +24,6 @@ import ca.uhn.fhir.rest.server.exceptions.MethodNotAllowedException;
|
|||
import ca.uhn.fhir.util.StopWatch;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import org.hl7.fhir.instance.model.api.IBaseBundle;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
|
@ -166,7 +163,7 @@ public abstract class BaseHapiFhirSystemDao<T extends IBaseBundle, MT> extends B
|
|||
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.MANDATORY)
|
||||
public void preFetchResources(List<ResourcePersistentId> theResolvedIds) {
|
||||
public <P extends ResourcePersistentId> void preFetchResources(List<P> theResolvedIds) {
|
||||
List<Long> pids = theResolvedIds
|
||||
.stream()
|
||||
.map(t -> ((JpaPid) t).getId())
|
||||
|
|
|
@ -43,7 +43,7 @@ public interface IFulltextSearchSvc {
|
|||
* @param theParams the full query - modified to return only params unused by the index.
|
||||
* @return the pid list for the matchign resources.
|
||||
*/
|
||||
List<ResourcePersistentId> search(String theResourceName, SearchParameterMap theParams);
|
||||
<T extends ResourcePersistentId> List<T> search(String theResourceName, SearchParameterMap theParams);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -63,7 +63,7 @@ public interface IFulltextSearchSvc {
|
|||
*/
|
||||
IBaseResource tokenAutocompleteValueSetSearch(ValueSetAutocompleteOptions theOptions);
|
||||
|
||||
List<ResourcePersistentId> everything(String theResourceName, SearchParameterMap theParams, ResourcePersistentId theReferencingPid);
|
||||
<T extends ResourcePersistentId> List<T> everything(String theResourceName, SearchParameterMap theParams, T theReferencingPid);
|
||||
|
||||
boolean isDisabled();
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ public class TransactionProcessor extends BaseTransactionProcessor {
|
|||
@Autowired(required = false)
|
||||
private HapiFhirHibernateJpaDialect myHapiFhirHibernateJpaDialect;
|
||||
@Autowired
|
||||
private IIdHelperService myIdHelperService;
|
||||
private IIdHelperService<JpaPid> myIdHelperService;
|
||||
@Autowired
|
||||
private PartitionSettings myPartitionSettings;
|
||||
@Autowired
|
||||
|
|
|
@ -52,7 +52,6 @@ import ca.uhn.fhir.jpa.model.entity.ResourceTable;
|
|||
import ca.uhn.fhir.jpa.util.MemoryCacheService;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.rest.api.server.RequestDetails;
|
||||
import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId;
|
||||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||
import ca.uhn.fhir.rest.server.util.CompositeInterceptorBroadcaster;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
@ -75,8 +74,8 @@ import java.util.List;
|
|||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
@Service
|
||||
public class ResourceExpungeService implements IResourceExpungeService {
|
||||
private static final Logger ourLog = LoggerFactory.getLogger(ResourceExpungeService.class);
|
||||
public class JpaResourceExpungeService implements IResourceExpungeService<JpaPid> {
|
||||
private static final Logger ourLog = LoggerFactory.getLogger(JpaResourceExpungeService.class);
|
||||
|
||||
@Autowired
|
||||
private IForcedIdDao myForcedIdDao;
|
||||
|
@ -129,20 +128,19 @@ public class ResourceExpungeService implements IResourceExpungeService {
|
|||
|
||||
@Override
|
||||
@Transactional
|
||||
public List<ResourcePersistentId> findHistoricalVersionsOfNonDeletedResources(String theResourceName, ResourcePersistentId theResourceId, int theRemainingCount) {
|
||||
public List<JpaPid> findHistoricalVersionsOfNonDeletedResources(String theResourceName, JpaPid theJpaPid, int theRemainingCount) {
|
||||
if (isEmptyQuery(theRemainingCount)) {
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
|
||||
Pageable page = PageRequest.of(0, theRemainingCount);
|
||||
JpaPid jpaPid = (JpaPid) theResourceId;
|
||||
|
||||
Slice<Long> ids;
|
||||
if (jpaPid != null && jpaPid.getId() != null) {
|
||||
if (jpaPid.getVersion() != null) {
|
||||
ids = toSlice(myResourceHistoryTableDao.findForIdAndVersionAndFetchProvenance(jpaPid.getId(), jpaPid.getVersion()));
|
||||
if (theJpaPid != null && theJpaPid.getId() != null) {
|
||||
if (theJpaPid.getVersion() != null) {
|
||||
ids = toSlice(myResourceHistoryTableDao.findForIdAndVersionAndFetchProvenance(theJpaPid.getId(), theJpaPid.getVersion()));
|
||||
} else {
|
||||
ids = myResourceHistoryTableDao.findIdsOfPreviousVersionsOfResourceId(page, jpaPid.getId());
|
||||
ids = myResourceHistoryTableDao.findIdsOfPreviousVersionsOfResourceId(page, theJpaPid.getId());
|
||||
}
|
||||
} else {
|
||||
if (theResourceName != null) {
|
||||
|
@ -157,7 +155,7 @@ public class ResourceExpungeService implements IResourceExpungeService {
|
|||
|
||||
@Override
|
||||
@Transactional
|
||||
public List<ResourcePersistentId> findHistoricalVersionsOfDeletedResources(String theResourceName, ResourcePersistentId theResourceId, int theRemainingCount) {
|
||||
public List<JpaPid> findHistoricalVersionsOfDeletedResources(String theResourceName, JpaPid theResourceId, int theRemainingCount) {
|
||||
if (isEmptyQuery(theRemainingCount)) {
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
|
@ -181,8 +179,8 @@ public class ResourceExpungeService implements IResourceExpungeService {
|
|||
|
||||
@Override
|
||||
@Transactional
|
||||
public void expungeCurrentVersionOfResources(RequestDetails theRequestDetails, List<ResourcePersistentId> theResourceIds, AtomicInteger theRemainingCount) {
|
||||
for (ResourcePersistentId next : theResourceIds) {
|
||||
public void expungeCurrentVersionOfResources(RequestDetails theRequestDetails, List<JpaPid> theResourceIds, AtomicInteger theRemainingCount) {
|
||||
for (JpaPid next : theResourceIds) {
|
||||
expungeCurrentVersionOfResource(theRequestDetails,((JpaPid) next).getId(), theRemainingCount);
|
||||
if (expungeLimitReached(theRemainingCount)) {
|
||||
return;
|
||||
|
@ -238,8 +236,8 @@ public class ResourceExpungeService implements IResourceExpungeService {
|
|||
|
||||
@Override
|
||||
@Transactional
|
||||
public void expungeHistoricalVersionsOfIds(RequestDetails theRequestDetails, List<ResourcePersistentId> theResourceIds, AtomicInteger theRemainingCount) {
|
||||
for (ResourcePersistentId next : theResourceIds) {
|
||||
public void expungeHistoricalVersionsOfIds(RequestDetails theRequestDetails, List<JpaPid> theResourceIds, AtomicInteger theRemainingCount) {
|
||||
for (JpaPid next : theResourceIds) {
|
||||
expungeHistoricalVersionsOfId(theRequestDetails, ((JpaPid) next).getId(), theRemainingCount);
|
||||
if (expungeLimitReached(theRemainingCount)) {
|
||||
return;
|
||||
|
@ -249,8 +247,8 @@ public class ResourceExpungeService implements IResourceExpungeService {
|
|||
|
||||
@Override
|
||||
@Transactional
|
||||
public void expungeHistoricalVersions(RequestDetails theRequestDetails, List<ResourcePersistentId> theHistoricalIds, AtomicInteger theRemainingCount) {
|
||||
for (ResourcePersistentId next : theHistoricalIds) {
|
||||
public void expungeHistoricalVersions(RequestDetails theRequestDetails, List<JpaPid> theHistoricalIds, AtomicInteger theRemainingCount) {
|
||||
for (JpaPid next : theHistoricalIds) {
|
||||
expungeHistoricalVersion(theRequestDetails, ((JpaPid) next).getId(), theRemainingCount);
|
||||
if (expungeLimitReached(theRemainingCount)) {
|
||||
return;
|
||||
|
@ -284,7 +282,7 @@ public class ResourceExpungeService implements IResourceExpungeService {
|
|||
|
||||
@Override
|
||||
@Transactional
|
||||
public void deleteAllSearchParams(ResourcePersistentId theResourceId) {
|
||||
public void deleteAllSearchParams(JpaPid theResourceId) {
|
||||
Long theResourceLongId = ((JpaPid) theResourceId).getId();
|
||||
ResourceTable resource = myResourceTableDao.findById(theResourceLongId).orElse(null);
|
||||
|
|
@ -21,7 +21,7 @@ package ca.uhn.fhir.jpa.dao.index;
|
|||
*/
|
||||
|
||||
import ca.uhn.fhir.jpa.api.svc.IIdHelperService;
|
||||
import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId;
|
||||
import ca.uhn.fhir.jpa.model.dao.JpaPid;
|
||||
import org.hl7.fhir.instance.model.api.IAnyResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
|
@ -48,7 +48,7 @@ import java.util.Set;
|
|||
* but they also have caching and partition awareness so the tradeoff for that
|
||||
* extra effort is that they are better.
|
||||
*/
|
||||
public interface IJpaIdHelperService extends IIdHelperService {
|
||||
public interface IJpaIdHelperService extends IIdHelperService<JpaPid> {
|
||||
|
||||
/**
|
||||
* @deprecated This method doesn't take a partition ID as input, so it is unsafe. It
|
||||
|
@ -77,7 +77,7 @@ public interface IJpaIdHelperService extends IIdHelperService {
|
|||
Long getPidOrThrowException(IIdType theId);
|
||||
|
||||
@Nonnull
|
||||
ResourcePersistentId getPidOrThrowException(@Nonnull IAnyResource theResource);
|
||||
JpaPid getPidOrThrowException(@Nonnull IAnyResource theResource);
|
||||
|
||||
IIdType resourceIdFromPidOrThrowException(Long thePid);
|
||||
|
||||
|
@ -92,6 +92,6 @@ public interface IJpaIdHelperService extends IIdHelperService {
|
|||
* @param thePids The Set of pids you would like to resolve to external FHIR Resource IDs.
|
||||
* @return A Set of strings representing the FHIR IDs of the pids.
|
||||
*/
|
||||
Set<String> translatePidsToFhirResourceIds(Set<ResourcePersistentId> thePids);
|
||||
Set<String> translatePidsToFhirResourceIds(Set<JpaPid> thePids);
|
||||
|
||||
}
|
||||
|
|
|
@ -26,12 +26,12 @@ import ca.uhn.fhir.interceptor.model.RequestPartitionId;
|
|||
import ca.uhn.fhir.jpa.api.config.DaoConfig;
|
||||
import ca.uhn.fhir.jpa.api.model.PersistentIdToForcedIdMap;
|
||||
import ca.uhn.fhir.jpa.api.svc.IIdHelperService;
|
||||
import ca.uhn.fhir.jpa.model.dao.JpaPid;
|
||||
import ca.uhn.fhir.jpa.dao.data.IForcedIdDao;
|
||||
import ca.uhn.fhir.jpa.dao.data.IResourceTableDao;
|
||||
import ca.uhn.fhir.jpa.model.config.PartitionSettings;
|
||||
import ca.uhn.fhir.jpa.model.cross.IResourceLookup;
|
||||
import ca.uhn.fhir.jpa.model.cross.ResourceLookup;
|
||||
import ca.uhn.fhir.jpa.model.dao.JpaPid;
|
||||
import ca.uhn.fhir.jpa.model.entity.ForcedId;
|
||||
import ca.uhn.fhir.jpa.model.entity.ResourceTable;
|
||||
import ca.uhn.fhir.jpa.search.builder.SearchBuilder;
|
||||
|
@ -99,7 +99,7 @@ import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
|||
* </p>
|
||||
*/
|
||||
@Service
|
||||
public class IdHelperService implements IIdHelperService {
|
||||
public class IdHelperService implements IIdHelperService<JpaPid> {
|
||||
public static final Predicate[] EMPTY_PREDICATE_ARRAY = new Predicate[0];
|
||||
public static final String RESOURCE_PID = "RESOURCE_PID";
|
||||
@Autowired
|
||||
|
@ -131,7 +131,7 @@ public class IdHelperService implements IIdHelperService {
|
|||
*/
|
||||
@Override
|
||||
@Nonnull
|
||||
public IResourceLookup resolveResourceIdentity(@Nonnull RequestPartitionId theRequestPartitionId, String theResourceType, String theResourceId) throws ResourceNotFoundException {
|
||||
public IResourceLookup<JpaPid> resolveResourceIdentity(@Nonnull RequestPartitionId theRequestPartitionId, String theResourceType, String theResourceId) throws ResourceNotFoundException {
|
||||
return resolveResourceIdentity(theRequestPartitionId, theResourceType, theResourceId, false);
|
||||
}
|
||||
|
||||
|
@ -144,12 +144,12 @@ public class IdHelperService implements IIdHelperService {
|
|||
*/
|
||||
@Override
|
||||
@Nonnull
|
||||
public IResourceLookup resolveResourceIdentity(@Nonnull RequestPartitionId theRequestPartitionId, String theResourceType, String theResourceId, boolean theExcludeDeleted) throws ResourceNotFoundException {
|
||||
public IResourceLookup<JpaPid> resolveResourceIdentity(@Nonnull RequestPartitionId theRequestPartitionId, String theResourceType, String theResourceId, boolean theExcludeDeleted) throws ResourceNotFoundException {
|
||||
assert myDontCheckActiveTransactionForUnitTest || TransactionSynchronizationManager.isSynchronizationActive();
|
||||
assert theRequestPartitionId != null;
|
||||
|
||||
IdDt id = new IdDt(theResourceType, theResourceId);
|
||||
Map<String, List<IResourceLookup>> matches = translateForcedIdToPids(theRequestPartitionId,
|
||||
Map<String, List<IResourceLookup<JpaPid>>> matches = translateForcedIdToPids(theRequestPartitionId,
|
||||
Collections.singletonList(id),
|
||||
theExcludeDeleted);
|
||||
|
||||
|
@ -177,7 +177,7 @@ public class IdHelperService implements IIdHelperService {
|
|||
*/
|
||||
@Override
|
||||
@Nonnull
|
||||
public Map<String, ResourcePersistentId> resolveResourcePersistentIds(@Nonnull RequestPartitionId theRequestPartitionId,
|
||||
public Map<String, JpaPid> resolveResourcePersistentIds(@Nonnull RequestPartitionId theRequestPartitionId,
|
||||
String theResourceType,
|
||||
List<String> theIds) {
|
||||
return resolveResourcePersistentIds(theRequestPartitionId, theResourceType, theIds, false);
|
||||
|
@ -190,7 +190,7 @@ public class IdHelperService implements IIdHelperService {
|
|||
*/
|
||||
@Override
|
||||
@Nonnull
|
||||
public Map<String, ResourcePersistentId> resolveResourcePersistentIds(@Nonnull RequestPartitionId theRequestPartitionId,
|
||||
public Map<String, JpaPid> resolveResourcePersistentIds(@Nonnull RequestPartitionId theRequestPartitionId,
|
||||
String theResourceType,
|
||||
List<String> theIds,
|
||||
boolean theExcludeDeleted) {
|
||||
|
@ -198,10 +198,10 @@ public class IdHelperService implements IIdHelperService {
|
|||
Validate.notNull(theIds, "theIds cannot be null");
|
||||
Validate.isTrue(!theIds.isEmpty(), "theIds must not be empty");
|
||||
|
||||
Map<String, ResourcePersistentId> retVals = new HashMap<>();
|
||||
Map<String, JpaPid> retVals = new HashMap<>();
|
||||
|
||||
for (String id : theIds) {
|
||||
ResourcePersistentId retVal;
|
||||
JpaPid retVal;
|
||||
if (!idRequiresForcedId(id)) {
|
||||
// is already a PID
|
||||
retVal = new JpaPid(Long.parseLong(id));
|
||||
|
@ -218,7 +218,7 @@ public class IdHelperService implements IIdHelperService {
|
|||
retVal = myMemoryCacheService.getThenPutAfterCommit(MemoryCacheService.CacheEnum.FORCED_ID_TO_PID, key, t -> {
|
||||
List<IIdType> ids = Collections.singletonList(new IdType(theResourceType, id));
|
||||
// fetches from cache using a function that checks cache first...
|
||||
List<ResourcePersistentId> resolvedIds = resolveResourcePersistentIdsWithCache(theRequestPartitionId, ids);
|
||||
List<JpaPid> resolvedIds = resolveResourcePersistentIdsWithCache(theRequestPartitionId, ids);
|
||||
if (resolvedIds.isEmpty()) {
|
||||
throw new ResourceNotFoundException(Msg.code(1100) + ids.get(0));
|
||||
}
|
||||
|
@ -239,7 +239,7 @@ public class IdHelperService implements IIdHelperService {
|
|||
*/
|
||||
@Override
|
||||
@Nonnull
|
||||
public ResourcePersistentId resolveResourcePersistentIds(@Nonnull RequestPartitionId theRequestPartitionId, String theResourceType, String theId) {
|
||||
public JpaPid resolveResourcePersistentIds(@Nonnull RequestPartitionId theRequestPartitionId, String theResourceType, String theId) {
|
||||
return resolveResourcePersistentIds(theRequestPartitionId, theResourceType, theId, false);
|
||||
}
|
||||
|
||||
|
@ -250,10 +250,10 @@ public class IdHelperService implements IIdHelperService {
|
|||
* @throws ResourceNotFoundException If the ID can not be found
|
||||
*/
|
||||
@Override
|
||||
public ResourcePersistentId resolveResourcePersistentIds(@Nonnull RequestPartitionId theRequestPartitionId, String theResourceType, String theId, boolean theExcludeDeleted){
|
||||
public JpaPid resolveResourcePersistentIds(@Nonnull RequestPartitionId theRequestPartitionId, String theResourceType, String theId, boolean theExcludeDeleted){
|
||||
Validate.notNull(theId, "theId must not be null");
|
||||
|
||||
Map<String, ResourcePersistentId> retVal = resolveResourcePersistentIds(theRequestPartitionId,
|
||||
Map<String, JpaPid> retVal = resolveResourcePersistentIds(theRequestPartitionId,
|
||||
theResourceType,
|
||||
Collections.singletonList(theId),
|
||||
theExcludeDeleted);
|
||||
|
@ -285,7 +285,7 @@ public class IdHelperService implements IIdHelperService {
|
|||
*/
|
||||
@Override
|
||||
@Nonnull
|
||||
public List<ResourcePersistentId> resolveResourcePersistentIdsWithCache(RequestPartitionId theRequestPartitionId, List<IIdType> theIds) {
|
||||
public List<JpaPid> resolveResourcePersistentIdsWithCache(RequestPartitionId theRequestPartitionId, List<IIdType> theIds) {
|
||||
boolean onlyForcedIds = false;
|
||||
return resolveResourcePersistentIdsWithCache(theRequestPartitionId, theIds, onlyForcedIds);
|
||||
}
|
||||
|
@ -300,10 +300,10 @@ public class IdHelperService implements IIdHelperService {
|
|||
*/
|
||||
@Override
|
||||
@Nonnull
|
||||
public List<ResourcePersistentId> resolveResourcePersistentIdsWithCache(RequestPartitionId theRequestPartitionId, List<IIdType> theIds, boolean theOnlyForcedIds) {
|
||||
public List<JpaPid> resolveResourcePersistentIdsWithCache(RequestPartitionId theRequestPartitionId, List<IIdType> theIds, boolean theOnlyForcedIds) {
|
||||
assert myDontCheckActiveTransactionForUnitTest || TransactionSynchronizationManager.isSynchronizationActive();
|
||||
|
||||
List<ResourcePersistentId> retVal = new ArrayList<>(theIds.size());
|
||||
List<JpaPid> retVal = new ArrayList<>(theIds.size());
|
||||
|
||||
for (IIdType id : theIds) {
|
||||
if (!id.hasIdPart()) {
|
||||
|
@ -317,14 +317,16 @@ public class IdHelperService implements IIdHelperService {
|
|||
if (myDaoConfig.getResourceClientIdStrategy() != DaoConfig.ClientIdStrategyEnum.ANY) {
|
||||
if (nextId.isIdPartValidLong()) {
|
||||
if (!theOnlyForcedIds) {
|
||||
retVal.add(new JpaPid(nextId.getIdPartAsLong()).setAssociatedResourceId(nextId));
|
||||
JpaPid jpaPid = new JpaPid(nextId.getIdPartAsLong());
|
||||
jpaPid.setAssociatedResourceId(nextId);
|
||||
retVal.add(jpaPid);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
String key = toForcedIdToPidKey(theRequestPartitionId, nextId.getResourceType(), nextId.getIdPart());
|
||||
ResourcePersistentId cachedId = myMemoryCacheService.getIfPresent(MemoryCacheService.CacheEnum.FORCED_ID_TO_PID, key);
|
||||
JpaPid cachedId = myMemoryCacheService.getIfPresent(MemoryCacheService.CacheEnum.FORCED_ID_TO_PID, key);
|
||||
if (cachedId != null) {
|
||||
retVal.add(cachedId);
|
||||
continue;
|
||||
|
@ -338,7 +340,7 @@ public class IdHelperService implements IIdHelperService {
|
|||
return retVal;
|
||||
}
|
||||
|
||||
private void doResolvePersistentIds(RequestPartitionId theRequestPartitionId, List<IIdType> theIds, List<ResourcePersistentId> theOutputListToPopulate) {
|
||||
private void doResolvePersistentIds(RequestPartitionId theRequestPartitionId, List<IIdType> theIds, List<JpaPid> theOutputListToPopulate) {
|
||||
CriteriaBuilder cb = myEntityManager.getCriteriaBuilder();
|
||||
CriteriaQuery<ForcedId> criteriaQuery = cb.createQuery(ForcedId.class);
|
||||
Root<ForcedId> from = criteriaQuery.from(ForcedId.class);
|
||||
|
@ -413,7 +415,7 @@ public class IdHelperService implements IIdHelperService {
|
|||
*/
|
||||
@Nonnull
|
||||
@Override
|
||||
public IIdType translatePidIdToForcedId(FhirContext theCtx, String theResourceType, ResourcePersistentId theId) {
|
||||
public IIdType translatePidIdToForcedId(FhirContext theCtx, String theResourceType, JpaPid theId) {
|
||||
if (theId.getAssociatedResourceId() != null) {
|
||||
return theId.getAssociatedResourceId();
|
||||
}
|
||||
|
@ -431,8 +433,8 @@ public class IdHelperService implements IIdHelperService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Optional<String> translatePidIdToForcedIdWithCache(ResourcePersistentId theId) {
|
||||
return myMemoryCacheService.get(MemoryCacheService.CacheEnum.PID_TO_FORCED_ID, ((JpaPid) theId).getId(), pid -> myForcedIdDao.findByResourcePid(pid).map(ForcedId::asTypedFhirResourceId));
|
||||
public Optional<String> translatePidIdToForcedIdWithCache(JpaPid theId) {
|
||||
return myMemoryCacheService.get(MemoryCacheService.CacheEnum.PID_TO_FORCED_ID, theId.getId(), pid -> myForcedIdDao.findByResourcePid(pid).map(ForcedId::asTypedFhirResourceId));
|
||||
}
|
||||
|
||||
private ListMultimap<String, String> organizeIdsByResourceType(Collection<IIdType> theIds) {
|
||||
|
@ -449,7 +451,7 @@ public class IdHelperService implements IIdHelperService {
|
|||
return typeToIds;
|
||||
}
|
||||
|
||||
private Map<String, List<IResourceLookup>> translateForcedIdToPids(@Nonnull RequestPartitionId theRequestPartitionId, Collection<IIdType> theId, boolean theExcludeDeleted) {
|
||||
private Map<String, List<IResourceLookup<JpaPid>>> translateForcedIdToPids(@Nonnull RequestPartitionId theRequestPartitionId, Collection<IIdType> theId, boolean theExcludeDeleted) {
|
||||
assert theRequestPartitionId != null;
|
||||
|
||||
theId.forEach(id -> Validate.isTrue(id.hasIdPart()));
|
||||
|
@ -458,7 +460,7 @@ public class IdHelperService implements IIdHelperService {
|
|||
return new HashMap<>();
|
||||
}
|
||||
|
||||
Map<String, List<IResourceLookup>> retVal = new HashMap<>();
|
||||
Map<String, List<IResourceLookup<JpaPid>>> retVal = new HashMap<>();
|
||||
RequestPartitionId requestPartitionId = replaceDefault(theRequestPartitionId);
|
||||
|
||||
if (myDaoConfig.getResourceClientIdStrategy() != DaoConfig.ClientIdStrategyEnum.ANY) {
|
||||
|
@ -547,7 +549,7 @@ public class IdHelperService implements IIdHelperService {
|
|||
return theRequestPartitionId;
|
||||
}
|
||||
|
||||
private void resolvePids(@Nonnull RequestPartitionId theRequestPartitionId, List<Long> thePidsToResolve, Map<String, List<IResourceLookup>> theTargets) {
|
||||
private void resolvePids(@Nonnull RequestPartitionId theRequestPartitionId, List<Long> thePidsToResolve, Map<String, List<IResourceLookup<JpaPid>>> theTargets) {
|
||||
if (!myDaoConfig.isDeleteEnabled()) {
|
||||
for (Iterator<Long> forcedIdIterator = thePidsToResolve.iterator(); forcedIdIterator.hasNext(); ) {
|
||||
Long nextPid = forcedIdIterator.next();
|
||||
|
@ -595,7 +597,7 @@ public class IdHelperService implements IIdHelperService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public PersistentIdToForcedIdMap translatePidsToForcedIds(Set<ResourcePersistentId> theResourceIds) {
|
||||
public PersistentIdToForcedIdMap translatePidsToForcedIds(Set<JpaPid> theResourceIds) {
|
||||
assert myDontCheckActiveTransactionForUnitTest || TransactionSynchronizationManager.isSynchronizationActive();
|
||||
Set<Long> thePids = theResourceIds.stream().map(t -> ((JpaPid) t).getId()).collect(Collectors.toSet());
|
||||
Map<Long, Optional<String>> retVal = new HashMap<>(myMemoryCacheService.getAllPresent(MemoryCacheService.CacheEnum.PID_TO_FORCED_ID, thePids));
|
||||
|
@ -637,7 +639,7 @@ public class IdHelperService implements IIdHelperService {
|
|||
* Pre-cache a PID-to-Resource-ID mapping for later retrieval by {@link #translatePidsToForcedIds(Set)} and related methods
|
||||
*/
|
||||
@Override
|
||||
public void addResolvedPidToForcedId(ResourcePersistentId theResourcePersistentId, @Nonnull RequestPartitionId theRequestPartitionId, String theResourceType, @Nullable String theForcedId, @Nullable Date theDeletedAt) {
|
||||
public void addResolvedPidToForcedId(JpaPid theResourcePersistentId, @Nonnull RequestPartitionId theRequestPartitionId, String theResourceType, @Nullable String theForcedId, @Nullable Date theDeletedAt) {
|
||||
JpaPid jpaPid = (JpaPid) theResourcePersistentId;
|
||||
if (theForcedId != null) {
|
||||
if (theResourcePersistentId.getAssociatedResourceId() == null) {
|
||||
|
@ -679,14 +681,14 @@ public class IdHelperService implements IIdHelperService {
|
|||
|
||||
@Override
|
||||
@Nonnull
|
||||
public List<ResourcePersistentId> getPidsOrThrowException(@Nonnull RequestPartitionId theRequestPartitionId, List<IIdType> theIds) {
|
||||
List<ResourcePersistentId> resourcePersistentIds = resolveResourcePersistentIdsWithCache(theRequestPartitionId, theIds);
|
||||
public List<JpaPid> getPidsOrThrowException(@Nonnull RequestPartitionId theRequestPartitionId, List<IIdType> theIds) {
|
||||
List<JpaPid> resourcePersistentIds = resolveResourcePersistentIdsWithCache(theRequestPartitionId, theIds);
|
||||
return resourcePersistentIds;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ResourcePersistentId getPidOrNull(@Nonnull RequestPartitionId theRequestPartitionId, IBaseResource theResource) {
|
||||
public JpaPid getPidOrNull(@Nonnull RequestPartitionId theRequestPartitionId, IBaseResource theResource) {
|
||||
Object resourceId = theResource.getUserData(RESOURCE_PID);
|
||||
JpaPid retVal;
|
||||
if (resourceId == null) {
|
||||
|
@ -704,15 +706,15 @@ public class IdHelperService implements IIdHelperService {
|
|||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ResourcePersistentId getPidOrThrowException(@Nonnull RequestPartitionId theRequestPartitionId, IIdType theId) {
|
||||
public JpaPid getPidOrThrowException(@Nonnull RequestPartitionId theRequestPartitionId, IIdType theId) {
|
||||
List<IIdType> ids = Collections.singletonList(theId);
|
||||
List<ResourcePersistentId> resourcePersistentIds = resolveResourcePersistentIdsWithCache(theRequestPartitionId, ids);
|
||||
List<JpaPid> resourcePersistentIds = resolveResourcePersistentIdsWithCache(theRequestPartitionId, ids);
|
||||
return resourcePersistentIds.get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ResourcePersistentId getPidOrThrowException(@Nonnull IAnyResource theResource) {
|
||||
public JpaPid getPidOrThrowException(@Nonnull IAnyResource theResource) {
|
||||
Long theResourcePID = (Long) theResource.getUserData(RESOURCE_PID);
|
||||
if (theResourcePID == null) {
|
||||
throw new IllegalStateException(Msg.code(2108) + String.format("Unable to find %s in the user data for %s with ID %s", RESOURCE_PID, theResource, theResource.getId()));
|
||||
|
@ -721,7 +723,7 @@ public class IdHelperService implements IIdHelperService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public IIdType resourceIdFromPidOrThrowException(ResourcePersistentId thePid, String theResourceType) {
|
||||
public IIdType resourceIdFromPidOrThrowException(JpaPid thePid, String theResourceType) {
|
||||
Optional<ResourceTable> optionalResource = myResourceTableDao.findById(((JpaPid) thePid).getId());
|
||||
if (!optionalResource.isPresent()) {
|
||||
throw new ResourceNotFoundException(Msg.code(2124) + "Requested resource not found");
|
||||
|
@ -741,7 +743,7 @@ public class IdHelperService implements IIdHelperService {
|
|||
* @return A Set of strings representing the FHIR IDs of the pids.
|
||||
*/
|
||||
@Override
|
||||
public Set<String> translatePidsToFhirResourceIds(Set<ResourcePersistentId> thePids) {
|
||||
public Set<String> translatePidsToFhirResourceIds(Set<JpaPid> thePids) {
|
||||
assert TransactionSynchronizationManager.isSynchronizationActive();
|
||||
|
||||
PersistentIdToForcedIdMap pidToForcedIdMap = translatePidsToForcedIds(thePids);
|
||||
|
|
|
@ -23,11 +23,9 @@ package ca.uhn.fhir.jpa.dao.index;
|
|||
import ca.uhn.fhir.i18n.Msg;
|
||||
import ca.uhn.fhir.interceptor.model.RequestPartitionId;
|
||||
import ca.uhn.fhir.jpa.api.model.PersistentIdToForcedIdMap;
|
||||
import ca.uhn.fhir.jpa.api.svc.IIdHelperService;
|
||||
import ca.uhn.fhir.jpa.model.dao.JpaPid;
|
||||
import ca.uhn.fhir.jpa.dao.data.IResourceTableDao;
|
||||
import ca.uhn.fhir.jpa.model.dao.JpaPid;
|
||||
import ca.uhn.fhir.jpa.model.entity.ResourceTable;
|
||||
import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId;
|
||||
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
||||
import org.hl7.fhir.instance.model.api.IAnyResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
@ -46,7 +44,7 @@ import java.util.stream.Collectors;
|
|||
/**
|
||||
* See {@link IJpaIdHelperService} for an explanation of this class.
|
||||
*/
|
||||
public class JpaIdHelperService extends IdHelperService implements IJpaIdHelperService, IIdHelperService {
|
||||
public class JpaIdHelperService extends IdHelperService implements IJpaIdHelperService {
|
||||
@Autowired
|
||||
protected IResourceTableDao myResourceTableDao;
|
||||
|
||||
|
@ -107,7 +105,7 @@ public class JpaIdHelperService extends IdHelperService implements IJpaIdHelperS
|
|||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ResourcePersistentId getPidOrThrowException(@Nonnull IAnyResource theResource) {
|
||||
public JpaPid getPidOrThrowException(@Nonnull IAnyResource theResource) {
|
||||
Long retVal = (Long) theResource.getUserData(RESOURCE_PID);
|
||||
if (retVal == null) {
|
||||
throw new IllegalStateException(Msg.code(1102) + String.format("Unable to find %s in the user data for %s with ID %s", RESOURCE_PID, theResource, theResource.getId())
|
||||
|
@ -137,7 +135,7 @@ public class JpaIdHelperService extends IdHelperService implements IJpaIdHelperS
|
|||
* @return A Set of strings representing the FHIR IDs of the pids.
|
||||
*/
|
||||
@Override
|
||||
public Set<String> translatePidsToFhirResourceIds(Set<ResourcePersistentId> thePids) {
|
||||
public Set<String> translatePidsToFhirResourceIds(Set<JpaPid> thePids) {
|
||||
assert TransactionSynchronizationManager.isSynchronizationActive();
|
||||
|
||||
PersistentIdToForcedIdMap pidToForcedIdMap = super.translatePidsToForcedIds(thePids);
|
||||
|
|
|
@ -30,11 +30,11 @@ import ca.uhn.fhir.jpa.api.config.DaoConfig;
|
|||
import ca.uhn.fhir.jpa.api.svc.IIdHelperService;
|
||||
import ca.uhn.fhir.jpa.dao.BaseHapiFhirDao;
|
||||
import ca.uhn.fhir.jpa.dao.BaseStorageDao;
|
||||
import ca.uhn.fhir.jpa.model.dao.JpaPid;
|
||||
import ca.uhn.fhir.jpa.dao.MatchResourceUrlService;
|
||||
import ca.uhn.fhir.jpa.dao.data.IResourceIndexedComboStringUniqueDao;
|
||||
import ca.uhn.fhir.jpa.model.config.PartitionSettings;
|
||||
import ca.uhn.fhir.jpa.model.cross.IBasePersistedResource;
|
||||
import ca.uhn.fhir.jpa.model.dao.JpaPid;
|
||||
import ca.uhn.fhir.jpa.model.entity.BaseResourceIndexedSearchParam;
|
||||
import ca.uhn.fhir.jpa.model.entity.ResourceIndexedComboStringUnique;
|
||||
import ca.uhn.fhir.jpa.model.entity.ResourceIndexedComboTokenNonUnique;
|
||||
|
@ -88,13 +88,13 @@ public class SearchParamWithInlineReferencesExtractor {
|
|||
@PersistenceContext(type = PersistenceContextType.TRANSACTION)
|
||||
protected EntityManager myEntityManager;
|
||||
@Autowired
|
||||
private MatchResourceUrlService myMatchResourceUrlService;
|
||||
private MatchResourceUrlService<JpaPid> myMatchResourceUrlService;
|
||||
@Autowired
|
||||
private DaoConfig myDaoConfig;
|
||||
@Autowired
|
||||
private FhirContext myContext;
|
||||
@Autowired
|
||||
private IIdHelperService myIdHelperService;
|
||||
private IIdHelperService<JpaPid> myIdHelperService;
|
||||
@Autowired
|
||||
private ISearchParamRegistry mySearchParamRegistry;
|
||||
@Autowired
|
||||
|
|
|
@ -23,12 +23,11 @@ package ca.uhn.fhir.jpa.delete.batch2;
|
|||
import ca.uhn.fhir.i18n.Msg;
|
||||
import ca.uhn.fhir.jpa.api.config.DaoConfig;
|
||||
import ca.uhn.fhir.jpa.api.svc.IIdHelperService;
|
||||
import ca.uhn.fhir.jpa.model.dao.JpaPid;
|
||||
import ca.uhn.fhir.jpa.dao.data.IResourceLinkDao;
|
||||
import ca.uhn.fhir.jpa.dao.expunge.ResourceForeignKey;
|
||||
import ca.uhn.fhir.jpa.dao.expunge.ResourceTableFKProvider;
|
||||
import ca.uhn.fhir.jpa.model.dao.JpaPid;
|
||||
import ca.uhn.fhir.jpa.model.entity.ResourceLink;
|
||||
import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -58,8 +57,8 @@ public class DeleteExpungeSqlBuilder {
|
|||
|
||||
|
||||
@Nonnull
|
||||
List<String> convertPidsToDeleteExpungeSql(List<ResourcePersistentId> thePersistentIds) {
|
||||
List<Long> pids = JpaPid.toLongList(thePersistentIds);
|
||||
List<String> convertPidsToDeleteExpungeSql(List<JpaPid> theJpaPids) {
|
||||
List<Long> pids = JpaPid.toLongList(theJpaPids);
|
||||
|
||||
validateOkToDeleteAndExpunge(pids);
|
||||
|
||||
|
@ -84,7 +83,7 @@ public class DeleteExpungeSqlBuilder {
|
|||
return;
|
||||
}
|
||||
|
||||
List<ResourcePersistentId> targetPidsAsResourceIds = JpaPid.fromLongList(thePids);
|
||||
List<JpaPid> targetPidsAsResourceIds = JpaPid.fromLongList(thePids);
|
||||
List<ResourceLink> conflictResourceLinks = Collections.synchronizedList(new ArrayList<>());
|
||||
findResourceLinksWithTargetPidIn(targetPidsAsResourceIds, targetPidsAsResourceIds, conflictResourceLinks);
|
||||
|
||||
|
@ -104,7 +103,7 @@ public class DeleteExpungeSqlBuilder {
|
|||
targetResourceId + " because " + sourceResourceId + " refers to it via the path " + firstConflict.getSourcePath());
|
||||
}
|
||||
|
||||
public void findResourceLinksWithTargetPidIn(List<ResourcePersistentId> theAllTargetPids, List<ResourcePersistentId> theSomeTargetPids, List<ResourceLink> theConflictResourceLinks) {
|
||||
public void findResourceLinksWithTargetPidIn(List<JpaPid> theAllTargetPids, List<JpaPid> theSomeTargetPids, List<ResourceLink> theConflictResourceLinks) {
|
||||
List<Long> allTargetPidsAsLongs = JpaPid.toLongList(theAllTargetPids);
|
||||
List<Long> someTargetPidsAsLongs = JpaPid.toLongList(theSomeTargetPids);
|
||||
// We only need to find one conflict, so if we found one already in an earlier partition run, we can skip the rest of the searches
|
||||
|
|
|
@ -50,8 +50,8 @@ public class DeleteExpungeSvcImpl implements IDeleteExpungeSvc {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void deleteExpunge(List<ResourcePersistentId> thePersistentIds) {
|
||||
List<String> sqlList = myDeleteExpungeSqlBuilder.convertPidsToDeleteExpungeSql(thePersistentIds);
|
||||
public void deleteExpunge(List<JpaPid> theJpaPids) {
|
||||
List<String> sqlList = myDeleteExpungeSqlBuilder.convertPidsToDeleteExpungeSql(theJpaPids);
|
||||
|
||||
ourLog.debug("Executing {} delete expunge sql commands", sqlList.size());
|
||||
long totalDeleted = 0;
|
||||
|
@ -61,7 +61,7 @@ public class DeleteExpungeSvcImpl implements IDeleteExpungeSvc {
|
|||
}
|
||||
|
||||
ourLog.info("{} records deleted", totalDeleted);
|
||||
clearHibernateSearchIndex(thePersistentIds);
|
||||
clearHibernateSearchIndex(theJpaPids);
|
||||
|
||||
// TODO KHS instead of logging progress, produce result chunks that get aggregated into a delete expunge report
|
||||
}
|
||||
|
@ -70,10 +70,10 @@ public class DeleteExpungeSvcImpl implements IDeleteExpungeSvc {
|
|||
* If we are running with HS enabled, the expunge operation will cause dangling documents because Hibernate Search is not aware of custom SQL queries that delete resources.
|
||||
* This method clears the Hibernate Search index for the given resources.
|
||||
*/
|
||||
private void clearHibernateSearchIndex(List<ResourcePersistentId> thePersistentIds) {
|
||||
private void clearHibernateSearchIndex(List<JpaPid> thePersistentIds) {
|
||||
if (myFullTextSearchSvc != null) {
|
||||
//TODO KM Changing the class looks insignificant, since everything is then again converted from Long to Object, is there anything else that needs to be changed?
|
||||
List<Object> objectIds = thePersistentIds.stream().map(id -> ((JpaPid) id).getId()).collect(Collectors.toList());
|
||||
List<Object> objectIds = thePersistentIds.stream().map(ResourcePersistentId::getId).collect(Collectors.toList());
|
||||
myFullTextSearchSvc.deleteIndexedDocumentsByTypeAndId(ResourceTable.class, objectIds);
|
||||
ourLog.info("Cleared Hibernate Search indexes.");
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ package ca.uhn.fhir.jpa.interceptor;
|
|||
*/
|
||||
|
||||
import ca.uhn.fhir.jpa.dao.ISearchBuilder;
|
||||
import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId;
|
||||
import ca.uhn.fhir.jpa.model.dao.JpaPid;
|
||||
import ca.uhn.fhir.rest.api.server.IPreResourceAccessDetails;
|
||||
import ca.uhn.fhir.util.ICallable;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
@ -37,12 +37,12 @@ import java.util.List;
|
|||
@NotThreadSafe
|
||||
public class JpaPreResourceAccessDetails implements IPreResourceAccessDetails {
|
||||
|
||||
private final List<ResourcePersistentId> myResourcePids;
|
||||
private final List<JpaPid> myResourcePids;
|
||||
private final boolean[] myBlocked;
|
||||
private final ICallable<ISearchBuilder> mySearchBuilderSupplier;
|
||||
private List<IBaseResource> myResources;
|
||||
|
||||
public JpaPreResourceAccessDetails(List<ResourcePersistentId> theResourcePids, ICallable<ISearchBuilder> theSearchBuilderSupplier) {
|
||||
public JpaPreResourceAccessDetails(List<JpaPid> theResourcePids, ICallable<ISearchBuilder> theSearchBuilderSupplier) {
|
||||
myResourcePids = theResourcePids;
|
||||
myBlocked = new boolean[myResourcePids.size()];
|
||||
mySearchBuilderSupplier = theSearchBuilderSupplier;
|
||||
|
|
|
@ -36,6 +36,7 @@ import ca.uhn.fhir.jpa.dao.ISearchBuilder;
|
|||
import ca.uhn.fhir.jpa.dao.SearchBuilderFactory;
|
||||
import ca.uhn.fhir.jpa.entity.Search;
|
||||
import ca.uhn.fhir.jpa.entity.SearchTypeEnum;
|
||||
import ca.uhn.fhir.jpa.model.dao.JpaPid;
|
||||
import ca.uhn.fhir.jpa.model.entity.BaseHasResource;
|
||||
import ca.uhn.fhir.jpa.model.entity.ResourceHistoryTable;
|
||||
import ca.uhn.fhir.jpa.partition.RequestPartitionHelperSvc;
|
||||
|
@ -50,7 +51,6 @@ import ca.uhn.fhir.rest.api.server.IPreResourceShowDetails;
|
|||
import ca.uhn.fhir.rest.api.server.RequestDetails;
|
||||
import ca.uhn.fhir.rest.api.server.SimplePreResourceAccessDetails;
|
||||
import ca.uhn.fhir.rest.api.server.SimplePreResourceShowDetails;
|
||||
import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId;
|
||||
import ca.uhn.fhir.rest.server.interceptor.ServerInterceptorUtil;
|
||||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||
import ca.uhn.fhir.rest.server.util.CompositeInterceptorBroadcaster;
|
||||
|
@ -90,7 +90,7 @@ public class PersistedJpaBundleProvider implements IBundleProvider {
|
|||
@Autowired
|
||||
private IInterceptorBroadcaster myInterceptorBroadcaster;
|
||||
@Autowired
|
||||
private SearchBuilderFactory mySearchBuilderFactory;
|
||||
private SearchBuilderFactory<JpaPid> mySearchBuilderFactory;
|
||||
@Autowired
|
||||
private HistoryBuilderFactory myHistoryBuilderFactory;
|
||||
@Autowired
|
||||
|
@ -98,7 +98,7 @@ public class PersistedJpaBundleProvider implements IBundleProvider {
|
|||
@Autowired
|
||||
private FhirContext myContext;
|
||||
@Autowired
|
||||
private ISearchCoordinatorSvc mySearchCoordinatorSvc;
|
||||
private ISearchCoordinatorSvc<JpaPid> mySearchCoordinatorSvc;
|
||||
@Autowired
|
||||
private ISearchCacheSvc mySearchCacheSvc;
|
||||
@Autowired
|
||||
|
@ -135,18 +135,6 @@ public class PersistedJpaBundleProvider implements IBundleProvider {
|
|||
mySearchEntity = theSearch;
|
||||
}
|
||||
|
||||
/**
|
||||
* When HAPI FHIR server is running "for real", a new
|
||||
* instance of the bundle provider is created to serve
|
||||
* every HTTP request, so it's ok for us to keep
|
||||
* state in here and expect that it will go away. But
|
||||
* in unit tests we keep this object around for longer
|
||||
* sometimes.
|
||||
*/
|
||||
public void clearCachedDataForUnitTest() {
|
||||
mySearchEntity = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform a history search
|
||||
*/
|
||||
|
@ -224,7 +212,7 @@ public class PersistedJpaBundleProvider implements IBundleProvider {
|
|||
|
||||
final ISearchBuilder sb = mySearchBuilderFactory.newSearchBuilder(dao, resourceName, resourceType);
|
||||
|
||||
final List<ResourcePersistentId> pidsSubList = mySearchCoordinatorSvc.getResources(myUuid, theFromIndex, theToIndex, myRequest);
|
||||
final List<JpaPid> pidsSubList = mySearchCoordinatorSvc.getResources(myUuid, theFromIndex, theToIndex, myRequest);
|
||||
|
||||
TransactionTemplate template = new TransactionTemplate(myTxManager);
|
||||
template.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
|
||||
|
@ -412,14 +400,14 @@ public class PersistedJpaBundleProvider implements IBundleProvider {
|
|||
|
||||
// Note: Leave as protected, HSPC depends on this
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
protected List<IBaseResource> toResourceList(ISearchBuilder theSearchBuilder, List<ResourcePersistentId> thePids) {
|
||||
protected List<IBaseResource> toResourceList(ISearchBuilder theSearchBuilder, List<JpaPid> thePids) {
|
||||
|
||||
List<ResourcePersistentId> includedPidList = new ArrayList<>();
|
||||
List<JpaPid> includedPidList = new ArrayList<>();
|
||||
if (mySearchEntity.getSearchType() == SearchTypeEnum.SEARCH) {
|
||||
Integer maxIncludes = myDaoConfig.getMaximumIncludesToLoadPerPage();
|
||||
|
||||
// Load _revincludes
|
||||
Set<ResourcePersistentId> includedPids = theSearchBuilder.loadIncludes(myContext, myEntityManager, thePids, mySearchEntity.toRevIncludesList(), true, mySearchEntity.getLastUpdated(), myUuid, myRequest, maxIncludes);
|
||||
Set<JpaPid> includedPids = theSearchBuilder.loadIncludes(myContext, myEntityManager, thePids, mySearchEntity.toRevIncludesList(), true, mySearchEntity.getLastUpdated(), myUuid, myRequest, maxIncludes);
|
||||
if (maxIncludes != null) {
|
||||
maxIncludes -= includedPids.size();
|
||||
}
|
||||
|
@ -427,7 +415,7 @@ public class PersistedJpaBundleProvider implements IBundleProvider {
|
|||
includedPidList.addAll(includedPids);
|
||||
|
||||
// Load _includes
|
||||
Set<ResourcePersistentId> revIncludedPids = theSearchBuilder.loadIncludes(myContext, myEntityManager, thePids, mySearchEntity.toIncludesList(), false, mySearchEntity.getLastUpdated(), myUuid, myRequest, maxIncludes);
|
||||
Set<JpaPid> revIncludedPids = theSearchBuilder.loadIncludes(myContext, myEntityManager, thePids, mySearchEntity.toIncludesList(), false, mySearchEntity.getLastUpdated(), myUuid, myRequest, maxIncludes);
|
||||
thePids.addAll(revIncludedPids);
|
||||
includedPidList.addAll(revIncludedPids);
|
||||
|
||||
|
|
|
@ -22,10 +22,10 @@ package ca.uhn.fhir.jpa.search;
|
|||
|
||||
import ca.uhn.fhir.jpa.dao.ISearchBuilder;
|
||||
import ca.uhn.fhir.jpa.entity.Search;
|
||||
import ca.uhn.fhir.jpa.util.QueryParameterUtils;
|
||||
import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId;
|
||||
import ca.uhn.fhir.jpa.model.dao.JpaPid;
|
||||
import ca.uhn.fhir.jpa.model.search.SearchStatusEnum;
|
||||
import ca.uhn.fhir.jpa.search.builder.tasks.SearchTask;
|
||||
import ca.uhn.fhir.jpa.util.QueryParameterUtils;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum;
|
||||
import ca.uhn.fhir.model.valueset.BundleEntrySearchModeEnum;
|
||||
|
@ -67,7 +67,7 @@ public class PersistedJpaSearchFirstPageBundleProvider extends PersistedJpaBundl
|
|||
mySearchTask.awaitInitialSync();
|
||||
|
||||
ourLog.trace("Fetching search resource PIDs from task: {}", mySearchTask.getClass());
|
||||
final List<ResourcePersistentId> pids = mySearchTask.getResourcePids(theFromIndex, theToIndex);
|
||||
final List<JpaPid> pids = mySearchTask.getResourcePids(theFromIndex, theToIndex);
|
||||
ourLog.trace("Done fetching search resource PIDs");
|
||||
|
||||
TransactionTemplate txTemplate = new TransactionTemplate(myTxManager);
|
||||
|
|
|
@ -37,6 +37,7 @@ import ca.uhn.fhir.jpa.dao.ISearchBuilder;
|
|||
import ca.uhn.fhir.jpa.dao.SearchBuilderFactory;
|
||||
import ca.uhn.fhir.jpa.dao.search.ResourceNotFoundInIndexException;
|
||||
import ca.uhn.fhir.jpa.entity.Search;
|
||||
import ca.uhn.fhir.jpa.model.dao.JpaPid;
|
||||
import ca.uhn.fhir.jpa.model.search.SearchStatusEnum;
|
||||
import ca.uhn.fhir.jpa.partition.IRequestPartitionHelperSvc;
|
||||
import ca.uhn.fhir.jpa.search.builder.StorageInterceptorHooksFacade;
|
||||
|
@ -55,7 +56,6 @@ import ca.uhn.fhir.rest.api.RestSearchParameterTypeEnum;
|
|||
import ca.uhn.fhir.rest.api.SearchTotalModeEnum;
|
||||
import ca.uhn.fhir.rest.api.server.IBundleProvider;
|
||||
import ca.uhn.fhir.rest.api.server.RequestDetails;
|
||||
import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||
|
@ -96,7 +96,7 @@ import static org.apache.commons.lang3.StringUtils.isBlank;
|
|||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||
|
||||
@Component("mySearchCoordinatorSvc")
|
||||
public class SearchCoordinatorSvcImpl implements ISearchCoordinatorSvc {
|
||||
public class SearchCoordinatorSvcImpl implements ISearchCoordinatorSvc<JpaPid> {
|
||||
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(SearchCoordinatorSvcImpl.class);
|
||||
|
||||
|
@ -107,7 +107,7 @@ public class SearchCoordinatorSvcImpl implements ISearchCoordinatorSvc {
|
|||
private final ISearchCacheSvc mySearchCacheSvc;
|
||||
private final ISearchResultCacheSvc mySearchResultCacheSvc;
|
||||
private final DaoRegistry myDaoRegistry;
|
||||
private final SearchBuilderFactory mySearchBuilderFactory;
|
||||
private final SearchBuilderFactory<JpaPid> mySearchBuilderFactory;
|
||||
private final ISynchronousSearchSvc mySynchronousSearchSvc;
|
||||
private final PersistedJpaBundleProviderFactory myPersistedJpaBundleProviderFactory;
|
||||
private final IRequestPartitionHelperSvc myRequestPartitionHelperService;
|
||||
|
@ -124,9 +124,7 @@ public class SearchCoordinatorSvcImpl implements ISearchCoordinatorSvc {
|
|||
|
||||
private final ConcurrentHashMap<String, SearchTask> myIdToSearchTask = new ConcurrentHashMap<>();
|
||||
|
||||
private final Consumer<String> myOnRemoveSearchTask = (theId) -> {
|
||||
myIdToSearchTask.remove(theId);
|
||||
};
|
||||
private final Consumer<String> myOnRemoveSearchTask = (theId) -> myIdToSearchTask.remove(theId);
|
||||
|
||||
private final StorageInterceptorHooksFacade myStorageInterceptorHooks;
|
||||
|
||||
|
@ -141,7 +139,7 @@ public class SearchCoordinatorSvcImpl implements ISearchCoordinatorSvc {
|
|||
ISearchCacheSvc theSearchCacheSvc,
|
||||
ISearchResultCacheSvc theSearchResultCacheSvc,
|
||||
DaoRegistry theDaoRegistry,
|
||||
SearchBuilderFactory theSearchBuilderFactory,
|
||||
SearchBuilderFactory<JpaPid> theSearchBuilderFactory,
|
||||
ISynchronousSearchSvc theSynchronousSearchSvc,
|
||||
PersistedJpaBundleProviderFactory thePersistedJpaBundleProviderFactory,
|
||||
IRequestPartitionHelperSvc theRequestPartitionHelperService,
|
||||
|
@ -211,7 +209,7 @@ public class SearchCoordinatorSvcImpl implements ISearchCoordinatorSvc {
|
|||
*/
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.NEVER)
|
||||
public List<ResourcePersistentId> getResources(final String theUuid, int theFrom, int theTo, @Nullable RequestDetails theRequestDetails) {
|
||||
public List<JpaPid> getResources(final String theUuid, int theFrom, int theTo, @Nullable RequestDetails theRequestDetails) {
|
||||
TransactionTemplate txTemplate = new TransactionTemplate(myManagedTxManager);
|
||||
txTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
|
||||
|
||||
|
@ -231,7 +229,7 @@ public class SearchCoordinatorSvcImpl implements ISearchCoordinatorSvc {
|
|||
if (myNeverUseLocalSearchForUnitTests == false) {
|
||||
if (searchTask != null) {
|
||||
ourLog.trace("Local search found");
|
||||
List<ResourcePersistentId> resourcePids = searchTask.getResourcePids(theFrom, theTo);
|
||||
List<JpaPid> resourcePids = searchTask.getResourcePids(theFrom, theTo);
|
||||
ourLog.trace("Local search returned {} pids, wanted {}-{} - Search: {}", resourcePids.size(), theFrom, theTo, searchTask.getSearch());
|
||||
|
||||
/*
|
||||
|
@ -301,7 +299,7 @@ public class SearchCoordinatorSvcImpl implements ISearchCoordinatorSvc {
|
|||
|
||||
ourLog.trace("Finished looping");
|
||||
|
||||
List<ResourcePersistentId> pids = mySearchResultCacheSvc.fetchResultPids(search, theFrom, theTo);
|
||||
List<JpaPid> pids = mySearchResultCacheSvc.fetchResultPids(search, theFrom, theTo);
|
||||
if (pids == null) {
|
||||
throw myExceptionSvc.newUnknownSearchException(theUuid);
|
||||
}
|
||||
|
@ -326,7 +324,7 @@ public class SearchCoordinatorSvcImpl implements ISearchCoordinatorSvc {
|
|||
validateSearch(theParams);
|
||||
|
||||
Class<? extends IBaseResource> resourceTypeClass = myContext.getResourceDefinition(theResourceType).getImplementingClass();
|
||||
final ISearchBuilder sb = mySearchBuilderFactory.newSearchBuilder(theCallingDao, theResourceType, resourceTypeClass);
|
||||
final ISearchBuilder<JpaPid> sb = mySearchBuilderFactory.newSearchBuilder(theCallingDao, theResourceType, resourceTypeClass);
|
||||
sb.setFetchSize(mySyncSize);
|
||||
|
||||
final Integer loadSynchronousUpTo = getLoadSynchronousUpToOrNull(theCacheControlDirective);
|
||||
|
@ -359,7 +357,7 @@ public class SearchCoordinatorSvcImpl implements ISearchCoordinatorSvc {
|
|||
* instead
|
||||
*/
|
||||
SearchCacheStatusEnum cacheStatus = SearchCacheStatusEnum.MISS;
|
||||
if (theCacheControlDirective != null && theCacheControlDirective.isNoCache() == true) {
|
||||
if (theCacheControlDirective != null && theCacheControlDirective.isNoCache()) {
|
||||
cacheStatus = SearchCacheStatusEnum.NOT_TRIED;
|
||||
}
|
||||
|
||||
|
@ -375,7 +373,7 @@ public class SearchCoordinatorSvcImpl implements ISearchCoordinatorSvc {
|
|||
}
|
||||
}
|
||||
|
||||
PersistedJpaSearchFirstPageBundleProvider retVal = submitSearch(theCallingDao, theParams, theResourceType, theRequestDetails, searchUuid, sb, queryString, theRequestPartitionId, search);
|
||||
PersistedJpaSearchFirstPageBundleProvider retVal = submitSearch(theCallingDao, theParams, theResourceType, theRequestDetails, sb, theRequestPartitionId, search);
|
||||
retVal.setCacheStatus(cacheStatus);
|
||||
return retVal;
|
||||
}
|
||||
|
@ -463,7 +461,7 @@ public class SearchCoordinatorSvcImpl implements ISearchCoordinatorSvc {
|
|||
}
|
||||
|
||||
@Nonnull
|
||||
private PersistedJpaSearchFirstPageBundleProvider submitSearch(IDao theCallingDao, SearchParameterMap theParams, String theResourceType, RequestDetails theRequestDetails, String theSearchUuid, ISearchBuilder theSb, String theQueryString, RequestPartitionId theRequestPartitionId, Search theSearch) {
|
||||
private PersistedJpaSearchFirstPageBundleProvider submitSearch(IDao theCallingDao, SearchParameterMap theParams, String theResourceType, RequestDetails theRequestDetails, ISearchBuilder<JpaPid> theSb, RequestPartitionId theRequestPartitionId, Search theSearch) {
|
||||
StopWatch w = new StopWatch();
|
||||
|
||||
SearchTaskParameters stp = new SearchTaskParameters(
|
||||
|
|
|
@ -33,6 +33,7 @@ import ca.uhn.fhir.jpa.dao.IResultIterator;
|
|||
import ca.uhn.fhir.jpa.dao.ISearchBuilder;
|
||||
import ca.uhn.fhir.jpa.dao.SearchBuilderFactory;
|
||||
import ca.uhn.fhir.jpa.interceptor.JpaPreResourceAccessDetails;
|
||||
import ca.uhn.fhir.jpa.model.dao.JpaPid;
|
||||
import ca.uhn.fhir.jpa.model.search.SearchRuntimeDetails;
|
||||
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
|
||||
import ca.uhn.fhir.model.api.IQueryParameterType;
|
||||
|
@ -40,7 +41,6 @@ import ca.uhn.fhir.rest.api.Constants;
|
|||
import ca.uhn.fhir.rest.api.server.IBundleProvider;
|
||||
import ca.uhn.fhir.rest.api.server.IPreResourceAccessDetails;
|
||||
import ca.uhn.fhir.rest.api.server.RequestDetails;
|
||||
import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId;
|
||||
import ca.uhn.fhir.rest.server.SimpleBundleProvider;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||
import ca.uhn.fhir.rest.server.interceptor.ServerInterceptorUtil;
|
||||
|
@ -104,7 +104,7 @@ public class SynchronousSearchSvcImpl implements ISynchronousSearchSvc {
|
|||
return txTemplate.execute(t -> {
|
||||
|
||||
// Load the results synchronously
|
||||
final List<ResourcePersistentId> pids = new ArrayList<>();
|
||||
final List<JpaPid> pids = new ArrayList<>();
|
||||
|
||||
Long count = 0L;
|
||||
if (wantCount) {
|
||||
|
@ -130,7 +130,7 @@ public class SynchronousSearchSvcImpl implements ISynchronousSearchSvc {
|
|||
return bundleProvider;
|
||||
}
|
||||
|
||||
try (IResultIterator resultIter = theSb.createQuery(theParams, searchRuntimeDetails, theRequestDetails, theRequestPartitionId)) {
|
||||
try (IResultIterator<JpaPid> resultIter = theSb.createQuery(theParams, searchRuntimeDetails, theRequestDetails, theRequestPartitionId)) {
|
||||
while (resultIter.hasNext()) {
|
||||
pids.add(resultIter.next());
|
||||
if (theLoadSynchronousUpTo != null && pids.size() >= theLoadSynchronousUpTo) {
|
||||
|
@ -170,16 +170,16 @@ public class SynchronousSearchSvcImpl implements ISynchronousSearchSvc {
|
|||
|
||||
// _includes
|
||||
Integer maxIncludes = myDaoConfig.getMaximumIncludesToLoadPerPage();
|
||||
final Set<ResourcePersistentId> includedPids = theSb.loadIncludes(myContext, myEntityManager, pids, theParams.getRevIncludes(), true, theParams.getLastUpdated(), "(synchronous)", theRequestDetails, maxIncludes);
|
||||
final Set<JpaPid> includedPids = theSb.loadIncludes(myContext, myEntityManager, pids, theParams.getRevIncludes(), true, theParams.getLastUpdated(), "(synchronous)", theRequestDetails, maxIncludes);
|
||||
if (maxIncludes != null) {
|
||||
maxIncludes -= includedPids.size();
|
||||
}
|
||||
pids.addAll(includedPids);
|
||||
List<ResourcePersistentId> includedPidsList = new ArrayList<>(includedPids);
|
||||
List<JpaPid> includedPidsList = new ArrayList<>(includedPids);
|
||||
|
||||
// _revincludes
|
||||
if (theParams.getEverythingMode() == null && (maxIncludes == null || maxIncludes > 0)) {
|
||||
Set<ResourcePersistentId> revIncludedPids = theSb.loadIncludes(myContext, myEntityManager, pids, theParams.getIncludes(), false, theParams.getLastUpdated(), "(synchronous)", theRequestDetails, maxIncludes);
|
||||
Set<JpaPid> revIncludedPids = theSb.loadIncludes(myContext, myEntityManager, pids, theParams.getIncludes(), false, theParams.getLastUpdated(), "(synchronous)", theRequestDetails, maxIncludes);
|
||||
includedPids.addAll(revIncludedPids);
|
||||
pids.addAll(revIncludedPids);
|
||||
includedPidsList.addAll(revIncludedPids);
|
||||
|
|
|
@ -81,7 +81,6 @@ import ca.uhn.fhir.rest.api.SortOrderEnum;
|
|||
import ca.uhn.fhir.rest.api.SortSpec;
|
||||
import ca.uhn.fhir.rest.api.server.IPreResourceAccessDetails;
|
||||
import ca.uhn.fhir.rest.api.server.RequestDetails;
|
||||
import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId;
|
||||
import ca.uhn.fhir.rest.param.DateRangeParam;
|
||||
import ca.uhn.fhir.rest.param.ReferenceParam;
|
||||
import ca.uhn.fhir.rest.param.StringParam;
|
||||
|
@ -136,7 +135,7 @@ import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
|||
* The SearchBuilder is responsible for actually forming the SQL query that handles
|
||||
* searches for resources
|
||||
*/
|
||||
public class SearchBuilder implements ISearchBuilder {
|
||||
public class SearchBuilder implements ISearchBuilder<JpaPid> {
|
||||
|
||||
/**
|
||||
* See loadResourcesByPid
|
||||
|
@ -169,18 +168,18 @@ public class SearchBuilder implements ISearchBuilder {
|
|||
private final DaoRegistry myDaoRegistry;
|
||||
private final IResourceSearchViewDao myResourceSearchViewDao;
|
||||
private final FhirContext myContext;
|
||||
private final IIdHelperService myIdHelperService;
|
||||
private final IIdHelperService<JpaPid> myIdHelperService;
|
||||
private final DaoConfig myDaoConfig;
|
||||
private final IDao myCallingDao;
|
||||
@PersistenceContext(type = PersistenceContextType.TRANSACTION)
|
||||
protected EntityManager myEntityManager;
|
||||
private List<ResourcePersistentId> myAlsoIncludePids;
|
||||
private List<JpaPid> myAlsoIncludePids;
|
||||
private CriteriaBuilder myCriteriaBuilder;
|
||||
private SearchParameterMap myParams;
|
||||
private String mySearchUuid;
|
||||
private int myFetchSize;
|
||||
private Integer myMaxResultsToFetch;
|
||||
private Set<ResourcePersistentId> myPidSet;
|
||||
private Set<JpaPid> myPidSet;
|
||||
private boolean myHasNextIteratorQuery = false;
|
||||
private RequestPartitionId myRequestPartitionId;
|
||||
@Autowired(required = false)
|
||||
|
@ -314,7 +313,7 @@ public class SearchBuilder implements ISearchBuilder {
|
|||
* @param thePidSet May be null
|
||||
*/
|
||||
@Override
|
||||
public void setPreviouslyAddedResourcePids(@Nonnull List<ResourcePersistentId> thePidSet) {
|
||||
public void setPreviouslyAddedResourcePids(@Nonnull List<JpaPid> thePidSet) {
|
||||
myPidSet = new HashSet<>(thePidSet);
|
||||
}
|
||||
|
||||
|
@ -352,7 +351,7 @@ public class SearchBuilder implements ISearchBuilder {
|
|||
|
||||
// Ugh - we have two different return types for now
|
||||
ISearchQueryExecutor fulltextExecutor = null;
|
||||
List<ResourcePersistentId> fulltextMatchIds = null;
|
||||
List<JpaPid> fulltextMatchIds = null;
|
||||
int resultCount = 0;
|
||||
if (myParams.isLastN()) {
|
||||
fulltextMatchIds = executeLastNAgainstIndex(theMaximumResults);
|
||||
|
@ -442,7 +441,7 @@ public class SearchBuilder implements ISearchBuilder {
|
|||
}
|
||||
}
|
||||
|
||||
private List<ResourcePersistentId> executeLastNAgainstIndex(Integer theMaximumResults) {
|
||||
private List<JpaPid> executeLastNAgainstIndex(Integer theMaximumResults) {
|
||||
// Can we use our hibernate search generated index on resource to support lastN?:
|
||||
if (myDaoConfig.isAdvancedHSearchIndexing()) {
|
||||
if (myFulltextSearchSvc == null) {
|
||||
|
@ -462,8 +461,8 @@ public class SearchBuilder implements ISearchBuilder {
|
|||
}
|
||||
}
|
||||
|
||||
private List<ResourcePersistentId> queryHibernateSearchForEverythingPids() {
|
||||
ResourcePersistentId pid = null;
|
||||
private List<JpaPid> queryHibernateSearchForEverythingPids() {
|
||||
JpaPid pid = null;
|
||||
if (myParams.get(IAnyResource.SP_RES_ID) != null) {
|
||||
String idParamValue;
|
||||
IQueryParameterType idParam = myParams.get(IAnyResource.SP_RES_ID).get(0).get(0);
|
||||
|
@ -477,7 +476,7 @@ public class SearchBuilder implements ISearchBuilder {
|
|||
|
||||
pid = myIdHelperService.resolveResourcePersistentIds(myRequestPartitionId, myResourceName, idParamValue);
|
||||
}
|
||||
List<ResourcePersistentId> pids = myFulltextSearchSvc.everything(myResourceName, myParams, pid);
|
||||
List<JpaPid> pids = myFulltextSearchSvc.everything(myResourceName, myParams, pid);
|
||||
return pids;
|
||||
}
|
||||
|
||||
|
@ -515,7 +514,7 @@ public class SearchBuilder implements ISearchBuilder {
|
|||
|
||||
// fetch our target Pids
|
||||
// this will throw if an id is not found
|
||||
Map<String, ResourcePersistentId> idToPid = myIdHelperService.resolveResourcePersistentIds(myRequestPartitionId,
|
||||
Map<String, JpaPid> idToPid = myIdHelperService.resolveResourcePersistentIds(myRequestPartitionId,
|
||||
myResourceName,
|
||||
new ArrayList<>(ids));
|
||||
if (myAlsoIncludePids == null) {
|
||||
|
@ -523,7 +522,7 @@ public class SearchBuilder implements ISearchBuilder {
|
|||
}
|
||||
|
||||
// add the pids to targetPids
|
||||
for (ResourcePersistentId pid : idToPid.values()) {
|
||||
for (JpaPid pid : idToPid.values()) {
|
||||
myAlsoIncludePids.add(pid);
|
||||
theTargetPids.add(((JpaPid) pid).getId());
|
||||
}
|
||||
|
@ -840,11 +839,11 @@ public class SearchBuilder implements ISearchBuilder {
|
|||
|
||||
}
|
||||
|
||||
private void doLoadPids(Collection<ResourcePersistentId> thePids, Collection<ResourcePersistentId> theIncludedPids, List<IBaseResource> theResourceListToPopulate, boolean theForHistoryOperation,
|
||||
Map<ResourcePersistentId, Integer> thePosition) {
|
||||
private void doLoadPids(Collection<JpaPid> thePids, Collection<JpaPid> theIncludedPids, List<IBaseResource> theResourceListToPopulate, boolean theForHistoryOperation,
|
||||
Map<JpaPid, Integer> thePosition) {
|
||||
|
||||
Map<Long, Long> resourcePidToVersion = null;
|
||||
for (ResourcePersistentId next : thePids) {
|
||||
for (JpaPid next : thePids) {
|
||||
if (next.getVersion() != null && myModelConfig.isRespectVersionsForSearchIncludes()) {
|
||||
if (resourcePidToVersion == null) {
|
||||
resourcePidToVersion = new HashMap<>();
|
||||
|
@ -966,7 +965,7 @@ public class SearchBuilder implements ISearchBuilder {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void loadResourcesByPid(Collection<ResourcePersistentId> thePids, Collection<ResourcePersistentId> theIncludedPids, List<IBaseResource> theResourceListToPopulate, boolean theForHistoryOperation, RequestDetails theDetails) {
|
||||
public void loadResourcesByPid(Collection<JpaPid> thePids, Collection<JpaPid> theIncludedPids, List<IBaseResource> theResourceListToPopulate, boolean theForHistoryOperation, RequestDetails theDetails) {
|
||||
if (thePids.isEmpty()) {
|
||||
ourLog.debug("The include pids are empty");
|
||||
// return;
|
||||
|
@ -976,8 +975,8 @@ public class SearchBuilder implements ISearchBuilder {
|
|||
// when running asserts
|
||||
assert new HashSet<>(thePids).size() == thePids.size() : "PID list contains duplicates: " + thePids;
|
||||
|
||||
Map<ResourcePersistentId, Integer> position = new HashMap<>();
|
||||
for (ResourcePersistentId next : thePids) {
|
||||
Map<JpaPid, Integer> position = new HashMap<>();
|
||||
for (JpaPid next : thePids) {
|
||||
position.put(next, theResourceListToPopulate.size());
|
||||
theResourceListToPopulate.add(null);
|
||||
}
|
||||
|
@ -995,7 +994,7 @@ public class SearchBuilder implements ISearchBuilder {
|
|||
}
|
||||
|
||||
// We only chunk because some jdbc drivers can't handle long param lists.
|
||||
new QueryChunker<ResourcePersistentId>().chunk(thePids, t -> doLoadPids(t, theIncludedPids, theResourceListToPopulate, theForHistoryOperation, position));
|
||||
new QueryChunker<JpaPid>().chunk(thePids, t -> doLoadPids(t, theIncludedPids, theResourceListToPopulate, theForHistoryOperation, position));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1007,7 +1006,7 @@ public class SearchBuilder implements ISearchBuilder {
|
|||
* @param thePids the pids to check for versioned references
|
||||
* @return can we fetch from Hibernate Search?
|
||||
*/
|
||||
private boolean isLoadingFromElasticSearchSupported(Collection<ResourcePersistentId> thePids) {
|
||||
private boolean isLoadingFromElasticSearchSupported(Collection<JpaPid> thePids) {
|
||||
// is storage enabled?
|
||||
return myDaoConfig.isStoreResourceInHSearchIndex() &&
|
||||
myDaoConfig.isAdvancedHSearchIndexing() &&
|
||||
|
@ -1017,7 +1016,7 @@ public class SearchBuilder implements ISearchBuilder {
|
|||
myContext.getVersion().getVersion().isEqualOrNewerThan(FhirVersionEnum.DSTU3);
|
||||
}
|
||||
|
||||
private List<IBaseResource> loadResourcesFromElasticSearch(Collection<ResourcePersistentId> thePids) {
|
||||
private List<IBaseResource> loadResourcesFromElasticSearch(Collection<JpaPid> thePids) {
|
||||
// Do we use the fulltextsvc via hibernate-search to load resources or be backwards compatible with older ES only impl
|
||||
// to handle lastN?
|
||||
if (myDaoConfig.isAdvancedHSearchIndexing() && myDaoConfig.isStoreResourceInHSearchIndex()) {
|
||||
|
@ -1036,10 +1035,10 @@ public class SearchBuilder implements ISearchBuilder {
|
|||
/**
|
||||
* THIS SHOULD RETURN HASHSET and not just Set because we add to it later
|
||||
* so it can't be Collections.emptySet() or some such thing.
|
||||
* The ResourcePersistentId returned will have resource type populated.
|
||||
* The JpaPid returned will have resource type populated.
|
||||
*/
|
||||
@Override
|
||||
public Set<ResourcePersistentId> loadIncludes(FhirContext theContext, EntityManager theEntityManager, Collection<ResourcePersistentId> theMatches, Collection<Include> theIncludes,
|
||||
public Set<JpaPid> loadIncludes(FhirContext theContext, EntityManager theEntityManager, Collection<JpaPid> theMatches, Collection<Include> theIncludes,
|
||||
boolean theReverseMode, DateRangeParam theLastUpdated, String theSearchIdOrDescription, RequestDetails theRequest, Integer theMaxCount) {
|
||||
if (theMatches.size() == 0) {
|
||||
return new HashSet<>();
|
||||
|
@ -1055,9 +1054,9 @@ public class SearchBuilder implements ISearchBuilder {
|
|||
findVersionFieldName = MY_TARGET_RESOURCE_VERSION;
|
||||
}
|
||||
|
||||
List<ResourcePersistentId> nextRoundMatches = new ArrayList<>(theMatches);
|
||||
HashSet<ResourcePersistentId> allAdded = new HashSet<>();
|
||||
HashSet<ResourcePersistentId> original = new HashSet<>(theMatches);
|
||||
List<JpaPid> nextRoundMatches = new ArrayList<>(theMatches);
|
||||
HashSet<JpaPid> allAdded = new HashSet<>();
|
||||
HashSet<JpaPid> original = new HashSet<>(theMatches);
|
||||
ArrayList<Include> includes = new ArrayList<>(theIncludes);
|
||||
|
||||
int roundCounts = 0;
|
||||
|
@ -1067,7 +1066,7 @@ public class SearchBuilder implements ISearchBuilder {
|
|||
do {
|
||||
roundCounts++;
|
||||
|
||||
HashSet<ResourcePersistentId> pidsToInclude = new HashSet<>();
|
||||
HashSet<JpaPid> pidsToInclude = new HashSet<>();
|
||||
|
||||
for (Iterator<Include> iter = includes.iterator(); iter.hasNext(); ) {
|
||||
Include nextInclude = iter.next();
|
||||
|
@ -1113,8 +1112,8 @@ public class SearchBuilder implements ISearchBuilder {
|
|||
}
|
||||
|
||||
String sql = sqlBuilder.toString();
|
||||
List<Collection<ResourcePersistentId>> partitions = partition(nextRoundMatches, getMaximumPageSize());
|
||||
for (Collection<ResourcePersistentId> nextPartition : partitions) {
|
||||
List<Collection<JpaPid>> partitions = partition(nextRoundMatches, getMaximumPageSize());
|
||||
for (Collection<JpaPid> nextPartition : partitions) {
|
||||
TypedQuery<?> q = theEntityManager.createQuery(sql, Object[].class);
|
||||
q.setParameter("target_pids", JpaPid.toLongList(nextPartition));
|
||||
if (wantResourceType != null) {
|
||||
|
@ -1232,8 +1231,8 @@ public class SearchBuilder implements ISearchBuilder {
|
|||
|
||||
String sql = resourceIdBasedQuery + " UNION " + resourceUrlBasedQuery;
|
||||
|
||||
List<Collection<ResourcePersistentId>> partitions = partition(nextRoundMatches, getMaximumPageSize());
|
||||
for (Collection<ResourcePersistentId> nextPartition : partitions) {
|
||||
List<Collection<JpaPid>> partitions = partition(nextRoundMatches, getMaximumPageSize());
|
||||
for (Collection<JpaPid> nextPartition : partitions) {
|
||||
Query q = theEntityManager.createNativeQuery(sql, Tuple.class);
|
||||
q.setParameter("src_path", nextPath);
|
||||
q.setParameter("target_pids", JpaPid.toLongList(nextPartition));
|
||||
|
@ -1269,7 +1268,7 @@ public class SearchBuilder implements ISearchBuilder {
|
|||
}
|
||||
|
||||
nextRoundMatches.clear();
|
||||
for (ResourcePersistentId next : pidsToInclude) {
|
||||
for (JpaPid next : pidsToInclude) {
|
||||
if (original.contains(next) == false && allAdded.contains(next) == false) {
|
||||
nextRoundMatches.add(next);
|
||||
}
|
||||
|
@ -1293,7 +1292,7 @@ public class SearchBuilder implements ISearchBuilder {
|
|||
if (allAdded.size() > 0) {
|
||||
|
||||
if (CompositeInterceptorBroadcaster.hasHooks(Pointcut.STORAGE_PREACCESS_RESOURCES, myInterceptorBroadcaster, theRequest)) {
|
||||
List<ResourcePersistentId> includedPidList = new ArrayList<>(allAdded);
|
||||
List<JpaPid> includedPidList = new ArrayList<>(allAdded);
|
||||
JpaPreResourceAccessDetails accessDetails = new JpaPreResourceAccessDetails(includedPidList, () -> this);
|
||||
HookParams params = new HookParams()
|
||||
.add(IPreResourceAccessDetails.class, accessDetails)
|
||||
|
@ -1303,7 +1302,7 @@ public class SearchBuilder implements ISearchBuilder {
|
|||
|
||||
for (int i = includedPidList.size() - 1; i >= 0; i--) {
|
||||
if (accessDetails.isDontReturnResourceAtIndex(i)) {
|
||||
ResourcePersistentId value = includedPidList.remove(i);
|
||||
JpaPid value = includedPidList.remove(i);
|
||||
if (value != null) {
|
||||
allAdded.remove(value);
|
||||
}
|
||||
|
@ -1315,14 +1314,14 @@ public class SearchBuilder implements ISearchBuilder {
|
|||
return allAdded;
|
||||
}
|
||||
|
||||
private List<Collection<ResourcePersistentId>> partition(Collection<ResourcePersistentId> theNextRoundMatches, int theMaxLoad) {
|
||||
private List<Collection<JpaPid>> partition(Collection<JpaPid> theNextRoundMatches, int theMaxLoad) {
|
||||
if (theNextRoundMatches.size() <= theMaxLoad) {
|
||||
return Collections.singletonList(theNextRoundMatches);
|
||||
} else {
|
||||
|
||||
List<Collection<ResourcePersistentId>> retVal = new ArrayList<>();
|
||||
Collection<ResourcePersistentId> current = null;
|
||||
for (ResourcePersistentId next : theNextRoundMatches) {
|
||||
List<Collection<JpaPid>> retVal = new ArrayList<>();
|
||||
Collection<JpaPid> current = null;
|
||||
for (JpaPid next : theNextRoundMatches) {
|
||||
if (current == null) {
|
||||
current = new ArrayList<>(theMaxLoad);
|
||||
retVal.add(current);
|
||||
|
@ -1483,14 +1482,14 @@ public class SearchBuilder implements ISearchBuilder {
|
|||
return myResourceName;
|
||||
}
|
||||
|
||||
public class IncludesIterator extends BaseIterator<ResourcePersistentId> implements Iterator<ResourcePersistentId> {
|
||||
public class IncludesIterator extends BaseIterator<JpaPid> implements Iterator<JpaPid> {
|
||||
|
||||
private final RequestDetails myRequest;
|
||||
private final Set<ResourcePersistentId> myCurrentPids;
|
||||
private Iterator<ResourcePersistentId> myCurrentIterator;
|
||||
private ResourcePersistentId myNext;
|
||||
private final Set<JpaPid> myCurrentPids;
|
||||
private Iterator<JpaPid> myCurrentIterator;
|
||||
private JpaPid myNext;
|
||||
|
||||
IncludesIterator(Set<ResourcePersistentId> thePidSet, RequestDetails theRequest) {
|
||||
IncludesIterator(Set<JpaPid> thePidSet, RequestDetails theRequest) {
|
||||
myCurrentPids = new HashSet<>(thePidSet);
|
||||
myCurrentIterator = null;
|
||||
myRequest = theRequest;
|
||||
|
@ -1501,7 +1500,7 @@ public class SearchBuilder implements ISearchBuilder {
|
|||
|
||||
if (myCurrentIterator == null) {
|
||||
Set<Include> includes = Collections.singleton(new Include("*", true));
|
||||
Set<ResourcePersistentId> newPids = loadIncludes(myContext, myEntityManager, myCurrentPids, includes, false, getParams().getLastUpdated(), mySearchUuid, myRequest, null);
|
||||
Set<JpaPid> newPids = loadIncludes(myContext, myEntityManager, myCurrentPids, includes, false, getParams().getLastUpdated(), mySearchUuid, myRequest, null);
|
||||
myCurrentIterator = newPids.iterator();
|
||||
}
|
||||
|
||||
|
@ -1521,16 +1520,16 @@ public class SearchBuilder implements ISearchBuilder {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ResourcePersistentId next() {
|
||||
public JpaPid next() {
|
||||
fetchNext();
|
||||
ResourcePersistentId retVal = myNext;
|
||||
JpaPid retVal = myNext;
|
||||
myNext = null;
|
||||
return retVal;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private final class QueryIterator extends BaseIterator<ResourcePersistentId> implements IResultIterator {
|
||||
private final class QueryIterator extends BaseIterator<JpaPid> implements IResultIterator<JpaPid> {
|
||||
|
||||
private final SearchRuntimeDetails mySearchRuntimeDetails;
|
||||
private final RequestDetails myRequest;
|
||||
|
@ -1540,7 +1539,7 @@ public class SearchBuilder implements ISearchBuilder {
|
|||
private final Integer myOffset;
|
||||
private boolean myFirst = true;
|
||||
private IncludesIterator myIncludesIterator;
|
||||
private ResourcePersistentId myNext;
|
||||
private JpaPid myNext;
|
||||
private ISearchQueryExecutor myResultsIterator;
|
||||
private boolean myFetchIncludesForEverythingOperation;
|
||||
private int mySkipCount = 0;
|
||||
|
@ -1592,8 +1591,8 @@ public class SearchBuilder implements ISearchBuilder {
|
|||
if (myNext == null) {
|
||||
|
||||
|
||||
for (Iterator<ResourcePersistentId> myPreResultsIterator = myAlsoIncludePids.iterator(); myPreResultsIterator.hasNext(); ) {
|
||||
ResourcePersistentId next = myPreResultsIterator.next();
|
||||
for (Iterator<JpaPid> myPreResultsIterator = myAlsoIncludePids.iterator(); myPreResultsIterator.hasNext(); ) {
|
||||
JpaPid next = myPreResultsIterator.next();
|
||||
if (next != null)
|
||||
if (myPidSet.add(next)) {
|
||||
myNext = next;
|
||||
|
@ -1656,7 +1655,7 @@ public class SearchBuilder implements ISearchBuilder {
|
|||
}
|
||||
if (myIncludesIterator != null) {
|
||||
while (myIncludesIterator.hasNext()) {
|
||||
ResourcePersistentId next = myIncludesIterator.next();
|
||||
JpaPid next = myIncludesIterator.next();
|
||||
if (next != null)
|
||||
if (myPidSet.add(next)) {
|
||||
myNext = next;
|
||||
|
@ -1741,9 +1740,9 @@ public class SearchBuilder implements ISearchBuilder {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ResourcePersistentId next() {
|
||||
public JpaPid next() {
|
||||
fetchNext();
|
||||
ResourcePersistentId retVal = myNext;
|
||||
JpaPid retVal = myNext;
|
||||
myNext = null;
|
||||
Validate.isTrue(!NO_MORE.equals(retVal), "No more elements");
|
||||
return retVal;
|
||||
|
@ -1760,8 +1759,8 @@ public class SearchBuilder implements ISearchBuilder {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourcePersistentId> getNextResultBatch(long theBatchSize) {
|
||||
Collection<ResourcePersistentId> batch = new ArrayList<>();
|
||||
public Collection<JpaPid> getNextResultBatch(long theBatchSize) {
|
||||
Collection<JpaPid> batch = new ArrayList<>();
|
||||
while (this.hasNext() && batch.size() < theBatchSize) {
|
||||
batch.add(this.next());
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ package ca.uhn.fhir.jpa.search.builder;
|
|||
*/
|
||||
|
||||
import ca.uhn.fhir.jpa.model.dao.JpaPid;
|
||||
import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
@ -94,18 +93,18 @@ public class SearchQueryExecutors {
|
|||
}
|
||||
}
|
||||
|
||||
static public ISearchQueryExecutor from(Iterator<ResourcePersistentId> theIterator) {
|
||||
return new ResourcePersistentIdQueryAdaptor(theIterator);
|
||||
static public ISearchQueryExecutor from(Iterator<JpaPid> theIterator) {
|
||||
return new JpaPidQueryAdaptor(theIterator);
|
||||
}
|
||||
|
||||
static public ISearchQueryExecutor from(Iterable<ResourcePersistentId> theIterable) {
|
||||
return new ResourcePersistentIdQueryAdaptor(theIterable.iterator());
|
||||
static public ISearchQueryExecutor from(Iterable<JpaPid> theIterable) {
|
||||
return new JpaPidQueryAdaptor(theIterable.iterator());
|
||||
}
|
||||
|
||||
static class ResourcePersistentIdQueryAdaptor implements ISearchQueryExecutor {
|
||||
final Iterator<ResourcePersistentId> myIterator;
|
||||
static class JpaPidQueryAdaptor implements ISearchQueryExecutor {
|
||||
final Iterator<JpaPid> myIterator;
|
||||
|
||||
ResourcePersistentIdQueryAdaptor(Iterator<ResourcePersistentId> theIterator) {
|
||||
JpaPidQueryAdaptor(Iterator<JpaPid> theIterator) {
|
||||
myIterator = theIterator;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,12 +22,11 @@ package ca.uhn.fhir.jpa.search.builder.predicate;
|
|||
|
||||
import ca.uhn.fhir.interceptor.model.RequestPartitionId;
|
||||
import ca.uhn.fhir.jpa.api.svc.IIdHelperService;
|
||||
import ca.uhn.fhir.jpa.model.dao.JpaPid;
|
||||
import ca.uhn.fhir.jpa.dao.predicate.SearchFilterParser;
|
||||
import ca.uhn.fhir.jpa.util.QueryParameterUtils;
|
||||
import ca.uhn.fhir.jpa.model.dao.JpaPid;
|
||||
import ca.uhn.fhir.jpa.search.builder.sql.SearchQueryBuilder;
|
||||
import ca.uhn.fhir.jpa.util.QueryParameterUtils;
|
||||
import ca.uhn.fhir.model.api.IQueryParameterType;
|
||||
import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId;
|
||||
import ca.uhn.fhir.rest.param.TokenParam;
|
||||
import ca.uhn.fhir.rest.param.TokenParamModifier;
|
||||
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
||||
|
@ -50,7 +49,7 @@ public class ResourceIdPredicateBuilder extends BasePredicateBuilder {
|
|||
private static final Logger ourLog = LoggerFactory.getLogger(ResourceIdPredicateBuilder.class);
|
||||
|
||||
@Autowired
|
||||
private IIdHelperService myIdHelperService;
|
||||
private IIdHelperService<JpaPid> myIdHelperService;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
@ -63,12 +62,12 @@ public class ResourceIdPredicateBuilder extends BasePredicateBuilder {
|
|||
@Nullable
|
||||
public Condition createPredicateResourceId(@Nullable DbColumn theSourceJoinColumn, String theResourceName, List<List<IQueryParameterType>> theValues, SearchFilterParser.CompareOperation theOperation, RequestPartitionId theRequestPartitionId) {
|
||||
|
||||
Set<ResourcePersistentId> allOrPids = null;
|
||||
Set<JpaPid> allOrPids = null;
|
||||
SearchFilterParser.CompareOperation defaultOperation = SearchFilterParser.CompareOperation.eq;
|
||||
|
||||
boolean allIdsAreForcedIds = true;
|
||||
for (List<? extends IQueryParameterType> nextValue : theValues) {
|
||||
Set<ResourcePersistentId> orPids = new HashSet<>();
|
||||
Set<JpaPid> orPids = new HashSet<>();
|
||||
boolean haveValue = false;
|
||||
for (IQueryParameterType next : nextValue) {
|
||||
String value = next.getValueAsQueryToken(getFhirContext());
|
||||
|
@ -84,7 +83,7 @@ public class ResourceIdPredicateBuilder extends BasePredicateBuilder {
|
|||
haveValue = true;
|
||||
try {
|
||||
boolean excludeDeleted = true;
|
||||
ResourcePersistentId pid = myIdHelperService.resolveResourcePersistentIds(theRequestPartitionId, theResourceName, valueAsId.getIdPart(), excludeDeleted);
|
||||
JpaPid pid = myIdHelperService.resolveResourcePersistentIds(theRequestPartitionId, theResourceName, valueAsId.getIdPart(), excludeDeleted);
|
||||
orPids.add(pid);
|
||||
} catch (ResourceNotFoundException e) {
|
||||
// This is not an error in a search, it just results in no matches
|
||||
|
|
|
@ -37,17 +37,17 @@ import ca.uhn.fhir.jpa.api.dao.DaoRegistry;
|
|||
import ca.uhn.fhir.jpa.api.dao.IDao;
|
||||
import ca.uhn.fhir.jpa.api.svc.IIdHelperService;
|
||||
import ca.uhn.fhir.jpa.dao.BaseStorageDao;
|
||||
import ca.uhn.fhir.jpa.model.dao.JpaPid;
|
||||
import ca.uhn.fhir.jpa.dao.predicate.SearchFilterParser;
|
||||
import ca.uhn.fhir.jpa.model.dao.JpaPid;
|
||||
import ca.uhn.fhir.jpa.model.search.StorageProcessingMessage;
|
||||
import ca.uhn.fhir.jpa.search.SearchCoordinatorSvcImpl;
|
||||
import ca.uhn.fhir.jpa.util.QueryParameterUtils;
|
||||
import ca.uhn.fhir.jpa.search.builder.QueryStack;
|
||||
import ca.uhn.fhir.jpa.search.builder.models.MissingQueryParameterPredicateParams;
|
||||
import ca.uhn.fhir.jpa.search.builder.sql.SearchQueryBuilder;
|
||||
import ca.uhn.fhir.jpa.searchparam.MatchUrlService;
|
||||
import ca.uhn.fhir.jpa.searchparam.ResourceMetaParams;
|
||||
import ca.uhn.fhir.jpa.searchparam.util.JpaParamUtil;
|
||||
import ca.uhn.fhir.jpa.util.QueryParameterUtils;
|
||||
import ca.uhn.fhir.model.api.IQueryParameterType;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.parser.DataFormatException;
|
||||
|
@ -55,7 +55,6 @@ import ca.uhn.fhir.rest.api.Constants;
|
|||
import ca.uhn.fhir.rest.api.RestSearchParameterTypeEnum;
|
||||
import ca.uhn.fhir.rest.api.SearchContainedModeEnum;
|
||||
import ca.uhn.fhir.rest.api.server.RequestDetails;
|
||||
import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId;
|
||||
import ca.uhn.fhir.rest.param.CompositeParam;
|
||||
import ca.uhn.fhir.rest.param.DateParam;
|
||||
import ca.uhn.fhir.rest.param.NumberParam;
|
||||
|
@ -97,9 +96,6 @@ import java.util.ListIterator;
|
|||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static ca.uhn.fhir.jpa.util.QueryParameterUtils.toAndPredicate;
|
||||
import static ca.uhn.fhir.jpa.util.QueryParameterUtils.toEqualToOrInPredicate;
|
||||
import static ca.uhn.fhir.jpa.util.QueryParameterUtils.toOrPredicate;
|
||||
import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||
import static org.apache.commons.lang3.StringUtils.trim;
|
||||
|
||||
|
@ -239,7 +235,7 @@ public class ResourceLinkPredicateBuilder
|
|||
inverse = true;
|
||||
}
|
||||
|
||||
List<ResourcePersistentId> targetPids = myIdHelperService.resolveResourcePersistentIdsWithCache(theRequestPartitionId, targetIds);
|
||||
List<JpaPid> targetPids = myIdHelperService.resolveResourcePersistentIdsWithCache(theRequestPartitionId, targetIds);
|
||||
List<Long> targetPidList = JpaPid.toLongList(targetPids);
|
||||
|
||||
if (targetPidList.isEmpty() && targetQualifiedUrls.isEmpty()) {
|
||||
|
|
|
@ -24,8 +24,8 @@ import ca.uhn.fhir.context.FhirContext;
|
|||
import ca.uhn.fhir.i18n.Msg;
|
||||
import ca.uhn.fhir.interceptor.model.RequestPartitionId;
|
||||
import ca.uhn.fhir.jpa.config.HibernatePropertiesProvider;
|
||||
import ca.uhn.fhir.jpa.model.dao.JpaPid;
|
||||
import ca.uhn.fhir.jpa.model.config.PartitionSettings;
|
||||
import ca.uhn.fhir.jpa.model.dao.JpaPid;
|
||||
import ca.uhn.fhir.jpa.model.entity.ModelConfig;
|
||||
import ca.uhn.fhir.jpa.search.builder.QueryStack;
|
||||
import ca.uhn.fhir.jpa.search.builder.predicate.BaseJoiningPredicateBuilder;
|
||||
|
@ -46,7 +46,6 @@ import ca.uhn.fhir.jpa.search.builder.predicate.StringPredicateBuilder;
|
|||
import ca.uhn.fhir.jpa.search.builder.predicate.TagPredicateBuilder;
|
||||
import ca.uhn.fhir.jpa.search.builder.predicate.TokenPredicateBuilder;
|
||||
import ca.uhn.fhir.jpa.search.builder.predicate.UriPredicateBuilder;
|
||||
import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId;
|
||||
import ca.uhn.fhir.rest.param.DateParam;
|
||||
import ca.uhn.fhir.rest.param.DateRangeParam;
|
||||
import ca.uhn.fhir.rest.param.ParamPrefixEnum;
|
||||
|
@ -681,13 +680,13 @@ public class SearchQueryBuilder {
|
|||
addPredicate(predicate);
|
||||
}
|
||||
|
||||
public void excludeResourceIdsPredicate(Set<ResourcePersistentId> theExsitinghPidSetToExclude) {
|
||||
public void excludeResourceIdsPredicate(Set<JpaPid> theExistingPidSetToExclude) {
|
||||
|
||||
// Do nothing if it's empty
|
||||
if (theExsitinghPidSetToExclude == null || theExsitinghPidSetToExclude.isEmpty())
|
||||
if (theExistingPidSetToExclude == null || theExistingPidSetToExclude.isEmpty())
|
||||
return;
|
||||
|
||||
List<Long> excludePids = JpaPid.toLongList(theExsitinghPidSetToExclude);
|
||||
List<Long> excludePids = JpaPid.toLongList(theExistingPidSetToExclude);
|
||||
|
||||
ourLog.trace("excludePids = " + excludePids);
|
||||
|
||||
|
|
|
@ -24,12 +24,11 @@ import ca.uhn.fhir.context.FhirContext;
|
|||
import ca.uhn.fhir.interceptor.api.IInterceptorBroadcaster;
|
||||
import ca.uhn.fhir.jpa.api.config.DaoConfig;
|
||||
import ca.uhn.fhir.jpa.dao.SearchBuilderFactory;
|
||||
import ca.uhn.fhir.jpa.model.dao.JpaPid;
|
||||
import ca.uhn.fhir.jpa.model.search.SearchStatusEnum;
|
||||
import ca.uhn.fhir.jpa.search.ExceptionService;
|
||||
import ca.uhn.fhir.jpa.search.SearchStrategyFactory;
|
||||
import ca.uhn.fhir.jpa.search.cache.ISearchCacheSvc;
|
||||
import ca.uhn.fhir.jpa.search.cache.ISearchResultCacheSvc;
|
||||
import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId;
|
||||
import ca.uhn.fhir.rest.server.IPagingProvider;
|
||||
import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
|
@ -47,7 +46,6 @@ public class SearchContinuationTask extends SearchTask {
|
|||
SearchTaskParameters theCreationParams,
|
||||
PlatformTransactionManager theManagedTxManager,
|
||||
FhirContext theContext,
|
||||
SearchStrategyFactory theSearchStrategyFactory,
|
||||
IInterceptorBroadcaster theInterceptorBroadcaster,
|
||||
SearchBuilderFactory theSearchBuilderFactory,
|
||||
ISearchResultCacheSvc theSearchResultCacheSvc,
|
||||
|
@ -60,7 +58,6 @@ public class SearchContinuationTask extends SearchTask {
|
|||
theCreationParams,
|
||||
theManagedTxManager,
|
||||
theContext,
|
||||
theSearchStrategyFactory,
|
||||
theInterceptorBroadcaster,
|
||||
theSearchBuilderFactory,
|
||||
theSearchResultCacheSvc,
|
||||
|
@ -78,7 +75,7 @@ public class SearchContinuationTask extends SearchTask {
|
|||
TransactionTemplate txTemplate = new TransactionTemplate(myManagedTxManager);
|
||||
txTemplate.afterPropertiesSet();
|
||||
txTemplate.execute(t -> {
|
||||
List<ResourcePersistentId> previouslyAddedResourcePids = mySearchResultCacheSvc.fetchAllResultPids(getSearch());
|
||||
List<JpaPid> previouslyAddedResourcePids = mySearchResultCacheSvc.fetchAllResultPids(getSearch());
|
||||
if (previouslyAddedResourcePids == null) {
|
||||
throw myExceptionSvc.newUnknownSearchException(getSearch().getUuid());
|
||||
}
|
||||
|
|
|
@ -33,9 +33,9 @@ import ca.uhn.fhir.jpa.dao.ISearchBuilder;
|
|||
import ca.uhn.fhir.jpa.dao.SearchBuilderFactory;
|
||||
import ca.uhn.fhir.jpa.entity.Search;
|
||||
import ca.uhn.fhir.jpa.interceptor.JpaPreResourceAccessDetails;
|
||||
import ca.uhn.fhir.jpa.model.dao.JpaPid;
|
||||
import ca.uhn.fhir.jpa.model.search.SearchRuntimeDetails;
|
||||
import ca.uhn.fhir.jpa.model.search.SearchStatusEnum;
|
||||
import ca.uhn.fhir.jpa.search.SearchStrategyFactory;
|
||||
import ca.uhn.fhir.jpa.search.cache.ISearchCacheSvc;
|
||||
import ca.uhn.fhir.jpa.search.cache.ISearchResultCacheSvc;
|
||||
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
|
||||
|
@ -43,7 +43,6 @@ import ca.uhn.fhir.jpa.util.QueryParameterUtils;
|
|||
import ca.uhn.fhir.jpa.util.SearchParameterMapCalculator;
|
||||
import ca.uhn.fhir.rest.api.server.IPreResourceAccessDetails;
|
||||
import ca.uhn.fhir.rest.api.server.RequestDetails;
|
||||
import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId;
|
||||
import ca.uhn.fhir.rest.server.IPagingProvider;
|
||||
import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||
|
@ -102,10 +101,10 @@ public class SearchTask implements Callable<Void> {
|
|||
private final SearchParameterMap myParams;
|
||||
private final IDao myCallingDao;
|
||||
private final String myResourceType;
|
||||
private final ArrayList<ResourcePersistentId> mySyncedPids = new ArrayList<>();
|
||||
private final ArrayList<JpaPid> mySyncedPids = new ArrayList<>();
|
||||
private final CountDownLatch myInitialCollectionLatch = new CountDownLatch(1);
|
||||
private final CountDownLatch myCompletionLatch;
|
||||
private final ArrayList<ResourcePersistentId> myUnsyncedPids = new ArrayList<>();
|
||||
private final ArrayList<JpaPid> myUnsyncedPids = new ArrayList<>();
|
||||
private final RequestDetails myRequest;
|
||||
private final RequestPartitionId myRequestPartitionId;
|
||||
private final SearchRuntimeDetails mySearchRuntimeDetails;
|
||||
|
@ -116,7 +115,7 @@ public class SearchTask implements Callable<Void> {
|
|||
private int myCountSavedThisPass = 0;
|
||||
private int myCountBlockedThisPass = 0;
|
||||
private boolean myAdditionalPrefetchThresholdsRemaining;
|
||||
private List<ResourcePersistentId> myPreviouslyAddedResourcePids;
|
||||
private List<JpaPid> myPreviouslyAddedResourcePids;
|
||||
private Integer myMaxResultsToFetch;
|
||||
|
||||
private final Consumer<String> myOnRemove;
|
||||
|
@ -130,7 +129,7 @@ public class SearchTask implements Callable<Void> {
|
|||
protected final PlatformTransactionManager myManagedTxManager;
|
||||
protected final FhirContext myContext;
|
||||
private final IInterceptorBroadcaster myInterceptorBroadcaster;
|
||||
private final SearchBuilderFactory mySearchBuilderFactory;
|
||||
private final SearchBuilderFactory<JpaPid> mySearchBuilderFactory;
|
||||
protected final ISearchResultCacheSvc mySearchResultCacheSvc;
|
||||
private final DaoConfig myDaoConfig;
|
||||
private final ISearchCacheSvc mySearchCacheSvc;
|
||||
|
@ -143,7 +142,6 @@ public class SearchTask implements Callable<Void> {
|
|||
SearchTaskParameters theCreationParams,
|
||||
PlatformTransactionManager theManagedTxManager,
|
||||
FhirContext theContext,
|
||||
SearchStrategyFactory theSearchStrategyFactory,
|
||||
IInterceptorBroadcaster theInterceptorBroadcaster,
|
||||
SearchBuilderFactory theSearchBuilderFactory,
|
||||
ISearchResultCacheSvc theSearchResultCacheSvc,
|
||||
|
@ -215,7 +213,7 @@ public class SearchTask implements Callable<Void> {
|
|||
return myInitialCollectionLatch;
|
||||
}
|
||||
|
||||
public void setPreviouslyAddedResourcePids(List<ResourcePersistentId> thePreviouslyAddedResourcePids) {
|
||||
public void setPreviouslyAddedResourcePids(List<JpaPid> thePreviouslyAddedResourcePids) {
|
||||
myPreviouslyAddedResourcePids = thePreviouslyAddedResourcePids;
|
||||
myCountSavedTotal = myPreviouslyAddedResourcePids.size();
|
||||
}
|
||||
|
@ -226,7 +224,7 @@ public class SearchTask implements Callable<Void> {
|
|||
}
|
||||
|
||||
@Nonnull
|
||||
public List<ResourcePersistentId> getResourcePids(int theFromIndex, int theToIndex) {
|
||||
public List<JpaPid> getResourcePids(int theFromIndex, int theToIndex) {
|
||||
ourLog.debug("Requesting search PIDs from {}-{}", theFromIndex, theToIndex);
|
||||
|
||||
boolean keepWaiting;
|
||||
|
@ -268,7 +266,7 @@ public class SearchTask implements Callable<Void> {
|
|||
|
||||
ourLog.debug("Proceeding, as we have {} results", mySyncedPids.size());
|
||||
|
||||
ArrayList<ResourcePersistentId> retVal = new ArrayList<>();
|
||||
ArrayList<JpaPid> retVal = new ArrayList<>();
|
||||
synchronized (mySyncedPids) {
|
||||
QueryParameterUtils.verifySearchHasntFailedOrThrowInternalErrorException(mySearch);
|
||||
|
||||
|
@ -308,7 +306,7 @@ public class SearchTask implements Callable<Void> {
|
|||
doSaveSearch();
|
||||
}
|
||||
|
||||
ArrayList<ResourcePersistentId> unsyncedPids = myUnsyncedPids;
|
||||
ArrayList<JpaPid> unsyncedPids = myUnsyncedPids;
|
||||
int countBlocked = 0;
|
||||
|
||||
// Interceptor call: STORAGE_PREACCESS_RESOURCES
|
||||
|
@ -634,7 +632,7 @@ public class SearchTask implements Callable<Void> {
|
|||
* This is an odd implementation behaviour, but the change
|
||||
* for this will require a lot more handling at higher levels
|
||||
*/
|
||||
try (IResultIterator resultIterator = sb.createQuery(myParams, mySearchRuntimeDetails, myRequest, myRequestPartitionId)) {
|
||||
try (IResultIterator<JpaPid> resultIterator = sb.createQuery(myParams, mySearchRuntimeDetails, myRequest, myRequestPartitionId)) {
|
||||
assert (resultIterator != null);
|
||||
|
||||
/*
|
||||
|
|
|
@ -20,19 +20,18 @@ package ca.uhn.fhir.jpa.search.cache;
|
|||
* #L%
|
||||
*/
|
||||
|
||||
import ca.uhn.fhir.jpa.model.dao.JpaPid;
|
||||
import ca.uhn.fhir.jpa.dao.data.ISearchResultDao;
|
||||
import ca.uhn.fhir.jpa.entity.Search;
|
||||
import ca.uhn.fhir.jpa.entity.SearchResult;
|
||||
import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId;
|
||||
import ca.uhn.fhir.jpa.model.dao.JpaPid;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -46,7 +45,7 @@ public class DatabaseSearchResultCacheSvcImpl implements ISearchResultCacheSvc {
|
|||
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.REQUIRED)
|
||||
public List<ResourcePersistentId> fetchResultPids(Search theSearch, int theFrom, int theTo) {
|
||||
public List<JpaPid> fetchResultPids(Search theSearch, int theFrom, int theTo) {
|
||||
final Pageable page = toPage(theFrom, theTo);
|
||||
if (page == null) {
|
||||
return Collections.emptyList();
|
||||
|
@ -63,7 +62,7 @@ public class DatabaseSearchResultCacheSvcImpl implements ISearchResultCacheSvc {
|
|||
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.REQUIRED)
|
||||
public List<ResourcePersistentId> fetchAllResultPids(Search theSearch) {
|
||||
public List<JpaPid> fetchAllResultPids(Search theSearch) {
|
||||
List<Long> retVal = mySearchResultDao.findWithSearchPidOrderIndependent(theSearch.getId());
|
||||
ourLog.trace("fetchAllResultPids returned {} pids", retVal.size());
|
||||
return JpaPid.fromLongList(retVal);
|
||||
|
@ -71,15 +70,15 @@ public class DatabaseSearchResultCacheSvcImpl implements ISearchResultCacheSvc {
|
|||
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.REQUIRED)
|
||||
public void storeResults(Search theSearch, List<ResourcePersistentId> thePreviouslyStoredResourcePids, List<ResourcePersistentId> theNewResourcePids) {
|
||||
public void storeResults(Search theSearch, List<JpaPid> thePreviouslyStoredResourcePids, List<JpaPid> theNewResourcePids) {
|
||||
List<SearchResult> resultsToSave = Lists.newArrayList();
|
||||
|
||||
ourLog.debug("Storing {} results with {} previous for search", theNewResourcePids.size(), thePreviouslyStoredResourcePids.size());
|
||||
|
||||
int order = thePreviouslyStoredResourcePids.size();
|
||||
for (ResourcePersistentId nextPid : theNewResourcePids) {
|
||||
for (JpaPid nextPid : theNewResourcePids) {
|
||||
SearchResult nextResult = new SearchResult(theSearch);
|
||||
nextResult.setResourcePid(((JpaPid) nextPid).getId());
|
||||
nextResult.setResourcePid(nextPid.getId());
|
||||
nextResult.setOrder(order);
|
||||
resultsToSave.add(nextResult);
|
||||
ourLog.trace("Saving ORDER[{}] Resource {}", order, nextResult.getResourcePid());
|
||||
|
|
|
@ -20,8 +20,8 @@ package ca.uhn.fhir.jpa.search.cache;
|
|||
* #L%
|
||||
*/
|
||||
|
||||
import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId;
|
||||
import ca.uhn.fhir.jpa.entity.Search;
|
||||
import ca.uhn.fhir.jpa.model.dao.JpaPid;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
@ -32,7 +32,7 @@ public interface ISearchResultCacheSvc {
|
|||
* @param thePreviouslyStoredResourcePids A list of resource PIDs that have previously been saved to this search
|
||||
* @param theNewResourcePids A list of new resoure PIDs to add to this search (these ones have not been previously saved)
|
||||
*/
|
||||
void storeResults(Search theSearch, List<ResourcePersistentId> thePreviouslyStoredResourcePids, List<ResourcePersistentId> theNewResourcePids);
|
||||
void storeResults(Search theSearch, List<JpaPid> thePreviouslyStoredResourcePids, List<JpaPid> theNewResourcePids);
|
||||
|
||||
/**
|
||||
* Fetch a sunset of the search result IDs from the cache
|
||||
|
@ -44,7 +44,7 @@ public interface ISearchResultCacheSvc {
|
|||
* have been removed from the cache for some reason, such as expiry or manual purge)
|
||||
*/
|
||||
@Nullable
|
||||
List<ResourcePersistentId> fetchResultPids(Search theSearch, int theFrom, int theTo);
|
||||
List<JpaPid> fetchResultPids(Search theSearch, int theFrom, int theTo);
|
||||
|
||||
/**
|
||||
* Fetch all result PIDs for a given search with no particular order required
|
||||
|
@ -54,6 +54,6 @@ public interface ISearchResultCacheSvc {
|
|||
* have been removed from the cache for some reason, such as expiry or manual purge)
|
||||
*/
|
||||
@Nullable
|
||||
List<ResourcePersistentId> fetchAllResultPids(Search theSearch);
|
||||
List<JpaPid> fetchAllResultPids(Search theSearch);
|
||||
|
||||
}
|
||||
|
|
|
@ -20,8 +20,8 @@ package ca.uhn.fhir.jpa.search.lastn;
|
|||
* #L%
|
||||
*/
|
||||
|
||||
import ca.uhn.fhir.i18n.Msg;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.i18n.Msg;
|
||||
import ca.uhn.fhir.jpa.dao.TolerantJsonParser;
|
||||
import ca.uhn.fhir.jpa.model.config.PartitionSettings;
|
||||
import ca.uhn.fhir.jpa.model.entity.IBaseResourceEntity;
|
||||
|
@ -752,7 +752,7 @@ public class ElasticsearchSvcImpl implements IElasticsearchSvc {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<IBaseResource> getObservationResources(Collection<ResourcePersistentId> thePids) {
|
||||
public List<IBaseResource> getObservationResources(Collection<? extends ResourcePersistentId> thePids) {
|
||||
SearchRequest searchRequest = buildObservationResourceSearchRequest(thePids);
|
||||
try {
|
||||
SearchResponse observationDocumentResponse = executeSearchRequest(searchRequest);
|
||||
|
@ -780,7 +780,7 @@ public class ElasticsearchSvcImpl implements IElasticsearchSvc {
|
|||
}
|
||||
}
|
||||
|
||||
private SearchRequest buildObservationResourceSearchRequest(Collection<ResourcePersistentId> thePids) {
|
||||
private SearchRequest buildObservationResourceSearchRequest(Collection<? extends ResourcePersistentId> thePids) {
|
||||
SearchRequest searchRequest = new SearchRequest(OBSERVATION_INDEX);
|
||||
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
|
||||
// Query
|
||||
|
|
|
@ -96,6 +96,6 @@ public interface IElasticsearchSvc {
|
|||
* @param thePids
|
||||
* @return Resources list or empty if nothing found
|
||||
*/
|
||||
List<IBaseResource> getObservationResources(Collection<ResourcePersistentId> thePids);
|
||||
List<IBaseResource> getObservationResources(Collection<? extends ResourcePersistentId> thePids);
|
||||
|
||||
}
|
||||
|
|
|
@ -31,7 +31,6 @@ import ca.uhn.fhir.jpa.model.search.SearchStatusEnum;
|
|||
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
|
||||
import ca.uhn.fhir.model.api.Include;
|
||||
import ca.uhn.fhir.model.primitive.InstantDt;
|
||||
import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId;
|
||||
import ca.uhn.fhir.rest.param.DateRangeParam;
|
||||
import ca.uhn.fhir.rest.param.ParamPrefixEnum;
|
||||
import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException;
|
||||
|
@ -195,7 +194,7 @@ public class QueryParameterUtils {
|
|||
return lastUpdatedPredicates;
|
||||
}
|
||||
|
||||
public static List<ResourcePersistentId> filterResourceIdsByLastUpdated(EntityManager theEntityManager, final DateRangeParam theLastUpdated, Collection<ResourcePersistentId> thePids) {
|
||||
public static List<JpaPid> filterResourceIdsByLastUpdated(EntityManager theEntityManager, final DateRangeParam theLastUpdated, Collection<JpaPid> thePids) {
|
||||
if (thePids.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
|
|
@ -11,9 +11,9 @@ import ca.uhn.fhir.jpa.api.svc.IIdHelperService;
|
|||
import ca.uhn.fhir.jpa.bulk.export.model.ExportPIDIteratorParameters;
|
||||
import ca.uhn.fhir.jpa.dao.IResultIterator;
|
||||
import ca.uhn.fhir.jpa.dao.ISearchBuilder;
|
||||
import ca.uhn.fhir.jpa.model.dao.JpaPid;
|
||||
import ca.uhn.fhir.jpa.dao.SearchBuilderFactory;
|
||||
import ca.uhn.fhir.jpa.dao.mdm.MdmExpansionCacheSvc;
|
||||
import ca.uhn.fhir.jpa.model.dao.JpaPid;
|
||||
import ca.uhn.fhir.jpa.model.search.SearchRuntimeDetails;
|
||||
import ca.uhn.fhir.jpa.partition.SystemRequestDetails;
|
||||
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
|
||||
|
@ -23,9 +23,6 @@ import ca.uhn.fhir.mdm.model.MdmPidTuple;
|
|||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.rest.api.server.bulk.BulkDataExportOptions;
|
||||
import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId;
|
||||
import ca.uhn.fhir.rest.param.HasOrListParam;
|
||||
import ca.uhn.fhir.rest.param.HasParam;
|
||||
import ch.qos.logback.classic.spi.ILoggingEvent;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||
import org.hl7.fhir.r4.model.Group;
|
||||
|
@ -35,7 +32,6 @@ import org.junit.jupiter.api.Test;
|
|||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.ValueSource;
|
||||
import org.mockito.ArgumentMatcher;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Spy;
|
||||
|
@ -53,7 +49,6 @@ import java.util.List;
|
|||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import static ca.uhn.fhir.rest.api.Constants.PARAM_HAS;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
@ -61,9 +56,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
|||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.mockito.AdditionalMatchers.not;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyList;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.argThat;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
@ -216,7 +209,7 @@ public class JpaBulkExportProcessorTest {
|
|||
.thenReturn(resultIterator);
|
||||
|
||||
// test
|
||||
Iterator<ResourcePersistentId> pidIterator = myProcessor.getResourcePidIterator(parameters);
|
||||
Iterator<JpaPid> pidIterator = myProcessor.getResourcePidIterator(parameters);
|
||||
|
||||
// verify
|
||||
assertNotNull(pidIterator);
|
||||
|
@ -314,7 +307,7 @@ public class JpaBulkExportProcessorTest {
|
|||
}
|
||||
|
||||
// test
|
||||
Iterator<ResourcePersistentId> pidIterator = myProcessor.getResourcePidIterator(parameters);
|
||||
Iterator<JpaPid> pidIterator = myProcessor.getResourcePidIterator(parameters);
|
||||
|
||||
// verify
|
||||
assertNotNull(pidIterator);
|
||||
|
@ -402,7 +395,7 @@ public class JpaBulkExportProcessorTest {
|
|||
}
|
||||
|
||||
// test
|
||||
Iterator<ResourcePersistentId> pidIterator = myProcessor.getResourcePidIterator(parameters);
|
||||
Iterator<JpaPid> pidIterator = myProcessor.getResourcePidIterator(parameters);
|
||||
|
||||
// verify
|
||||
assertNotNull(pidIterator, "PID iterator null for mdm = " + theMdm);
|
||||
|
@ -445,7 +438,7 @@ public class JpaBulkExportProcessorTest {
|
|||
)).thenReturn(resultIterator);
|
||||
|
||||
// test
|
||||
Iterator<ResourcePersistentId> iterator = myProcessor.getResourcePidIterator(parameters);
|
||||
Iterator<JpaPid> iterator = myProcessor.getResourcePidIterator(parameters);
|
||||
|
||||
// verify
|
||||
assertNotNull(iterator);
|
||||
|
|
|
@ -5,7 +5,6 @@ import ca.uhn.fhir.jpa.model.dao.JpaPid;
|
|||
import ca.uhn.fhir.jpa.search.builder.SearchBuilder;
|
||||
import ca.uhn.fhir.jpa.search.lastn.ElasticsearchSvcImpl;
|
||||
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
|
||||
import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId;
|
||||
import ca.uhn.fhir.rest.param.ReferenceParam;
|
||||
import ca.uhn.fhir.rest.param.TokenParam;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
|
@ -136,10 +135,10 @@ public class FhirResourceDaoR4SearchLastNIT extends BaseR4SearchLastN {
|
|||
}
|
||||
|
||||
void verifyResourcesLoadedFromElastic(List<IIdType> theObservationIds, List<String> theResults) {
|
||||
List<ResourcePersistentId> expectedArgumentPids = JpaPid.fromLongList(
|
||||
List<JpaPid> expectedArgumentPids = JpaPid.fromLongList(
|
||||
theObservationIds.stream().map(IIdType::getIdPartAsLong).collect(Collectors.toList())
|
||||
);
|
||||
ArgumentCaptor<List<ResourcePersistentId>> actualPids = ArgumentCaptor.forClass(List.class);
|
||||
ArgumentCaptor<List<JpaPid>> actualPids = ArgumentCaptor.forClass(List.class);
|
||||
verify(myElasticsearchSvc, times(1)).getObservationResources(actualPids.capture());
|
||||
assertThat(actualPids.getValue(), is(expectedArgumentPids));
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId;
|
|||
|
||||
import java.util.Date;
|
||||
|
||||
public interface IResourceLookup {
|
||||
public interface IResourceLookup<T extends ResourcePersistentId> {
|
||||
String getResourceType();
|
||||
|
||||
/**
|
||||
|
@ -32,6 +32,6 @@ public interface IResourceLookup {
|
|||
*/
|
||||
Date getDeleted();
|
||||
|
||||
ResourcePersistentId getPersistentId();
|
||||
T getPersistentId();
|
||||
|
||||
}
|
||||
|
|
|
@ -15,16 +15,16 @@ public class JpaPid extends ResourcePersistentId<Long> {
|
|||
super(theId, theVersion);
|
||||
}
|
||||
|
||||
public static List<Long> toLongList(Collection<ResourcePersistentId> thePids) {
|
||||
public static List<Long> toLongList(Collection<JpaPid> thePids) {
|
||||
List<Long> retVal = new ArrayList<>(thePids.size());
|
||||
for (ResourcePersistentId next : thePids) {
|
||||
retVal.add(((JpaPid) next).getId());
|
||||
for (JpaPid next : thePids) {
|
||||
retVal.add(next.getId());
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
public static List<ResourcePersistentId> fromLongList(List<Long> theResultList) {
|
||||
List<ResourcePersistentId> retVal = new ArrayList<>(theResultList.size());
|
||||
public static List<JpaPid> fromLongList(List<Long> theResultList) {
|
||||
List<JpaPid> retVal = new ArrayList<>(theResultList.size());
|
||||
for (Long next : theResultList) {
|
||||
retVal.add(new JpaPid(next));
|
||||
}
|
||||
|
|
|
@ -5,9 +5,9 @@ import ca.uhn.fhir.jpa.api.config.DaoConfig;
|
|||
import ca.uhn.fhir.jpa.api.model.HistoryCountModeEnum;
|
||||
import ca.uhn.fhir.jpa.dao.BaseHapiFhirDao;
|
||||
import ca.uhn.fhir.jpa.dao.BaseStorageDao;
|
||||
import ca.uhn.fhir.jpa.model.dao.JpaPid;
|
||||
import ca.uhn.fhir.jpa.dao.DaoTestUtils;
|
||||
import ca.uhn.fhir.jpa.dao.data.IForcedIdDao;
|
||||
import ca.uhn.fhir.jpa.model.dao.JpaPid;
|
||||
import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamString;
|
||||
import ca.uhn.fhir.jpa.model.entity.TagTypeEnum;
|
||||
import ca.uhn.fhir.jpa.searchparam.SearchParamConstants;
|
||||
|
@ -288,7 +288,7 @@ public class FhirResourceDaoDstu2Test extends BaseJpaDstu2Test {
|
|||
assertThat(toUnqualifiedVersionlessIdValues(found), hasItem(id2.getValue()));
|
||||
}
|
||||
{
|
||||
List<ResourcePersistentId> found = myObservationDao.searchForIds(new SearchParameterMap(Observation.SP_DATE, new DateParam(">2016-01-02")), null);
|
||||
List<JpaPid> found = myObservationDao.searchForIds(new SearchParameterMap(Observation.SP_DATE, new DateParam(">2016-01-02")), null);
|
||||
assertThat(JpaPid.toLongList(found), not(hasItem(id2.getIdPartAsLong())));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@ import ca.uhn.fhir.model.dstu2.resource.Patient;
|
|||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.model.primitive.StringDt;
|
||||
import ca.uhn.fhir.rest.api.MethodOutcome;
|
||||
import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
|
@ -169,7 +168,7 @@ public class FhirResourceDaoDstu2UpdateTest extends BaseJpaDstu2Test {
|
|||
p2.addName().addFamily("Tester").addGiven("testUpdateMaintainsSearchParamsDstu2BBB");
|
||||
myPatientDao.create(p2, mySrd);
|
||||
|
||||
List<ResourcePersistentId> ids = myPatientDao.searchForIds(new SearchParameterMap(Patient.SP_GIVEN, new StringDt("testUpdateMaintainsSearchParamsDstu2AAA")), null);
|
||||
List<JpaPid> ids = myPatientDao.searchForIds(new SearchParameterMap(Patient.SP_GIVEN, new StringDt("testUpdateMaintainsSearchParamsDstu2AAA")), null);
|
||||
assertEquals(1, ids.size());
|
||||
assertThat(JpaPid.toLongList(ids), contains(p1id.getIdPartAsLong()));
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
|
|||
import ca.uhn.fhir.model.dstu2.resource.Organization;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId;
|
||||
import ca.uhn.fhir.rest.param.StringAndListParam;
|
||||
import ca.uhn.fhir.rest.param.StringOrListParam;
|
||||
import ca.uhn.fhir.rest.param.StringParam;
|
||||
|
@ -60,7 +59,7 @@ public class FhirSearchDaoDstu2Test extends BaseJpaDstu2Test {
|
|||
content.addAnd(new StringOrListParam().addOr(new StringParam("AAAS")));
|
||||
|
||||
map.add(Constants.PARAM_CONTENT, content);
|
||||
List<ResourcePersistentId> found = mySearchDao.search(resourceName, map);
|
||||
List<JpaPid> found = mySearchDao.search(resourceName, map);
|
||||
assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1));
|
||||
}
|
||||
// OR
|
||||
|
@ -69,7 +68,7 @@ public class FhirSearchDaoDstu2Test extends BaseJpaDstu2Test {
|
|||
content.addAnd(new StringOrListParam().addOr(new StringParam("AAAS")).addOr(new StringParam("AAAB")));
|
||||
|
||||
map.add(Constants.PARAM_CONTENT, content);
|
||||
List<ResourcePersistentId> found = mySearchDao.search(resourceName, map);
|
||||
List<JpaPid> found = mySearchDao.search(resourceName, map);
|
||||
assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1, id2));
|
||||
}
|
||||
// AND
|
||||
|
@ -79,7 +78,7 @@ public class FhirSearchDaoDstu2Test extends BaseJpaDstu2Test {
|
|||
content.addAnd(new StringOrListParam().addOr(new StringParam("CCC")));
|
||||
|
||||
map.add(Constants.PARAM_CONTENT, content);
|
||||
List<ResourcePersistentId> found = mySearchDao.search(resourceName, map);
|
||||
List<JpaPid> found = mySearchDao.search(resourceName, map);
|
||||
assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1));
|
||||
}
|
||||
// AND OR
|
||||
|
@ -89,7 +88,7 @@ public class FhirSearchDaoDstu2Test extends BaseJpaDstu2Test {
|
|||
content.addAnd(new StringOrListParam().addOr(new StringParam("CCC")));
|
||||
|
||||
map.add(Constants.PARAM_CONTENT, content);
|
||||
List<ResourcePersistentId> found = mySearchDao.search(resourceName, map);
|
||||
List<JpaPid> found = mySearchDao.search(resourceName, map);
|
||||
assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1, id2));
|
||||
}
|
||||
// All Resource Types
|
||||
|
@ -98,7 +97,7 @@ public class FhirSearchDaoDstu2Test extends BaseJpaDstu2Test {
|
|||
content.addAnd(new StringOrListParam().addOr(new StringParam("CCC")).addOr(new StringParam("DDD")));
|
||||
|
||||
map.add(Constants.PARAM_CONTENT, content);
|
||||
List<ResourcePersistentId> found = mySearchDao.search(null, map);
|
||||
List<JpaPid> found = mySearchDao.search(null, map);
|
||||
assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1, id2, id3));
|
||||
}
|
||||
|
||||
|
@ -128,7 +127,7 @@ public class FhirSearchDaoDstu2Test extends BaseJpaDstu2Test {
|
|||
content.addAnd(new StringOrListParam().addOr(new StringParam("AAAS")));
|
||||
|
||||
map.add(Constants.PARAM_TEXT, content);
|
||||
List<ResourcePersistentId> found = mySearchDao.search(resourceName, map);
|
||||
List<JpaPid> found = mySearchDao.search(resourceName, map);
|
||||
assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1));
|
||||
}
|
||||
// OR
|
||||
|
@ -137,7 +136,7 @@ public class FhirSearchDaoDstu2Test extends BaseJpaDstu2Test {
|
|||
content.addAnd(new StringOrListParam().addOr(new StringParam("AAAS")).addOr(new StringParam("AAAB")));
|
||||
|
||||
map.add(Constants.PARAM_TEXT, content);
|
||||
List<ResourcePersistentId> found = mySearchDao.search(resourceName, map);
|
||||
List<JpaPid> found = mySearchDao.search(resourceName, map);
|
||||
assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1, id2));
|
||||
}
|
||||
// AND
|
||||
|
@ -147,7 +146,7 @@ public class FhirSearchDaoDstu2Test extends BaseJpaDstu2Test {
|
|||
content.addAnd(new StringOrListParam().addOr(new StringParam("CCC")));
|
||||
|
||||
map.add(Constants.PARAM_TEXT, content);
|
||||
List<ResourcePersistentId> found = mySearchDao.search(resourceName, map);
|
||||
List<JpaPid> found = mySearchDao.search(resourceName, map);
|
||||
assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1));
|
||||
}
|
||||
// AND OR
|
||||
|
@ -157,7 +156,7 @@ public class FhirSearchDaoDstu2Test extends BaseJpaDstu2Test {
|
|||
content.addAnd(new StringOrListParam().addOr(new StringParam("CCC")));
|
||||
|
||||
map.add(Constants.PARAM_TEXT, content);
|
||||
List<ResourcePersistentId> found = mySearchDao.search(resourceName, map);
|
||||
List<JpaPid> found = mySearchDao.search(resourceName, map);
|
||||
assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1, id2));
|
||||
}
|
||||
// Tag Contents
|
||||
|
@ -166,7 +165,7 @@ public class FhirSearchDaoDstu2Test extends BaseJpaDstu2Test {
|
|||
content.addAnd(new StringOrListParam().addOr(new StringParam("div")));
|
||||
|
||||
map.add(Constants.PARAM_TEXT, content);
|
||||
List<ResourcePersistentId> found = mySearchDao.search(resourceName, map);
|
||||
List<JpaPid> found = mySearchDao.search(resourceName, map);
|
||||
assertThat(JpaPid.toLongList(found), empty());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@ import ca.uhn.fhir.jpa.api.config.DaoConfig;
|
|||
import ca.uhn.fhir.jpa.api.dao.DaoRegistry;
|
||||
import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao;
|
||||
import ca.uhn.fhir.jpa.dao.IResultIterator;
|
||||
import ca.uhn.fhir.jpa.model.dao.JpaPid;
|
||||
import ca.uhn.fhir.jpa.dao.SearchBuilderFactory;
|
||||
import ca.uhn.fhir.jpa.model.dao.JpaPid;
|
||||
import ca.uhn.fhir.jpa.search.builder.SearchBuilder;
|
||||
import ca.uhn.fhir.jpa.util.BaseIterator;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
|
@ -30,7 +30,7 @@ import static org.mockito.Mockito.verify;
|
|||
public class BaseSearchSvc {
|
||||
protected int myExpectedNumberOfSearchBuildersCreated = 2;
|
||||
@Mock
|
||||
protected SearchBuilderFactory mySearchBuilderFactory;
|
||||
protected SearchBuilderFactory<JpaPid> mySearchBuilderFactory;
|
||||
|
||||
@Mock
|
||||
protected PlatformTransactionManager myTxManager;
|
||||
|
@ -76,7 +76,7 @@ public class BaseSearchSvc {
|
|||
};
|
||||
}
|
||||
|
||||
public static class ResultIterator extends BaseIterator<ResourcePersistentId> implements IResultIterator {
|
||||
public static class ResultIterator extends BaseIterator<JpaPid> implements IResultIterator<JpaPid> {
|
||||
|
||||
private final Iterator<JpaPid> myWrap;
|
||||
private int myCount;
|
||||
|
@ -107,8 +107,8 @@ public class BaseSearchSvc {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourcePersistentId> getNextResultBatch(long theBatchSize) {
|
||||
Collection<ResourcePersistentId> batch = new ArrayList<>();
|
||||
public Collection<JpaPid> getNextResultBatch(long theBatchSize) {
|
||||
Collection<JpaPid> batch = new ArrayList<>();
|
||||
while (this.hasNext() && batch.size() < theBatchSize) {
|
||||
batch.add(this.next());
|
||||
}
|
||||
|
|
|
@ -7,10 +7,10 @@ import ca.uhn.fhir.jpa.api.config.DaoConfig;
|
|||
import ca.uhn.fhir.jpa.config.SearchConfig;
|
||||
import ca.uhn.fhir.jpa.dao.IResultIterator;
|
||||
import ca.uhn.fhir.jpa.dao.ISearchBuilder;
|
||||
import ca.uhn.fhir.jpa.model.dao.JpaPid;
|
||||
import ca.uhn.fhir.jpa.dao.SearchBuilderFactory;
|
||||
import ca.uhn.fhir.jpa.entity.Search;
|
||||
import ca.uhn.fhir.jpa.entity.SearchTypeEnum;
|
||||
import ca.uhn.fhir.jpa.model.dao.JpaPid;
|
||||
import ca.uhn.fhir.jpa.model.search.SearchStatusEnum;
|
||||
import ca.uhn.fhir.jpa.partition.IRequestPartitionHelperSvc;
|
||||
import ca.uhn.fhir.jpa.search.builder.tasks.SearchContinuationTask;
|
||||
|
@ -94,7 +94,7 @@ public class SearchCoordinatorSvcImplTest extends BaseSearchSvc{
|
|||
@Mock
|
||||
private IInterceptorBroadcaster myInterceptorBroadcaster;
|
||||
@Mock
|
||||
private SearchBuilderFactory mySearchBuilderFactory;
|
||||
private SearchBuilderFactory<JpaPid> mySearchBuilderFactory;
|
||||
@Mock
|
||||
private PersistedJpaBundleProviderFactory myPersistedJpaBundleProviderFactory;
|
||||
@Mock
|
||||
|
@ -152,7 +152,7 @@ public class SearchCoordinatorSvcImplTest extends BaseSearchSvc{
|
|||
params.add("name", new StringParam("ANAME"));
|
||||
|
||||
List<JpaPid> pids = createPidSequence(800);
|
||||
IResultIterator iter = new FailAfterNIterator(new SlowIterator(pids.iterator(), 2), 300);
|
||||
IResultIterator<JpaPid> iter = new FailAfterNIterator(new SlowIterator(pids.iterator(), 2), 300);
|
||||
when(mySearchBuilder.createQuery(same(params), any(), any(), nullable(RequestPartitionId.class))).thenReturn(iter);
|
||||
mockSearchTask();
|
||||
|
||||
|
@ -301,7 +301,7 @@ public class SearchCoordinatorSvcImplTest extends BaseSearchSvc{
|
|||
RequestDetails requestDetails = t.getArgument(0, RequestDetails.class);
|
||||
Search search = t.getArgument(1, Search.class);
|
||||
SearchTask searchTask = t.getArgument(2, SearchTask.class);
|
||||
ISearchBuilder searchBuilder = t.getArgument(3, ISearchBuilder.class);
|
||||
ISearchBuilder<JpaPid> searchBuilder = t.getArgument(3, ISearchBuilder.class);
|
||||
PersistedJpaSearchFirstPageBundleProvider retVal = new PersistedJpaSearchFirstPageBundleProvider(search, searchTask, searchBuilder, requestDetails);
|
||||
retVal.setDaoConfigForUnitTest(new DaoConfig());
|
||||
retVal.setTxManagerForUnitTest(myTxManager);
|
||||
|
@ -326,7 +326,7 @@ public class SearchCoordinatorSvcImplTest extends BaseSearchSvc{
|
|||
|
||||
ourLog.info("Registering the first search");
|
||||
new Thread(() -> mySvc.registerSearch(myCallingDao, params, "Patient", new CacheControlDirective(), null, RequestPartitionId.allPartitions())).start();
|
||||
await().until(()->iter.getCountReturned(), Matchers.greaterThan(0));
|
||||
await().until(iter::getCountReturned, Matchers.greaterThan(0));
|
||||
|
||||
String searchId = mySvc.getActiveSearchIds().iterator().next();
|
||||
CountDownLatch completionLatch = new CountDownLatch(1);
|
||||
|
@ -334,7 +334,7 @@ public class SearchCoordinatorSvcImplTest extends BaseSearchSvc{
|
|||
try {
|
||||
assertNotNull(searchId);
|
||||
ourLog.info("About to pull the first resource");
|
||||
List<ResourcePersistentId> resources = mySvc.getResources(searchId, 0, 1, null);
|
||||
List<JpaPid> resources = mySvc.getResources(searchId, 0, 1, null);
|
||||
ourLog.info("Done pulling the first resource");
|
||||
assertEquals(1, resources.size());
|
||||
} finally {
|
||||
|
@ -610,10 +610,10 @@ public class SearchCoordinatorSvcImplTest extends BaseSearchSvc{
|
|||
|
||||
}
|
||||
|
||||
public static class FailAfterNIterator extends BaseIterator<ResourcePersistentId> implements IResultIterator {
|
||||
public static class FailAfterNIterator extends BaseIterator<JpaPid> implements IResultIterator<JpaPid> {
|
||||
|
||||
private int myCount;
|
||||
private final IResultIterator myWrap;
|
||||
private final IResultIterator<JpaPid> myWrap;
|
||||
|
||||
FailAfterNIterator(IResultIterator theWrap, int theCount) {
|
||||
myWrap = theWrap;
|
||||
|
@ -626,7 +626,7 @@ public class SearchCoordinatorSvcImplTest extends BaseSearchSvc{
|
|||
}
|
||||
|
||||
@Override
|
||||
public ResourcePersistentId next() {
|
||||
public JpaPid next() {
|
||||
myCount--;
|
||||
if (myCount == 0) {
|
||||
throw new NullPointerException("FAILED");
|
||||
|
@ -645,8 +645,8 @@ public class SearchCoordinatorSvcImplTest extends BaseSearchSvc{
|
|||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourcePersistentId> getNextResultBatch(long theBatchSize) {
|
||||
Collection<ResourcePersistentId> batch = new ArrayList<>();
|
||||
public Collection<JpaPid> getNextResultBatch(long theBatchSize) {
|
||||
Collection<JpaPid> batch = new ArrayList<>();
|
||||
while (this.hasNext() && batch.size() < theBatchSize) {
|
||||
batch.add(this.next());
|
||||
}
|
||||
|
@ -665,7 +665,7 @@ public class SearchCoordinatorSvcImplTest extends BaseSearchSvc{
|
|||
* <p>
|
||||
* Don't use it in real code!
|
||||
*/
|
||||
public static class SlowIterator extends BaseIterator<ResourcePersistentId> implements IResultIterator {
|
||||
public static class SlowIterator extends BaseIterator<JpaPid> implements IResultIterator<JpaPid> {
|
||||
|
||||
private static final Logger ourLog = LoggerFactory.getLogger(SlowIterator.class);
|
||||
private final IResultIterator myResultIteratorWrap;
|
||||
|
@ -698,13 +698,13 @@ public class SearchCoordinatorSvcImplTest extends BaseSearchSvc{
|
|||
}
|
||||
|
||||
@Override
|
||||
public ResourcePersistentId next() {
|
||||
public JpaPid next() {
|
||||
try {
|
||||
Thread.sleep(myDelay);
|
||||
} catch (InterruptedException e) {
|
||||
// ignore
|
||||
}
|
||||
ResourcePersistentId retVal = myWrap.next();
|
||||
JpaPid retVal = myWrap.next();
|
||||
myReturnedValues.add(retVal);
|
||||
myCountReturned.incrementAndGet();
|
||||
return retVal;
|
||||
|
@ -725,8 +725,8 @@ public class SearchCoordinatorSvcImplTest extends BaseSearchSvc{
|
|||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourcePersistentId> getNextResultBatch(long theBatchSize) {
|
||||
Collection<ResourcePersistentId> batch = new ArrayList<>();
|
||||
public Collection<JpaPid> getNextResultBatch(long theBatchSize) {
|
||||
Collection<JpaPid> batch = new ArrayList<>();
|
||||
while (this.hasNext() && batch.size() < theBatchSize) {
|
||||
batch.add(this.next());
|
||||
}
|
||||
|
@ -753,8 +753,7 @@ public class SearchCoordinatorSvcImplTest extends BaseSearchSvc{
|
|||
invocation.getArgument(1),
|
||||
myTxManager,
|
||||
ourCtx,
|
||||
mySearchStrategyFactory,
|
||||
myInterceptorBroadcaster,
|
||||
myInterceptorBroadcaster,
|
||||
mySearchBuilderFactory,
|
||||
mySearchResultCacheSvc,
|
||||
myDaoConfig,
|
||||
|
@ -766,7 +765,6 @@ public class SearchCoordinatorSvcImplTest extends BaseSearchSvc{
|
|||
invocation.getArgument(1),
|
||||
myTxManager,
|
||||
ourCtx,
|
||||
mySearchStrategyFactory,
|
||||
myInterceptorBroadcaster,
|
||||
mySearchBuilderFactory,
|
||||
mySearchResultCacheSvc,
|
||||
|
|
|
@ -8,9 +8,9 @@ import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao;
|
|||
import ca.uhn.fhir.jpa.api.model.DaoMethodOutcome;
|
||||
import ca.uhn.fhir.jpa.api.model.HistoryCountModeEnum;
|
||||
import ca.uhn.fhir.jpa.dao.BaseHapiFhirDao;
|
||||
import ca.uhn.fhir.jpa.model.dao.JpaPid;
|
||||
import ca.uhn.fhir.jpa.dao.DaoTestUtils;
|
||||
import ca.uhn.fhir.jpa.entity.ResourceSearchView;
|
||||
import ca.uhn.fhir.jpa.model.dao.JpaPid;
|
||||
import ca.uhn.fhir.jpa.model.entity.ResourceHistoryTable;
|
||||
import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamString;
|
||||
import ca.uhn.fhir.jpa.model.entity.ResourceTable;
|
||||
|
@ -264,11 +264,11 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test {
|
|||
IIdType id2 = myObservationDao.create(o2, mySrd).getId();
|
||||
|
||||
{
|
||||
List<ResourcePersistentId> found = myObservationDao.searchForIds(new SearchParameterMap(Observation.SP_DATE, new DateParam(">2001-01-02")), null);
|
||||
List<JpaPid> found = myObservationDao.searchForIds(new SearchParameterMap(Observation.SP_DATE, new DateParam(">2001-01-02")), null);
|
||||
assertThat(JpaPid.toLongList(found), hasItem(id2.getIdPartAsLong()));
|
||||
}
|
||||
{
|
||||
List<ResourcePersistentId> found = myObservationDao.searchForIds(new SearchParameterMap(Observation.SP_DATE, new DateParam(">2016-01-02")), null);
|
||||
List<JpaPid> found = myObservationDao.searchForIds(new SearchParameterMap(Observation.SP_DATE, new DateParam(">2016-01-02")), null);
|
||||
assertThat(JpaPid.toLongList(found), not(hasItem(id2.getIdPartAsLong())));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
|
|||
import ca.uhn.fhir.jpa.test.BaseJpaDstu3Test;
|
||||
import ca.uhn.fhir.model.primitive.InstantDt;
|
||||
import ca.uhn.fhir.rest.api.MethodOutcome;
|
||||
import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId;
|
||||
import ca.uhn.fhir.rest.param.StringParam;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.ResourceGoneException;
|
||||
|
@ -468,7 +467,7 @@ public class FhirResourceDaoDstu3UpdateTest extends BaseJpaDstu3Test {
|
|||
p2.addName().setFamily("Tester").addGiven("testUpdateMaintainsSearchParamsDstu2BBB");
|
||||
myPatientDao.create(p2, mySrd).getId();
|
||||
|
||||
List<ResourcePersistentId> ids = myPatientDao.searchForIds(new SearchParameterMap(Patient.SP_GIVEN, new StringParam("testUpdateMaintainsSearchParamsDstu2AAA")), null);
|
||||
List<JpaPid> ids = myPatientDao.searchForIds(new SearchParameterMap(Patient.SP_GIVEN, new StringParam("testUpdateMaintainsSearchParamsDstu2AAA")), null);
|
||||
assertEquals(1, ids.size());
|
||||
assertThat(JpaPid.toLongList(ids), contains(p1id.getIdPartAsLong()));
|
||||
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
package ca.uhn.fhir.jpa.dao.dstu3;
|
||||
|
||||
import ca.uhn.fhir.jpa.dao.IFulltextSearchSvc;
|
||||
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
|
||||
import ca.uhn.fhir.jpa.model.dao.JpaPid;
|
||||
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
|
||||
import ca.uhn.fhir.jpa.test.BaseJpaDstu3Test;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId;
|
||||
import ca.uhn.fhir.rest.param.StringAndListParam;
|
||||
import ca.uhn.fhir.rest.param.StringOrListParam;
|
||||
import ca.uhn.fhir.rest.param.StringParam;
|
||||
|
@ -61,7 +60,7 @@ public class FhirSearchDaoDstu3Test extends BaseJpaDstu3Test {
|
|||
content.addAnd(new StringOrListParam().addOr(new StringParam("AAAS")));
|
||||
|
||||
map.add(Constants.PARAM_CONTENT, content);
|
||||
List<ResourcePersistentId> found = mySearchDao.search(resourceName, map);
|
||||
List<JpaPid> found = mySearchDao.search(resourceName, map);
|
||||
assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1));
|
||||
}
|
||||
// OR
|
||||
|
@ -70,7 +69,7 @@ public class FhirSearchDaoDstu3Test extends BaseJpaDstu3Test {
|
|||
content.addAnd(new StringOrListParam().addOr(new StringParam("AAAS")).addOr(new StringParam("AAAB")));
|
||||
|
||||
map.add(Constants.PARAM_CONTENT, content);
|
||||
List<ResourcePersistentId> found = mySearchDao.search(resourceName, map);
|
||||
List<JpaPid> found = mySearchDao.search(resourceName, map);
|
||||
assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1, id2));
|
||||
}
|
||||
// AND
|
||||
|
@ -80,7 +79,7 @@ public class FhirSearchDaoDstu3Test extends BaseJpaDstu3Test {
|
|||
content.addAnd(new StringOrListParam().addOr(new StringParam("CCC")));
|
||||
|
||||
map.add(Constants.PARAM_CONTENT, content);
|
||||
List<ResourcePersistentId> found = mySearchDao.search(resourceName, map);
|
||||
List<JpaPid> found = mySearchDao.search(resourceName, map);
|
||||
assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1));
|
||||
}
|
||||
// AND OR
|
||||
|
@ -90,7 +89,7 @@ public class FhirSearchDaoDstu3Test extends BaseJpaDstu3Test {
|
|||
content.addAnd(new StringOrListParam().addOr(new StringParam("CCC")));
|
||||
|
||||
map.add(Constants.PARAM_CONTENT, content);
|
||||
List<ResourcePersistentId> found = mySearchDao.search(resourceName, map);
|
||||
List<JpaPid> found = mySearchDao.search(resourceName, map);
|
||||
assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1, id2));
|
||||
}
|
||||
// All Resource Types
|
||||
|
@ -99,7 +98,7 @@ public class FhirSearchDaoDstu3Test extends BaseJpaDstu3Test {
|
|||
content.addAnd(new StringOrListParam().addOr(new StringParam("CCC")).addOr(new StringParam("DDD")));
|
||||
|
||||
map.add(Constants.PARAM_CONTENT, content);
|
||||
List<ResourcePersistentId> found = mySearchDao.search(null, map);
|
||||
List<JpaPid> found = mySearchDao.search(null, map);
|
||||
assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1, id2, id3));
|
||||
}
|
||||
|
||||
|
@ -134,7 +133,7 @@ public class FhirSearchDaoDstu3Test extends BaseJpaDstu3Test {
|
|||
content.addAnd(new StringOrListParam().addOr(new StringParam("AAAS")));
|
||||
|
||||
map.add(Constants.PARAM_TEXT, content);
|
||||
List<ResourcePersistentId> found = mySearchDao.search(resourceName, map);
|
||||
List<JpaPid> found = mySearchDao.search(resourceName, map);
|
||||
assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1));
|
||||
}
|
||||
// OR
|
||||
|
@ -143,7 +142,7 @@ public class FhirSearchDaoDstu3Test extends BaseJpaDstu3Test {
|
|||
content.addAnd(new StringOrListParam().addOr(new StringParam("AAAS")).addOr(new StringParam("AAAB")));
|
||||
|
||||
map.add(Constants.PARAM_TEXT, content);
|
||||
List<ResourcePersistentId> found = mySearchDao.search(resourceName, map);
|
||||
List<JpaPid> found = mySearchDao.search(resourceName, map);
|
||||
assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1, id2));
|
||||
}
|
||||
// AND
|
||||
|
@ -153,7 +152,7 @@ public class FhirSearchDaoDstu3Test extends BaseJpaDstu3Test {
|
|||
content.addAnd(new StringOrListParam().addOr(new StringParam("CCC")));
|
||||
|
||||
map.add(Constants.PARAM_TEXT, content);
|
||||
List<ResourcePersistentId> found = mySearchDao.search(resourceName, map);
|
||||
List<JpaPid> found = mySearchDao.search(resourceName, map);
|
||||
assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1));
|
||||
}
|
||||
// AND OR
|
||||
|
@ -163,7 +162,7 @@ public class FhirSearchDaoDstu3Test extends BaseJpaDstu3Test {
|
|||
content.addAnd(new StringOrListParam().addOr(new StringParam("CCC")));
|
||||
|
||||
map.add(Constants.PARAM_TEXT, content);
|
||||
List<ResourcePersistentId> found = mySearchDao.search(resourceName, map);
|
||||
List<JpaPid> found = mySearchDao.search(resourceName, map);
|
||||
assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1, id2));
|
||||
}
|
||||
// Tag Contents
|
||||
|
@ -172,7 +171,7 @@ public class FhirSearchDaoDstu3Test extends BaseJpaDstu3Test {
|
|||
content.addAnd(new StringOrListParam().addOr(new StringParam("div")));
|
||||
|
||||
map.add(Constants.PARAM_TEXT, content);
|
||||
List<ResourcePersistentId> found = mySearchDao.search(resourceName, map);
|
||||
List<JpaPid> found = mySearchDao.search(resourceName, map);
|
||||
assertThat(JpaPid.toLongList(found), empty());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,12 +2,11 @@ package ca.uhn.fhir.jpa.dao.index;
|
|||
|
||||
import ca.uhn.fhir.interceptor.model.RequestPartitionId;
|
||||
import ca.uhn.fhir.jpa.api.config.DaoConfig;
|
||||
import ca.uhn.fhir.jpa.model.dao.JpaPid;
|
||||
import ca.uhn.fhir.jpa.dao.data.IForcedIdDao;
|
||||
import ca.uhn.fhir.jpa.model.config.PartitionSettings;
|
||||
import ca.uhn.fhir.jpa.model.cross.IResourceLookup;
|
||||
import ca.uhn.fhir.jpa.model.dao.JpaPid;
|
||||
import ca.uhn.fhir.jpa.util.MemoryCacheService;
|
||||
import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId;
|
||||
import org.hl7.fhir.r4.model.Patient;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
@ -67,7 +66,7 @@ public class IdHelperServiceTest {
|
|||
patientIdsToResolve.add("456");
|
||||
|
||||
// test
|
||||
Map<String, ResourcePersistentId> idToPid = myHelperService.resolveResourcePersistentIds(partitionId,
|
||||
Map<String, JpaPid> idToPid = myHelperService.resolveResourcePersistentIds(partitionId,
|
||||
resourceType,
|
||||
patientIdsToResolve);
|
||||
|
||||
|
@ -107,7 +106,7 @@ public class IdHelperServiceTest {
|
|||
.thenReturn(Collections.singletonList(blueView));
|
||||
|
||||
// test
|
||||
Map<String, ResourcePersistentId> map = myHelperService.resolveResourcePersistentIds(
|
||||
Map<String, JpaPid> map = myHelperService.resolveResourcePersistentIds(
|
||||
partitionId,
|
||||
resourceType,
|
||||
patientIdsToResolve);
|
||||
|
@ -137,7 +136,7 @@ public class IdHelperServiceTest {
|
|||
.thenReturn(blue);
|
||||
|
||||
// test
|
||||
Map<String, ResourcePersistentId> map = myHelperService.resolveResourcePersistentIds(
|
||||
Map<String, JpaPid> map = myHelperService.resolveResourcePersistentIds(
|
||||
partitionId,
|
||||
resourceType,
|
||||
patientIdsToResolve
|
||||
|
|
|
@ -7,9 +7,9 @@ import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao;
|
|||
import ca.uhn.fhir.jpa.api.model.HistoryCountModeEnum;
|
||||
import ca.uhn.fhir.jpa.dao.BaseHapiFhirDao;
|
||||
import ca.uhn.fhir.jpa.dao.BaseStorageDao;
|
||||
import ca.uhn.fhir.jpa.model.dao.JpaPid;
|
||||
import ca.uhn.fhir.jpa.dao.JpaResourceDao;
|
||||
import ca.uhn.fhir.jpa.entity.TermConcept;
|
||||
import ca.uhn.fhir.jpa.model.dao.JpaPid;
|
||||
import ca.uhn.fhir.jpa.model.entity.NormalizedQuantitySearchLevel;
|
||||
import ca.uhn.fhir.jpa.model.entity.ResourceEncodingEnum;
|
||||
import ca.uhn.fhir.jpa.model.entity.ResourceHistoryTable;
|
||||
|
@ -478,11 +478,11 @@ public class FhirResourceDaoR4Test extends BaseJpaR4Test {
|
|||
IIdType id2 = myObservationDao.create(o2, mySrd).getId();
|
||||
|
||||
{
|
||||
List<ResourcePersistentId> found = myObservationDao.searchForIds(new SearchParameterMap(Observation.SP_DATE, new DateParam(">2001-01-02")), null);
|
||||
List<JpaPid> found = myObservationDao.searchForIds(new SearchParameterMap(Observation.SP_DATE, new DateParam(">2001-01-02")), null);
|
||||
assertThat(JpaPid.toLongList(found), hasItem(id2.getIdPartAsLong()));
|
||||
}
|
||||
{
|
||||
List<ResourcePersistentId> found = myObservationDao.searchForIds(new SearchParameterMap(Observation.SP_DATE, new DateParam(">2016-01-02")), null);
|
||||
List<JpaPid> found = myObservationDao.searchForIds(new SearchParameterMap(Observation.SP_DATE, new DateParam(">2016-01-02")), null);
|
||||
assertThat(JpaPid.toLongList(found), not(hasItem(id2.getIdPartAsLong())));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ import ca.uhn.fhir.jpa.util.TestUtil;
|
|||
import ca.uhn.fhir.model.primitive.InstantDt;
|
||||
import ca.uhn.fhir.rest.api.MethodOutcome;
|
||||
import ca.uhn.fhir.rest.api.server.IBundleProvider;
|
||||
import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId;
|
||||
import ca.uhn.fhir.rest.param.StringParam;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.ResourceGoneException;
|
||||
|
@ -22,7 +21,6 @@ import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
|
|||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.hl7.fhir.r4.model.CanonicalType;
|
||||
import org.hl7.fhir.r4.model.CodeSystem;
|
||||
import org.hl7.fhir.r4.model.Coding;
|
||||
import org.hl7.fhir.r4.model.ContactPoint;
|
||||
import org.hl7.fhir.r4.model.IdType;
|
||||
|
@ -699,7 +697,7 @@ public class FhirResourceDaoR4UpdateTest extends BaseJpaR4Test {
|
|||
p2.addName().setFamily("Tester").addGiven("testUpdateMaintainsSearchParamsDstu2BBB");
|
||||
myPatientDao.create(p2, mySrd).getId();
|
||||
|
||||
List<ResourcePersistentId> ids = myPatientDao.searchForIds(new SearchParameterMap(Patient.SP_GIVEN, new StringParam("testUpdateMaintainsSearchParamsDstu2AAA")), null);
|
||||
List<JpaPid> ids = myPatientDao.searchForIds(new SearchParameterMap(Patient.SP_GIVEN, new StringParam("testUpdateMaintainsSearchParamsDstu2AAA")), null);
|
||||
assertEquals(1, ids.size());
|
||||
assertThat(JpaPid.toLongList(ids), contains(p1id.getIdPartAsLong()));
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ import ca.uhn.fhir.jpa.test.BaseJpaR4Test;
|
|||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.api.SearchTotalModeEnum;
|
||||
import ca.uhn.fhir.rest.api.server.IBundleProvider;
|
||||
import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId;
|
||||
import ca.uhn.fhir.rest.param.StringAndListParam;
|
||||
import ca.uhn.fhir.rest.param.StringOrListParam;
|
||||
import ca.uhn.fhir.rest.param.StringParam;
|
||||
|
@ -134,7 +133,7 @@ public class FhirSearchDaoR4Test extends BaseJpaR4Test {
|
|||
|
||||
map = new SearchParameterMap();
|
||||
map.add(Constants.PARAM_CONTENT, content);
|
||||
List<ResourcePersistentId> found = mySearchDao.search(resourceName, map);
|
||||
List<JpaPid> found = mySearchDao.search(resourceName, map);
|
||||
assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1));
|
||||
}
|
||||
// OR
|
||||
|
@ -145,7 +144,7 @@ public class FhirSearchDaoR4Test extends BaseJpaR4Test {
|
|||
map = new SearchParameterMap();
|
||||
map.add(Constants.PARAM_CONTENT, content);
|
||||
map.add(Constants.PARAM_CONTENT, content);
|
||||
List<ResourcePersistentId> found = mySearchDao.search(resourceName, map);
|
||||
List<JpaPid> found = mySearchDao.search(resourceName, map);
|
||||
assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1, id2));
|
||||
}
|
||||
// AND
|
||||
|
@ -156,7 +155,7 @@ public class FhirSearchDaoR4Test extends BaseJpaR4Test {
|
|||
|
||||
map = new SearchParameterMap();
|
||||
map.add(Constants.PARAM_CONTENT, content);
|
||||
List<ResourcePersistentId> found = mySearchDao.search(resourceName, map);
|
||||
List<JpaPid> found = mySearchDao.search(resourceName, map);
|
||||
assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1));
|
||||
}
|
||||
// AND OR
|
||||
|
@ -167,7 +166,7 @@ public class FhirSearchDaoR4Test extends BaseJpaR4Test {
|
|||
|
||||
map = new SearchParameterMap();
|
||||
map.add(Constants.PARAM_CONTENT, content);
|
||||
List<ResourcePersistentId> found = mySearchDao.search(resourceName, map);
|
||||
List<JpaPid> found = mySearchDao.search(resourceName, map);
|
||||
assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1, id2));
|
||||
}
|
||||
// All Resource Types
|
||||
|
@ -177,7 +176,7 @@ public class FhirSearchDaoR4Test extends BaseJpaR4Test {
|
|||
|
||||
map = new SearchParameterMap();
|
||||
map.add(Constants.PARAM_CONTENT, content);
|
||||
List<ResourcePersistentId> found = mySearchDao.search(null, map);
|
||||
List<JpaPid> found = mySearchDao.search(null, map);
|
||||
assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1, id2, id3));
|
||||
}
|
||||
|
||||
|
@ -213,7 +212,7 @@ public class FhirSearchDaoR4Test extends BaseJpaR4Test {
|
|||
|
||||
map = new SearchParameterMap();
|
||||
map.add(Constants.PARAM_TEXT, content);
|
||||
List<ResourcePersistentId> found = mySearchDao.search(resourceName, map);
|
||||
List<JpaPid> found = mySearchDao.search(resourceName, map);
|
||||
assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1));
|
||||
}
|
||||
// OR
|
||||
|
@ -223,7 +222,7 @@ public class FhirSearchDaoR4Test extends BaseJpaR4Test {
|
|||
|
||||
map = new SearchParameterMap();
|
||||
map.add(Constants.PARAM_TEXT, content);
|
||||
List<ResourcePersistentId> found = mySearchDao.search(resourceName, map);
|
||||
List<JpaPid> found = mySearchDao.search(resourceName, map);
|
||||
assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1, id2));
|
||||
}
|
||||
// AND
|
||||
|
@ -234,7 +233,7 @@ public class FhirSearchDaoR4Test extends BaseJpaR4Test {
|
|||
|
||||
map = new SearchParameterMap();
|
||||
map.add(Constants.PARAM_TEXT, content);
|
||||
List<ResourcePersistentId> found = mySearchDao.search(resourceName, map);
|
||||
List<JpaPid> found = mySearchDao.search(resourceName, map);
|
||||
assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1));
|
||||
}
|
||||
// AND OR
|
||||
|
@ -245,7 +244,7 @@ public class FhirSearchDaoR4Test extends BaseJpaR4Test {
|
|||
|
||||
map = new SearchParameterMap();
|
||||
map.add(Constants.PARAM_TEXT, content);
|
||||
List<ResourcePersistentId> found = mySearchDao.search(resourceName, map);
|
||||
List<JpaPid> found = mySearchDao.search(resourceName, map);
|
||||
assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1, id2));
|
||||
}
|
||||
// Tag Contents
|
||||
|
@ -255,7 +254,7 @@ public class FhirSearchDaoR4Test extends BaseJpaR4Test {
|
|||
|
||||
map = new SearchParameterMap();
|
||||
map.add(Constants.PARAM_TEXT, content);
|
||||
List<ResourcePersistentId> found = mySearchDao.search(resourceName, map);
|
||||
List<JpaPid> found = mySearchDao.search(resourceName, map);
|
||||
assertThat(JpaPid.toLongList(found), empty());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,45 +20,27 @@ package ca.uhn.fhir.mdm.model;
|
|||
* #L%
|
||||
*/
|
||||
|
||||
import ca.uhn.fhir.jpa.model.dao.JpaPid;
|
||||
import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId;
|
||||
|
||||
public class MdmPidTuple {
|
||||
//TODO KM Should I change the type of these fields and the methods where they are used?
|
||||
private ResourcePersistentId myGoldenPid;
|
||||
private ResourcePersistentId mySourcePid;
|
||||
public class MdmPidTuple<T extends ResourcePersistentId> {
|
||||
private T myGoldenPid;
|
||||
private T mySourcePid;
|
||||
|
||||
public ResourcePersistentId getGoldenPid(){
|
||||
public T getGoldenPid(){
|
||||
return myGoldenPid;
|
||||
}
|
||||
|
||||
public MdmPidTuple setGoldenPid(ResourcePersistentId theGoldenPid) {
|
||||
public MdmPidTuple setGoldenPid(T theGoldenPid) {
|
||||
myGoldenPid = theGoldenPid;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MdmPidTuple setSourcePid(ResourcePersistentId theSourcePid) {
|
||||
public MdmPidTuple setSourcePid(T theSourcePid) {
|
||||
mySourcePid = theSourcePid;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResourcePersistentId getSourcePid(){
|
||||
public T getSourcePid(){
|
||||
return mySourcePid;
|
||||
}
|
||||
|
||||
public Long getGoldenPidAsLong() {
|
||||
return ((JpaPid) myGoldenPid).getId();
|
||||
}
|
||||
|
||||
public Long getSourcePidAsLong() {
|
||||
return ((JpaPid) myGoldenPid).getId();
|
||||
}
|
||||
|
||||
public String getGoldenPidAsString() {
|
||||
return (String) myGoldenPid.getId();
|
||||
}
|
||||
|
||||
public String getSourcePidAsString() {
|
||||
return (String) mySourcePid.getId();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ public class ResourcePersistentId<T> {
|
|||
return myAssociatedResourceId;
|
||||
}
|
||||
|
||||
public ResourcePersistentId setAssociatedResourceId(IIdType theAssociatedResourceId) {
|
||||
public ResourcePersistentId<T> setAssociatedResourceId(IIdType theAssociatedResourceId) {
|
||||
myAssociatedResourceId = theAssociatedResourceId;
|
||||
return this;
|
||||
}
|
||||
|
@ -86,9 +86,6 @@ public class ResourcePersistentId<T> {
|
|||
return retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use getId() method of subclass
|
||||
*/
|
||||
public T getId() {
|
||||
return myId;
|
||||
}
|
||||
|
|
|
@ -54,7 +54,6 @@ import java.util.function.Supplier;
|
|||
*/
|
||||
public class TransactionDetails {
|
||||
|
||||
// TODO KM can't use JpaPid here since module doesn't have the dependency and I get Circular Dependency warning when I try to add it
|
||||
public static final ResourcePersistentId NOT_FOUND = new ResourcePersistentId(-1L);
|
||||
|
||||
private final Date myTransactionDate;
|
||||
|
|
|
@ -28,13 +28,14 @@ import ca.uhn.fhir.batch2.api.StepExecutionDetails;
|
|||
import ca.uhn.fhir.batch2.api.VoidModel;
|
||||
import ca.uhn.fhir.batch2.jobs.chunk.ResourceIdListWorkChunkJson;
|
||||
import ca.uhn.fhir.batch2.jobs.reindex.ReindexJobParameters;
|
||||
import ca.uhn.fhir.i18n.Msg;
|
||||
import ca.uhn.fhir.jpa.api.svc.IDeleteExpungeSvc;
|
||||
import ca.uhn.fhir.jpa.dao.tx.HapiTransactionService;
|
||||
import ca.uhn.fhir.jpa.model.dao.JpaPid;
|
||||
import ca.uhn.fhir.jpa.partition.SystemRequestDetails;
|
||||
import ca.uhn.fhir.rest.api.server.RequestDetails;
|
||||
import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId;
|
||||
import ca.uhn.fhir.rest.api.server.storage.TransactionDetails;
|
||||
import ca.uhn.fhir.util.StopWatch;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.transaction.TransactionStatus;
|
||||
|
@ -92,11 +93,21 @@ public class DeleteExpungeStep implements IJobStepWorker<ReindexJobParameters, R
|
|||
@Override
|
||||
public Void doInTransaction(@Nonnull TransactionStatus theStatus) {
|
||||
|
||||
List<ResourcePersistentId> persistentIds = myData.getResourcePersistentIds();
|
||||
List<ResourcePersistentId<?>> persistentIds = myData.getResourcePersistentIds();
|
||||
|
||||
if (persistentIds.isEmpty()) {
|
||||
ourLog.info("Starting delete expunge work chunk. Ther are no resources to delete expunge - Instance[{}] Chunk[{}]", myInstanceId, myChunkId);
|
||||
return null;
|
||||
}
|
||||
|
||||
ResourcePersistentId firstId = persistentIds.get(0);
|
||||
if (!(firstId instanceof JpaPid)) {
|
||||
throw new IllegalStateException(Msg.code(2208) + "Delete Expunge is currently only supported on relational databases. Got: " + firstId.getClass());
|
||||
}
|
||||
|
||||
ourLog.info("Starting delete expunge work chunk with {} resources - Instance[{}] Chunk[{}]", persistentIds.size(), myInstanceId, myChunkId);
|
||||
|
||||
myDeleteExpungeSvc.deleteExpunge(persistentIds);
|
||||
myDeleteExpungeSvc.deleteExpunge((List<JpaPid>) (List<?>) persistentIds);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ public class ReindexStep implements IJobStepWorker<ReindexJobParameters, Resourc
|
|||
@Autowired
|
||||
private DaoRegistry myDaoRegistry;
|
||||
@Autowired
|
||||
private IIdHelperService myIdHelperService;
|
||||
private IIdHelperService<ResourcePersistentId> myIdHelperService;
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
|
@ -120,7 +120,7 @@ public class ReindexStep implements IJobStepWorker<ReindexJobParameters, Resourc
|
|||
|
||||
String nextResourceType = myData.getResourceType(i);
|
||||
IFhirResourceDao<?> dao = myDaoRegistry.getResourceDao(nextResourceType);
|
||||
ResourcePersistentId resourcePersistentId = persistentIds.get(i);
|
||||
ResourcePersistentId<?> resourcePersistentId = persistentIds.get(i);
|
||||
try {
|
||||
dao.reindex(resourcePersistentId, myRequestDetails, myTransactionDetails);
|
||||
} catch (BaseServerResponseException | DataFormatException e) {
|
||||
|
|
|
@ -20,7 +20,6 @@ package ca.uhn.fhir.batch2.jobs.chunk;
|
|||
* #L%
|
||||
*/
|
||||
|
||||
import ca.uhn.fhir.jpa.model.dao.JpaPid;
|
||||
import ca.uhn.fhir.model.api.IModelJson;
|
||||
import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
@ -58,7 +57,7 @@ public class ResourceIdListWorkChunkJson implements IModelJson {
|
|||
.toString();
|
||||
}
|
||||
|
||||
public List<ResourcePersistentId> getResourcePersistentIds() {
|
||||
public <T extends ResourcePersistentId> List<T> getResourcePersistentIds() {
|
||||
if (myTypedPids.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
@ -66,7 +65,7 @@ public class ResourceIdListWorkChunkJson implements IModelJson {
|
|||
return myTypedPids
|
||||
.stream()
|
||||
.map(t -> {
|
||||
JpaPid retval = new JpaPid(Long.parseLong(t.getPid()));
|
||||
T retval = t.asResourcePersistentId();
|
||||
retval.setResourceType(t.getResourceType());
|
||||
return retval;
|
||||
})
|
||||
|
|
|
@ -22,6 +22,7 @@ package ca.uhn.fhir.batch2.jobs.chunk;
|
|||
|
||||
import ca.uhn.fhir.jpa.api.pid.TypedResourcePid;
|
||||
import ca.uhn.fhir.model.api.IModelJson;
|
||||
import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import org.apache.commons.lang3.builder.EqualsBuilder;
|
||||
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
||||
|
@ -86,4 +87,8 @@ public class TypedPidJson implements IModelJson {
|
|||
public int hashCode() {
|
||||
return new HashCodeBuilder(17, 37).append(myResourceType).append(myPid).toHashCode();
|
||||
}
|
||||
|
||||
public <T extends ResourcePersistentId> T asResourcePersistentId() {
|
||||
return (T) new ResourcePersistentId(myPid);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,6 @@ import ca.uhn.fhir.jpa.api.svc.IIdHelperService;
|
|||
import ca.uhn.fhir.jpa.dao.tx.HapiTransactionService;
|
||||
import ca.uhn.fhir.jpa.delete.DeleteConflictUtil;
|
||||
import ca.uhn.fhir.jpa.partition.SystemRequestDetails;
|
||||
import ca.uhn.fhir.mdm.api.IMdmLinkSvc;
|
||||
import ca.uhn.fhir.mdm.dao.IMdmLinkDao;
|
||||
import ca.uhn.fhir.rest.api.server.RequestDetails;
|
||||
import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId;
|
||||
|
@ -100,7 +99,7 @@ public class MdmClearStep implements IJobStepWorker<MdmClearJobParameters, Resou
|
|||
|
||||
@Override
|
||||
public Void doInTransaction(@Nonnull TransactionStatus theStatus) {
|
||||
List<ResourcePersistentId> persistentIds = myData.getResourcePersistentIds();
|
||||
List<ResourcePersistentId<?>> persistentIds = myData.getResourcePersistentIds();
|
||||
if (persistentIds.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,12 @@ package ca.uhn.fhir.mdm.batch2.submit;
|
|||
* #L%
|
||||
*/
|
||||
|
||||
import ca.uhn.fhir.batch2.api.*;
|
||||
import ca.uhn.fhir.batch2.api.IJobDataSink;
|
||||
import ca.uhn.fhir.batch2.api.IJobStepWorker;
|
||||
import ca.uhn.fhir.batch2.api.JobExecutionFailedException;
|
||||
import ca.uhn.fhir.batch2.api.RunOutcome;
|
||||
import ca.uhn.fhir.batch2.api.StepExecutionDetails;
|
||||
import ca.uhn.fhir.batch2.api.VoidModel;
|
||||
import ca.uhn.fhir.batch2.jobs.chunk.ResourceIdListWorkChunkJson;
|
||||
import ca.uhn.fhir.jpa.api.dao.DaoRegistry;
|
||||
import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao;
|
||||
|
@ -75,7 +80,7 @@ public class MdmInflateAndSubmitResourcesStep implements IJobStepWorker<MdmSubmi
|
|||
return new RunOutcome(allResources.size());
|
||||
}
|
||||
|
||||
private List<IBaseResource> fetchAllResources(List<ResourcePersistentId> theIds) {
|
||||
private List<IBaseResource> fetchAllResources(List<ResourcePersistentId<?>> theIds) {
|
||||
List<IBaseResource> resources = new ArrayList<>();
|
||||
for (ResourcePersistentId id : theIds) {
|
||||
assert id.getResourceType() != null;
|
||||
|
|
|
@ -249,7 +249,7 @@ public interface IFhirResourceDao<T extends IBaseResource> extends IDao {
|
|||
/**
|
||||
* Search for IDs for processing a match URLs, etc.
|
||||
*/
|
||||
default List<ResourcePersistentId> searchForIds(SearchParameterMap theParams, RequestDetails theRequest) {
|
||||
default <T extends ResourcePersistentId> List<T> searchForIds(SearchParameterMap theParams, RequestDetails theRequest) {
|
||||
return searchForIds(theParams, theRequest, null);
|
||||
}
|
||||
|
||||
|
@ -260,7 +260,7 @@ public interface IFhirResourceDao<T extends IBaseResource> extends IDao {
|
|||
* create/update, this is the resource being searched for
|
||||
* @since 5.5.0
|
||||
*/
|
||||
default List<ResourcePersistentId> searchForIds(SearchParameterMap theParams, RequestDetails theRequest, @Nullable IBaseResource theConditionalOperationTargetOrNull) {
|
||||
default <T extends ResourcePersistentId> List<T> searchForIds(SearchParameterMap theParams, RequestDetails theRequest, @Nullable IBaseResource theConditionalOperationTargetOrNull) {
|
||||
return searchForIds(theParams, theRequest);
|
||||
}
|
||||
|
||||
|
@ -330,7 +330,7 @@ public interface IFhirResourceDao<T extends IBaseResource> extends IDao {
|
|||
* @param theRequest the request that initiated the request
|
||||
* @return response back to the client
|
||||
*/
|
||||
DeleteMethodOutcome deletePidList(String theUrl, Collection<ResourcePersistentId> theResourceIds, DeleteConflictList theDeleteConflicts, RequestDetails theRequest);
|
||||
<P extends ResourcePersistentId> DeleteMethodOutcome deletePidList(String theUrl, Collection<P> theResourceIds, DeleteConflictList theDeleteConflicts, RequestDetails theRequest);
|
||||
|
||||
/**
|
||||
* @deprecated use #read(IIdType, RequestDetails) instead
|
||||
|
|
|
@ -90,7 +90,7 @@ public interface IFhirSystemDao<T, MT> extends IDao {
|
|||
* Preload resources from the database in batch. This method is purely
|
||||
* a performance optimization and must be purely idempotent.
|
||||
*/
|
||||
default void preFetchResources(List<ResourcePersistentId> theResolvedIds) {
|
||||
default <P extends ResourcePersistentId> void preFetchResources(List<P> theResolvedIds) {
|
||||
// nothing by default
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,10 +27,10 @@ import java.util.Optional;
|
|||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class PersistentIdToForcedIdMap {
|
||||
private final Map<ResourcePersistentId, Optional<String>> myResourcePersistentIdOptionalMap;
|
||||
public class PersistentIdToForcedIdMap<P extends ResourcePersistentId> {
|
||||
private final Map<P, Optional<String>> myResourcePersistentIdOptionalMap;
|
||||
|
||||
public PersistentIdToForcedIdMap(Map<ResourcePersistentId, Optional<String>> theResourcePersistentIdOptionalMap){
|
||||
public PersistentIdToForcedIdMap(Map<P, Optional<String>> theResourcePersistentIdOptionalMap){
|
||||
myResourcePersistentIdOptionalMap = theResourcePersistentIdOptionalMap;
|
||||
}
|
||||
|
||||
|
@ -41,16 +41,16 @@ public class PersistentIdToForcedIdMap {
|
|||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
private String getResolvedPid(Map.Entry<ResourcePersistentId, Optional<String>> entry) {
|
||||
private String getResolvedPid(Map.Entry<P, Optional<String>> entry) {
|
||||
//If the result of the translation is an empty optional, it means there is no forced id, and we can use the PID as the resource ID.
|
||||
return entry.getValue().isPresent() ? entry.getValue().get() : entry.getKey().toString();
|
||||
}
|
||||
|
||||
public Optional<String> get(ResourcePersistentId theResourcePersistentId) {
|
||||
public Optional<String> get(P theResourcePersistentId) {
|
||||
return myResourcePersistentIdOptionalMap.get(theResourcePersistentId);
|
||||
}
|
||||
|
||||
public Map<ResourcePersistentId, Optional<String>> getResourcePersistentIdOptionalMap(){
|
||||
public Map<P, Optional<String>> getResourcePersistentIdOptionalMap(){
|
||||
return myResourcePersistentIdOptionalMap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ package ca.uhn.fhir.jpa.api.svc;
|
|||
* #L%
|
||||
*/
|
||||
|
||||
import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId;
|
||||
import ca.uhn.fhir.jpa.model.dao.JpaPid;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
@ -29,5 +29,5 @@ import java.util.List;
|
|||
@Transactional(propagation = Propagation.MANDATORY)
|
||||
public interface IDeleteExpungeSvc {
|
||||
|
||||
void deleteExpunge(List<ResourcePersistentId> thePersistentIds);
|
||||
void deleteExpunge(List<JpaPid> thePersistentIds);
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ import java.util.Set;
|
|||
* This interface is used to translate between {@link ResourcePersistentId}
|
||||
* and actual resource IDs.
|
||||
*/
|
||||
public interface IIdHelperService {
|
||||
public interface IIdHelperService<T extends ResourcePersistentId> {
|
||||
|
||||
/**
|
||||
* Given a collection of resource IDs (resource type + id), resolves the internal persistent IDs.
|
||||
|
@ -54,7 +54,7 @@ public interface IIdHelperService {
|
|||
*/
|
||||
//TODO KM Should I change the type of returned value in all these methods?
|
||||
@Nonnull
|
||||
List<ResourcePersistentId> resolveResourcePersistentIdsWithCache(@Nonnull RequestPartitionId theRequestPartitionId, List<IIdType> theIds, boolean theOnlyForcedIds);
|
||||
List<T> resolveResourcePersistentIdsWithCache(@Nonnull RequestPartitionId theRequestPartitionId, List<IIdType> theIds, boolean theOnlyForcedIds);
|
||||
|
||||
/**
|
||||
* Given a resource type and ID, determines the internal persistent ID for the resource.
|
||||
|
@ -62,7 +62,7 @@ public interface IIdHelperService {
|
|||
* @throws ResourceNotFoundException If the ID can not be found
|
||||
*/
|
||||
@Nonnull
|
||||
ResourcePersistentId resolveResourcePersistentIds(@Nonnull RequestPartitionId theRequestPartitionId, String theResourceType, String theId);
|
||||
T resolveResourcePersistentIds(@Nonnull RequestPartitionId theRequestPartitionId, String theResourceType, String theId);
|
||||
|
||||
/**
|
||||
* Given a resource type and ID, determines the internal persistent ID for a resource.
|
||||
|
@ -71,7 +71,7 @@ public interface IIdHelperService {
|
|||
* @throws ResourceNotFoundException If the ID can not be found
|
||||
*/
|
||||
@Nonnull
|
||||
ResourcePersistentId resolveResourcePersistentIds(@Nonnull RequestPartitionId theRequestPartitionId, String theResourceType, String theId, boolean theExcludeDeleted);
|
||||
T resolveResourcePersistentIds(@Nonnull RequestPartitionId theRequestPartitionId, String theResourceType, String theId, boolean theExcludeDeleted);
|
||||
|
||||
/**
|
||||
* Returns a mapping of Id -> ResourcePersistentId.
|
||||
|
@ -79,7 +79,7 @@ public interface IIdHelperService {
|
|||
* (and no map will be returned)
|
||||
*/
|
||||
@Nonnull
|
||||
Map<String, ResourcePersistentId> resolveResourcePersistentIds(@Nonnull RequestPartitionId theRequestPartitionId, String theResourceType, List<String> theIds);
|
||||
Map<String, T> resolveResourcePersistentIds(@Nonnull RequestPartitionId theRequestPartitionId, String theResourceType, List<String> theIds);
|
||||
|
||||
/**
|
||||
* Returns a mapping of Id -> ResourcePersistentId.
|
||||
|
@ -87,13 +87,13 @@ public interface IIdHelperService {
|
|||
* Optionally filters out deleted resources.
|
||||
*/
|
||||
@Nonnull
|
||||
Map<String, ResourcePersistentId> resolveResourcePersistentIds(@Nonnull RequestPartitionId theRequestPartitionId, String theResourceType, List<String> theIds, boolean theExcludeDeleted);
|
||||
Map<String, T> resolveResourcePersistentIds(@Nonnull RequestPartitionId theRequestPartitionId, String theResourceType, List<String> theIds, boolean theExcludeDeleted);
|
||||
|
||||
/**
|
||||
* Given a persistent ID, returns the associated resource ID
|
||||
*/
|
||||
@Nonnull
|
||||
IIdType translatePidIdToForcedId(FhirContext theCtx, String theResourceType, ResourcePersistentId theId);
|
||||
IIdType translatePidIdToForcedId(FhirContext theCtx, String theResourceType, T theId);
|
||||
|
||||
/**
|
||||
* Given a forced ID, convert it to it's Long value. Since you are allowed to use string IDs for resources, we need to
|
||||
|
@ -130,30 +130,30 @@ public interface IIdHelperService {
|
|||
* are deleted (but note that forced IDs can't change, so the cache can't return incorrect results)
|
||||
*/
|
||||
@Nonnull
|
||||
List<ResourcePersistentId> resolveResourcePersistentIdsWithCache(RequestPartitionId theRequestPartitionId, List<IIdType> theIds);
|
||||
List<T> resolveResourcePersistentIdsWithCache(RequestPartitionId theRequestPartitionId, List<IIdType> theIds);
|
||||
|
||||
Optional<String> translatePidIdToForcedIdWithCache(ResourcePersistentId theResourcePersistentId);
|
||||
Optional<String> translatePidIdToForcedIdWithCache(T theResourcePersistentId);
|
||||
|
||||
PersistentIdToForcedIdMap translatePidsToForcedIds(Set<ResourcePersistentId> theResourceIds);
|
||||
PersistentIdToForcedIdMap translatePidsToForcedIds(Set<T> theResourceIds);
|
||||
|
||||
/**
|
||||
* Pre-cache a PID-to-Resource-ID mapping for later retrieval by {@link #translatePidsToForcedIds(Set)} and related methods
|
||||
*/
|
||||
void addResolvedPidToForcedId(ResourcePersistentId theResourcePersistentId, @Nonnull RequestPartitionId theRequestPartitionId, String theResourceType, @Nullable String theForcedId, @Nullable Date theDeletedAt);
|
||||
void addResolvedPidToForcedId(T theResourcePersistentId, @Nonnull RequestPartitionId theRequestPartitionId, String theResourceType, @Nullable String theForcedId, @Nullable Date theDeletedAt);
|
||||
|
||||
@Nonnull
|
||||
List<ResourcePersistentId> getPidsOrThrowException(RequestPartitionId theRequestPartitionId, List<IIdType> theIds);
|
||||
List<T> getPidsOrThrowException(RequestPartitionId theRequestPartitionId, List<IIdType> theIds);
|
||||
|
||||
@Nullable
|
||||
ResourcePersistentId getPidOrNull(RequestPartitionId theRequestPartitionId, IBaseResource theResource);
|
||||
T getPidOrNull(RequestPartitionId theRequestPartitionId, IBaseResource theResource);
|
||||
|
||||
@Nonnull
|
||||
ResourcePersistentId getPidOrThrowException(RequestPartitionId theRequestPartitionId, IIdType theId);
|
||||
T getPidOrThrowException(RequestPartitionId theRequestPartitionId, IIdType theId);
|
||||
|
||||
@Nonnull
|
||||
ResourcePersistentId getPidOrThrowException(@Nonnull IAnyResource theResource);
|
||||
T getPidOrThrowException(@Nonnull IAnyResource theResource);
|
||||
|
||||
IIdType resourceIdFromPidOrThrowException(ResourcePersistentId thePid, String theResourceType);
|
||||
IIdType resourceIdFromPidOrThrowException(T thePid, String theResourceType);
|
||||
|
||||
/**
|
||||
* Given a set of PIDs, return a set of public FHIR Resource IDs.
|
||||
|
@ -166,7 +166,7 @@ public interface IIdHelperService {
|
|||
* @param thePids The Set of pids you would like to resolve to external FHIR Resource IDs.
|
||||
* @return A Set of strings representing the FHIR IDs of the pids.
|
||||
*/
|
||||
Set<String> translatePidsToFhirResourceIds(Set<ResourcePersistentId> thePids);
|
||||
Set<String> translatePidsToFhirResourceIds(Set<T> thePids);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -32,11 +32,11 @@ import javax.annotation.Nullable;
|
|||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface ISearchCoordinatorSvc {
|
||||
public interface ISearchCoordinatorSvc<T extends ResourcePersistentId> {
|
||||
|
||||
void cancelAllActiveSearches();
|
||||
|
||||
List<ResourcePersistentId> getResources(String theUuid, int theFrom, int theTo, @Nullable RequestDetails theRequestDetails);
|
||||
List<T> getResources(String theUuid, int theFrom, int theTo, @Nullable RequestDetails theRequestDetails);
|
||||
|
||||
IBundleProvider registerSearch(IFhirResourceDao<?> theCallingDao, SearchParameterMap theParams, String theResourceType, CacheControlDirective theCacheControlDirective, @Nullable RequestDetails theRequestDetails, RequestPartitionId theRequestPartitionId);
|
||||
|
||||
|
|
|
@ -27,14 +27,14 @@ import org.hl7.fhir.instance.model.api.IBaseResource;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public interface IBulkExportProcessor {
|
||||
public interface IBulkExportProcessor<T extends ResourcePersistentId> {
|
||||
|
||||
/**
|
||||
* For fetching PIDs of resources
|
||||
* @param theParams
|
||||
* @return
|
||||
*/
|
||||
Iterator<ResourcePersistentId> getResourcePidIterator(ExportPIDIteratorParameters theParams);
|
||||
Iterator<T> getResourcePidIterator(ExportPIDIteratorParameters theParams);
|
||||
|
||||
/**
|
||||
* Does the MDM expansion of resources if necessary
|
||||
|
|
|
@ -26,6 +26,7 @@ import ca.uhn.fhir.jpa.api.dao.IJpaDao;
|
|||
import ca.uhn.fhir.jpa.api.model.DaoMethodOutcome;
|
||||
import ca.uhn.fhir.jpa.dao.tx.HapiTransactionService;
|
||||
import ca.uhn.fhir.jpa.model.cross.IBasePersistedResource;
|
||||
import ca.uhn.fhir.jpa.model.dao.JpaPid;
|
||||
import ca.uhn.fhir.jpa.patch.FhirPatch;
|
||||
import ca.uhn.fhir.jpa.patch.JsonPatchUtils;
|
||||
import ca.uhn.fhir.jpa.patch.XmlPatchUtils;
|
||||
|
@ -76,12 +77,12 @@ public abstract class BaseStorageResourceDao<T extends IBaseResource> extends Ba
|
|||
IIdType resourceId;
|
||||
if (isNotBlank(theConditionalUrl)) {
|
||||
|
||||
Set<ResourcePersistentId> match = getMatchResourceUrlService().processMatchUrl(theConditionalUrl, getResourceType(), theTransactionDetails, theRequestDetails);
|
||||
Set<JpaPid> match = getMatchResourceUrlService().processMatchUrl(theConditionalUrl, getResourceType(), theTransactionDetails, theRequestDetails);
|
||||
if (match.size() > 1) {
|
||||
String msg = getContext().getLocalizer().getMessageSanitized(BaseStorageDao.class, "transactionOperationWithMultipleMatchFailure", "PATCH", theConditionalUrl, match.size());
|
||||
throw new PreconditionFailedException(Msg.code(972) + msg);
|
||||
} else if (match.size() == 1) {
|
||||
ResourcePersistentId pid = match.iterator().next();
|
||||
JpaPid pid = match.iterator().next();
|
||||
entityToUpdate = readEntityLatestVersion(pid, theRequestDetails, theTransactionDetails);
|
||||
resourceId = entityToUpdate.getIdDt();
|
||||
} else {
|
||||
|
|
|
@ -26,12 +26,12 @@ import java.io.Closeable;
|
|||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
public interface IResultIterator extends Iterator<ResourcePersistentId>, Closeable {
|
||||
public interface IResultIterator<T extends ResourcePersistentId> extends Iterator<T>, Closeable {
|
||||
|
||||
int getSkippedCount();
|
||||
|
||||
int getNonSkippedCount();
|
||||
|
||||
Collection<ResourcePersistentId> getNextResultBatch(long theBatchSize);
|
||||
Collection<T> getNextResultBatch(long theBatchSize);
|
||||
|
||||
}
|
||||
|
|
|
@ -22,22 +22,21 @@ package ca.uhn.fhir.jpa.dao;
|
|||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.interceptor.model.RequestPartitionId;
|
||||
import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId;
|
||||
import ca.uhn.fhir.jpa.model.search.SearchRuntimeDetails;
|
||||
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
|
||||
import ca.uhn.fhir.model.api.Include;
|
||||
import ca.uhn.fhir.rest.api.server.RequestDetails;
|
||||
import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId;
|
||||
import ca.uhn.fhir.rest.param.DateRangeParam;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.persistence.EntityManager;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public interface ISearchBuilder {
|
||||
public interface ISearchBuilder<T extends ResourcePersistentId> {
|
||||
String SEARCH_BUILDER_BEAN_NAME = "SearchBuilder";
|
||||
|
||||
IResultIterator createQuery(SearchParameterMap theParams, SearchRuntimeDetails theSearchRuntime, RequestDetails theRequest, @Nonnull RequestPartitionId theRequestPartitionId);
|
||||
|
@ -46,9 +45,9 @@ public interface ISearchBuilder {
|
|||
|
||||
void setMaxResultsToFetch(Integer theMaxResultsToFetch);
|
||||
|
||||
void loadResourcesByPid(Collection<ResourcePersistentId> thePids, Collection<ResourcePersistentId> theIncludedPids, List<IBaseResource> theResourceListToPopulate, boolean theForHistoryOperation, RequestDetails theDetails);
|
||||
void loadResourcesByPid(Collection<T> thePids, Collection<T> theIncludedPids, List<IBaseResource> theResourceListToPopulate, boolean theForHistoryOperation, RequestDetails theDetails);
|
||||
|
||||
Set<ResourcePersistentId> loadIncludes(FhirContext theContext, EntityManager theEntityManager, Collection<ResourcePersistentId> theMatches, Collection<Include> theRevIncludes, boolean theReverseMode,
|
||||
Set<T> loadIncludes(FhirContext theContext, EntityManager theEntityManager, Collection<T> theMatches, Collection<Include> theRevIncludes, boolean theReverseMode,
|
||||
DateRangeParam theLastUpdated, String theSearchIdOrDescription, RequestDetails theRequest, Integer theMaxCount);
|
||||
|
||||
/**
|
||||
|
@ -56,6 +55,6 @@ public interface ISearchBuilder {
|
|||
*/
|
||||
void setFetchSize(int theFetchSize);
|
||||
|
||||
void setPreviouslyAddedResourcePids(List<ResourcePersistentId> thePreviouslyAddedResourcePids);
|
||||
void setPreviouslyAddedResourcePids(List<T> thePreviouslyAddedResourcePids);
|
||||
|
||||
}
|
||||
|
|
|
@ -20,9 +20,9 @@ package ca.uhn.fhir.jpa.dao;
|
|||
* #L%
|
||||
*/
|
||||
|
||||
import ca.uhn.fhir.i18n.Msg;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||
import ca.uhn.fhir.i18n.Msg;
|
||||
import ca.uhn.fhir.interceptor.api.HookParams;
|
||||
import ca.uhn.fhir.interceptor.api.IInterceptorBroadcaster;
|
||||
import ca.uhn.fhir.interceptor.api.Pointcut;
|
||||
|
@ -60,7 +60,7 @@ import java.util.Set;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class MatchResourceUrlService {
|
||||
public class MatchResourceUrlService<T extends ResourcePersistentId> {
|
||||
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(MatchResourceUrlService.class);
|
||||
|
||||
|
@ -80,20 +80,20 @@ public class MatchResourceUrlService {
|
|||
/**
|
||||
* Note that this will only return a maximum of 2 results!!
|
||||
*/
|
||||
public <R extends IBaseResource> Set<ResourcePersistentId> processMatchUrl(String theMatchUrl, Class<R> theResourceType, TransactionDetails theTransactionDetails, RequestDetails theRequest) {
|
||||
public <R extends IBaseResource> Set<T> processMatchUrl(String theMatchUrl, Class<R> theResourceType, TransactionDetails theTransactionDetails, RequestDetails theRequest) {
|
||||
return processMatchUrl(theMatchUrl, theResourceType, theTransactionDetails, theRequest, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Note that this will only return a maximum of 2 results!!
|
||||
*/
|
||||
public <R extends IBaseResource> Set<ResourcePersistentId> processMatchUrl(String theMatchUrl, Class<R> theResourceType, TransactionDetails theTransactionDetails, RequestDetails theRequest, IBaseResource theConditionalOperationTargetOrNull) {
|
||||
Set<ResourcePersistentId> retVal = null;
|
||||
public <R extends IBaseResource> Set<T> processMatchUrl(String theMatchUrl, Class<R> theResourceType, TransactionDetails theTransactionDetails, RequestDetails theRequest, IBaseResource theConditionalOperationTargetOrNull) {
|
||||
Set<T> retVal = null;
|
||||
|
||||
String resourceType = myContext.getResourceType(theResourceType);
|
||||
String matchUrl = massageForStorage(resourceType, theMatchUrl);
|
||||
|
||||
ResourcePersistentId resolvedInTransaction = theTransactionDetails.getResolvedMatchUrls().get(matchUrl);
|
||||
T resolvedInTransaction = (T) theTransactionDetails.getResolvedMatchUrls().get(matchUrl);
|
||||
if (resolvedInTransaction != null) {
|
||||
// If the resource has previously been looked up within the transaction, there's no need to re-authorize it.
|
||||
if (resolvedInTransaction == TransactionDetails.NOT_FOUND) {
|
||||
|
@ -103,7 +103,7 @@ public class MatchResourceUrlService {
|
|||
}
|
||||
}
|
||||
|
||||
ResourcePersistentId resolvedInCache = processMatchUrlUsingCacheOnly(resourceType, matchUrl);
|
||||
T resolvedInCache = processMatchUrlUsingCacheOnly(resourceType, matchUrl);
|
||||
if (resolvedInCache != null) {
|
||||
retVal = Collections.singleton(resolvedInCache);
|
||||
}
|
||||
|
@ -121,11 +121,11 @@ public class MatchResourceUrlService {
|
|||
|
||||
// Interceptor broadcast: STORAGE_PRESHOW_RESOURCES
|
||||
if (CompositeInterceptorBroadcaster.hasHooks(Pointcut.STORAGE_PRESHOW_RESOURCES, myInterceptorBroadcaster, theRequest)) {
|
||||
Map<IBaseResource, ResourcePersistentId> resourceToPidMap = new HashMap<>();
|
||||
Map<IBaseResource, T> resourceToPidMap = new HashMap<>();
|
||||
|
||||
IFhirResourceDao<R> dao = getResourceDao(theResourceType);
|
||||
|
||||
for (ResourcePersistentId pid : retVal) {
|
||||
for (T pid : retVal) {
|
||||
resourceToPidMap.put(dao.readByPid(pid), pid);
|
||||
}
|
||||
|
||||
|
@ -152,7 +152,7 @@ public class MatchResourceUrlService {
|
|||
}
|
||||
|
||||
if (retVal.size() == 1) {
|
||||
ResourcePersistentId pid = retVal.iterator().next();
|
||||
T pid = retVal.iterator().next();
|
||||
theTransactionDetails.addResolvedMatchUrl(matchUrl, pid);
|
||||
if (myDaoConfig.isMatchUrlCacheEnabled()) {
|
||||
myMemoryCacheService.putAfterCommit(MemoryCacheService.CacheEnum.MATCH_URL, matchUrl, pid);
|
||||
|
@ -183,8 +183,8 @@ public class MatchResourceUrlService {
|
|||
}
|
||||
|
||||
@Nullable
|
||||
public ResourcePersistentId processMatchUrlUsingCacheOnly(String theResourceType, String theMatchUrl) {
|
||||
ResourcePersistentId existing = null;
|
||||
public T processMatchUrlUsingCacheOnly(String theResourceType, String theMatchUrl) {
|
||||
T existing = null;
|
||||
if (myDaoConfig.isMatchUrlCacheEnabled()) {
|
||||
String matchUrl = massageForStorage(theResourceType, theMatchUrl);
|
||||
existing = myMemoryCacheService.getIfPresent(MemoryCacheService.CacheEnum.MATCH_URL, matchUrl);
|
||||
|
@ -192,11 +192,11 @@ public class MatchResourceUrlService {
|
|||
return existing;
|
||||
}
|
||||
|
||||
public <R extends IBaseResource> Set<ResourcePersistentId> search(SearchParameterMap theParamMap, Class<R> theResourceType, RequestDetails theRequest, @Nullable IBaseResource theConditionalOperationTargetOrNull) {
|
||||
public <R extends IBaseResource> Set<T> search(SearchParameterMap theParamMap, Class<R> theResourceType, RequestDetails theRequest, @Nullable IBaseResource theConditionalOperationTargetOrNull) {
|
||||
StopWatch sw = new StopWatch();
|
||||
IFhirResourceDao<R> dao = getResourceDao(theResourceType);
|
||||
|
||||
List<ResourcePersistentId> retVal = dao.searchForIds(theParamMap, theRequest, theConditionalOperationTargetOrNull);
|
||||
List<T> retVal = dao.searchForIds(theParamMap, theRequest, theConditionalOperationTargetOrNull);
|
||||
|
||||
// Interceptor broadcast: JPA_PERFTRACE_INFO
|
||||
if (CompositeInterceptorBroadcaster.hasHooks(Pointcut.JPA_PERFTRACE_INFO, myInterceptorBroadcaster, theRequest)) {
|
||||
|
@ -213,7 +213,7 @@ public class MatchResourceUrlService {
|
|||
}
|
||||
|
||||
|
||||
public void matchUrlResolved(TransactionDetails theTransactionDetails, String theResourceType, String theMatchUrl, ResourcePersistentId theResourcePersistentId) {
|
||||
public void matchUrlResolved(TransactionDetails theTransactionDetails, String theResourceType, String theMatchUrl, T theResourcePersistentId) {
|
||||
Validate.notBlank(theMatchUrl);
|
||||
Validate.notNull(theResourcePersistentId);
|
||||
String matchUrl = massageForStorage(theResourceType, theMatchUrl);
|
||||
|
|
|
@ -22,19 +22,20 @@ package ca.uhn.fhir.jpa.dao;
|
|||
|
||||
import ca.uhn.fhir.jpa.api.config.DaoConfig;
|
||||
import ca.uhn.fhir.jpa.api.dao.IDao;
|
||||
import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
|
||||
public class SearchBuilderFactory {
|
||||
public class SearchBuilderFactory<T extends ResourcePersistentId<?>> {
|
||||
|
||||
@Autowired
|
||||
private ApplicationContext myApplicationContext;
|
||||
@Autowired
|
||||
private DaoConfig myDaoConfig;
|
||||
|
||||
public ISearchBuilder newSearchBuilder(IDao theDao, String theResourceName, Class<? extends IBaseResource> theResourceType) {
|
||||
return (ISearchBuilder) myApplicationContext.getBean(ISearchBuilder.SEARCH_BUILDER_BEAN_NAME, theDao, theResourceName, theResourceType, myDaoConfig);
|
||||
public ISearchBuilder<T> newSearchBuilder(IDao theDao, String theResourceName, Class<? extends IBaseResource> theResourceType) {
|
||||
return (ISearchBuilder<T>) myApplicationContext.getBean(ISearchBuilder.SEARCH_BUILDER_BEAN_NAME, theDao, theResourceName, theResourceType, myDaoConfig);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,16 +26,16 @@ import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId;
|
|||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public interface IResourceExpungeService {
|
||||
List<ResourcePersistentId> findHistoricalVersionsOfDeletedResources(String theResourceName, ResourcePersistentId theResourceId, int theI);
|
||||
public interface IResourceExpungeService<T extends ResourcePersistentId> {
|
||||
List<T> findHistoricalVersionsOfDeletedResources(String theResourceName, T theResourceId, int theI);
|
||||
|
||||
List<ResourcePersistentId> findHistoricalVersionsOfNonDeletedResources(String theResourceName, ResourcePersistentId theResourceId, int theI);
|
||||
List<T> findHistoricalVersionsOfNonDeletedResources(String theResourceName, T theResourceId, int theI);
|
||||
|
||||
void expungeHistoricalVersions(RequestDetails theRequestDetails, List<ResourcePersistentId> thePartition, AtomicInteger theRemainingCount);
|
||||
void expungeHistoricalVersions(RequestDetails theRequestDetails, List<T> thePartition, AtomicInteger theRemainingCount);
|
||||
|
||||
void expungeCurrentVersionOfResources(RequestDetails theRequestDetails, List<ResourcePersistentId> theResourceIds, AtomicInteger theRemainingCount);
|
||||
void expungeCurrentVersionOfResources(RequestDetails theRequestDetails, List<T> theResourceIds, AtomicInteger theRemainingCount);
|
||||
|
||||
void expungeHistoricalVersionsOfIds(RequestDetails theRequestDetails, List<ResourcePersistentId> theResourceIds, AtomicInteger theRemainingCount);
|
||||
void expungeHistoricalVersionsOfIds(RequestDetails theRequestDetails, List<T> theResourceIds, AtomicInteger theRemainingCount);
|
||||
|
||||
void deleteAllSearchParams(ResourcePersistentId theResourceId);
|
||||
void deleteAllSearchParams(T theResourceId);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue