diff --git a/hapi-deployable-pom/pom.xml b/hapi-deployable-pom/pom.xml index 06a732ff02c..56ebb88005f 100644 --- a/hapi-deployable-pom/pom.xml +++ b/hapi-deployable-pom/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-fhir - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../pom.xml diff --git a/hapi-fhir-android/pom.xml b/hapi-fhir-android/pom.xml index f3fa6ed28ea..75d54eca43d 100644 --- a/hapi-fhir-android/pom.xml +++ b/hapi-fhir-android/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-base/pom.xml b/hapi-fhir-base/pom.xml index 005235ccd16..ae98a263c52 100644 --- a/hapi-fhir-base/pom.xml +++ b/hapi-fhir-base/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-bom/pom.xml b/hapi-fhir-bom/pom.xml index 825e4431039..a53533e49a2 100644 --- a/hapi-fhir-bom/pom.xml +++ b/hapi-fhir-bom/pom.xml @@ -3,14 +3,14 @@ 4.0.0 ca.uhn.hapi.fhir hapi-fhir-bom - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT pom HAPI FHIR BOM ca.uhn.hapi.fhir hapi-deployable-pom - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-checkstyle/pom.xml b/hapi-fhir-checkstyle/pom.xml index b986d1077f1..53e14ec959c 100644 --- a/hapi-fhir-checkstyle/pom.xml +++ b/hapi-fhir-checkstyle/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../pom.xml diff --git a/hapi-fhir-cli/hapi-fhir-cli-api/pom.xml b/hapi-fhir-cli/hapi-fhir-cli-api/pom.xml index 70f2caf3980..db98a06187f 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-api/pom.xml +++ b/hapi-fhir-cli/hapi-fhir-cli-api/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-cli/hapi-fhir-cli-app/pom.xml b/hapi-fhir-cli/hapi-fhir-cli-app/pom.xml index 62b42c5e86b..3b5dd0cb554 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-app/pom.xml +++ b/hapi-fhir-cli/hapi-fhir-cli-app/pom.xml @@ -6,7 +6,7 @@ ca.uhn.hapi.fhir hapi-fhir-cli - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../pom.xml diff --git a/hapi-fhir-cli/hapi-fhir-cli-jpaserver/pom.xml b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/pom.xml index 1c624dadc7c..ef9f55fabf8 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-jpaserver/pom.xml +++ b/hapi-fhir-cli/hapi-fhir-cli-jpaserver/pom.xml @@ -6,7 +6,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../../hapi-deployable-pom diff --git a/hapi-fhir-cli/pom.xml b/hapi-fhir-cli/pom.xml index 1a3e2fe756d..f3b1a1b4fdf 100644 --- a/hapi-fhir-cli/pom.xml +++ b/hapi-fhir-cli/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../pom.xml diff --git a/hapi-fhir-client-okhttp/pom.xml b/hapi-fhir-client-okhttp/pom.xml index 590d627faab..bac49a42668 100644 --- a/hapi-fhir-client-okhttp/pom.xml +++ b/hapi-fhir-client-okhttp/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-client/pom.xml b/hapi-fhir-client/pom.xml index 60c6713c747..e30f3af42c5 100644 --- a/hapi-fhir-client/pom.xml +++ b/hapi-fhir-client/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-converter/pom.xml b/hapi-fhir-converter/pom.xml index ebb58ce95dc..d6e9ed0650a 100644 --- a/hapi-fhir-converter/pom.xml +++ b/hapi-fhir-converter/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-dist/pom.xml b/hapi-fhir-dist/pom.xml index f88a1cd4aa9..4e5afa796ad 100644 --- a/hapi-fhir-dist/pom.xml +++ b/hapi-fhir-dist/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../pom.xml diff --git a/hapi-fhir-docs/pom.xml b/hapi-fhir-docs/pom.xml index adffe9d0272..e2ba789838b 100644 --- a/hapi-fhir-docs/pom.xml +++ b/hapi-fhir-docs/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/6_1_0/3379-mdm-operation-fixes.yaml b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/6_1_0/3379-mdm-operation-fixes.yaml index 694c6941109..c595ad178ec 100644 --- a/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/6_1_0/3379-mdm-operation-fixes.yaml +++ b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/6_1_0/3379-mdm-operation-fixes.yaml @@ -1,5 +1,5 @@ --- type: fix issue: 3379 -title: "Fixed an issue where FindCandidateByLinkSvc still uses long to store persistent ids rather than ResourcePersistentId, +title: "Fixed an issue where FindCandidateByLinkSvc still uses long to store persistent ids rather than IResourcePersistentId, also fixed an issue where MdmLinkCreateSvc was not setting the resource type of MdmLinks properly" diff --git a/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/6_4_0/4245-replace-resourcepersitentid-with-interface.yaml b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/6_4_0/4245-replace-resourcepersitentid-with-interface.yaml new file mode 100644 index 00000000000..d5652d05304 --- /dev/null +++ b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/6_4_0/4245-replace-resourcepersitentid-with-interface.yaml @@ -0,0 +1,5 @@ +--- +type: change +issue: 4244 +title: "Replace usages of ResourcePersistentId with an interface IResourcePersistentId and parameterize specific +implementations of it in classes that rely on a specific implementation." diff --git a/hapi-fhir-jacoco/pom.xml b/hapi-fhir-jacoco/pom.xml index b5add09df5c..cb3558562a0 100644 --- a/hapi-fhir-jacoco/pom.xml +++ b/hapi-fhir-jacoco/pom.xml @@ -11,7 +11,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jaxrsserver-base/pom.xml b/hapi-fhir-jaxrsserver-base/pom.xml index 2e20067fa7f..1d7ec70544d 100644 --- a/hapi-fhir-jaxrsserver-base/pom.xml +++ b/hapi-fhir-jaxrsserver-base/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpa/pom.xml b/hapi-fhir-jpa/pom.xml index 19277e66e95..46a6721952f 100644 --- a/hapi-fhir-jpa/pom.xml +++ b/hapi-fhir-jpa/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../hapi-deployable-pom/pom.xml 4.0.0 diff --git a/hapi-fhir-jpaserver-base/pom.xml b/hapi-fhir-jpaserver-base/pom.xml index 2fff7a3da69..3ce2eb57d13 100644 --- a/hapi-fhir-jpaserver-base/pom.xml +++ b/hapi-fhir-jpaserver-base/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/bulk/export/svc/JpaBulkExportProcessor.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/bulk/export/svc/JpaBulkExportProcessor.java index cc2b8b35fc8..393753e1c50 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/bulk/export/svc/JpaBulkExportProcessor.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/bulk/export/svc/JpaBulkExportProcessor.java @@ -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; @@ -72,6 +72,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Optional; @@ -81,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 { private static final Logger ourLog = LoggerFactory.getLogger(JpaBulkExportProcessor.class); public static final int QUERY_CHUNK_SIZE = 100; @@ -100,10 +101,10 @@ public class JpaBulkExportProcessor implements IBulkExportProcessor { private DaoRegistry myDaoRegistry; @Autowired - protected SearchBuilderFactory mySearchBuilderFactory; + protected SearchBuilderFactory mySearchBuilderFactory; @Autowired - private IIdHelperService myIdHelperService; + private IIdHelperService myIdHelperService; @Autowired private IMdmLinkDao myMdmLinkDao; @@ -118,12 +119,12 @@ public class JpaBulkExportProcessor implements IBulkExportProcessor { @Transactional @Override - public Iterator getResourcePidIterator(ExportPIDIteratorParameters theParams) { + public Iterator getResourcePidIterator(ExportPIDIteratorParameters theParams) { String resourceType = theParams.getResourceType(); String jobId = theParams.getJobId(); RuntimeResourceDefinition def = myContext.getResourceDefinition(resourceType); - Set pids; + LinkedHashSet pids; if (theParams.getExportStyle() == BulkDataExportOptions.ExportStyle.PATIENT) { pids = getPidsForPatientStyleExport(theParams, resourceType, jobId, def); } else if (theParams.getExportStyle() == BulkDataExportOptions.ExportStyle.GROUP) { @@ -136,8 +137,8 @@ public class JpaBulkExportProcessor implements IBulkExportProcessor { return pids.iterator(); } - private Set getPidsForPatientStyleExport(ExportPIDIteratorParameters theParams, String resourceType, String jobId, RuntimeResourceDefinition def) { - Set pids = new HashSet<>(); + private LinkedHashSet getPidsForPatientStyleExport(ExportPIDIteratorParameters theParams, String resourceType, String jobId, RuntimeResourceDefinition def) { + LinkedHashSet 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"; @@ -152,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 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 resultIterator = searchBuilder.createQuery(map, searchRuntime, null, RequestPartitionId.allPartitions()); while (resultIterator.hasNext()) { pids.add(resultIterator.next()); } @@ -190,15 +191,15 @@ public class JpaBulkExportProcessor implements IBulkExportProcessor { return referenceOrListParam; } - private Set getPidsForSystemStyleExport(ExportPIDIteratorParameters theParams, String theJobId, RuntimeResourceDefinition theDef) { - Set pids = new HashSet<>(); + private LinkedHashSet getPidsForSystemStyleExport(ExportPIDIteratorParameters theParams, String theJobId, RuntimeResourceDefinition theDef) { + LinkedHashSet pids = new LinkedHashSet<>(); // System List maps = myBulkExportHelperSvc.createSearchParameterMapsForResourceType(theDef, theParams); - ISearchBuilder searchBuilder = getSearchBuilderForResourceType(theParams.getResourceType()); + ISearchBuilder searchBuilder = getSearchBuilderForResourceType(theParams.getResourceType()); for (SearchParameterMap map : maps) { // requires a transaction - IResultIterator resultIterator = searchBuilder.createQuery(map, + IResultIterator resultIterator = searchBuilder.createQuery(map, new SearchRuntimeDetails(null, theJobId), null, RequestPartitionId.allPartitions()); @@ -209,8 +210,8 @@ public class JpaBulkExportProcessor implements IBulkExportProcessor { return pids; } - private Set getPidsForGroupStyleExport(ExportPIDIteratorParameters theParams, String theResourceType, RuntimeResourceDefinition theDef) { - Set pids; + private LinkedHashSet getPidsForGroupStyleExport(ExportPIDIteratorParameters theParams, String theResourceType, RuntimeResourceDefinition theDef) { + LinkedHashSet pids; if (theResourceType.equalsIgnoreCase("Patient")) { ourLog.info("Expanding Patients of a Group Bulk Export."); @@ -224,9 +225,9 @@ public class JpaBulkExportProcessor implements IBulkExportProcessor { return pids; } - private Set getRelatedResourceTypePids(ExportPIDIteratorParameters theParams, RuntimeResourceDefinition theDef) { - Set pids = new HashSet<>(); - Set expandedMemberResourceIds = expandAllPatientPidsFromGroup(theParams); + private LinkedHashSet getRelatedResourceTypePids(ExportPIDIteratorParameters theParams, RuntimeResourceDefinition theDef) { + LinkedHashSet pids = new LinkedHashSet<>(); + Set expandedMemberResourceIds = expandAllPatientPidsFromGroup(theParams); assert expandedMemberResourceIds != null && !expandedMemberResourceIds.isEmpty(); if (ourLog.isDebugEnabled()) { ourLog.debug("{} has been expanded to members:[{}]", theParams.getGroupId(), expandedMemberResourceIds); @@ -234,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 queryChunker = new QueryChunker<>(); + QueryChunker queryChunker = new QueryChunker<>(); queryChunker.chunk(expandedMemberResourceIds, QUERY_CHUNK_SIZE, (idChunk) -> { queryResourceTypeWithReferencesToPatients(pids, idChunk, theParams, theDef); }); return pids; } - private Set getSingletonGroupList(ExportPIDIteratorParameters theParams) { + private LinkedHashSet getSingletonGroupList(ExportPIDIteratorParameters theParams) { IBaseResource group = myDaoRegistry.getResourceDao("Group").read(new IdDt(theParams.getGroupId()), SystemRequestDetails.newSystemRequestAllPartitions()); - ResourcePersistentId pidOrNull = myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), group); - Set pids = new HashSet<>(); + JpaPid pidOrNull = myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), group); + LinkedHashSet pids = new LinkedHashSet<>(); pids.add(pidOrNull); return pids; } @@ -252,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 getSearchBuilderForResourceType(String theResourceType) { IFhirResourceDao dao = myDaoRegistry.getResourceDao(theResourceType); RuntimeResourceDefinition def = myContext.getResourceDefinition(theResourceType); Class typeClass = def.getImplementingClass(); @@ -307,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 Set getExpandedPatientList(ExportPIDIteratorParameters theParameters) { - List members = getMembersFromGroupWithFilter(theParameters); + private LinkedHashSet getExpandedPatientList(ExportPIDIteratorParameters theParameters) { + List members = getMembersFromGroupWithFilter(theParameters); List 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 pidsOrThrowException = members; - Set patientPidsToExport = new HashSet<>(pidsOrThrowException); + List pidsOrThrowException = members; + LinkedHashSet 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 goldenPidSourcePidTuple = myMdmLinkDao.expandPidsFromGroupPidGivenMatchResult(pidOrNull, MdmMatchResultEnum.MATCH); + JpaPid pidOrNull = myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), group); + List> goldenPidSourcePidTuple = myMdmLinkDao.expandPidsFromGroupPidGivenMatchResult(pidOrNull, MdmMatchResultEnum.MATCH); goldenPidSourcePidTuple.forEach(tuple -> { patientPidsToExport.add(tuple.getGoldenPid()); patientPidsToExport.add(tuple.getSourcePid()); @@ -336,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 getMembersFromGroupWithFilter(ExportPIDIteratorParameters theParameters) { + private List getMembersFromGroupWithFilter(ExportPIDIteratorParameters theParameters) { RuntimeResourceDefinition def = myContext.getResourceDefinition("Patient"); List pids = new ArrayList<>(); - List resPids = new ArrayList<>(); + List resPids = new ArrayList<>(); List maps = myBulkExportHelperSvc.createSearchParameterMapsForResourceType(def, theParameters); maps.forEach(map -> addMembershipToGroupClause(map, theParameters.getGroupId())); for (SearchParameterMap map : maps) { - ISearchBuilder searchBuilder = getSearchBuilderForResourceType("Patient"); + ISearchBuilder 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 resultIterator = searchBuilder.createQuery(map, new SearchRuntimeDetails(null, theParameters.getJobId()), null, RequestPartitionId.allPartitions()); @@ -376,7 +377,7 @@ public class JpaBulkExportProcessor implements IBulkExportProcessor { /** * @param thePidTuples */ - private void populateMdmResourceCache(List thePidTuples) { + private void populateMdmResourceCache(List> thePidTuples) { if (myMdmExpansionCacheSvc.hasBeenPopulated()) { return; } @@ -385,7 +386,7 @@ public class JpaBulkExportProcessor implements IBulkExportProcessor { // patient/gold-1 -> [patient/1, patient/2] // patient/gold-2 -> [patient/3, patient/4] //} - Map> goldenResourceToSourcePidMap = new HashMap<>(); + Map> goldenResourceToSourcePidMap = new HashMap<>(); extract(thePidTuples, goldenResourceToSourcePidMap); //Next, lets convert it to an inverted index for fast lookup @@ -410,21 +411,21 @@ public class JpaBulkExportProcessor implements IBulkExportProcessor { myMdmExpansionCacheSvc.setCacheContents(sourceResourceIdToGoldenResourceIdMap); } - private void extract(List theGoldenPidTargetPidTuples, Map> theGoldenResourceToSourcePidMap) { - for (MdmPidTuple goldenPidTargetPidTuple : theGoldenPidTargetPidTuples) { - ResourcePersistentId goldenPid = goldenPidTargetPidTuple.getGoldenPid(); - ResourcePersistentId sourcePid = goldenPidTargetPidTuple.getSourcePid(); + private void extract(List> theGoldenPidTargetPidTuples, Map> theGoldenResourceToSourcePidMap) { + for (MdmPidTuple goldenPidTargetPidTuple : theGoldenPidTargetPidTuples) { + JpaPid goldenPid = goldenPidTargetPidTuple.getGoldenPid(); + JpaPid sourcePid = goldenPidTargetPidTuple.getSourcePid(); theGoldenResourceToSourcePidMap.computeIfAbsent(goldenPid, key -> new HashSet<>()).add(sourcePid); } } - private void queryResourceTypeWithReferencesToPatients(Set myReadPids, - List resourcePersistentIdChunk, + private void queryResourceTypeWithReferencesToPatients(Set theReadPids, + List JpaPidChunk, ExportPIDIteratorParameters theParams, RuntimeResourceDefinition theDef) { //Convert Resource Persistent IDs to actual client IDs. - Set pidSet = new HashSet<>(resourcePersistentIdChunk); + Set pidSet = new HashSet<>(JpaPidChunk); Set resourceIds = myIdHelperService.translatePidsToFhirResourceIds(pidSet); //Build SP map @@ -436,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 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())) { @@ -446,20 +447,20 @@ public class JpaBulkExportProcessor implements IBulkExportProcessor { } //Execute query and all found pids to our local iterator. - IResultIterator resultIterator = searchBuilder.createQuery(expandedSpMap, + IResultIterator 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 includes = Collections.singleton(new Include("*", true)); SystemRequestDetails requestDetails = SystemRequestDetails.newSystemRequestAllPartitions(); - Set includeIds = searchBuilder.loadIncludes(myContext, myEntityManager, myReadPids, includes, false, expandedSpMap.getLastUpdated(), theParams.getJobId(), requestDetails, null); + Set 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())); } } @@ -504,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 expandAllPatientPidsFromGroup(ExportPIDIteratorParameters theParams) { - Set expandedIds = new HashSet<>(); + private Set expandAllPatientPidsFromGroup(ExportPIDIteratorParameters theParams) { + Set 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 = myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), group); //Attempt to perform MDM Expansion of membership if (theParams.isExpandMdm()) { @@ -517,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 membersFromGroupWithFilter = getMembersFromGroupWithFilter(theParams); + List membersFromGroupWithFilter = getMembersFromGroupWithFilter(theParams); ourLog.debug("Group with ID [{}] has been expanded to: {}", theParams.getGroupId(), membersFromGroupWithFilter); expandedIds.addAll(membersFromGroupWithFilter); return expandedIds; } - private Set performMembershipExpansionViaMdmTable(ResourcePersistentId pidOrNull) { - List goldenPidTargetPidTuples = myMdmLinkDao.expandPidsFromGroupPidGivenMatchResult(pidOrNull, MdmMatchResultEnum.MATCH); + private Set performMembershipExpansionViaMdmTable(JpaPid pidOrNull) { + List> goldenPidTargetPidTuples = myMdmLinkDao.expandPidsFromGroupPidGivenMatchResult(pidOrNull, MdmMatchResultEnum.MATCH); //Now lets translate these pids into resource IDs - Set uniquePids = new HashSet<>(); + Set uniquePids = new HashSet<>(); goldenPidTargetPidTuples.forEach(tuple -> { uniquePids.add(tuple.getGoldenPid()); uniquePids.add(tuple.getSourcePid()); }); PersistentIdToForcedIdMap pidToForcedIdMap = myIdHelperService.translatePidsToForcedIds(uniquePids); - Map> goldenResourceToSourcePidMap = new HashMap<>(); + Map> goldenResourceToSourcePidMap = new HashMap<>(); extract(goldenPidTargetPidTuples, goldenResourceToSourcePidMap); populateMdmResourceCache(goldenPidTargetPidTuples); diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/cache/ResourceVersionSvcDaoImpl.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/cache/ResourceVersionSvcDaoImpl.java index 984f47e2525..8364e3d2fa6 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/cache/ResourceVersionSvcDaoImpl.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/cache/ResourceVersionSvcDaoImpl.java @@ -25,12 +25,11 @@ 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.dao.data.IResourceTableDao; -import ca.uhn.fhir.jpa.dao.index.IdHelperService; +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 myIdHelperService; @Override @Nonnull @@ -72,8 +71,9 @@ public class ResourceVersionSvcDaoImpl implements IResourceVersionSvc { ourLog.debug("About to retrieve version map for resource type: {}", theResourceName); } - List matchingIds = dao.searchForIds(theSearchParamMap, new SystemRequestDetails().setRequestPartitionId(theRequestPartitionId)).stream() - .map(ResourcePersistentId::getIdAsLong) + List jpaPids = dao.searchForIds(theSearchParamMap, new SystemRequestDetails().setRequestPartitionId(theRequestPartitionId)); + List matchingIds = jpaPids.stream() + .map(JpaPid::getId) .collect(Collectors.toList()); List allById = new ArrayList<>(); @@ -137,16 +137,15 @@ public class ResourceVersionSvcDaoImpl implements IResourceVersionSvc { return retval; } - List resourcePersistentIds = myIdHelperService.resolveResourcePersistentIdsWithCache(thePartitionId, - theIds.stream().collect(Collectors.toList())); + List jpaPids = myIdHelperService.resolveResourcePersistentIdsWithCache(thePartitionId, new ArrayList<>(theIds)); // we'll use this map to fetch pids that require versions - HashMap pidsToVersionToResourcePid = new HashMap<>(); + HashMap pidsToVersionToResourcePid = new HashMap<>(); // fill in our map - for (ResourcePersistentId pid : resourcePersistentIds) { + for (JpaPid pid : jpaPids) { if (pid.getVersion() == null) { - pidsToVersionToResourcePid.put(pid.getIdAsLong(), pid); + pidsToVersionToResourcePid.put(pid.getId(), pid); } Optional idOp = theIds.stream() .filter(i -> i.getIdPart().equals(pid.getAssociatedResourceId().getIdPart())) diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/Batch2SupportConfig.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/Batch2SupportConfig.java index de8adf4362c..5b1a7d35c99 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/Batch2SupportConfig.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/Batch2SupportConfig.java @@ -27,7 +27,6 @@ import ca.uhn.fhir.jpa.api.svc.IIdHelperService; import ca.uhn.fhir.jpa.dao.IFulltextSearchSvc; import ca.uhn.fhir.jpa.dao.data.IResourceLinkDao; import ca.uhn.fhir.jpa.dao.expunge.ResourceTableFKProvider; -import ca.uhn.fhir.jpa.dao.index.IJpaIdHelperService; import ca.uhn.fhir.jpa.delete.batch2.DeleteExpungeSqlBuilder; import ca.uhn.fhir.jpa.delete.batch2.DeleteExpungeSvcImpl; import ca.uhn.fhir.jpa.reindex.Batch2DaoSvcImpl; diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/HapiJpaConfig.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/HapiJpaConfig.java index a2c61eef0e9..9ea6d26d512 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/HapiJpaConfig.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/HapiJpaConfig.java @@ -26,7 +26,6 @@ import ca.uhn.fhir.jpa.config.util.ResourceCountCacheUtil; import ca.uhn.fhir.jpa.config.util.ValidationSupportConfigUtil; import ca.uhn.fhir.jpa.dao.FulltextSearchSvcImpl; import ca.uhn.fhir.jpa.dao.IFulltextSearchSvc; -import ca.uhn.fhir.jpa.dao.mdm.MdmLinkDaoJpaImpl; import ca.uhn.fhir.jpa.dao.search.HSearchSortHelperImpl; import ca.uhn.fhir.jpa.dao.search.IHSearchSortHelper; import ca.uhn.fhir.jpa.provider.DaoRegistryResourceSupportedSvc; @@ -35,7 +34,6 @@ import ca.uhn.fhir.jpa.search.IStaleSearchDeletingSvc; import ca.uhn.fhir.jpa.search.StaleSearchDeletingSvcImpl; import ca.uhn.fhir.jpa.util.ResourceCountCache; import ca.uhn.fhir.jpa.validation.JpaValidationSupportChain; -import ca.uhn.fhir.mdm.dao.IMdmLinkDao; import ca.uhn.fhir.rest.api.IResourceSupportedSvc; import ca.uhn.fhir.rest.server.util.ISearchParamRegistry; import org.hl7.fhir.common.hapi.validation.support.CachingValidationSupport; @@ -87,9 +85,4 @@ public class HapiJpaConfig { public ResourceCountCache resourceCountsCache(IFhirSystemDao theSystemDao) { return ResourceCountCacheUtil.newResourceCountCache(theSystemDao); } - - @Bean - public static IMdmLinkDao mdmLinkDao(){ - return new MdmLinkDaoJpaImpl(); - } } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/JpaConfig.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/JpaConfig.java index 853f2ae507e..934cb60ba40 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/JpaConfig.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/JpaConfig.java @@ -37,22 +37,26 @@ 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; import ca.uhn.fhir.jpa.dao.index.IdHelperService; import ca.uhn.fhir.jpa.dao.index.SearchParamWithInlineReferencesExtractor; +import ca.uhn.fhir.jpa.dao.mdm.JpaMdmLinkImplFactory; +import ca.uhn.fhir.jpa.dao.mdm.MdmLinkDaoJpaImpl; import ca.uhn.fhir.jpa.dao.tx.HapiTransactionService; import ca.uhn.fhir.jpa.delete.DeleteConflictFinderService; import ca.uhn.fhir.jpa.delete.DeleteConflictService; import ca.uhn.fhir.jpa.delete.ThreadSafeResourceDeleterSvc; +import ca.uhn.fhir.jpa.entity.MdmLink; import ca.uhn.fhir.jpa.entity.Search; import ca.uhn.fhir.jpa.graphql.DaoRegistryGraphQLStorageServices; import ca.uhn.fhir.jpa.interceptor.CascadingDeleteInterceptor; import ca.uhn.fhir.jpa.interceptor.JpaConsentContextServices; import ca.uhn.fhir.jpa.interceptor.OverridePathBasedReferentialIntegrityForDeletesInterceptor; import ca.uhn.fhir.jpa.interceptor.validation.RepositoryValidatingRuleBuilder; +import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.jpa.model.sched.ISchedulerService; import ca.uhn.fhir.jpa.packages.IHapiPackageCacheManager; import ca.uhn.fhir.jpa.packages.IPackageInstallerSvc; @@ -131,10 +135,12 @@ import ca.uhn.fhir.jpa.term.config.TermCodeSystemConfig; import ca.uhn.fhir.jpa.util.MemoryCacheService; import ca.uhn.fhir.jpa.validation.ResourceLoaderImpl; import ca.uhn.fhir.jpa.validation.ValidationSettings; +import ca.uhn.fhir.mdm.dao.IMdmLinkDao; +import ca.uhn.fhir.mdm.dao.IMdmLinkImplFactory; import ca.uhn.fhir.mdm.svc.MdmLinkExpandSvc; import ca.uhn.fhir.rest.api.server.RequestDetails; import ca.uhn.fhir.rest.api.server.storage.IDeleteExpungeJobSubmitter; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import ca.uhn.fhir.rest.server.interceptor.ResponseTerminologyTranslationInterceptor; import ca.uhn.fhir.rest.server.interceptor.ResponseTerminologyTranslationSvc; import ca.uhn.fhir.rest.server.interceptor.consent.IConsentContextServices; @@ -299,7 +305,7 @@ public class JpaConfig { @Bean @Primary public IResourceLinkResolver daoResourceLinkResolver() { - return new DaoResourceLinkResolver(); + return new DaoResourceLinkResolver(); } @Bean @@ -679,7 +685,7 @@ public class JpaConfig { @Bean @Scope("prototype") - public ExpungeOperation expungeOperation(String theResourceName, ResourcePersistentId theResourceId, ExpungeOptions theExpungeOptions, RequestDetails theRequestDetails) { + public ExpungeOperation expungeOperation(String theResourceName, IResourcePersistentId theResourceId, ExpungeOptions theExpungeOptions, RequestDetails theRequestDetails) { return new ExpungeOperation(theResourceName, theResourceId, theExpungeOptions, theRequestDetails); } @@ -690,7 +696,7 @@ public class JpaConfig { @Bean public IResourceExpungeService resourceExpungeService() { - return new ResourceExpungeService(); + return new JpaResourceExpungeService(); } @Bean @@ -791,5 +797,11 @@ public class JpaConfig { return new ObservationLastNIndexPersistSvc(); } + @Bean + public IMdmLinkDao mdmLinkDao(){ + return new MdmLinkDaoJpaImpl(); + } + @Bean + IMdmLinkImplFactory mdmLinkImplFactory() {return new JpaMdmLinkImplFactory();} } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/SearchConfig.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/SearchConfig.java index 6ec3658a30b..77ede49a7b8 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/SearchConfig.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/SearchConfig.java @@ -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, diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java index e6288c8dc20..59af1adb4e4 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java @@ -30,13 +30,12 @@ import ca.uhn.fhir.jpa.dao.index.SearchParamWithInlineReferencesExtractor; import ca.uhn.fhir.jpa.dao.tx.HapiTransactionService; import ca.uhn.fhir.jpa.delete.DeleteConflictService; import ca.uhn.fhir.jpa.entity.PartitionEntity; -import ca.uhn.fhir.jpa.entity.ResourceSearchView; import ca.uhn.fhir.jpa.model.config.PartitionSettings; import ca.uhn.fhir.jpa.model.cross.IBasePersistedResource; +import ca.uhn.fhir.jpa.model.cross.IResourceLookup; +import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.jpa.model.entity.BaseHasResource; import ca.uhn.fhir.jpa.model.entity.BaseTag; -import ca.uhn.fhir.jpa.model.entity.IBaseResourceEntity; -import ca.uhn.fhir.jpa.model.entity.PartitionablePartitionId; import ca.uhn.fhir.jpa.model.entity.ResourceEncodingEnum; import ca.uhn.fhir.jpa.model.entity.ResourceHistoryProvenanceEntity; import ca.uhn.fhir.jpa.model.entity.ResourceHistoryTable; @@ -60,21 +59,16 @@ import ca.uhn.fhir.jpa.util.MemoryCacheService; import ca.uhn.fhir.jpa.util.QueryChunker; import ca.uhn.fhir.model.api.IResource; import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum; -import ca.uhn.fhir.model.api.StorageResponseCodeEnum; import ca.uhn.fhir.model.api.Tag; import ca.uhn.fhir.model.api.TagList; import ca.uhn.fhir.model.base.composite.BaseCodingDt; import ca.uhn.fhir.model.primitive.IdDt; -import ca.uhn.fhir.model.primitive.InstantDt; -import ca.uhn.fhir.model.valueset.BundleEntryTransactionMethodEnum; import ca.uhn.fhir.parser.DataFormatException; import ca.uhn.fhir.parser.IParser; -import ca.uhn.fhir.parser.LenientErrorHandler; import ca.uhn.fhir.rest.api.Constants; import ca.uhn.fhir.rest.api.InterceptorInvocationTimingEnum; import ca.uhn.fhir.rest.api.RestOperationTypeEnum; 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.rest.server.exceptions.InternalErrorException; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; @@ -86,7 +80,6 @@ import ca.uhn.fhir.util.CoverageIgnore; import ca.uhn.fhir.util.HapiExtensions; import ca.uhn.fhir.util.MetaUtil; import ca.uhn.fhir.util.StopWatch; -import ca.uhn.fhir.util.UrlUtil; import ca.uhn.fhir.util.XmlUtil; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Charsets; @@ -108,7 +101,6 @@ import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IDomainResource; import org.hl7.fhir.instance.model.api.IIdType; import org.hl7.fhir.instance.model.api.IPrimitiveType; -import org.hl7.fhir.r4.model.Bundle.HTTPVerb; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeansException; @@ -205,11 +197,11 @@ public abstract class BaseHapiFhirDao extends BaseStora @PersistenceContext(type = PersistenceContextType.TRANSACTION) protected EntityManager myEntityManager; @Autowired - protected IIdHelperService myIdHelperService; + protected IIdHelperService myIdHelperService; @Autowired protected IForcedIdDao myForcedIdDao; @Autowired - protected ISearchCoordinatorSvc mySearchCoordinatorSvc; + protected ISearchCoordinatorSvc mySearchCoordinatorSvc; @Autowired protected ITermReadSvc myTerminologySvc; @Autowired @@ -1110,7 +1102,7 @@ public abstract class BaseHapiFhirDao extends BaseStora */ if (thePerformIndexing) { if (newParams == null) { - myExpungeService.deleteAllSearchParams(new ResourcePersistentId(entity.getId())); + myExpungeService.deleteAllSearchParams(JpaPid.fromId(entity.getId())); } else { // Synchronize search param indexes @@ -1425,16 +1417,14 @@ public abstract class BaseHapiFhirDao extends BaseStora doCallHooks(theTransactionDetails, theRequestDetails, interceptorPointcut, hookParams); } - protected void addPidToResource(IBasePersistedResource theEntity, IBaseResource theResource) { + protected void addPidToResource(IResourceLookup theEntity, IBaseResource theResource) { if (theResource instanceof IAnyResource) { - IDao.RESOURCE_PID.put((IAnyResource) theResource, theEntity.getPersistentId().getIdAsLong()); + IDao.RESOURCE_PID.put((IAnyResource) theResource, theEntity.getPersistentId().getId()); } else if (theResource instanceof IResource) { - IDao.RESOURCE_PID.put((IResource) theResource, theEntity.getPersistentId().getIdAsLong()); + IDao.RESOURCE_PID.put((IResource) theResource, theEntity.getPersistentId().getId()); } } - - private void validateChildReferenceTargetTypes(IBase theElement, String thePath) { if (theElement == null) { return; diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDao.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDao.java index ae584a2d5a6..c052140b2d3 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDao.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDao.java @@ -46,6 +46,7 @@ import ca.uhn.fhir.jpa.dao.index.IdHelperService; import ca.uhn.fhir.jpa.dao.tx.HapiTransactionService; import ca.uhn.fhir.jpa.delete.DeleteConflictUtil; import ca.uhn.fhir.jpa.model.cross.IBasePersistedResource; +import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.jpa.model.entity.BaseHasResource; import ca.uhn.fhir.jpa.model.entity.BaseTag; import ca.uhn.fhir.jpa.model.entity.ForcedId; @@ -84,7 +85,7 @@ 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.IDeleteExpungeJobSubmitter; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import ca.uhn.fhir.rest.api.server.storage.TransactionDetails; import ca.uhn.fhir.rest.param.HasParam; import ca.uhn.fhir.rest.param.HistorySearchDateRangeParam; @@ -163,9 +164,9 @@ public abstract class BaseHapiFhirResourceDao extends B @Autowired protected HapiTransactionService myTransactionService; @Autowired - private MatchResourceUrlService myMatchResourceUrlService; + private MatchResourceUrlService myMatchResourceUrlService; @Autowired - private SearchBuilderFactory mySearchBuilderFactory; + private SearchBuilderFactory mySearchBuilderFactory; @Autowired private DaoRegistry myDaoRegistry; @Autowired @@ -288,12 +289,12 @@ public abstract class BaseHapiFhirResourceDao extends B entity.setVersion(1); if (isNotBlank(theMatchUrl) && theProcessMatchUrl) { - Set match = myMatchResourceUrlService.processMatchUrl(theMatchUrl, myResourceType, theTransactionDetails, theRequest); + Set 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); } else if (match.size() == 1) { - ResourcePersistentId pid = match.iterator().next(); + JpaPid pid = match.iterator().next(); Supplier entitySupplier = () -> { return myTxTemplate.execute(tx -> { @@ -308,12 +309,12 @@ public abstract class BaseHapiFhirResourceDao extends B return myTxTemplate.execute(tx -> { IIdType retVal = myIdHelperService.translatePidIdToForcedId(myFhirContext, myResourceName, pid); if (!retVal.hasVersionIdPart()) { - IIdType idWithVersion = myMemoryCacheService.getIfPresent(MemoryCacheService.CacheEnum.RESOURCE_CONDITIONAL_CREATE_VERSION, pid.getIdAsLong()); + IIdType idWithVersion = myMemoryCacheService.getIfPresent(MemoryCacheService.CacheEnum.RESOURCE_CONDITIONAL_CREATE_VERSION, pid.getId()); if (idWithVersion == null) { - Long version = myResourceTableDao.findCurrentVersionByPid(pid.getIdAsLong()); + Long version = myResourceTableDao.findCurrentVersionByPid(pid.getId()); if (version != null) { retVal = myFhirContext.getVersion().newIdType().setParts(retVal.getBaseUrl(), retVal.getResourceType(), retVal.getIdPart(), Long.toString(version)); - myMemoryCacheService.putAfterCommit(MemoryCacheService.CacheEnum.RESOURCE_CONDITIONAL_CREATE_VERSION, pid.getIdAsLong(), retVal); + myMemoryCacheService.putAfterCommit(MemoryCacheService.CacheEnum.RESOURCE_CONDITIONAL_CREATE_VERSION, pid.getId(), retVal); } } else { retVal = idWithVersion; @@ -364,7 +365,7 @@ public abstract class BaseHapiFhirResourceDao extends B ResourceTable updatedEntity = updateEntity(theRequest, theResource, entity, null, thePerformIndexing, false, theTransactionDetails, false, thePerformIndexing); // Store the resource forced ID if necessary - ResourcePersistentId persistentId = new ResourcePersistentId(updatedEntity.getResourceId()); + JpaPid jpaPid = JpaPid.fromId(updatedEntity.getResourceId()); if (resourceHadIdBeforeStorage) { if (resourceIdWasServerAssigned) { boolean createForPureNumericIds = true; @@ -393,13 +394,13 @@ public abstract class BaseHapiFhirResourceDao extends B theResource.setId(entity.getIdDt()); // Pre-cache the resource ID - persistentId.setAssociatedResourceId(entity.getIdType(myFhirContext)); - myIdHelperService.addResolvedPidToForcedId(persistentId, theRequestPartitionId, getResourceName(), entity.getTransientForcedId(), null); - theTransactionDetails.addResolvedResourceId(persistentId.getAssociatedResourceId(), persistentId); + jpaPid.setAssociatedResourceId(entity.getIdType(myFhirContext)); + myIdHelperService.addResolvedPidToForcedId(jpaPid, theRequestPartitionId, getResourceName(), entity.getTransientForcedId(), null); + theTransactionDetails.addResolvedResourceId(jpaPid.getAssociatedResourceId(), jpaPid); // Pre-cache the match URL if (theMatchUrl != null) { - myMatchResourceUrlService.matchUrlResolved(theTransactionDetails, getResourceName(), theMatchUrl, persistentId); + myMatchResourceUrlService.matchUrlResolved(theTransactionDetails, getResourceName(), theMatchUrl, jpaPid); } // Update the version/last updated in the resource so that interceptors get @@ -556,7 +557,7 @@ public abstract class BaseHapiFhirResourceDao extends B DaoMethodOutcome outcome = createMethodOutcomeForResourceId(entity.getIdDt().getValue(), MESSAGE_KEY_DELETE_RESOURCE_ALREADY_DELETED, StorageResponseCodeEnum.SUCCESSFUL_DELETE_ALREADY_DELETED); // used to exist, so we'll set the persistent id - outcome.setPersistentId(new ResourcePersistentId(entity.getResourceId())); + outcome.setPersistentId(JpaPid.fromId(entity.getResourceId())); outcome.setEntity(entity); return outcome; @@ -639,7 +640,7 @@ public abstract class BaseHapiFhirResourceDao extends B SearchParameterMap paramMap = resourceSearch.getSearchParameterMap(); paramMap.setLoadSynchronous(true); - Set resourceIds = myMatchResourceUrlService.search(paramMap, myResourceType, theRequest, null); + Set resourceIds = myMatchResourceUrlService.search(paramMap, myResourceType, theRequest, null); if (resourceIds.size() > 1) { if (!getConfig().isAllowMultipleDelete()) { @@ -670,12 +671,13 @@ public abstract class BaseHapiFhirResourceDao extends B @Nonnull @Override - public DeleteMethodOutcome deletePidList(String theUrl, Collection theResourceIds, DeleteConflictList theDeleteConflicts, RequestDetails theRequest) { + public

DeleteMethodOutcome deletePidList(String theUrl, Collection

theResourceIds, DeleteConflictList theDeleteConflicts, RequestDetails theRequest) { StopWatch w = new StopWatch(); TransactionDetails transactionDetails = new TransactionDetails(); List deletedResources = new ArrayList<>(); - for (ResourcePersistentId pid : theResourceIds) { - ResourceTable entity = myEntityManager.find(ResourceTable.class, pid.getIdAsLong()); + for (P pid : theResourceIds) { + JpaPid jpaPid = (JpaPid)pid; + ResourceTable entity = myEntityManager.find(ResourceTable.class, jpaPid.getId()); deletedResources.add(entity); T resourceToDelete = myJpaStorageResourceParser.toResource(myResourceType, entity, null, false); @@ -878,10 +880,10 @@ public abstract class BaseHapiFhirResourceDao extends B throw new PreconditionFailedException(Msg.code(969) + "Can not perform version-specific expunge of resource " + theId.toUnqualified().getValue() + " as this is the current version"); } - return myExpungeService.expunge(getResourceName(), new ResourcePersistentId(entity.getResourceId(), entity.getVersion()), theExpungeOptions, theRequest); + return myExpungeService.expunge(getResourceName(), JpaPid.fromIdAndVersion(entity.getResourceId(), entity.getVersion()), theExpungeOptions, theRequest); } - return myExpungeService.expunge(getResourceName(), new ResourcePersistentId(entity.getResourceId()), theExpungeOptions, theRequest); + return myExpungeService.expunge(getResourceName(), JpaPid.fromId(entity.getResourceId()), theExpungeOptions, theRequest); } @Override @@ -1132,18 +1134,19 @@ public abstract class BaseHapiFhirResourceDao extends B @Override @Transactional - public T readByPid(ResourcePersistentId thePid) { + public T readByPid(IResourcePersistentId thePid) { return readByPid(thePid, false); } @Override @Transactional - public T readByPid(ResourcePersistentId thePid, boolean theDeletedOk) { + public T readByPid(IResourcePersistentId thePid, boolean theDeletedOk) { StopWatch w = new StopWatch(); + JpaPid jpaPid = (JpaPid)thePid; - Optional entity = myResourceTableDao.findById(thePid.getIdAsLong()); + Optional entity = myResourceTableDao.findById(jpaPid.getId()); if (!entity.isPresent()) { - throw new ResourceNotFoundException(Msg.code(975) + "No resource found with PID " + thePid); + throw new ResourceNotFoundException(Msg.code(975) + "No resource found with PID " + jpaPid); } if (isDeleted(entity.get()) && !theDeletedOk) { throw createResourceGoneException(entity.get()); @@ -1151,7 +1154,7 @@ public abstract class BaseHapiFhirResourceDao extends B T retVal = myJpaStorageResourceParser.toResource(myResourceType, entity.get(), null, false); - ourLog.debug("Processed read on {} in {}ms", thePid, w.getMillis()); + ourLog.debug("Processed read on {} in {}ms", jpaPid, w.getMillis()); return retVal; } @@ -1228,10 +1231,11 @@ public abstract class BaseHapiFhirResourceDao extends B @SuppressWarnings("unchecked") @Override - public void reindex(ResourcePersistentId theResourcePersistentId, RequestDetails theRequest, TransactionDetails theTransactionDetails) { - Optional entityOpt = myResourceTableDao.findById(theResourcePersistentId.getIdAsLong()); + public void reindex(IResourcePersistentId thePid, RequestDetails theRequest, TransactionDetails theTransactionDetails) { + JpaPid jpaPid = (JpaPid)thePid; + Optional entityOpt = myResourceTableDao.findById(jpaPid.getId()); if (!entityOpt.isPresent()) { - ourLog.warn("Unable to find entity with PID: {}", theResourcePersistentId.getId()); + ourLog.warn("Unable to find entity with PID: {}", jpaPid.getId()); return; } @@ -1253,24 +1257,24 @@ public abstract class BaseHapiFhirResourceDao extends B RequestPartitionId requestPartitionId = myRequestPartitionHelperService.determineReadPartitionForRequestForRead(theRequest, getResourceName(), theId); BaseHasResource entity; - ResourcePersistentId pid = myIdHelperService.resolveResourcePersistentIds(requestPartitionId, getResourceName(), theId.getIdPart()); + JpaPid pid = myIdHelperService.resolveResourcePersistentIds(requestPartitionId, getResourceName(), theId.getIdPart()); Set readPartitions = null; if (requestPartitionId.isAllPartitions()) { - entity = myEntityManager.find(ResourceTable.class, pid.getIdAsLong()); + entity = myEntityManager.find(ResourceTable.class, pid.getId()); } else { readPartitions = myRequestPartitionHelperService.toReadPartitions(requestPartitionId); if (readPartitions.size() == 1) { if (readPartitions.contains(null)) { - entity = myResourceTableDao.readByPartitionIdNull(pid.getIdAsLong()).orElse(null); + entity = myResourceTableDao.readByPartitionIdNull(pid.getId()).orElse(null); } else { - entity = myResourceTableDao.readByPartitionId(readPartitions.iterator().next(), pid.getIdAsLong()).orElse(null); + entity = myResourceTableDao.readByPartitionId(readPartitions.iterator().next(), pid.getId()).orElse(null); } } else { if (readPartitions.contains(null)) { List readPartitionsWithoutNull = readPartitions.stream().filter(t -> t != null).collect(Collectors.toList()); - entity = myResourceTableDao.readByPartitionIdsOrNull(readPartitionsWithoutNull, pid.getIdAsLong()).orElse(null); + entity = myResourceTableDao.readByPartitionIdsOrNull(readPartitionsWithoutNull, pid.getId()).orElse(null); } else { - entity = myResourceTableDao.readByPartitionIds(readPartitions, pid.getIdAsLong()).orElse(null); + entity = myResourceTableDao.readByPartitionIds(readPartitions, pid.getId()).orElse(null); } } } @@ -1320,8 +1324,9 @@ public abstract class BaseHapiFhirResourceDao extends B } @Override - protected IBasePersistedResource readEntityLatestVersion(ResourcePersistentId thePersistentId, RequestDetails theRequestDetails, TransactionDetails theTransactionDetails) { - return myEntityManager.find(ResourceTable.class, thePersistentId.getIdAsLong()); + protected IBasePersistedResource readEntityLatestVersion(IResourcePersistentId thePersistentId, RequestDetails theRequestDetails, TransactionDetails theTransactionDetails) { + JpaPid jpaPid = (JpaPid)thePersistentId; + return myEntityManager.find(ResourceTable.class, jpaPid.getId()); } @@ -1336,13 +1341,13 @@ public abstract class BaseHapiFhirResourceDao extends B private ResourceTable readEntityLatestVersion(IIdType theId, @Nonnull RequestPartitionId theRequestPartitionId, TransactionDetails theTransactionDetails) { validateResourceTypeAndThrowInvalidRequestException(theId); - ResourcePersistentId persistentId = null; + JpaPid persistentId = null; if (theTransactionDetails != null) { if (theTransactionDetails.isResolvedResourceIdEmpty(theId.toUnqualifiedVersionless())) { throw new ResourceNotFoundException(Msg.code(1997) + theId); } if (theTransactionDetails.hasResolvedResourceIds()) { - persistentId = theTransactionDetails.getResolvedResourceId(theId); + persistentId = (JpaPid)theTransactionDetails.getResolvedResourceId(theId); } } @@ -1517,7 +1522,7 @@ public abstract class BaseHapiFhirResourceDao extends B } @Override - public List searchForIds(SearchParameterMap theParams, RequestDetails theRequest, @Nullable IBaseResource theConditionalOperationTargetOrNull) { + public List searchForIds(SearchParameterMap theParams, RequestDetails theRequest, @Nullable IBaseResource theConditionalOperationTargetOrNull) { TransactionDetails transactionDetails = new TransactionDetails(); return myTransactionService.execute(theRequest, transactionDetails, tx -> { @@ -1530,13 +1535,13 @@ public abstract class BaseHapiFhirResourceDao extends B ISearchBuilder builder = mySearchBuilderFactory.newSearchBuilder(this, getResourceName(), getResourceType()); - List ids = new ArrayList<>(); + List 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 iter = builder.createQuery(theParams, searchRuntimeDetails, theRequest, requestPartitionId)) { while (iter.hasNext()) { ids.add(iter.next()); } @@ -1652,12 +1657,12 @@ public abstract class BaseHapiFhirResourceDao extends B IIdType resourceId; RestOperationTypeEnum update = RestOperationTypeEnum.UPDATE; if (isNotBlank(theMatchUrl)) { - Set match = myMatchResourceUrlService.processMatchUrl(theMatchUrl, myResourceType, theTransactionDetails, theRequest, theResource); + Set match = myMatchResourceUrlService.processMatchUrl(theMatchUrl, myResourceType, theTransactionDetails, theRequest, theResource); if (match.size() > 1) { String msg = getContext().getLocalizer().getMessageSanitized(BaseStorageDao.class, "transactionOperationWithMultipleMatchFailure", "UPDATE", theMatchUrl, match.size()); throw new PreconditionFailedException(Msg.code(988) + msg); } else if (match.size() == 1) { - ResourcePersistentId pid = match.iterator().next(); + JpaPid pid = match.iterator().next(); entity = myEntityManager.find(ResourceTable.class, pid.getId()); resourceId = entity.getIdDt(); } else { @@ -1666,7 +1671,7 @@ public abstract class BaseHapiFhirResourceDao 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; diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirSystemDao.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirSystemDao.java index 20e882f7f0c..df2a119e3ca 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirSystemDao.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirSystemDao.java @@ -7,11 +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.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; @@ -20,12 +19,11 @@ import ca.uhn.fhir.jpa.util.QueryChunker; import ca.uhn.fhir.jpa.util.ResourceCountCache; 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.api.server.storage.IResourcePersistentId; 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; @@ -165,10 +163,10 @@ public abstract class BaseHapiFhirSystemDao extends B @Override @Transactional(propagation = Propagation.MANDATORY) - public void preFetchResources(List theResolvedIds) { + public

void preFetchResources(List

theResolvedIds) { List pids = theResolvedIds .stream() - .map(t -> t.getIdAsLong()) + .map(t -> ((JpaPid) t).getId()) .collect(Collectors.toList()); new QueryChunker().chunk(pids, ids->{ diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/FulltextSearchSvcImpl.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/FulltextSearchSvcImpl.java index 18ba4b53dd1..3b377e5130d 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/FulltextSearchSvcImpl.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/FulltextSearchSvcImpl.java @@ -30,6 +30,7 @@ import ca.uhn.fhir.jpa.dao.search.ExtendedHSearchResourceProjection; import ca.uhn.fhir.jpa.dao.search.ExtendedHSearchSearchBuilder; import ca.uhn.fhir.jpa.dao.search.IHSearchSortHelper; import ca.uhn.fhir.jpa.dao.search.LastNOperation; +import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.jpa.model.entity.ModelConfig; import ca.uhn.fhir.jpa.model.entity.ResourceTable; import ca.uhn.fhir.jpa.model.search.ExtendedHSearchIndexData; @@ -43,7 +44,7 @@ import ca.uhn.fhir.jpa.searchparam.extractor.ResourceIndexedSearchParams; import ca.uhn.fhir.model.api.IQueryParameterType; import ca.uhn.fhir.parser.IParser; import ca.uhn.fhir.rest.api.Constants; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import ca.uhn.fhir.rest.server.util.ISearchParamRegistry; import ca.uhn.fhir.rest.server.util.ResourceSearchParams; import com.google.common.collect.Ordering; @@ -156,7 +157,7 @@ public class FulltextSearchSvcImpl implements IFulltextSearchSvc { // keep this in sync with supportsSomeOf(); private ISearchQueryExecutor doSearch(String theResourceType, SearchParameterMap theParams, - ResourcePersistentId theReferencingPid, Integer theMaxResultsToFetch) { + IResourcePersistentId theReferencingPid, Integer theMaxResultsToFetch) { int offset = theParams.getOffset() == null ? 0 : theParams.getOffset(); int count = getMaxFetchSize(theParams, theMaxResultsToFetch); @@ -185,7 +186,7 @@ public class FulltextSearchSvcImpl implements IFulltextSearchSvc { private SearchQueryOptionsStep getSearchQueryOptionsStep( - String theResourceType, SearchParameterMap theParams, ResourcePersistentId theReferencingPid) { + String theResourceType, SearchParameterMap theParams, IResourcePersistentId theReferencingPid) { dispatchEvent(IHSearchEventListener.HSearchEventType.SEARCH); var query= getSearchSession().search(ResourceTable.class) @@ -213,7 +214,7 @@ public class FulltextSearchSvcImpl implements IFulltextSearchSvc { private PredicateFinalStep buildWhereClause(SearchPredicateFactory f, String theResourceType, - SearchParameterMap theParams, ResourcePersistentId theReferencingPid) { + SearchParameterMap theParams, IResourcePersistentId theReferencingPid) { return f.bool(b -> { ExtendedHSearchClauseBuilder builder = new ExtendedHSearchClauseBuilder(myFhirContext, myModelConfig, b, f); @@ -261,18 +262,18 @@ public class FulltextSearchSvcImpl implements IFulltextSearchSvc { return Search.session(myEntityManager); } - private List convertLongsToResourcePersistentIds(List theLongPids) { + private List convertLongsToResourcePersistentIds(List theLongPids) { return theLongPids.stream() - .map(ResourcePersistentId::new) + .map(JpaPid::fromId) .collect(Collectors.toList()); } @Override - public List everything(String theResourceName, SearchParameterMap theParams, ResourcePersistentId theReferencingPid) { + public List everything(String theResourceName, SearchParameterMap theParams, IResourcePersistentId theReferencingPid) { validateHibernateSearchIsEnabled(); // todo mb what about max results here? - List retVal = toList(doSearch(null, theParams, theReferencingPid, 10_000), 10_000); + List retVal = toList(doSearch(null, theParams, theReferencingPid, 10_000), 10_000); if (theReferencingPid != null) { retVal.add(theReferencingPid); } @@ -310,7 +311,7 @@ public class FulltextSearchSvcImpl implements IFulltextSearchSvc { @Transactional() @Override - public List search(String theResourceName, SearchParameterMap theParams) { + public List search(String theResourceName, SearchParameterMap theParams) { validateHibernateSearchIsEnabled(); return toList(doSearch(theResourceName, theParams, null, DEFAULT_MAX_NON_PAGED_SIZE), DEFAULT_MAX_NON_PAGED_SIZE); } @@ -318,9 +319,9 @@ public class FulltextSearchSvcImpl implements IFulltextSearchSvc { /** * Adapt our async interface to the legacy concrete List */ - private List toList(ISearchQueryExecutor theSearchResultStream, long theMaxSize) { + private List toList(ISearchQueryExecutor theSearchResultStream, long theMaxSize) { return StreamSupport.stream(Spliterators.spliteratorUnknownSize(theSearchResultStream, 0), false) - .map(ResourcePersistentId::new) + .map(JpaPid::fromId) .limit(theMaxSize) .collect(Collectors.toList()); } @@ -356,7 +357,7 @@ public class FulltextSearchSvcImpl implements IFulltextSearchSvc { } @Override - public List lastN(SearchParameterMap theParams, Integer theMaximumResults) { + public List lastN(SearchParameterMap theParams, Integer theMaximumResults) { ensureElastic(); dispatchEvent(IHSearchEventListener.HSearchEventType.SEARCH); List pidList = new LastNOperation(getSearchSession(), myFhirContext, myModelConfig, mySearchParamRegistry) diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/HistoryBuilder.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/HistoryBuilder.java index d69e20c82c6..7ca29f6daa1 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/HistoryBuilder.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/HistoryBuilder.java @@ -27,8 +27,8 @@ 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.config.PartitionSettings; +import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.jpa.model.entity.ResourceHistoryTable; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; import ca.uhn.fhir.rest.param.HistorySearchStyleEnum; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import com.google.common.collect.ImmutableListMultimap; @@ -128,7 +128,7 @@ public class HistoryBuilder { List tables = query.getResultList(); if (tables.size() > 0) { ImmutableListMultimap resourceIdToHistoryEntries = Multimaps.index(tables, ResourceHistoryTable::getResourceId); - Set pids = resourceIdToHistoryEntries.keySet().stream().map(t-> new ResourcePersistentId(t)).collect(Collectors.toSet()); + Set pids = resourceIdToHistoryEntries.keySet().stream().map(JpaPid::fromId).collect(Collectors.toSet()); PersistentIdToForcedIdMap pidToForcedId = myIdHelperService.translatePidsToForcedIds(pids); ourLog.trace("Translated IDs: {}", pidToForcedId.getResourcePersistentIdOptionalMap()); @@ -137,7 +137,7 @@ public class HistoryBuilder { String resourceId; - Optional forcedId = pidToForcedId.get(new ResourcePersistentId(nextResourceId)); + Optional forcedId = pidToForcedId.get(JpaPid.fromId(nextResourceId)); if (forcedId.isPresent()) { resourceId = forcedId.get(); } else { diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/IFulltextSearchSvc.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/IFulltextSearchSvc.java index dfa8b1e0971..3b508def2d6 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/IFulltextSearchSvc.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/IFulltextSearchSvc.java @@ -26,7 +26,7 @@ import ca.uhn.fhir.jpa.search.autocomplete.ValueSetAutocompleteOptions; import ca.uhn.fhir.jpa.search.builder.ISearchQueryExecutor; import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; import ca.uhn.fhir.jpa.searchparam.extractor.ResourceIndexedSearchParams; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import org.hl7.fhir.instance.model.api.IBaseResource; import java.util.Collection; @@ -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 search(String theResourceName, SearchParameterMap theParams); + List search(String theResourceName, SearchParameterMap theParams); /** @@ -63,7 +63,7 @@ public interface IFulltextSearchSvc { */ IBaseResource tokenAutocompleteValueSetSearch(ValueSetAutocompleteOptions theOptions); - List everything(String theResourceName, SearchParameterMap theParams, ResourcePersistentId theReferencingPid); + List everything(String theResourceName, SearchParameterMap theParams, T theReferencingPid); boolean isDisabled(); @@ -81,7 +81,7 @@ public interface IFulltextSearchSvc { */ void reindex(ResourceTable theEntity); - List lastN(SearchParameterMap theParams, Integer theMaximumResults); + List lastN(SearchParameterMap theParams, Integer theMaximumResults); /** * Returns inlined resource stored along with index mappings for matched identifiers diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/JpaResourceDaoCodeSystem.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/JpaResourceDaoCodeSystem.java index f8285ba471b..3a4fc8bd720 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/JpaResourceDaoCodeSystem.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/JpaResourceDaoCodeSystem.java @@ -36,7 +36,7 @@ import ca.uhn.fhir.jpa.term.api.ITermCodeSystemStorageSvc; import ca.uhn.fhir.jpa.term.api.ITermDeferredStorageSvc; import ca.uhn.fhir.jpa.util.LogicUtil; 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.IResourcePersistentId; import ca.uhn.fhir.rest.api.server.storage.TransactionDetails; import ca.uhn.fhir.rest.param.TokenParam; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; @@ -88,9 +88,9 @@ public class JpaResourceDaoCodeSystem extends BaseHapiF @Override public List findCodeSystemIdsContainingSystemAndCode(String theCode, String theSystem, RequestDetails theRequest) { List valueSetIds; - List ids = searchForIds(new SearchParameterMap(org.hl7.fhir.r4.model.CodeSystem.SP_CODE, new TokenParam(theSystem, theCode)), theRequest); + List ids = searchForIds(new SearchParameterMap(org.hl7.fhir.r4.model.CodeSystem.SP_CODE, new TokenParam(theSystem, theCode)), theRequest); valueSetIds = new ArrayList<>(); - for (ResourcePersistentId next : ids) { + for (IResourcePersistentId next : ids) { IIdType id = myIdHelperService.translatePidIdToForcedId(myFhirContext, "CodeSystem", next); valueSetIds.add(id); } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/JpaResourceDaoComposition.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/JpaResourceDaoComposition.java index 4875ed0652e..70f59d42e86 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/JpaResourceDaoComposition.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/JpaResourceDaoComposition.java @@ -31,7 +31,6 @@ import ca.uhn.fhir.rest.param.StringParam; import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IIdType; import org.hl7.fhir.instance.model.api.IPrimitiveType; -import org.hl7.fhir.r4.model.Composition; import javax.servlet.http.HttpServletRequest; import java.util.Collections; diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/JpaResourceDaoObservation.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/JpaResourceDaoObservation.java index c1c767fcad1..bf8b4a9b2b3 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/JpaResourceDaoObservation.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/JpaResourceDaoObservation.java @@ -24,6 +24,7 @@ import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.interceptor.model.RequestPartitionId; import ca.uhn.fhir.jpa.api.dao.IFhirResourceDaoObservation; import ca.uhn.fhir.jpa.model.cross.IBasePersistedResource; +import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.jpa.model.entity.ResourceTable; import ca.uhn.fhir.jpa.partition.IRequestPartitionHelperSvc; import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; @@ -34,7 +35,6 @@ import ca.uhn.fhir.rest.api.SortOrderEnum; import ca.uhn.fhir.rest.api.SortSpec; 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.api.server.storage.TransactionDetails; import ca.uhn.fhir.rest.param.ReferenceOrListParam; import ca.uhn.fhir.rest.param.ReferenceParam; @@ -152,8 +152,8 @@ public class JpaResourceDaoObservation extends BaseHapi for (IQueryParameterType nextOr : nextPatientList) { if (nextOr instanceof ReferenceParam) { ReferenceParam ref = (ReferenceParam) nextOr; - ResourcePersistentId pid = myIdHelperService.resolveResourcePersistentIds(requestPartitionId, ref.getResourceType(), ref.getIdPart()); - orderedSubjectReferenceMap.put(pid.getIdAsLong(), nextOr); + JpaPid pid = myIdHelperService.resolveResourcePersistentIds(requestPartitionId, ref.getResourceType(), ref.getIdPart()); + orderedSubjectReferenceMap.put(pid.getId(), nextOr); } else { throw new IllegalArgumentException(Msg.code(942) + "Invalid token type (expecting ReferenceParam): " + nextOr.getClass()); } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/TransactionProcessor.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/TransactionProcessor.java index 912f634d8e0..cf400db5c72 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/TransactionProcessor.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/TransactionProcessor.java @@ -28,16 +28,14 @@ import ca.uhn.fhir.jpa.api.dao.IFhirSystemDao; import ca.uhn.fhir.jpa.api.model.DaoMethodOutcome; import ca.uhn.fhir.jpa.api.svc.IIdHelperService; import ca.uhn.fhir.jpa.config.HapiFhirHibernateJpaDialect; -import ca.uhn.fhir.jpa.dao.index.IdHelperService; import ca.uhn.fhir.jpa.model.config.PartitionSettings; +import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamToken; -import ca.uhn.fhir.jpa.model.entity.ResourceTable; import ca.uhn.fhir.jpa.partition.IRequestPartitionHelperSvc; import ca.uhn.fhir.jpa.searchparam.MatchUrlService; import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; import ca.uhn.fhir.model.api.IQueryParameterType; 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.rest.param.TokenParam; import ca.uhn.fhir.util.StopWatch; @@ -90,7 +88,7 @@ public class TransactionProcessor extends BaseTransactionProcessor { @Autowired(required = false) private HapiFhirHibernateJpaDialect myHapiFhirHibernateJpaDialect; @Autowired - private IIdHelperService myIdHelperService; + private IIdHelperService myIdHelperService; @Autowired private PartitionSettings myPartitionSettings; @Autowired @@ -98,7 +96,7 @@ public class TransactionProcessor extends BaseTransactionProcessor { @Autowired private FhirContext myFhirContext; @Autowired - private MatchResourceUrlService myMatchResourceUrlService; + private MatchResourceUrlService myMatchResourceUrlService; @Autowired private MatchUrlService myMatchUrlService; @Autowired @@ -166,12 +164,13 @@ public class TransactionProcessor extends BaseTransactionProcessor { } } } - List outcome = myIdHelperService.resolveResourcePersistentIdsWithCache(requestPartitionId, idsToPreResolve); - for (ResourcePersistentId next : outcome) { + List outcome = myIdHelperService.resolveResourcePersistentIdsWithCache(requestPartitionId, idsToPreResolve) + .stream().collect(Collectors.toList()); + for (JpaPid next : outcome) { foundIds.add(next.getAssociatedResourceId().toUnqualifiedVersionless().getValue()); theTransactionDetails.addResolvedResourceId(next.getAssociatedResourceId(), next); if (myDaoConfig.getResourceClientIdStrategy() != DaoConfig.ClientIdStrategyEnum.ANY || !next.getAssociatedResourceId().isIdPartValidLong()) { - idsToPreFetch.add(next.getIdAsLong()); + idsToPreFetch.add(next.getId()); } } for (IIdType next : idsToPreResolve) { @@ -192,18 +191,18 @@ public class TransactionProcessor extends BaseTransactionProcessor { String requestIfNoneExist = versionAdapter.getEntryIfNoneExist(nextEntry); String resourceType = myFhirContext.getResourceType(resource); if ("PUT".equals(verb) && requestUrl != null && requestUrl.contains("?")) { - ResourcePersistentId cachedId = myMatchResourceUrlService.processMatchUrlUsingCacheOnly(resourceType, requestUrl); + JpaPid cachedId = myMatchResourceUrlService.processMatchUrlUsingCacheOnly(resourceType, requestUrl); if (cachedId != null) { - idsToPreFetch.add(cachedId.getIdAsLong()); + idsToPreFetch.add(cachedId.getId()); } else if (SINGLE_PARAMETER_MATCH_URL_PATTERN.matcher(requestUrl).matches()) { RuntimeResourceDefinition resourceDefinition = myFhirContext.getResourceDefinition(resource); SearchParameterMap matchUrlSearchMap = myMatchUrlService.translateMatchUrl(requestUrl, resourceDefinition); searchParameterMapsToResolve.add(new MatchUrlToResolve(requestUrl, matchUrlSearchMap, resourceDefinition)); } } else if ("POST".equals(verb) && requestIfNoneExist != null && requestIfNoneExist.contains("?")) { - ResourcePersistentId cachedId = myMatchResourceUrlService.processMatchUrlUsingCacheOnly(resourceType, requestIfNoneExist); + JpaPid cachedId = myMatchResourceUrlService.processMatchUrlUsingCacheOnly(resourceType, requestIfNoneExist); if (cachedId != null) { - idsToPreFetch.add(cachedId.getIdAsLong()); + idsToPreFetch.add(cachedId.getId()); } else if (SINGLE_PARAMETER_MATCH_URL_PATTERN.matcher(requestIfNoneExist).matches()) { RuntimeResourceDefinition resourceDefinition = myFhirContext.getResourceDefinition(resource); SearchParameterMap matchUrlSearchMap = myMatchUrlService.translateMatchUrl(requestIfNoneExist, resourceDefinition); @@ -277,7 +276,7 @@ public class TransactionProcessor extends BaseTransactionProcessor { } IFhirSystemDao systemDao = myApplicationContext.getBean(IFhirSystemDao.class); - systemDao.preFetchResources(ResourcePersistentId.fromLongList(idsToPreFetch)); + systemDao.preFetchResources(JpaPid.fromLongList(idsToPreFetch)); } @@ -322,8 +321,8 @@ public class TransactionProcessor extends BaseTransactionProcessor { private void setSearchToResolvedAndPrefetchFoundResourcePid(TransactionDetails theTransactionDetails, List idsToPreFetch, ResourceIndexedSearchParamToken nextResult, MatchUrlToResolve nextSearchParameterMap) { ourLog.debug("Matched url {} from database", nextSearchParameterMap.myRequestUrl); idsToPreFetch.add(nextResult.getResourcePid()); - myMatchResourceUrlService.matchUrlResolved(theTransactionDetails, nextSearchParameterMap.myResourceDefinition.getName(), nextSearchParameterMap.myRequestUrl, new ResourcePersistentId(nextResult.getResourcePid())); - theTransactionDetails.addResolvedMatchUrl(nextSearchParameterMap.myRequestUrl, new ResourcePersistentId(nextResult.getResourcePid())); + myMatchResourceUrlService.matchUrlResolved(theTransactionDetails, nextSearchParameterMap.myResourceDefinition.getName(), nextSearchParameterMap.myRequestUrl, JpaPid.fromId(nextResult.getResourcePid())); + theTransactionDetails.addResolvedMatchUrl(nextSearchParameterMap.myRequestUrl, JpaPid.fromId(nextResult.getResourcePid())); nextSearchParameterMap.setResolved(true); } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/expunge/ResourceExpungeService.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/expunge/JpaResourceExpungeService.java similarity index 85% rename from hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/expunge/ResourceExpungeService.java rename to hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/expunge/JpaResourceExpungeService.java index bdbeb29bcb7..e0dea8e6dc4 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/expunge/ResourceExpungeService.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/expunge/JpaResourceExpungeService.java @@ -45,13 +45,13 @@ import ca.uhn.fhir.jpa.dao.data.IResourceLinkDao; import ca.uhn.fhir.jpa.dao.data.IResourceTableDao; import ca.uhn.fhir.jpa.dao.data.IResourceTagDao; import ca.uhn.fhir.jpa.dao.data.ISearchParamPresentDao; +import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.jpa.model.entity.ForcedId; import ca.uhn.fhir.jpa.model.entity.ResourceHistoryTable; 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; @@ -74,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 { + private static final Logger ourLog = LoggerFactory.getLogger(JpaResourceExpungeService.class); @Autowired private IForcedIdDao myForcedIdDao; @@ -128,7 +128,7 @@ public class ResourceExpungeService implements IResourceExpungeService { @Override @Transactional - public List findHistoricalVersionsOfNonDeletedResources(String theResourceName, ResourcePersistentId theResourceId, int theRemainingCount) { + public List findHistoricalVersionsOfNonDeletedResources(String theResourceName, JpaPid theJpaPid, int theRemainingCount) { if (isEmptyQuery(theRemainingCount)) { return Collections.EMPTY_LIST; } @@ -136,11 +136,11 @@ public class ResourceExpungeService implements IResourceExpungeService { Pageable page = PageRequest.of(0, theRemainingCount); Slice ids; - if (theResourceId != null && theResourceId.getId() != null) { - if (theResourceId.getVersion() != null) { - ids = toSlice(myResourceHistoryTableDao.findForIdAndVersionAndFetchProvenance(theResourceId.getIdAsLong(), theResourceId.getVersion())); + if (theJpaPid != null && theJpaPid.getId() != null) { + if (theJpaPid.getVersion() != null) { + ids = toSlice(myResourceHistoryTableDao.findForIdAndVersionAndFetchProvenance(theJpaPid.getId(), theJpaPid.getVersion())); } else { - ids = myResourceHistoryTableDao.findIdsOfPreviousVersionsOfResourceId(page, theResourceId.getIdAsLong()); + ids = myResourceHistoryTableDao.findIdsOfPreviousVersionsOfResourceId(page, theJpaPid.getId()); } } else { if (theResourceName != null) { @@ -150,12 +150,12 @@ public class ResourceExpungeService implements IResourceExpungeService { } } - return ResourcePersistentId.fromLongList(ids.getContent()); + return JpaPid.fromLongList(ids.getContent()); } @Override @Transactional - public List findHistoricalVersionsOfDeletedResources(String theResourceName, ResourcePersistentId theResourceId, int theRemainingCount) { + public List findHistoricalVersionsOfDeletedResources(String theResourceName, JpaPid theResourceId, int theRemainingCount) { if (isEmptyQuery(theRemainingCount)) { return Collections.EMPTY_LIST; } @@ -163,7 +163,7 @@ public class ResourceExpungeService implements IResourceExpungeService { Pageable page = PageRequest.of(0, theRemainingCount); Slice ids; if (theResourceId != null) { - ids = myResourceTableDao.findIdsOfDeletedResourcesOfType(page, theResourceId.getIdAsLong(), theResourceName); + ids = myResourceTableDao.findIdsOfDeletedResourcesOfType(page, theResourceId.getId(), theResourceName); ourLog.info("Expunging {} deleted resources of type[{}] and ID[{}]", ids.getNumberOfElements(), theResourceName, theResourceId); } else { if (theResourceName != null) { @@ -174,14 +174,14 @@ public class ResourceExpungeService implements IResourceExpungeService { ourLog.info("Expunging {} deleted resources (all types)", ids.getNumberOfElements()); } } - return ResourcePersistentId.fromLongList(ids.getContent()); + return JpaPid.fromLongList(ids.getContent()); } @Override @Transactional - public void expungeCurrentVersionOfResources(RequestDetails theRequestDetails, List theResourceIds, AtomicInteger theRemainingCount) { - for (ResourcePersistentId next : theResourceIds) { - expungeCurrentVersionOfResource(theRequestDetails, next.getIdAsLong(), theRemainingCount); + public void expungeCurrentVersionOfResources(RequestDetails theRequestDetails, List theResourceIds, AtomicInteger theRemainingCount) { + for (JpaPid next : theResourceIds) { + expungeCurrentVersionOfResource(theRequestDetails,(next).getId(), theRemainingCount); if (expungeLimitReached(theRemainingCount)) { return; } @@ -236,9 +236,9 @@ public class ResourceExpungeService implements IResourceExpungeService { @Override @Transactional - public void expungeHistoricalVersionsOfIds(RequestDetails theRequestDetails, List theResourceIds, AtomicInteger theRemainingCount) { - for (ResourcePersistentId next : theResourceIds) { - expungeHistoricalVersionsOfId(theRequestDetails, next.getIdAsLong(), theRemainingCount); + public void expungeHistoricalVersionsOfIds(RequestDetails theRequestDetails, List theResourceIds, AtomicInteger theRemainingCount) { + for (JpaPid next : theResourceIds) { + expungeHistoricalVersionsOfId(theRequestDetails, (next).getId(), theRemainingCount); if (expungeLimitReached(theRemainingCount)) { return; } @@ -247,9 +247,9 @@ public class ResourceExpungeService implements IResourceExpungeService { @Override @Transactional - public void expungeHistoricalVersions(RequestDetails theRequestDetails, List theHistoricalIds, AtomicInteger theRemainingCount) { - for (ResourcePersistentId next : theHistoricalIds) { - expungeHistoricalVersion(theRequestDetails, next.getIdAsLong(), theRemainingCount); + public void expungeHistoricalVersions(RequestDetails theRequestDetails, List theHistoricalIds, AtomicInteger theRemainingCount) { + for (JpaPid next : theHistoricalIds) { + expungeHistoricalVersion(theRequestDetails, (next).getId(), theRemainingCount); if (expungeLimitReached(theRemainingCount)) { return; } @@ -266,7 +266,7 @@ public class ResourceExpungeService implements IResourceExpungeService { ourLog.info("Expunging current version of resource {}", resource.getIdDt().getValue()); - deleteAllSearchParams(new ResourcePersistentId(resource.getResourceId())); + deleteAllSearchParams(JpaPid.fromId(resource.getResourceId())); myResourceTagDao.deleteByResourceId(resource.getId()); @@ -282,44 +282,45 @@ public class ResourceExpungeService implements IResourceExpungeService { @Override @Transactional - public void deleteAllSearchParams(ResourcePersistentId theResourceId) { - ResourceTable resource = myResourceTableDao.findById(theResourceId.getIdAsLong()).orElse(null); + public void deleteAllSearchParams(JpaPid theResourceId) { + Long theResourceLongId = theResourceId.getId(); + ResourceTable resource = myResourceTableDao.findById(theResourceLongId).orElse(null); if (resource == null || resource.isParamsUriPopulated()) { - myResourceIndexedSearchParamUriDao.deleteByResourceId(theResourceId.getIdAsLong()); + myResourceIndexedSearchParamUriDao.deleteByResourceId(theResourceLongId); } if (resource == null || resource.isParamsCoordsPopulated()) { - myResourceIndexedSearchParamCoordsDao.deleteByResourceId(theResourceId.getIdAsLong()); + myResourceIndexedSearchParamCoordsDao.deleteByResourceId(theResourceLongId); } if (resource == null || resource.isParamsDatePopulated()) { - myResourceIndexedSearchParamDateDao.deleteByResourceId(theResourceId.getIdAsLong()); + myResourceIndexedSearchParamDateDao.deleteByResourceId(theResourceLongId); } if (resource == null || resource.isParamsNumberPopulated()) { - myResourceIndexedSearchParamNumberDao.deleteByResourceId(theResourceId.getIdAsLong()); + myResourceIndexedSearchParamNumberDao.deleteByResourceId(theResourceLongId); } if (resource == null || resource.isParamsQuantityPopulated()) { - myResourceIndexedSearchParamQuantityDao.deleteByResourceId(theResourceId.getIdAsLong()); + myResourceIndexedSearchParamQuantityDao.deleteByResourceId(theResourceLongId); } if (resource == null || resource.isParamsQuantityNormalizedPopulated()) { - myResourceIndexedSearchParamQuantityNormalizedDao.deleteByResourceId(theResourceId.getIdAsLong()); + myResourceIndexedSearchParamQuantityNormalizedDao.deleteByResourceId(theResourceLongId); } if (resource == null || resource.isParamsStringPopulated()) { - myResourceIndexedSearchParamStringDao.deleteByResourceId(theResourceId.getIdAsLong()); + myResourceIndexedSearchParamStringDao.deleteByResourceId(theResourceLongId); } if (resource == null || resource.isParamsTokenPopulated()) { - myResourceIndexedSearchParamTokenDao.deleteByResourceId(theResourceId.getIdAsLong()); + myResourceIndexedSearchParamTokenDao.deleteByResourceId(theResourceLongId); } if (resource == null || resource.isParamsComboStringUniquePresent()) { - myResourceIndexedCompositeStringUniqueDao.deleteByResourceId(theResourceId.getIdAsLong()); + myResourceIndexedCompositeStringUniqueDao.deleteByResourceId(theResourceLongId); } if (resource == null || resource.isParamsComboTokensNonUniquePresent()) { - myResourceIndexedComboTokensNonUniqueDao.deleteByResourceId(theResourceId.getIdAsLong()); + myResourceIndexedComboTokensNonUniqueDao.deleteByResourceId(theResourceLongId); } if (myDaoConfig.getIndexMissingFields() == DaoConfig.IndexEnabledEnum.ENABLED) { - mySearchParamPresentDao.deleteByResourceId(theResourceId.getIdAsLong()); + mySearchParamPresentDao.deleteByResourceId(theResourceLongId); } if (resource == null || resource.isHasLinks()) { - myResourceLinkDao.deleteByResourceId(theResourceId.getIdAsLong()); + myResourceLinkDao.deleteByResourceId(theResourceLongId); } } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/index/IJpaIdHelperService.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/index/IJpaIdHelperService.java deleted file mode 100644 index 889dadf1179..00000000000 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/index/IJpaIdHelperService.java +++ /dev/null @@ -1,97 +0,0 @@ -package ca.uhn.fhir.jpa.dao.index; - -/*- - * #%L - * HAPI FHIR JPA Server - * %% - * Copyright (C) 2014 - 2022 Smile CDR, Inc. - * %% - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * #L% - */ - -import ca.uhn.fhir.jpa.api.svc.IIdHelperService; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; -import org.hl7.fhir.instance.model.api.IAnyResource; -import org.hl7.fhir.instance.model.api.IBaseResource; -import org.hl7.fhir.instance.model.api.IIdType; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import java.util.List; -import java.util.Set; - -/** - * This class is an analog to {@link IIdHelperService} but with additional JPA server methods - * added. - * - * JA 2022-02-17 - I moved these methods out of IdHelperService because I want to reuse - * IdHelperService in storage-engine-neutral batch tasks such as bulk import. These methods - * are all just being used by MDM, so they're JPA specific. I believe it should be possible - * though to just replace all of these calls with equivalents from IdHelperService, - * at which point this interface and its implementation could just go away. - * - * All of the methods here aren't partition aware, so it's not great to use them - * anyhow. The equivalents in {@link IIdHelperService} are probably a bit more - * clunky because you have to convert between {@link Long} and - * {@link ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId} to use them, - * 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 { - - /** - * @deprecated This method doesn't take a partition ID as input, so it is unsafe. It - * should be reworked to include the partition ID before any new use is incorporated - */ - @Deprecated - @Nonnull - List getPidsOrThrowException(List theIds); - - - /** - * @deprecated This method doesn't take a partition ID as input, so it is unsafe. It - * should be reworked to include the partition ID before any new use is incorporated - */ - @Deprecated - @Nullable - Long getPidOrNull(IBaseResource theResource); - - - /** - * @deprecated This method doesn't take a partition ID as input, so it is unsafe. It - * should be reworked to include the partition ID before any new use is incorporated - */ - @Deprecated - @Nonnull - Long getPidOrThrowException(IIdType theId); - - @Nonnull - ResourcePersistentId getPidOrThrowException(@Nonnull IAnyResource theResource); - - IIdType resourceIdFromPidOrThrowException(Long thePid); - - /** - * Given a set of PIDs, return a set of public FHIR Resource IDs. - * This function will resolve a forced ID if it resolves, and if it fails to resolve to a forced it, will just return the pid - * Example: - * Let's say we have Patient/1(pid == 1), Patient/pat1 (pid == 2), Patient/3 (pid == 3), their pids would resolve as follows: - *

- * [1,2,3] -> ["1","pat1","3"] - * - * @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 translatePidsToFhirResourceIds(Set thePids); - -} diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/index/IdHelperService.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/index/IdHelperService.java index acc0c8f4c34..56315718845 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/index/IdHelperService.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/index/IdHelperService.java @@ -30,14 +30,16 @@ 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.cross.JpaResourceLookup; +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; import ca.uhn.fhir.jpa.util.MemoryCacheService; import ca.uhn.fhir.jpa.util.QueryChunker; import ca.uhn.fhir.model.primitive.IdDt; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.BaseResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.exceptions.PreconditionFailedException; import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; @@ -92,13 +94,13 @@ import static org.apache.commons.lang3.StringUtils.isNotBlank; *

* This service is highly optimized in order to minimize the number of DB calls as much as possible, * since ID resolution is fundamental to many basic operations. This service returns either - * {@link IResourceLookup} or {@link ResourcePersistentId} depending on the method being called. + * {@link IResourceLookup} or {@link BaseResourcePersistentId} depending on the method being called. * The former involves an extra database join that the latter does not require, so selecting the * right method here is important. *

*/ @Service -public class IdHelperService implements IIdHelperService { +public class IdHelperService implements IIdHelperService { public static final Predicate[] EMPTY_PREDICATE_ARRAY = new Predicate[0]; public static final String RESOURCE_PID = "RESOURCE_PID"; @Autowired @@ -130,7 +132,7 @@ public class IdHelperService implements IIdHelperService { */ @Override @Nonnull - public IResourceLookup resolveResourceIdentity(@Nonnull RequestPartitionId theRequestPartitionId, String theResourceType, String theResourceId) throws ResourceNotFoundException { + public IResourceLookup resolveResourceIdentity(@Nonnull RequestPartitionId theRequestPartitionId, String theResourceType, String theResourceId) throws ResourceNotFoundException { return resolveResourceIdentity(theRequestPartitionId, theResourceType, theResourceId, false); } @@ -143,12 +145,12 @@ public class IdHelperService implements IIdHelperService { */ @Override @Nonnull - public IResourceLookup resolveResourceIdentity(@Nonnull RequestPartitionId theRequestPartitionId, String theResourceType, String theResourceId, boolean theExcludeDeleted) throws ResourceNotFoundException { + public IResourceLookup 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> matches = translateForcedIdToPids(theRequestPartitionId, + Map>> matches = translateForcedIdToPids(theRequestPartitionId, Collections.singletonList(id), theExcludeDeleted); @@ -171,25 +173,25 @@ public class IdHelperService implements IIdHelperService { } /** - * Returns a mapping of Id -> ResourcePersistentId. + * Returns a mapping of Id -> IResourcePersistentId. * If any resource is not found, it will throw ResourceNotFound exception (and no map will be returned) */ @Override @Nonnull - public Map resolveResourcePersistentIds(@Nonnull RequestPartitionId theRequestPartitionId, + public Map resolveResourcePersistentIds(@Nonnull RequestPartitionId theRequestPartitionId, String theResourceType, List theIds) { return resolveResourcePersistentIds(theRequestPartitionId, theResourceType, theIds, false); } /** - * Returns a mapping of Id -> ResourcePersistentId. + * Returns a mapping of Id -> IResourcePersistentId. * If any resource is not found, it will throw ResourceNotFound exception (and no map will be returned) * Optionally filters out deleted resources. */ @Override @Nonnull - public Map resolveResourcePersistentIds(@Nonnull RequestPartitionId theRequestPartitionId, + public Map resolveResourcePersistentIds(@Nonnull RequestPartitionId theRequestPartitionId, String theResourceType, List theIds, boolean theExcludeDeleted) { @@ -197,13 +199,13 @@ public class IdHelperService implements IIdHelperService { Validate.notNull(theIds, "theIds cannot be null"); Validate.isTrue(!theIds.isEmpty(), "theIds must not be empty"); - Map retVals = new HashMap<>(); + Map retVals = new HashMap<>(); for (String id : theIds) { - ResourcePersistentId retVal; + JpaPid retVal; if (!idRequiresForcedId(id)) { // is already a PID - retVal = new ResourcePersistentId(Long.parseLong(id)); + retVal = JpaPid.fromId(Long.parseLong(id)); retVals.put(id, retVal); } else { // is a forced id @@ -217,7 +219,7 @@ public class IdHelperService implements IIdHelperService { retVal = myMemoryCacheService.getThenPutAfterCommit(MemoryCacheService.CacheEnum.FORCED_ID_TO_PID, key, t -> { List ids = Collections.singletonList(new IdType(theResourceType, id)); // fetches from cache using a function that checks cache first... - List resolvedIds = resolveResourcePersistentIdsWithCache(theRequestPartitionId, ids); + List resolvedIds = resolveResourcePersistentIdsWithCache(theRequestPartitionId, ids); if (resolvedIds.isEmpty()) { throw new ResourceNotFoundException(Msg.code(1100) + ids.get(0)); } @@ -238,7 +240,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); } @@ -249,10 +251,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 retVal = resolveResourcePersistentIds(theRequestPartitionId, + Map retVal = resolveResourcePersistentIds(theRequestPartitionId, theResourceType, Collections.singletonList(theId), theExcludeDeleted); @@ -284,7 +286,7 @@ public class IdHelperService implements IIdHelperService { */ @Override @Nonnull - public List resolveResourcePersistentIdsWithCache(RequestPartitionId theRequestPartitionId, List theIds) { + public List resolveResourcePersistentIdsWithCache(RequestPartitionId theRequestPartitionId, List theIds) { boolean onlyForcedIds = false; return resolveResourcePersistentIdsWithCache(theRequestPartitionId, theIds, onlyForcedIds); } @@ -299,10 +301,10 @@ public class IdHelperService implements IIdHelperService { */ @Override @Nonnull - public List resolveResourcePersistentIdsWithCache(RequestPartitionId theRequestPartitionId, List theIds, boolean theOnlyForcedIds) { + public List resolveResourcePersistentIdsWithCache(RequestPartitionId theRequestPartitionId, List theIds, boolean theOnlyForcedIds) { assert myDontCheckActiveTransactionForUnitTest || TransactionSynchronizationManager.isSynchronizationActive(); - List retVal = new ArrayList<>(theIds.size()); + List retVal = new ArrayList<>(theIds.size()); for (IIdType id : theIds) { if (!id.hasIdPart()) { @@ -316,14 +318,16 @@ public class IdHelperService implements IIdHelperService { if (myDaoConfig.getResourceClientIdStrategy() != DaoConfig.ClientIdStrategyEnum.ANY) { if (nextId.isIdPartValidLong()) { if (!theOnlyForcedIds) { - retVal.add(new ResourcePersistentId(nextId.getIdPartAsLong()).setAssociatedResourceId(nextId)); + JpaPid jpaPid = JpaPid.fromId(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; @@ -337,7 +341,7 @@ public class IdHelperService implements IIdHelperService { return retVal; } - private void doResolvePersistentIds(RequestPartitionId theRequestPartitionId, List theIds, List theOutputListToPopulate) { + private void doResolvePersistentIds(RequestPartitionId theRequestPartitionId, List theIds, List theOutputListToPopulate) { CriteriaBuilder cb = myEntityManager.getCriteriaBuilder(); CriteriaQuery criteriaQuery = cb.createQuery(ForcedId.class); Root from = criteriaQuery.from(ForcedId.class); @@ -365,12 +369,12 @@ public class IdHelperService implements IIdHelperService { for (ForcedId nextId : results) { // Check if the nextId has a resource ID. It may have a null resource ID if a commit is still pending. if (nextId.getResourceId() != null) { - ResourcePersistentId persistentId = new ResourcePersistentId(nextId.getResourceId()); - populateAssociatedResourceId(nextId.getResourceType(), nextId.getForcedId(), persistentId); - theOutputListToPopulate.add(persistentId); + JpaPid jpaPid = JpaPid.fromId(nextId.getResourceId()); + populateAssociatedResourceId(nextId.getResourceType(), nextId.getForcedId(), jpaPid); + theOutputListToPopulate.add(jpaPid); String key = toForcedIdToPidKey(theRequestPartitionId, nextId.getResourceType(), nextId.getForcedId()); - myMemoryCacheService.putAfterCommit(MemoryCacheService.CacheEnum.FORCED_ID_TO_PID, key, persistentId); + myMemoryCacheService.putAfterCommit(MemoryCacheService.CacheEnum.FORCED_ID_TO_PID, key, jpaPid); } } } @@ -401,10 +405,10 @@ public class IdHelperService implements IIdHelperService { return Optional.empty(); } - private void populateAssociatedResourceId(String nextResourceType, String forcedId, ResourcePersistentId persistentId) { + private void populateAssociatedResourceId(String nextResourceType, String forcedId, JpaPid jpaPid) { IIdType resourceId = myFhirCtx.getVersion().newIdType(); resourceId.setValue(nextResourceType + "/" + forcedId); - persistentId.setAssociatedResourceId(resourceId); + jpaPid.setAssociatedResourceId(resourceId); } /** @@ -412,7 +416,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(); } @@ -430,8 +434,8 @@ public class IdHelperService implements IIdHelperService { } @Override - public Optional translatePidIdToForcedIdWithCache(ResourcePersistentId theId) { - return myMemoryCacheService.get(MemoryCacheService.CacheEnum.PID_TO_FORCED_ID, theId.getIdAsLong(), pid -> myForcedIdDao.findByResourcePid(pid).map(ForcedId::asTypedFhirResourceId)); + public Optional translatePidIdToForcedIdWithCache(JpaPid theId) { + return myMemoryCacheService.get(MemoryCacheService.CacheEnum.PID_TO_FORCED_ID, theId.getId(), pid -> myForcedIdDao.findByResourcePid(pid).map(ForcedId::asTypedFhirResourceId)); } private ListMultimap organizeIdsByResourceType(Collection theIds) { @@ -448,7 +452,7 @@ public class IdHelperService implements IIdHelperService { return typeToIds; } - private Map> translateForcedIdToPids(@Nonnull RequestPartitionId theRequestPartitionId, Collection theId, boolean theExcludeDeleted) { + private Map>> translateForcedIdToPids(@Nonnull RequestPartitionId theRequestPartitionId, Collection theId, boolean theExcludeDeleted) { assert theRequestPartitionId != null; theId.forEach(id -> Validate.isTrue(id.hasIdPart())); @@ -457,7 +461,7 @@ public class IdHelperService implements IIdHelperService { return new HashMap<>(); } - Map> retVal = new HashMap<>(); + Map>> retVal = new HashMap<>(); RequestPartitionId requestPartitionId = replaceDefault(theRequestPartitionId); if (myDaoConfig.getResourceClientIdStrategy() != DaoConfig.ClientIdStrategyEnum.ANY) { @@ -514,7 +518,7 @@ public class IdHelperService implements IIdHelperService { String forcedId = (String) next[2]; Date deletedAt = (Date) next[3]; - ResourceLookup lookup = new ResourceLookup(resourceType, resourcePid, deletedAt); + JpaResourceLookup lookup = new JpaResourceLookup(resourceType, resourcePid, deletedAt); if (!retVal.containsKey(forcedId)) { retVal.put(forcedId, new ArrayList<>()); } @@ -546,7 +550,7 @@ public class IdHelperService implements IIdHelperService { return theRequestPartitionId; } - private void resolvePids(@Nonnull RequestPartitionId theRequestPartitionId, List thePidsToResolve, Map> theTargets) { + private void resolvePids(@Nonnull RequestPartitionId theRequestPartitionId, List thePidsToResolve, Map>> theTargets) { if (!myDaoConfig.isDeleteEnabled()) { for (Iterator forcedIdIterator = thePidsToResolve.iterator(); forcedIdIterator.hasNext(); ) { Long nextPid = forcedIdIterator.next(); @@ -577,7 +581,7 @@ public class IdHelperService implements IIdHelperService { } lookup .stream() - .map(t -> new ResourceLookup((String) t[0], (Long) t[1], (Date) t[2])) + .map(t -> new JpaResourceLookup((String) t[0], (Long) t[1], (Date) t[2])) .forEach(t -> { String id = t.getPersistentId().toString(); if (!theTargets.containsKey(id)) { @@ -594,9 +598,9 @@ public class IdHelperService implements IIdHelperService { } @Override - public PersistentIdToForcedIdMap translatePidsToForcedIds(Set theResourceIds) { + public PersistentIdToForcedIdMap translatePidsToForcedIds(Set theResourceIds) { assert myDontCheckActiveTransactionForUnitTest || TransactionSynchronizationManager.isSynchronizationActive(); - Set thePids = theResourceIds.stream().map(t -> t.getIdAsLong()).collect(Collectors.toSet()); + Set thePids = theResourceIds.stream().map(JpaPid::getId).collect(Collectors.toSet()); Map> retVal = new HashMap<>(myMemoryCacheService.getAllPresent(MemoryCacheService.CacheEnum.PID_TO_FORCED_ID, thePids)); List remainingPids = thePids @@ -623,10 +627,10 @@ public class IdHelperService implements IIdHelperService { retVal.put(nextResourcePid, Optional.empty()); myMemoryCacheService.putAfterCommit(MemoryCacheService.CacheEnum.PID_TO_FORCED_ID, nextResourcePid, Optional.empty()); } - Map> convertRetVal = new HashMap<>(); + Map> convertRetVal = new HashMap<>(); retVal.forEach( (k, v) -> { - convertRetVal.put(new ResourcePersistentId(k), v); + convertRetVal.put(JpaPid.fromId(k), v); } ); return new PersistentIdToForcedIdMap(convertRetVal); @@ -636,22 +640,22 @@ 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 theJpaPid, @Nonnull RequestPartitionId theRequestPartitionId, String theResourceType, @Nullable String theForcedId, @Nullable Date theDeletedAt) { if (theForcedId != null) { - if (theResourcePersistentId.getAssociatedResourceId() == null) { - populateAssociatedResourceId(theResourceType, theForcedId, theResourcePersistentId); + if (theJpaPid.getAssociatedResourceId() == null) { + populateAssociatedResourceId(theResourceType, theForcedId, theJpaPid); } - myMemoryCacheService.putAfterCommit(MemoryCacheService.CacheEnum.PID_TO_FORCED_ID, theResourcePersistentId.getIdAsLong(), Optional.of(theResourceType + "/" + theForcedId)); + myMemoryCacheService.putAfterCommit(MemoryCacheService.CacheEnum.PID_TO_FORCED_ID, theJpaPid.getId(), Optional.of(theResourceType + "/" + theForcedId)); String key = toForcedIdToPidKey(theRequestPartitionId, theResourceType, theForcedId); - myMemoryCacheService.putAfterCommit(MemoryCacheService.CacheEnum.FORCED_ID_TO_PID, key, theResourcePersistentId); + myMemoryCacheService.putAfterCommit(MemoryCacheService.CacheEnum.FORCED_ID_TO_PID, key, theJpaPid); } else { - myMemoryCacheService.putAfterCommit(MemoryCacheService.CacheEnum.PID_TO_FORCED_ID, theResourcePersistentId.getIdAsLong(), Optional.empty()); + myMemoryCacheService.putAfterCommit(MemoryCacheService.CacheEnum.PID_TO_FORCED_ID, theJpaPid.getId(), Optional.empty()); } if (!myDaoConfig.isDeleteEnabled()) { - ResourceLookup lookup = new ResourceLookup(theResourceType, theResourcePersistentId.getIdAsLong(), theDeletedAt); - String nextKey = theResourcePersistentId.toString(); + JpaResourceLookup lookup = new JpaResourceLookup(theResourceType, theJpaPid.getId(), theDeletedAt); + String nextKey = theJpaPid.toString(); myMemoryCacheService.putAfterCommit(MemoryCacheService.CacheEnum.RESOURCE_LOOKUP, nextKey, lookup); } @@ -677,47 +681,50 @@ public class IdHelperService implements IIdHelperService { @Override @Nonnull - public List getPidsOrThrowException(@Nonnull RequestPartitionId theRequestPartitionId, List theIds) { - List resourcePersistentIds = resolveResourcePersistentIdsWithCache(theRequestPartitionId, theIds); + public List getPidsOrThrowException(@Nonnull RequestPartitionId theRequestPartitionId, List theIds) { + List resourcePersistentIds = resolveResourcePersistentIdsWithCache(theRequestPartitionId, theIds); return resourcePersistentIds; } @Override @Nullable - public ResourcePersistentId getPidOrNull(@Nonnull RequestPartitionId theRequestPartitionId, IBaseResource theResource) { - ResourcePersistentId retVal = new ResourcePersistentId(theResource.getUserData(RESOURCE_PID)); - if (retVal.getId() == null) { + public JpaPid getPidOrNull(@Nonnull RequestPartitionId theRequestPartitionId, IBaseResource theResource) { + Object resourceId = theResource.getUserData(RESOURCE_PID); + JpaPid retVal; + if (resourceId == null) { IIdType id = theResource.getIdElement(); try { retVal = resolveResourcePersistentIds(theRequestPartitionId, id.getResourceType(), id.getIdPart()); } catch (ResourceNotFoundException e) { - return null; + retVal = null; } + } else { + retVal = JpaPid.fromId(Long.parseLong(resourceId.toString())); } return retVal; } @Override @Nonnull - public ResourcePersistentId getPidOrThrowException(@Nonnull RequestPartitionId theRequestPartitionId, IIdType theId) { + public JpaPid getPidOrThrowException(@Nonnull RequestPartitionId theRequestPartitionId, IIdType theId) { List ids = Collections.singletonList(theId); - List resourcePersistentIds = resolveResourcePersistentIdsWithCache(theRequestPartitionId, ids); + List resourcePersistentIds = resolveResourcePersistentIdsWithCache(theRequestPartitionId, ids); return resourcePersistentIds.get(0); } @Override @Nonnull - public ResourcePersistentId getPidOrThrowException(@Nonnull IAnyResource theResource) { - Object theResourcePID = theResource.getUserData(RESOURCE_PID); + 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())); } - return new ResourcePersistentId(theResourcePID); + return JpaPid.fromId(theResourcePID); } @Override - public IIdType resourceIdFromPidOrThrowException(ResourcePersistentId thePid, String theResourceType) { - Optional optionalResource = myResourceTableDao.findById(thePid.getIdAsLong()); + public IIdType resourceIdFromPidOrThrowException(JpaPid thePid, String theResourceType) { + Optional optionalResource = myResourceTableDao.findById(thePid.getId()); if (!optionalResource.isPresent()) { throw new ResourceNotFoundException(Msg.code(2124) + "Requested resource not found"); } @@ -736,11 +743,21 @@ public class IdHelperService implements IIdHelperService { * @return A Set of strings representing the FHIR IDs of the pids. */ @Override - public Set translatePidsToFhirResourceIds(Set thePids) { + public Set translatePidsToFhirResourceIds(Set thePids) { assert TransactionSynchronizationManager.isSynchronizationActive(); PersistentIdToForcedIdMap pidToForcedIdMap = translatePidsToForcedIds(thePids); return pidToForcedIdMap.getResolvedResourceIds(); } + + @Override + public JpaPid newPid(Object thePid) { + return JpaPid.fromId((Long) thePid); + } + + @Override + public JpaPid newPidFromStringIdAndResourceName(String thePid, String theResourceName) { + return JpaPid.fromIdAndResourceType(Long.parseLong(thePid), theResourceName); + } } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/index/JpaIdHelperService.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/index/JpaIdHelperService.java deleted file mode 100644 index 69a2c2960c8..00000000000 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/index/JpaIdHelperService.java +++ /dev/null @@ -1,143 +0,0 @@ -package ca.uhn.fhir.jpa.dao.index; - -/*- - * #%L - * HAPI FHIR JPA Server - * %% - * Copyright (C) 2014 - 2022 Smile CDR, Inc. - * %% - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * #L% - */ - -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.dao.data.IResourceTableDao; -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; -import org.hl7.fhir.instance.model.api.IIdType; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.transaction.support.TransactionSynchronizationManager; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import java.util.Collections; -import java.util.List; -import java.util.Optional; -import java.util.Set; -import java.util.stream.Collectors; - -/** - * See {@link IJpaIdHelperService} for an explanation of this class. - */ -public class JpaIdHelperService extends IdHelperService implements IJpaIdHelperService, IIdHelperService { - @Autowired - protected IResourceTableDao myResourceTableDao; - - /** - * @deprecated This method doesn't take a partition ID as input, so it is unsafe. It - * should be reworked to include the partition ID before any new use is incorporated - */ - @Override - @Deprecated - @Nonnull - public List getPidsOrThrowException(List theIds) { - List resourcePersistentIds = super.resolveResourcePersistentIdsWithCache(RequestPartitionId.allPartitions(), theIds); - return resourcePersistentIds.stream().map(ResourcePersistentId::getIdAsLong).collect(Collectors.toList()); - } - - - /** - * @deprecated This method doesn't take a partition ID as input, so it is unsafe. It - * should be reworked to include the partition ID before any new use is incorporated - */ - @Override - @Deprecated - @Nullable - public Long getPidOrNull(IBaseResource theResource) { - - IAnyResource anyResource = (IAnyResource) theResource; - Long retVal = (Long) anyResource.getUserData(RESOURCE_PID); - if (retVal == null) { - IIdType id = theResource.getIdElement(); - try { - retVal = super.resolveResourcePersistentIds(RequestPartitionId.allPartitions(), id.getResourceType(), id.getIdPart()).getIdAsLong(); - } catch (ResourceNotFoundException e) { - return null; - } - } - return retVal; - } - - - /** - * @deprecated This method doesn't take a partition ID as input, so it is unsafe. It - * should be reworked to include the partition ID before any new use is incorporated - */ - @Override - @Deprecated - @Nonnull - public Long getPidOrThrowException(IIdType theId) { - assert TransactionSynchronizationManager.isSynchronizationActive(); - - List ids = Collections.singletonList(theId); - List resourcePersistentIds = super.resolveResourcePersistentIdsWithCache(RequestPartitionId.allPartitions(), ids); - return resourcePersistentIds.get(0).getIdAsLong(); - } - - @Override - @Nonnull - public ResourcePersistentId 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()) - ); - } - return new ResourcePersistentId(retVal); - } - - @Override - public IIdType resourceIdFromPidOrThrowException(Long thePid) { - Optional optionalResource = myResourceTableDao.findById(thePid); - if (!optionalResource.isPresent()) { - throw new ResourceNotFoundException(Msg.code(1103) + "Requested resource not found"); - } - return optionalResource.get().getIdDt().toVersionless(); - } - - /** - * Given a set of PIDs, return a set of public FHIR Resource IDs. - * This function will resolve a forced ID if it resolves, and if it fails to resolve to a forced it, will just return the pid - * Example: - * Let's say we have Patient/1(pid == 1), Patient/pat1 (pid == 2), Patient/3 (pid == 3), their pids would resolve as follows: - *

- * [1,2,3] -> ["1","pat1","3"] - * - * @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. - */ - @Override - public Set translatePidsToFhirResourceIds(Set thePids) { - assert TransactionSynchronizationManager.isSynchronizationActive(); - - PersistentIdToForcedIdMap pidToForcedIdMap = super.translatePidsToForcedIds(thePids); - - return pidToForcedIdMap.getResolvedResourceIds(); - } - -} diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/index/SearchParamWithInlineReferencesExtractor.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/index/SearchParamWithInlineReferencesExtractor.java index ad078466624..655a6eb784e 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/index/SearchParamWithInlineReferencesExtractor.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/index/SearchParamWithInlineReferencesExtractor.java @@ -34,6 +34,7 @@ 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; @@ -46,7 +47,6 @@ import ca.uhn.fhir.jpa.util.MemoryCacheService; import ca.uhn.fhir.model.api.IQueryParameterType; import ca.uhn.fhir.rest.api.RestSearchParameterTypeEnum; 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.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.exceptions.PreconditionFailedException; @@ -88,19 +88,19 @@ public class SearchParamWithInlineReferencesExtractor { @PersistenceContext(type = PersistenceContextType.TRANSACTION) protected EntityManager myEntityManager; @Autowired - private MatchResourceUrlService myMatchResourceUrlService; + private MatchResourceUrlService myMatchResourceUrlService; @Autowired private DaoConfig myDaoConfig; @Autowired private FhirContext myContext; @Autowired - private IIdHelperService myIdHelperService; + private IIdHelperService myIdHelperService; @Autowired private ISearchParamRegistry mySearchParamRegistry; @Autowired private SearchParamExtractorService mySearchParamExtractorService; @Autowired - private DaoResourceLinkResolver myDaoResourceLinkResolver; + private DaoResourceLinkResolver myDaoResourceLinkResolver; @Autowired private DaoSearchParamSynchronizer myDaoSearchParamSynchronizer; @Autowired @@ -350,14 +350,14 @@ public class SearchParamWithInlineReferencesExtractor { Class matchResourceType = matchResourceDef.getImplementingClass(); //Attempt to find the target reference before creating a placeholder - Set matches = myMatchResourceUrlService.processMatchUrl(nextIdText, matchResourceType, theTransactionDetails, theRequest); + Set matches = myMatchResourceUrlService.processMatchUrl(nextIdText, matchResourceType, theTransactionDetails, theRequest); - ResourcePersistentId match; + JpaPid match; if (matches.isEmpty()) { Optional placeholderOpt = myDaoResourceLinkResolver.createPlaceholderTargetIfConfiguredToDoSo(matchResourceType, nextRef, null, theRequest, theTransactionDetails); if (placeholderOpt.isPresent()) { - match = placeholderOpt.get().getPersistentId(); + match = (JpaPid) placeholderOpt.get().getPersistentId(); match.setAssociatedResourceId(placeholderOpt.get().getIdDt()); theTransactionDetails.addResolvedMatchUrl(nextIdText, match); myMemoryCacheService.putAfterCommit(MemoryCacheService.CacheEnum.MATCH_URL, nextIdText, match); diff --git a/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/dao/JpaMdmLinkImplFactory.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/mdm/JpaMdmLinkImplFactory.java similarity index 96% rename from hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/dao/JpaMdmLinkImplFactory.java rename to hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/mdm/JpaMdmLinkImplFactory.java index ba4cced4b4c..b5ba2cdff11 100644 --- a/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/dao/JpaMdmLinkImplFactory.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/mdm/JpaMdmLinkImplFactory.java @@ -1,4 +1,4 @@ -package ca.uhn.fhir.jpa.mdm.dao; +package ca.uhn.fhir.jpa.dao.mdm; /*- * #%L diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/mdm/MdmLinkDaoJpaImpl.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/mdm/MdmLinkDaoJpaImpl.java index 4b5de945ce6..27d0ff428d5 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/mdm/MdmLinkDaoJpaImpl.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/mdm/MdmLinkDaoJpaImpl.java @@ -25,13 +25,13 @@ import ca.uhn.fhir.interceptor.model.RequestPartitionId; import ca.uhn.fhir.jpa.api.svc.IIdHelperService; import ca.uhn.fhir.jpa.dao.data.IMdmLinkJpaRepository; import ca.uhn.fhir.jpa.entity.MdmLink; +import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.mdm.api.IMdmLink; import ca.uhn.fhir.mdm.api.MdmLinkSourceEnum; import ca.uhn.fhir.mdm.api.MdmMatchResultEnum; import ca.uhn.fhir.mdm.api.paging.MdmPageRequest; import ca.uhn.fhir.mdm.dao.IMdmLinkDao; import ca.uhn.fhir.mdm.model.MdmPidTuple; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.ListUtils; @@ -56,81 +56,80 @@ import java.util.List; import java.util.Optional; import java.util.stream.Collectors; -public class MdmLinkDaoJpaImpl implements IMdmLinkDao { +public class MdmLinkDaoJpaImpl implements IMdmLinkDao { @Autowired IMdmLinkJpaRepository myMdmLinkDao; @Autowired protected EntityManager myEntityManager; @Autowired - private IIdHelperService myIdHelperService; + private IIdHelperService myIdHelperService; @Override - public int deleteWithAnyReferenceToPid(ResourcePersistentId thePid) { - return myMdmLinkDao.deleteWithAnyReferenceToPid(thePid.getIdAsLong()); + public int deleteWithAnyReferenceToPid(JpaPid thePid) { + return myMdmLinkDao.deleteWithAnyReferenceToPid(thePid.getId()); } @Override - public int deleteWithAnyReferenceToPidAndMatchResultNot(ResourcePersistentId thePid, MdmMatchResultEnum theMatchResult) { - return myMdmLinkDao.deleteWithAnyReferenceToPidAndMatchResultNot(thePid.getIdAsLong(), theMatchResult); + public int deleteWithAnyReferenceToPidAndMatchResultNot(JpaPid thePid, MdmMatchResultEnum theMatchResult) { + return myMdmLinkDao.deleteWithAnyReferenceToPidAndMatchResultNot(thePid.getId(), theMatchResult); } @Override - public List expandPidsFromGroupPidGivenMatchResult(ResourcePersistentId theGroupPid, MdmMatchResultEnum theMdmMatchResultEnum) { - return myMdmLinkDao.expandPidsFromGroupPidGivenMatchResult(theGroupPid.getIdAsLong(), theMdmMatchResultEnum) + public List> expandPidsFromGroupPidGivenMatchResult(JpaPid theGroupPid, MdmMatchResultEnum theMdmMatchResultEnum) { + return myMdmLinkDao.expandPidsFromGroupPidGivenMatchResult((theGroupPid).getId(), theMdmMatchResultEnum) .stream() - .map( theMdmPidTuple -> new MdmPidTuple() - .setSourcePid(new ResourcePersistentId(theMdmPidTuple.getSourcePid())) - .setGoldenPid(new ResourcePersistentId(theMdmPidTuple.getGoldenPid()))) + .map(this::daoTupleToMdmTuple) + .collect(Collectors.toList()); + } + + private MdmPidTuple daoTupleToMdmTuple(IMdmLinkJpaRepository.MdmPidTuple theMdmPidTuple) { + return MdmPidTuple.fromGoldenAndSource(JpaPid.fromId(theMdmPidTuple.getGoldenPid()), JpaPid.fromId(theMdmPidTuple.getSourcePid())); + } + + @Override + public List> expandPidsBySourcePidAndMatchResult(JpaPid theSourcePid, MdmMatchResultEnum theMdmMatchResultEnum) { + return myMdmLinkDao.expandPidsBySourcePidAndMatchResult((theSourcePid).getId(), theMdmMatchResultEnum) + .stream() + .map(this::daoTupleToMdmTuple) .collect(Collectors.toList()); } @Override - public List expandPidsBySourcePidAndMatchResult(ResourcePersistentId theSourcePid, MdmMatchResultEnum theMdmMatchResultEnum) { - return myMdmLinkDao.expandPidsBySourcePidAndMatchResult(theSourcePid.getIdAsLong(), theMdmMatchResultEnum) + public List> expandPidsByGoldenResourcePidAndMatchResult(JpaPid theSourcePid, MdmMatchResultEnum theMdmMatchResultEnum) { + return myMdmLinkDao.expandPidsByGoldenResourcePidAndMatchResult((theSourcePid).getId(), theMdmMatchResultEnum) .stream() - .map( theMdmPidTuple -> new MdmPidTuple() - .setSourcePid(new ResourcePersistentId(theMdmPidTuple.getSourcePid())) - .setGoldenPid(new ResourcePersistentId(theMdmPidTuple.getGoldenPid()))) + .map(this::daoTupleToMdmTuple) .collect(Collectors.toList()); } @Override - public List expandPidsByGoldenResourcePidAndMatchResult(ResourcePersistentId theSourcePid, MdmMatchResultEnum theMdmMatchResultEnum) { - return myMdmLinkDao.expandPidsByGoldenResourcePidAndMatchResult(theSourcePid.getIdAsLong(), theMdmMatchResultEnum) - .stream() - .map( theMdmPidTuple -> new MdmPidTuple() - .setSourcePid(new ResourcePersistentId(theMdmPidTuple.getSourcePid())) - .setGoldenPid(new ResourcePersistentId(theMdmPidTuple.getGoldenPid()))) - .collect(Collectors.toList()); - } - - @Override - public List findPidByResourceNameAndThreshold(String theResourceName, Date theHighThreshold, Pageable thePageable) { + public List findPidByResourceNameAndThreshold(String theResourceName, Date theHighThreshold, Pageable thePageable) { return myMdmLinkDao.findPidByResourceNameAndThreshold(theResourceName,theHighThreshold, thePageable) .stream() - .map( theResourcePids -> new ResourcePersistentId(theResourcePids)) + .map( theResourcePids -> JpaPid.fromId(theResourcePids)) .collect(Collectors.toList()); } @Override - public List findPidByResourceNameAndThresholdAndPartitionId(String theResourceName, Date theHighThreshold, List thePartitionIds, Pageable thePageable) { + public List findPidByResourceNameAndThresholdAndPartitionId(String theResourceName, Date theHighThreshold, List thePartitionIds, Pageable thePageable) { return myMdmLinkDao.findPidByResourceNameAndThresholdAndPartitionId(theResourceName,theHighThreshold, thePartitionIds, thePageable) .stream() - .map( theResourcePids -> new ResourcePersistentId(theResourcePids)) + .map( theResourcePids -> JpaPid.fromId(theResourcePids)) .collect(Collectors.toList()); } @Override - public List findAllById(List thePids) { - List theLongPids = thePids.stream().map(theResourcePersistentId -> theResourcePersistentId.getIdAsLong()).collect(Collectors.toList()); + public List findAllById(List thePids) { + List theLongPids = thePids.stream().map(JpaPid::getId).collect(Collectors.toList()); return myMdmLinkDao.findAllById(theLongPids); } @Override - public Optional findById(ResourcePersistentId thePid) { - return myMdmLinkDao.findById(thePid.getIdAsLong()); + public Optional findById(JpaPid thePid) { + return myMdmLinkDao.findById(thePid.getId()); } + @Override public void deleteAll(List theLinks) { myMdmLinkDao.deleteAll(theLinks); } @@ -190,11 +189,11 @@ public class MdmLinkDaoJpaImpl implements IMdmLinkDao { List andPredicates = new ArrayList<>(); if (theGoldenResourceId != null) { - Predicate goldenResourcePredicate = criteriaBuilder.equal(from.get("myGoldenResourcePid").as(Long.class), myIdHelperService.getPidOrThrowException(RequestPartitionId.allPartitions(), theGoldenResourceId).getIdAsLong()); + Predicate goldenResourcePredicate = criteriaBuilder.equal(from.get("myGoldenResourcePid").as(Long.class), (myIdHelperService.getPidOrThrowException(RequestPartitionId.allPartitions(), theGoldenResourceId)).getId()); andPredicates.add(goldenResourcePredicate); } if (theSourceId != null) { - Predicate sourceIdPredicate = criteriaBuilder.equal(from.get("mySourcePid").as(Long.class), myIdHelperService.getPidOrThrowException(RequestPartitionId.allPartitions(), theSourceId).getIdAsLong()); + Predicate sourceIdPredicate = criteriaBuilder.equal(from.get("mySourcePid").as(Long.class), (myIdHelperService.getPidOrThrowException(RequestPartitionId.allPartitions(), theSourceId)).getId()); andPredicates.add(sourceIdPredicate); } if (theMatchResult != null) { @@ -226,13 +225,13 @@ public class MdmLinkDaoJpaImpl implements IMdmLinkDao { } @Override - public Optional findBySourcePidAndMatchResult(ResourcePersistentId theSourcePid, MdmMatchResultEnum theMatch) { - return myMdmLinkDao.findBySourcePidAndMatchResult(theSourcePid.getIdAsLong(), theMatch); + public Optional findBySourcePidAndMatchResult(JpaPid theSourcePid, MdmMatchResultEnum theMatch) { + return myMdmLinkDao.findBySourcePidAndMatchResult((theSourcePid).getId(), theMatch); } @Override - public void deleteLinksWithAnyReferenceToPids(List theResourcePersistentIds) { - List goldenResourcePids = theResourcePersistentIds.stream().map(ResourcePersistentId::getIdAsLong).collect(Collectors.toList()); + public void deleteLinksWithAnyReferenceToPids(List theResourcePersistentIds) { + List goldenResourcePids = theResourcePersistentIds.stream().map(JpaPid::getId).collect(Collectors.toList()); // Split into chunks of 500 so older versions of Oracle don't run into issues (500 = 1000 / 2 since the dao // method uses the list twice in the sql predicate) List> chunks = ListUtils.partition(goldenResourcePids, 500); diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/delete/batch2/DeleteExpungeSqlBuilder.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/delete/batch2/DeleteExpungeSqlBuilder.java index 0361d78b44e..dfdb288a1f1 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/delete/batch2/DeleteExpungeSqlBuilder.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/delete/batch2/DeleteExpungeSqlBuilder.java @@ -26,9 +26,8 @@ import ca.uhn.fhir.jpa.api.svc.IIdHelperService; 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.dao.index.IJpaIdHelperService; +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 convertPidsToDeleteExpungeSql(List thePersistentIds) { - List pids = ResourcePersistentId.toLongList(thePersistentIds); + List convertPidsToDeleteExpungeSql(List theJpaPids) { + List pids = JpaPid.toLongList(theJpaPids); validateOkToDeleteAndExpunge(pids); @@ -84,7 +83,7 @@ public class DeleteExpungeSqlBuilder { return; } - List targetPidsAsResourceIds = ResourcePersistentId.fromLongList(thePids); + List targetPidsAsResourceIds = JpaPid.fromLongList(thePids); List conflictResourceLinks = Collections.synchronizedList(new ArrayList<>()); findResourceLinksWithTargetPidIn(targetPidsAsResourceIds, targetPidsAsResourceIds, conflictResourceLinks); @@ -97,16 +96,16 @@ public class DeleteExpungeSqlBuilder { //NB-GGG: We previously instantiated these ID values from firstConflict.getSourceResource().getIdDt(), but in a situation where we //actually had to run delete conflict checks in multiple partitions, the executor service starts its own sessions on a per thread basis, and by the time //we arrive here, those sessions are closed. So instead, we resolve them from PIDs, which are eagerly loaded. - String sourceResourceId = myIdHelper.resourceIdFromPidOrThrowException(new ResourcePersistentId(firstConflict.getSourceResourcePid()), firstConflict.getSourceResourceType()).toVersionless().getValue(); - String targetResourceId = myIdHelper.resourceIdFromPidOrThrowException(new ResourcePersistentId(firstConflict.getTargetResourcePid()), firstConflict.getTargetResourceType()).toVersionless().getValue(); + String sourceResourceId = myIdHelper.resourceIdFromPidOrThrowException(JpaPid.fromId(firstConflict.getSourceResourcePid()), firstConflict.getSourceResourceType()).toVersionless().getValue(); + String targetResourceId = myIdHelper.resourceIdFromPidOrThrowException(JpaPid.fromId(firstConflict.getTargetResourcePid()), firstConflict.getTargetResourceType()).toVersionless().getValue(); throw new InvalidRequestException(Msg.code(822) + "DELETE with _expunge=true failed. Unable to delete " + targetResourceId + " because " + sourceResourceId + " refers to it via the path " + firstConflict.getSourcePath()); } - public void findResourceLinksWithTargetPidIn(List theAllTargetPids, List theSomeTargetPids, List theConflictResourceLinks) { - List allTargetPidsAsLongs = ResourcePersistentId.toLongList(theAllTargetPids); - List someTargetPidsAsLongs = ResourcePersistentId.toLongList(theSomeTargetPids); + public void findResourceLinksWithTargetPidIn(List theAllTargetPids, List theSomeTargetPids, List theConflictResourceLinks) { + List allTargetPidsAsLongs = JpaPid.toLongList(theAllTargetPids); + List 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 if (theConflictResourceLinks.isEmpty()) { List conflictResourceLinks = myResourceLinkDao.findWithTargetPidIn(someTargetPidsAsLongs).stream() diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/delete/batch2/DeleteExpungeSvcImpl.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/delete/batch2/DeleteExpungeSvcImpl.java index 2cd3586d538..34eade16804 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/delete/batch2/DeleteExpungeSvcImpl.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/delete/batch2/DeleteExpungeSvcImpl.java @@ -22,8 +22,8 @@ package ca.uhn.fhir.jpa.delete.batch2; import ca.uhn.fhir.jpa.api.svc.IDeleteExpungeSvc; import ca.uhn.fhir.jpa.dao.IFulltextSearchSvc; +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 org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -49,8 +49,8 @@ public class DeleteExpungeSvcImpl implements IDeleteExpungeSvc { } @Override - public void deleteExpunge(List thePersistentIds) { - List sqlList = myDeleteExpungeSqlBuilder.convertPidsToDeleteExpungeSql(thePersistentIds); + public void deleteExpunge(List theJpaPids) { + List sqlList = myDeleteExpungeSqlBuilder.convertPidsToDeleteExpungeSql(theJpaPids); ourLog.debug("Executing {} delete expunge sql commands", sqlList.size()); long totalDeleted = 0; @@ -60,7 +60,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 } @@ -69,9 +69,9 @@ 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 thePersistentIds) { + private void clearHibernateSearchIndex(List thePersistentIds) { if (myFullTextSearchSvc != null) { - List objectIds = thePersistentIds.stream().map(ResourcePersistentId::getIdAsLong).collect(Collectors.toList()); + List objectIds = thePersistentIds.stream().map(JpaPid::getId).collect(Collectors.toList()); myFullTextSearchSvc.deleteIndexedDocumentsByTypeAndId(ResourceTable.class, objectIds); ourLog.info("Cleared Hibernate Search indexes."); } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/MdmLink.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/MdmLink.java index d1138b0030b..b0a02af78be 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/MdmLink.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/MdmLink.java @@ -20,12 +20,12 @@ package ca.uhn.fhir.jpa.entity; * #L% */ +import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.jpa.model.entity.BasePartitionable; import ca.uhn.fhir.jpa.model.entity.ResourceTable; import ca.uhn.fhir.mdm.api.IMdmLink; import ca.uhn.fhir.mdm.api.MdmLinkSourceEnum; import ca.uhn.fhir.mdm.api.MdmMatchResultEnum; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; import org.apache.commons.lang3.builder.ToStringBuilder; import javax.persistence.Column; @@ -57,7 +57,7 @@ import java.util.Date; }, indexes = { @Index(name = "IDX_EMPI_MATCH_TGT_VER", columnList = "MATCH_RESULT, TARGET_PID, VERSION") }) -public class MdmLink extends BasePartitionable implements IMdmLink { +public class MdmLink extends BasePartitionable implements IMdmLink { public static final int VERSION_LENGTH = 16; private static final int MATCH_RESULT_LENGTH = 16; private static final int LINK_SOURCE_LENGTH = 16; @@ -139,37 +139,38 @@ public class MdmLink extends BasePartitionable implements IMdmLink { private String myMdmSourceType; @Override - public ResourcePersistentId getId() { - return new ResourcePersistentId(myId); + public JpaPid getId() { + return JpaPid.fromId(myId); } @Override - public MdmLink setId(ResourcePersistentId theId) { - myId = theId.getIdAsLong(); + public MdmLink setId(JpaPid theId) { + myId = theId.getId(); return this; } @Override - public ResourcePersistentId getGoldenResourcePersistenceId() { - return new ResourcePersistentId(myGoldenResourcePid); + public JpaPid getGoldenResourcePersistenceId() { + return JpaPid.fromId(myGoldenResourcePid); } @Override - public IMdmLink setGoldenResourcePersistenceId(ResourcePersistentId theGoldenResourcePid) { - setPersonPid(theGoldenResourcePid.getIdAsLong()); + public IMdmLink setGoldenResourcePersistenceId(JpaPid theGoldenResourcePid) { + Long longPid = theGoldenResourcePid.getId(); + setPersonPid(longPid); - myGoldenResourcePid = theGoldenResourcePid.getIdAsLong(); + myGoldenResourcePid = longPid; return this; } @Override - public ResourcePersistentId getSourcePersistenceId() { - return new ResourcePersistentId(mySourcePid); + public JpaPid getSourcePersistenceId() { + return JpaPid.fromId(mySourcePid); } @Override - public IMdmLink setSourcePersistenceId(ResourcePersistentId theSourcePid) { - mySourcePid = theSourcePid.getIdAsLong(); + public IMdmLink setSourcePersistenceId(JpaPid theSourcePid) { + mySourcePid = theSourcePid.getId(); return this; } @@ -202,7 +203,7 @@ public class MdmLink extends BasePartitionable implements IMdmLink { } /** - * @deprecated Use {@link #setGoldenResourcePersistenceId(ResourcePersistentId)} instead + * @deprecated Use {@link #setGoldenResourcePersistenceId(JpaPid)} instead */ @Deprecated public MdmLink setGoldenResourcePid(Long theGoldenResourcePid) { @@ -228,7 +229,7 @@ public class MdmLink extends BasePartitionable implements IMdmLink { } /** - * @deprecated Use {@link #setSourcePersistenceId(ResourcePersistentId)} instead + * @deprecated Use {@link #setSourcePersistenceId(JpaPid)} instead */ @Deprecated public MdmLink setSourcePid(Long theSourcePid) { diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/interceptor/JpaPreResourceAccessDetails.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/interceptor/JpaPreResourceAccessDetails.java index 5e7f2514d74..1b2214dc8dc 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/interceptor/JpaPreResourceAccessDetails.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/interceptor/JpaPreResourceAccessDetails.java @@ -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 myResourcePids; + private final List myResourcePids; private final boolean[] myBlocked; private final ICallable mySearchBuilderSupplier; private List myResources; - public JpaPreResourceAccessDetails(List theResourcePids, ICallable theSearchBuilderSupplier) { + public JpaPreResourceAccessDetails(List theResourcePids, ICallable theSearchBuilderSupplier) { myResourcePids = theResourcePids; myBlocked = new boolean[myResourcePids.size()]; mySearchBuilderSupplier = theSearchBuilderSupplier; diff --git a/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/cross/ResourceLookup.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/model/cross/JpaResourceLookup.java similarity index 78% rename from hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/cross/ResourceLookup.java rename to hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/model/cross/JpaResourceLookup.java index d98aa036b28..850f75b285d 100644 --- a/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/cross/ResourceLookup.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/model/cross/JpaResourceLookup.java @@ -20,16 +20,16 @@ package ca.uhn.fhir.jpa.model.cross; * #L% */ -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.jpa.model.dao.JpaPid; import java.util.Date; -public class ResourceLookup implements IResourceLookup { +public class JpaResourceLookup implements IResourceLookup { private final String myResourceType; private final Long myResourcePid; private final Date myDeletedAt; - public ResourceLookup(String theResourceType, Long theResourcePid, Date theDeletedAt) { + public JpaResourceLookup(String theResourceType, Long theResourcePid, Date theDeletedAt) { myResourceType = theResourceType; myResourcePid = theResourcePid; myDeletedAt = theDeletedAt; @@ -46,7 +46,7 @@ public class ResourceLookup implements IResourceLookup { } @Override - public ResourcePersistentId getPersistentId() { - return new ResourcePersistentId(myResourcePid); + public JpaPid getPersistentId() { + return JpaPid.fromId(myResourcePid); } } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/packages/JpaPackageCache.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/packages/JpaPackageCache.java index fad8cf2754d..9066c07fe38 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/packages/JpaPackageCache.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/packages/JpaPackageCache.java @@ -34,6 +34,7 @@ import ca.uhn.fhir.jpa.dao.data.INpmPackageDao; import ca.uhn.fhir.jpa.dao.data.INpmPackageVersionDao; import ca.uhn.fhir.jpa.dao.data.INpmPackageVersionResourceDao; import ca.uhn.fhir.jpa.model.config.PartitionSettings; +import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.jpa.model.entity.NpmPackageEntity; import ca.uhn.fhir.jpa.model.entity.NpmPackageVersionEntity; import ca.uhn.fhir.jpa.model.entity.NpmPackageVersionResourceEntity; @@ -42,7 +43,6 @@ import ca.uhn.fhir.jpa.model.util.JpaConstants; import ca.uhn.fhir.jpa.partition.SystemRequestDetails; import ca.uhn.fhir.rest.api.Constants; import ca.uhn.fhir.rest.api.EncodingEnum; -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.exceptions.ResourceNotFoundException; @@ -72,6 +72,7 @@ import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Slice; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.support.TransactionTemplate; import javax.annotation.Nonnull; @@ -85,7 +86,6 @@ import javax.persistence.criteria.Join; import javax.persistence.criteria.JoinType; import javax.persistence.criteria.Predicate; import javax.persistence.criteria.Root; -import org.springframework.transaction.annotation.Transactional; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; @@ -182,7 +182,7 @@ public class JpaPackageCache extends BasePackageCacheManager implements IHapiPac private IHapiPackageCacheManager.PackageContents loadPackageContents(NpmPackageVersionEntity thePackageVersion) { IFhirResourceDao binaryDao = getBinaryDao(); - IBaseBinary binary = binaryDao.readByPid(new ResourcePersistentId(thePackageVersion.getPackageBinary().getId())); + IBaseBinary binary = binaryDao.readByPid(JpaPid.fromId(thePackageVersion.getPackageBinary().getId())); try { byte[] content = fetchBlobFromBinary(binary); PackageContents retVal = new PackageContents() @@ -529,7 +529,7 @@ public class JpaPackageCache extends BasePackageCacheManager implements IHapiPac private IBaseResource loadPackageEntity(NpmPackageVersionResourceEntity contents) { try { - ResourcePersistentId binaryPid = new ResourcePersistentId(contents.getResourceBinary().getId()); + JpaPid binaryPid = JpaPid.fromId(contents.getResourceBinary().getId()); IBaseBinary binary = getBinaryDao().readByPid(binaryPid); byte[] resourceContentsBytes= fetchBlobFromBinary(binary); String resourceContents = new String(resourceContentsBytes, StandardCharsets.UTF_8); diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/reindex/Batch2DaoSvcImpl.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/reindex/Batch2DaoSvcImpl.java index 91331428dd8..752c9e7af4d 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/reindex/Batch2DaoSvcImpl.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/reindex/Batch2DaoSvcImpl.java @@ -31,13 +31,14 @@ import ca.uhn.fhir.jpa.api.pid.IResourcePidList; import ca.uhn.fhir.jpa.api.pid.MixedResourcePidList; import ca.uhn.fhir.jpa.api.svc.IBatch2DaoSvc; import ca.uhn.fhir.jpa.dao.data.IResourceTableDao; +import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.jpa.partition.SystemRequestDetails; import ca.uhn.fhir.jpa.searchparam.MatchUrlService; import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; import ca.uhn.fhir.rest.api.Constants; import ca.uhn.fhir.rest.api.SortOrderEnum; import ca.uhn.fhir.rest.api.SortSpec; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import ca.uhn.fhir.rest.param.DateRangeParam; import ca.uhn.fhir.util.DateRangeUtil; import org.springframework.beans.factory.annotation.Autowired; @@ -95,7 +96,7 @@ public class Batch2DaoSvcImpl implements IBatch2DaoSvc { IFhirResourceDao dao = myDaoRegistry.getResourceDao(resourceType); SystemRequestDetails request = new SystemRequestDetails(); request.setRequestPartitionId(theRequestPartitionId); - List ids = dao.searchForIds(searchParamMap, request); + List ids = dao.searchForIds(searchParamMap, request); Date lastDate = null; if (ids.size() > 0) { @@ -122,9 +123,9 @@ public class Batch2DaoSvcImpl implements IBatch2DaoSvc { return new EmptyResourcePidList(); } - List ids = content + List ids = content .stream() - .map(t -> new ResourcePersistentId(t[0])) + .map(t -> JpaPid.fromId((Long) t[0])) .collect(Collectors.toList()); List types = content diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/PersistedJpaBundleProvider.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/PersistedJpaBundleProvider.java index 8cad69da494..0511c05b2b6 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/PersistedJpaBundleProvider.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/PersistedJpaBundleProvider.java @@ -33,10 +33,10 @@ import ca.uhn.fhir.jpa.dao.HistoryBuilder; import ca.uhn.fhir.jpa.dao.HistoryBuilderFactory; import ca.uhn.fhir.jpa.dao.IJpaStorageResourceParser; import ca.uhn.fhir.jpa.dao.ISearchBuilder; -import ca.uhn.fhir.jpa.dao.JpaStorageResourceParser; 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; @@ -51,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; @@ -91,7 +90,7 @@ public class PersistedJpaBundleProvider implements IBundleProvider { @Autowired private IInterceptorBroadcaster myInterceptorBroadcaster; @Autowired - private SearchBuilderFactory mySearchBuilderFactory; + private SearchBuilderFactory mySearchBuilderFactory; @Autowired private HistoryBuilderFactory myHistoryBuilderFactory; @Autowired @@ -99,7 +98,7 @@ public class PersistedJpaBundleProvider implements IBundleProvider { @Autowired private FhirContext myContext; @Autowired - private ISearchCoordinatorSvc mySearchCoordinatorSvc; + private ISearchCoordinatorSvc mySearchCoordinatorSvc; @Autowired private ISearchCacheSvc mySearchCacheSvc; @Autowired @@ -136,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 */ @@ -225,7 +212,7 @@ public class PersistedJpaBundleProvider implements IBundleProvider { final ISearchBuilder sb = mySearchBuilderFactory.newSearchBuilder(dao, resourceName, resourceType); - final List pidsSubList = mySearchCoordinatorSvc.getResources(myUuid, theFromIndex, theToIndex, myRequest); + final List pidsSubList = mySearchCoordinatorSvc.getResources(myUuid, theFromIndex, theToIndex, myRequest); TransactionTemplate template = new TransactionTemplate(myTxManager); template.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); @@ -413,14 +400,14 @@ public class PersistedJpaBundleProvider implements IBundleProvider { // Note: Leave as protected, HSPC depends on this @SuppressWarnings("WeakerAccess") - protected List toResourceList(ISearchBuilder theSearchBuilder, List thePids) { + protected List toResourceList(ISearchBuilder theSearchBuilder, List thePids) { - List includedPidList = new ArrayList<>(); + List includedPidList = new ArrayList<>(); if (mySearchEntity.getSearchType() == SearchTypeEnum.SEARCH) { Integer maxIncludes = myDaoConfig.getMaximumIncludesToLoadPerPage(); // Load _revincludes - Set includedPids = theSearchBuilder.loadIncludes(myContext, myEntityManager, thePids, mySearchEntity.toRevIncludesList(), true, mySearchEntity.getLastUpdated(), myUuid, myRequest, maxIncludes); + Set includedPids = theSearchBuilder.loadIncludes(myContext, myEntityManager, thePids, mySearchEntity.toRevIncludesList(), true, mySearchEntity.getLastUpdated(), myUuid, myRequest, maxIncludes); if (maxIncludes != null) { maxIncludes -= includedPids.size(); } @@ -428,7 +415,7 @@ public class PersistedJpaBundleProvider implements IBundleProvider { includedPidList.addAll(includedPids); // Load _includes - Set revIncludedPids = theSearchBuilder.loadIncludes(myContext, myEntityManager, thePids, mySearchEntity.toIncludesList(), false, mySearchEntity.getLastUpdated(), myUuid, myRequest, maxIncludes); + Set revIncludedPids = theSearchBuilder.loadIncludes(myContext, myEntityManager, thePids, mySearchEntity.toIncludesList(), false, mySearchEntity.getLastUpdated(), myUuid, myRequest, maxIncludes); thePids.addAll(revIncludedPids); includedPidList.addAll(revIncludedPids); diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/PersistedJpaSearchFirstPageBundleProvider.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/PersistedJpaSearchFirstPageBundleProvider.java index ce8fc6c12e9..50a5ec2b583 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/PersistedJpaSearchFirstPageBundleProvider.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/PersistedJpaSearchFirstPageBundleProvider.java @@ -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 pids = mySearchTask.getResourcePids(theFromIndex, theToIndex); + final List pids = mySearchTask.getResourcePids(theFromIndex, theToIndex); ourLog.trace("Done fetching search resource PIDs"); TransactionTemplate txTemplate = new TransactionTemplate(myTxManager); diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/SearchCoordinatorSvcImpl.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/SearchCoordinatorSvcImpl.java index ee793dbd18b..856cf00dc65 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/SearchCoordinatorSvcImpl.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/SearchCoordinatorSvcImpl.java @@ -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 { 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 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 myIdToSearchTask = new ConcurrentHashMap<>(); - private final Consumer myOnRemoveSearchTask = (theId) -> { - myIdToSearchTask.remove(theId); - }; + private final Consumer 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 theSearchBuilderFactory, ISynchronousSearchSvc theSynchronousSearchSvc, PersistedJpaBundleProviderFactory thePersistedJpaBundleProviderFactory, IRequestPartitionHelperSvc theRequestPartitionHelperService, @@ -211,7 +209,7 @@ public class SearchCoordinatorSvcImpl implements ISearchCoordinatorSvc { */ @Override @Transactional(propagation = Propagation.NEVER) - public List getResources(final String theUuid, int theFrom, int theTo, @Nullable RequestDetails theRequestDetails) { + public List 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 resourcePids = searchTask.getResourcePids(theFrom, theTo); + List 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 pids = mySearchResultCacheSvc.fetchResultPids(search, theFrom, theTo); + List 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 resourceTypeClass = myContext.getResourceDefinition(theResourceType).getImplementingClass(); - final ISearchBuilder sb = mySearchBuilderFactory.newSearchBuilder(theCallingDao, theResourceType, resourceTypeClass); + final ISearchBuilder 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 theSb, RequestPartitionId theRequestPartitionId, Search theSearch) { StopWatch w = new StopWatch(); SearchTaskParameters stp = new SearchTaskParameters( diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/SynchronousSearchSvcImpl.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/SynchronousSearchSvcImpl.java index 8e1d8b9bee3..68886560cbf 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/SynchronousSearchSvcImpl.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/SynchronousSearchSvcImpl.java @@ -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 pids = new ArrayList<>(); + final List 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 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 includedPids = theSb.loadIncludes(myContext, myEntityManager, pids, theParams.getRevIncludes(), true, theParams.getLastUpdated(), "(synchronous)", theRequestDetails, maxIncludes); + final Set includedPids = theSb.loadIncludes(myContext, myEntityManager, pids, theParams.getRevIncludes(), true, theParams.getLastUpdated(), "(synchronous)", theRequestDetails, maxIncludes); if (maxIncludes != null) { maxIncludes -= includedPids.size(); } pids.addAll(includedPids); - List includedPidsList = new ArrayList<>(includedPids); + List includedPidsList = new ArrayList<>(includedPids); // _revincludes if (theParams.getEverythingMode() == null && (maxIncludes == null || maxIncludes > 0)) { - Set revIncludedPids = theSb.loadIncludes(myContext, myEntityManager, pids, theParams.getIncludes(), false, theParams.getLastUpdated(), "(synchronous)", theRequestDetails, maxIncludes); + Set revIncludedPids = theSb.loadIncludes(myContext, myEntityManager, pids, theParams.getIncludes(), false, theParams.getLastUpdated(), "(synchronous)", theRequestDetails, maxIncludes); includedPids.addAll(revIncludedPids); pids.addAll(revIncludedPids); includedPidsList.addAll(revIncludedPids); diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/builder/SearchBuilder.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/builder/SearchBuilder.java index 83b7a04e1c8..c42f2224a03 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/builder/SearchBuilder.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/builder/SearchBuilder.java @@ -48,6 +48,7 @@ import ca.uhn.fhir.jpa.dao.search.ResourceNotFoundInIndexException; import ca.uhn.fhir.jpa.entity.ResourceSearchView; import ca.uhn.fhir.jpa.interceptor.JpaPreResourceAccessDetails; import ca.uhn.fhir.jpa.model.config.PartitionSettings; +import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.jpa.model.entity.IBaseResourceEntity; import ca.uhn.fhir.jpa.model.entity.ModelConfig; import ca.uhn.fhir.jpa.model.entity.ResourceTag; @@ -80,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; @@ -135,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 { /** * See loadResourcesByPid @@ -148,7 +148,7 @@ public class SearchBuilder implements ISearchBuilder { public static final String RESOURCE_ID_ALIAS = "resource_id"; public static final String RESOURCE_VERSION_ALIAS = "resource_version"; private static final Logger ourLog = LoggerFactory.getLogger(SearchBuilder.class); - private static final ResourcePersistentId NO_MORE = new ResourcePersistentId(-1L); + private static final JpaPid NO_MORE = JpaPid.fromId(-1L); private static final String MY_TARGET_RESOURCE_PID = "myTargetResourcePid"; private static final String MY_SOURCE_RESOURCE_PID = "mySourceResourcePid"; private static final String MY_TARGET_RESOURCE_TYPE = "myTargetResourceType"; @@ -168,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 myIdHelperService; private final DaoConfig myDaoConfig; private final IDao myCallingDao; @PersistenceContext(type = PersistenceContextType.TRANSACTION) protected EntityManager myEntityManager; - private List myAlsoIncludePids; + private List myAlsoIncludePids; private CriteriaBuilder myCriteriaBuilder; private SearchParameterMap myParams; private String mySearchUuid; private int myFetchSize; private Integer myMaxResultsToFetch; - private Set myPidSet; + private Set myPidSet; private boolean myHasNextIteratorQuery = false; private RequestPartitionId myRequestPartitionId; @Autowired(required = false) @@ -313,7 +313,7 @@ public class SearchBuilder implements ISearchBuilder { * @param thePidSet May be null */ @Override - public void setPreviouslyAddedResourcePids(@Nonnull List thePidSet) { + public void setPreviouslyAddedResourcePids(@Nonnull List thePidSet) { myPidSet = new HashSet<>(thePidSet); } @@ -351,7 +351,7 @@ public class SearchBuilder implements ISearchBuilder { // Ugh - we have two different return types for now ISearchQueryExecutor fulltextExecutor = null; - List fulltextMatchIds = null; + List fulltextMatchIds = null; int resultCount = 0; if (myParams.isLastN()) { fulltextMatchIds = executeLastNAgainstIndex(theMaximumResults); @@ -441,7 +441,7 @@ public class SearchBuilder implements ISearchBuilder { } } - private List executeLastNAgainstIndex(Integer theMaximumResults) { + private List executeLastNAgainstIndex(Integer theMaximumResults) { // Can we use our hibernate search generated index on resource to support lastN?: if (myDaoConfig.isAdvancedHSearchIndexing()) { if (myFulltextSearchSvc == null) { @@ -461,8 +461,8 @@ public class SearchBuilder implements ISearchBuilder { } } - private List queryHibernateSearchForEverythingPids() { - ResourcePersistentId pid = null; + private List 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); @@ -476,7 +476,7 @@ public class SearchBuilder implements ISearchBuilder { pid = myIdHelperService.resolveResourcePersistentIds(myRequestPartitionId, myResourceName, idParamValue); } - List pids = myFulltextSearchSvc.everything(myResourceName, myParams, pid); + List pids = myFulltextSearchSvc.everything(myResourceName, myParams, pid); return pids; } @@ -514,7 +514,7 @@ public class SearchBuilder implements ISearchBuilder { // fetch our target Pids // this will throw if an id is not found - Map idToPid = myIdHelperService.resolveResourcePersistentIds(myRequestPartitionId, + Map idToPid = myIdHelperService.resolveResourcePersistentIds(myRequestPartitionId, myResourceName, new ArrayList<>(ids)); if (myAlsoIncludePids == null) { @@ -522,9 +522,9 @@ 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(pid.getIdAsLong()); + theTargetPids.add(pid.getId()); } } @@ -563,7 +563,7 @@ public class SearchBuilder implements ISearchBuilder { if (myAlsoIncludePids == null) { myAlsoIncludePids = new ArrayList<>(output.size()); } - myAlsoIncludePids.addAll(ResourcePersistentId.fromLongList(output)); + myAlsoIncludePids.addAll(JpaPid.fromLongList(output)); } @@ -795,8 +795,8 @@ public class SearchBuilder implements ISearchBuilder { RuntimeSearchParam left = compositeList.get(0); RuntimeSearchParam right = compositeList.get(1); - createCompositeSort(theQueryStack, myResourceName, left.getParamType(), left.getName(), ascending); - createCompositeSort(theQueryStack, myResourceName, right.getParamType(), right.getName(), ascending); + createCompositeSort(theQueryStack, left.getParamType(), left.getName(), ascending); + createCompositeSort(theQueryStack, right.getParamType(), right.getName(), ascending); break; case SPECIAL: @@ -812,7 +812,7 @@ public class SearchBuilder implements ISearchBuilder { } - private void createCompositeSort(QueryStack theQueryStack, String theResourceName, RestSearchParameterTypeEnum theParamType, String theParamName, boolean theAscending) { + private void createCompositeSort(QueryStack theQueryStack, RestSearchParameterTypeEnum theParamType, String theParamName, boolean theAscending) { switch (theParamType) { case STRING: @@ -839,20 +839,20 @@ public class SearchBuilder implements ISearchBuilder { } - private void doLoadPids(Collection thePids, Collection theIncludedPids, List theResourceListToPopulate, boolean theForHistoryOperation, - Map thePosition) { + private void doLoadPids(Collection thePids, Collection theIncludedPids, List theResourceListToPopulate, boolean theForHistoryOperation, + Map thePosition) { Map resourcePidToVersion = null; - for (ResourcePersistentId next : thePids) { + for (JpaPid next : thePids) { if (next.getVersion() != null && myModelConfig.isRespectVersionsForSearchIncludes()) { if (resourcePidToVersion == null) { resourcePidToVersion = new HashMap<>(); } - resourcePidToVersion.put(next.getIdAsLong(), next.getVersion()); + resourcePidToVersion.put((next).getId(), next.getVersion()); } } - List versionlessPids = ResourcePersistentId.toLongList(thePids); + List versionlessPids = JpaPid.toLongList(thePids); if (versionlessPids.size() < getMaximumPageSize()) { versionlessPids = normalizeIdListForLastNInClause(versionlessPids); } @@ -870,7 +870,7 @@ public class SearchBuilder implements ISearchBuilder { Class resourceType = myContext.getResourceDefinition(next.getResourceType()).getImplementingClass(); - ResourcePersistentId resourceId = new ResourcePersistentId(next.getResourceId()); + JpaPid resourceId = JpaPid.fromId(next.getResourceId()); /* * If a specific version is requested via an include, we'll replace the current version @@ -946,16 +946,16 @@ public class SearchBuilder implements ISearchBuilder { Collection tagList = myResourceTagDao.findByResourceIds(thePidList); //-- build the map, key = resourceId, value = list of ResourceTag - ResourcePersistentId resourceId; + JpaPid resourceId; Collection tagCol; for (ResourceTag tag : tagList) { - resourceId = new ResourcePersistentId(tag.getResourceId()); - tagCol = tagMap.get(resourceId.getIdAsLong()); + resourceId = JpaPid.fromId(tag.getResourceId()); + tagCol = tagMap.get(resourceId.getId()); if (tagCol == null) { tagCol = new ArrayList<>(); tagCol.add(tag); - tagMap.put(resourceId.getIdAsLong(), tagCol); + tagMap.put(resourceId.getId(), tagCol); } else { tagCol.add(tag); } @@ -965,7 +965,7 @@ public class SearchBuilder implements ISearchBuilder { } @Override - public void loadResourcesByPid(Collection thePids, Collection theIncludedPids, List theResourceListToPopulate, boolean theForHistoryOperation, RequestDetails theDetails) { + public void loadResourcesByPid(Collection thePids, Collection theIncludedPids, List theResourceListToPopulate, boolean theForHistoryOperation, RequestDetails theDetails) { if (thePids.isEmpty()) { ourLog.debug("The include pids are empty"); // return; @@ -975,8 +975,8 @@ public class SearchBuilder implements ISearchBuilder { // when running asserts assert new HashSet<>(thePids).size() == thePids.size() : "PID list contains duplicates: " + thePids; - Map position = new HashMap<>(); - for (ResourcePersistentId next : thePids) { + Map position = new HashMap<>(); + for (JpaPid next : thePids) { position.put(next, theResourceListToPopulate.size()); theResourceListToPopulate.add(null); } @@ -994,7 +994,7 @@ public class SearchBuilder implements ISearchBuilder { } // We only chunk because some jdbc drivers can't handle long param lists. - new QueryChunker().chunk(thePids, t -> doLoadPids(t, theIncludedPids, theResourceListToPopulate, theForHistoryOperation, position)); + new QueryChunker().chunk(thePids, t -> doLoadPids(t, theIncludedPids, theResourceListToPopulate, theForHistoryOperation, position)); } /** @@ -1006,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 thePids) { + private boolean isLoadingFromElasticSearchSupported(Collection thePids) { // is storage enabled? return myDaoConfig.isStoreResourceInHSearchIndex() && myDaoConfig.isAdvancedHSearchIndexing() && @@ -1016,11 +1016,11 @@ public class SearchBuilder implements ISearchBuilder { myContext.getVersion().getVersion().isEqualOrNewerThan(FhirVersionEnum.DSTU3); } - private List loadResourcesFromElasticSearch(Collection thePids) { + private List loadResourcesFromElasticSearch(Collection 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()) { - List pidList = thePids.stream().map(ResourcePersistentId::getIdAsLong).collect(Collectors.toList()); + List pidList = thePids.stream().map(pid -> (pid).getId()).collect(Collectors.toList()); List resources = myFulltextSearchSvc.getResources(pidList); return resources; @@ -1035,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 loadIncludes(FhirContext theContext, EntityManager theEntityManager, Collection theMatches, Collection theIncludes, + public Set loadIncludes(FhirContext theContext, EntityManager theEntityManager, Collection theMatches, Collection theIncludes, boolean theReverseMode, DateRangeParam theLastUpdated, String theSearchIdOrDescription, RequestDetails theRequest, Integer theMaxCount) { if (theMatches.size() == 0) { return new HashSet<>(); @@ -1054,9 +1054,9 @@ public class SearchBuilder implements ISearchBuilder { findVersionFieldName = MY_TARGET_RESOURCE_VERSION; } - List nextRoundMatches = new ArrayList<>(theMatches); - HashSet allAdded = new HashSet<>(); - HashSet original = new HashSet<>(theMatches); + List nextRoundMatches = new ArrayList<>(theMatches); + HashSet allAdded = new HashSet<>(); + HashSet original = new HashSet<>(theMatches); ArrayList includes = new ArrayList<>(theIncludes); int roundCounts = 0; @@ -1066,7 +1066,7 @@ public class SearchBuilder implements ISearchBuilder { do { roundCounts++; - HashSet pidsToInclude = new HashSet<>(); + HashSet pidsToInclude = new HashSet<>(); for (Iterator iter = includes.iterator(); iter.hasNext(); ) { Include nextInclude = iter.next(); @@ -1112,10 +1112,10 @@ public class SearchBuilder implements ISearchBuilder { } String sql = sqlBuilder.toString(); - List> partitions = partition(nextRoundMatches, getMaximumPageSize()); - for (Collection nextPartition : partitions) { + List> partitions = partition(nextRoundMatches, getMaximumPageSize()); + for (Collection nextPartition : partitions) { TypedQuery q = theEntityManager.createQuery(sql, Object[].class); - q.setParameter("target_pids", ResourcePersistentId.toLongList(nextPartition)); + q.setParameter("target_pids", JpaPid.toLongList(nextPartition)); if (wantResourceType != null) { q.setParameter("want_resource_type", wantResourceType); } @@ -1138,8 +1138,7 @@ public class SearchBuilder implements ISearchBuilder { } if (resourceLink != null) { - ResourcePersistentId pid = new ResourcePersistentId(resourceLink, version); - pid.setResourceType(resourceType); + JpaPid pid = JpaPid.fromIdAndVersionAndResourceType(resourceLink, version, resourceType); pidsToInclude.add(pid); } } @@ -1231,11 +1230,11 @@ public class SearchBuilder implements ISearchBuilder { String sql = resourceIdBasedQuery + " UNION " + resourceUrlBasedQuery; - List> partitions = partition(nextRoundMatches, getMaximumPageSize()); - for (Collection nextPartition : partitions) { + List> partitions = partition(nextRoundMatches, getMaximumPageSize()); + for (Collection nextPartition : partitions) { Query q = theEntityManager.createNativeQuery(sql, Tuple.class); q.setParameter("src_path", nextPath); - q.setParameter("target_pids", ResourcePersistentId.toLongList(nextPartition)); + q.setParameter("target_pids", JpaPid.toLongList(nextPartition)); if (targetResourceType != null) { q.setParameter("target_resource_type", targetResourceType); } else if (haveTargetTypesDefinedByParam) { @@ -1253,7 +1252,7 @@ public class SearchBuilder implements ISearchBuilder { if (findVersionFieldName != null && result.get(RESOURCE_VERSION_ALIAS) != null) { resourceVersion = NumberUtils.createLong(String.valueOf(result.get(RESOURCE_VERSION_ALIAS))); } - pidsToInclude.add(new ResourcePersistentId(resourceId, resourceVersion)); + pidsToInclude.add(JpaPid.fromIdAndVersion(resourceId, resourceVersion)); } } } @@ -1268,7 +1267,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); } @@ -1292,7 +1291,7 @@ public class SearchBuilder implements ISearchBuilder { if (allAdded.size() > 0) { if (CompositeInterceptorBroadcaster.hasHooks(Pointcut.STORAGE_PREACCESS_RESOURCES, myInterceptorBroadcaster, theRequest)) { - List includedPidList = new ArrayList<>(allAdded); + List includedPidList = new ArrayList<>(allAdded); JpaPreResourceAccessDetails accessDetails = new JpaPreResourceAccessDetails(includedPidList, () -> this); HookParams params = new HookParams() .add(IPreResourceAccessDetails.class, accessDetails) @@ -1302,7 +1301,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); } @@ -1314,14 +1313,14 @@ public class SearchBuilder implements ISearchBuilder { return allAdded; } - private List> partition(Collection theNextRoundMatches, int theMaxLoad) { + private List> partition(Collection theNextRoundMatches, int theMaxLoad) { if (theNextRoundMatches.size() <= theMaxLoad) { return Collections.singletonList(theNextRoundMatches); } else { - List> retVal = new ArrayList<>(); - Collection current = null; - for (ResourcePersistentId next : theNextRoundMatches) { + List> retVal = new ArrayList<>(); + Collection current = null; + for (JpaPid next : theNextRoundMatches) { if (current == null) { current = new ArrayList<>(theMaxLoad); retVal.add(current); @@ -1482,14 +1481,14 @@ public class SearchBuilder implements ISearchBuilder { return myResourceName; } - public class IncludesIterator extends BaseIterator implements Iterator { + public class IncludesIterator extends BaseIterator implements Iterator { private final RequestDetails myRequest; - private final Set myCurrentPids; - private Iterator myCurrentIterator; - private ResourcePersistentId myNext; + private final Set myCurrentPids; + private Iterator myCurrentIterator; + private JpaPid myNext; - IncludesIterator(Set thePidSet, RequestDetails theRequest) { + IncludesIterator(Set thePidSet, RequestDetails theRequest) { myCurrentPids = new HashSet<>(thePidSet); myCurrentIterator = null; myRequest = theRequest; @@ -1500,7 +1499,7 @@ public class SearchBuilder implements ISearchBuilder { if (myCurrentIterator == null) { Set includes = Collections.singleton(new Include("*", true)); - Set newPids = loadIncludes(myContext, myEntityManager, myCurrentPids, includes, false, getParams().getLastUpdated(), mySearchUuid, myRequest, null); + Set newPids = loadIncludes(myContext, myEntityManager, myCurrentPids, includes, false, getParams().getLastUpdated(), mySearchUuid, myRequest, null); myCurrentIterator = newPids.iterator(); } @@ -1520,16 +1519,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 implements IResultIterator { + private final class QueryIterator extends BaseIterator implements IResultIterator { private final SearchRuntimeDetails mySearchRuntimeDetails; private final RequestDetails myRequest; @@ -1539,7 +1538,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; @@ -1591,8 +1590,8 @@ public class SearchBuilder implements ISearchBuilder { if (myNext == null) { - for (Iterator myPreResultsIterator = myAlsoIncludePids.iterator(); myPreResultsIterator.hasNext(); ) { - ResourcePersistentId next = myPreResultsIterator.next(); + for (Iterator myPreResultsIterator = myAlsoIncludePids.iterator(); myPreResultsIterator.hasNext(); ) { + JpaPid next = myPreResultsIterator.next(); if (next != null) if (myPidSet.add(next)) { myNext = next; @@ -1616,7 +1615,7 @@ public class SearchBuilder implements ISearchBuilder { } if (nextLong != null) { - ResourcePersistentId next = new ResourcePersistentId(nextLong); + JpaPid next = JpaPid.fromId(nextLong); if (myPidSet.add(next)) { myNext = next; myNonSkipCount++; @@ -1655,7 +1654,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; @@ -1740,9 +1739,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; @@ -1759,8 +1758,8 @@ public class SearchBuilder implements ISearchBuilder { } @Override - public Collection getNextResultBatch(long theBatchSize) { - Collection batch = new ArrayList<>(); + public Collection getNextResultBatch(long theBatchSize) { + Collection batch = new ArrayList<>(); while (this.hasNext() && batch.size() < theBatchSize) { batch.add(this.next()); } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/builder/SearchQueryExecutors.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/builder/SearchQueryExecutors.java index 106bbd39e06..60cb9f5f4c1 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/builder/SearchQueryExecutors.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/builder/SearchQueryExecutors.java @@ -20,7 +20,7 @@ package ca.uhn.fhir.jpa.search.builder; * #L% */ -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.jpa.model.dao.JpaPid; import org.apache.commons.lang3.Validate; import javax.annotation.Nonnull; @@ -93,18 +93,18 @@ public class SearchQueryExecutors { } } - static public ISearchQueryExecutor from(Iterator theIterator) { - return new ResourcePersistentIdQueryAdaptor(theIterator); + static public ISearchQueryExecutor from(Iterator theIterator) { + return new JpaPidQueryAdaptor(theIterator); } - static public ISearchQueryExecutor from(Iterable theIterable) { - return new ResourcePersistentIdQueryAdaptor(theIterable.iterator()); + static public ISearchQueryExecutor from(Iterable theIterable) { + return new JpaPidQueryAdaptor(theIterable.iterator()); } - static class ResourcePersistentIdQueryAdaptor implements ISearchQueryExecutor { - final Iterator myIterator; + static class JpaPidQueryAdaptor implements ISearchQueryExecutor { + final Iterator myIterator; - ResourcePersistentIdQueryAdaptor(Iterator theIterator) { + JpaPidQueryAdaptor(Iterator theIterator) { myIterator = theIterator; } @@ -119,8 +119,8 @@ public class SearchQueryExecutors { @Override public Long next() { - ResourcePersistentId next = myIterator.next(); - return next==null?null:next.getIdAsLong(); + JpaPid next = myIterator.next(); + return next == null ? null : next.getId(); } } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/builder/predicate/ResourceIdPredicateBuilder.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/builder/predicate/ResourceIdPredicateBuilder.java index dd18d2752c2..03b60c90aaf 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/builder/predicate/ResourceIdPredicateBuilder.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/builder/predicate/ResourceIdPredicateBuilder.java @@ -23,10 +23,10 @@ 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.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; @@ -49,7 +49,7 @@ public class ResourceIdPredicateBuilder extends BasePredicateBuilder { private static final Logger ourLog = LoggerFactory.getLogger(ResourceIdPredicateBuilder.class); @Autowired - private IIdHelperService myIdHelperService; + private IIdHelperService myIdHelperService; /** * Constructor @@ -62,12 +62,12 @@ public class ResourceIdPredicateBuilder extends BasePredicateBuilder { @Nullable public Condition createPredicateResourceId(@Nullable DbColumn theSourceJoinColumn, String theResourceName, List> theValues, SearchFilterParser.CompareOperation theOperation, RequestPartitionId theRequestPartitionId) { - Set allOrPids = null; + Set allOrPids = null; SearchFilterParser.CompareOperation defaultOperation = SearchFilterParser.CompareOperation.eq; boolean allIdsAreForcedIds = true; for (List nextValue : theValues) { - Set orPids = new HashSet<>(); + Set orPids = new HashSet<>(); boolean haveValue = false; for (IQueryParameterType next : nextValue) { String value = next.getValueAsQueryToken(getFhirContext()); @@ -83,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 @@ -117,7 +117,7 @@ public class ResourceIdPredicateBuilder extends BasePredicateBuilder { SearchFilterParser.CompareOperation operation = defaultIfNull(theOperation, defaultOperation); assert operation == SearchFilterParser.CompareOperation.eq || operation == SearchFilterParser.CompareOperation.ne; - List resourceIds = ResourcePersistentId.toLongList(allOrPids); + List resourceIds = JpaPid.toLongList(allOrPids); if (theSourceJoinColumn == null) { BaseJoiningPredicateBuilder queryRootTable = super.getOrCreateQueryRootTable(!allIdsAreForcedIds); Condition predicate; diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/builder/predicate/ResourceLinkPredicateBuilder.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/builder/predicate/ResourceLinkPredicateBuilder.java index 0a35138657a..eb0bf014c5b 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/builder/predicate/ResourceLinkPredicateBuilder.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/builder/predicate/ResourceLinkPredicateBuilder.java @@ -20,7 +20,6 @@ package ca.uhn.fhir.jpa.search.builder.predicate; * #L% */ -import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.context.BaseRuntimeChildDefinition; import ca.uhn.fhir.context.BaseRuntimeElementDefinition; import ca.uhn.fhir.context.ConfigurationException; @@ -28,6 +27,7 @@ import ca.uhn.fhir.context.RuntimeChildChoiceDefinition; import ca.uhn.fhir.context.RuntimeChildResourceDefinition; import ca.uhn.fhir.context.RuntimeResourceDefinition; import ca.uhn.fhir.context.RuntimeSearchParam; +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; @@ -38,15 +38,16 @@ 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.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; @@ -54,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; @@ -96,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; @@ -238,8 +235,8 @@ public class ResourceLinkPredicateBuilder inverse = true; } - List targetPids = myIdHelperService.resolveResourcePersistentIdsWithCache(theRequestPartitionId, targetIds); - List targetPidList = ResourcePersistentId.toLongList(targetPids); + List targetPids = myIdHelperService.resolveResourcePersistentIdsWithCache(theRequestPartitionId, targetIds); + List targetPidList = JpaPid.toLongList(targetPids); if (targetPidList.isEmpty() && targetQualifiedUrls.isEmpty()) { setMatchNothing(); diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/builder/sql/SearchQueryBuilder.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/builder/sql/SearchQueryBuilder.java index 1eb281a0943..7aed33e0631 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/builder/sql/SearchQueryBuilder.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/builder/sql/SearchQueryBuilder.java @@ -25,6 +25,7 @@ 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.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; @@ -45,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; @@ -680,14 +680,14 @@ public class SearchQueryBuilder { addPredicate(predicate); } - public void excludeResourceIdsPredicate(Set theExsitinghPidSetToExclude) { + public void excludeResourceIdsPredicate(Set theExistingPidSetToExclude) { // Do nothing if it's empty - if (theExsitinghPidSetToExclude == null || theExsitinghPidSetToExclude.isEmpty()) + if (theExistingPidSetToExclude == null || theExistingPidSetToExclude.isEmpty()) return; - - List excludePids = ResourcePersistentId.toLongList(theExsitinghPidSetToExclude); - + + List excludePids = JpaPid.toLongList(theExistingPidSetToExclude); + ourLog.trace("excludePids = " + excludePids); DbColumn resourceIdColumn = getOrCreateFirstPredicateBuilder().getResourceIdColumn(); diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/builder/tasks/SearchContinuationTask.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/builder/tasks/SearchContinuationTask.java index 335a54d8133..7fb999de3f6 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/builder/tasks/SearchContinuationTask.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/builder/tasks/SearchContinuationTask.java @@ -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 previouslyAddedResourcePids = mySearchResultCacheSvc.fetchAllResultPids(getSearch()); + List previouslyAddedResourcePids = mySearchResultCacheSvc.fetchAllResultPids(getSearch()); if (previouslyAddedResourcePids == null) { throw myExceptionSvc.newUnknownSearchException(getSearch().getUuid()); } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/builder/tasks/SearchTask.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/builder/tasks/SearchTask.java index e2770343ae7..fee4f2ea1a5 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/builder/tasks/SearchTask.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/builder/tasks/SearchTask.java @@ -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 { private final SearchParameterMap myParams; private final IDao myCallingDao; private final String myResourceType; - private final ArrayList mySyncedPids = new ArrayList<>(); + private final ArrayList mySyncedPids = new ArrayList<>(); private final CountDownLatch myInitialCollectionLatch = new CountDownLatch(1); private final CountDownLatch myCompletionLatch; - private final ArrayList myUnsyncedPids = new ArrayList<>(); + private final ArrayList myUnsyncedPids = new ArrayList<>(); private final RequestDetails myRequest; private final RequestPartitionId myRequestPartitionId; private final SearchRuntimeDetails mySearchRuntimeDetails; @@ -116,7 +115,7 @@ public class SearchTask implements Callable { private int myCountSavedThisPass = 0; private int myCountBlockedThisPass = 0; private boolean myAdditionalPrefetchThresholdsRemaining; - private List myPreviouslyAddedResourcePids; + private List myPreviouslyAddedResourcePids; private Integer myMaxResultsToFetch; private final Consumer myOnRemove; @@ -130,7 +129,7 @@ public class SearchTask implements Callable { protected final PlatformTransactionManager myManagedTxManager; protected final FhirContext myContext; private final IInterceptorBroadcaster myInterceptorBroadcaster; - private final SearchBuilderFactory mySearchBuilderFactory; + private final SearchBuilderFactory mySearchBuilderFactory; protected final ISearchResultCacheSvc mySearchResultCacheSvc; private final DaoConfig myDaoConfig; private final ISearchCacheSvc mySearchCacheSvc; @@ -143,7 +142,6 @@ public class SearchTask implements Callable { SearchTaskParameters theCreationParams, PlatformTransactionManager theManagedTxManager, FhirContext theContext, - SearchStrategyFactory theSearchStrategyFactory, IInterceptorBroadcaster theInterceptorBroadcaster, SearchBuilderFactory theSearchBuilderFactory, ISearchResultCacheSvc theSearchResultCacheSvc, @@ -215,7 +213,7 @@ public class SearchTask implements Callable { return myInitialCollectionLatch; } - public void setPreviouslyAddedResourcePids(List thePreviouslyAddedResourcePids) { + public void setPreviouslyAddedResourcePids(List thePreviouslyAddedResourcePids) { myPreviouslyAddedResourcePids = thePreviouslyAddedResourcePids; myCountSavedTotal = myPreviouslyAddedResourcePids.size(); } @@ -226,7 +224,7 @@ public class SearchTask implements Callable { } @Nonnull - public List getResourcePids(int theFromIndex, int theToIndex) { + public List getResourcePids(int theFromIndex, int theToIndex) { ourLog.debug("Requesting search PIDs from {}-{}", theFromIndex, theToIndex); boolean keepWaiting; @@ -268,7 +266,7 @@ public class SearchTask implements Callable { ourLog.debug("Proceeding, as we have {} results", mySyncedPids.size()); - ArrayList retVal = new ArrayList<>(); + ArrayList retVal = new ArrayList<>(); synchronized (mySyncedPids) { QueryParameterUtils.verifySearchHasntFailedOrThrowInternalErrorException(mySearch); @@ -308,7 +306,7 @@ public class SearchTask implements Callable { doSaveSearch(); } - ArrayList unsyncedPids = myUnsyncedPids; + ArrayList unsyncedPids = myUnsyncedPids; int countBlocked = 0; // Interceptor call: STORAGE_PREACCESS_RESOURCES @@ -634,7 +632,7 @@ public class SearchTask implements Callable { * 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 resultIterator = sb.createQuery(myParams, mySearchRuntimeDetails, myRequest, myRequestPartitionId)) { assert (resultIterator != null); /* diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/cache/DatabaseSearchResultCacheSvcImpl.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/cache/DatabaseSearchResultCacheSvcImpl.java index dd2002d913d..5ae7f595d00 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/cache/DatabaseSearchResultCacheSvcImpl.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/cache/DatabaseSearchResultCacheSvcImpl.java @@ -20,18 +20,18 @@ package ca.uhn.fhir.jpa.search.cache; * #L% */ -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; 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.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; @@ -45,7 +45,7 @@ public class DatabaseSearchResultCacheSvcImpl implements ISearchResultCacheSvc { @Override @Transactional(propagation = Propagation.REQUIRED) - public List fetchResultPids(Search theSearch, int theFrom, int theTo) { + public List fetchResultPids(Search theSearch, int theFrom, int theTo) { final Pageable page = toPage(theFrom, theTo); if (page == null) { return Collections.emptyList(); @@ -57,28 +57,28 @@ public class DatabaseSearchResultCacheSvcImpl implements ISearchResultCacheSvc { ourLog.debug("fetchResultPids for range {}-{} returned {} pids", theFrom, theTo, retVal.size()); - return ResourcePersistentId.fromLongList(retVal); + return JpaPid.fromLongList(retVal); } @Override @Transactional(propagation = Propagation.REQUIRED) - public List fetchAllResultPids(Search theSearch) { + public List fetchAllResultPids(Search theSearch) { List retVal = mySearchResultDao.findWithSearchPidOrderIndependent(theSearch.getId()); ourLog.trace("fetchAllResultPids returned {} pids", retVal.size()); - return ResourcePersistentId.fromLongList(retVal); + return JpaPid.fromLongList(retVal); } @Override @Transactional(propagation = Propagation.REQUIRED) - public void storeResults(Search theSearch, List thePreviouslyStoredResourcePids, List theNewResourcePids) { + public void storeResults(Search theSearch, List thePreviouslyStoredResourcePids, List theNewResourcePids) { List 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(nextPid.getIdAsLong()); + nextResult.setResourcePid(nextPid.getId()); nextResult.setOrder(order); resultsToSave.add(nextResult); ourLog.trace("Saving ORDER[{}] Resource {}", order, nextResult.getResourcePid()); diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/cache/ISearchResultCacheSvc.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/cache/ISearchResultCacheSvc.java index 5397e9ad914..a2c780c7412 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/cache/ISearchResultCacheSvc.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/cache/ISearchResultCacheSvc.java @@ -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 thePreviouslyStoredResourcePids, List theNewResourcePids); + void storeResults(Search theSearch, List thePreviouslyStoredResourcePids, List 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 fetchResultPids(Search theSearch, int theFrom, int theTo); + List 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 fetchAllResultPids(Search theSearch); + List fetchAllResultPids(Search theSearch); } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/lastn/ElasticsearchSvcImpl.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/lastn/ElasticsearchSvcImpl.java index 60d7dc0b26c..ce067af7fc7 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/lastn/ElasticsearchSvcImpl.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/lastn/ElasticsearchSvcImpl.java @@ -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; @@ -32,7 +32,7 @@ import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; import ca.uhn.fhir.jpa.searchparam.util.LastNParameterHelper; import ca.uhn.fhir.model.api.IQueryParameterType; import ca.uhn.fhir.parser.IParser; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import ca.uhn.fhir.rest.param.DateParam; import ca.uhn.fhir.rest.param.ParamPrefixEnum; import ca.uhn.fhir.rest.param.ReferenceParam; @@ -752,7 +752,7 @@ public class ElasticsearchSvcImpl implements IElasticsearchSvc { } @Override - public List getObservationResources(Collection thePids) { + public List getObservationResources(Collection thePids) { SearchRequest searchRequest = buildObservationResourceSearchRequest(thePids); try { SearchResponse observationDocumentResponse = executeSearchRequest(searchRequest); @@ -780,7 +780,7 @@ public class ElasticsearchSvcImpl implements IElasticsearchSvc { } } - private SearchRequest buildObservationResourceSearchRequest(Collection thePids) { + private SearchRequest buildObservationResourceSearchRequest(Collection thePids) { SearchRequest searchRequest = new SearchRequest(OBSERVATION_INDEX); SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); // Query diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/lastn/IElasticsearchSvc.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/lastn/IElasticsearchSvc.java index c95d3d1465a..6afdda1780b 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/lastn/IElasticsearchSvc.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/lastn/IElasticsearchSvc.java @@ -24,7 +24,7 @@ import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.jpa.search.lastn.json.CodeJson; import ca.uhn.fhir.jpa.search.lastn.json.ObservationJson; import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import org.hl7.fhir.instance.model.api.IBaseResource; import java.io.IOException; @@ -96,6 +96,6 @@ public interface IElasticsearchSvc { * @param thePids * @return Resources list or empty if nothing found */ - List getObservationResources(Collection thePids); + List getObservationResources(Collection thePids); } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/reindex/ResourceReindexer.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/reindex/ResourceReindexer.java index ad40a90fd75..34cf090d828 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/reindex/ResourceReindexer.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/reindex/ResourceReindexer.java @@ -20,18 +20,18 @@ package ca.uhn.fhir.jpa.search.reindex; * #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.jpa.api.dao.DaoRegistry; import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao; import ca.uhn.fhir.jpa.dao.IFulltextSearchSvc; import ca.uhn.fhir.jpa.dao.data.IForcedIdDao; import ca.uhn.fhir.jpa.dao.data.IResourceHistoryTableDao; import ca.uhn.fhir.jpa.dao.data.IResourceTableDao; +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.rest.api.server.storage.ResourcePersistentId; import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; import org.hl7.fhir.instance.model.api.IBaseResource; import org.slf4j.Logger; @@ -84,7 +84,7 @@ public class ResourceReindexer { IFhirResourceDao dao = myDaoRegistry.getResourceDao(theResourceTable.getResourceType()); long expectedVersion = theResourceTable.getVersion(); - IBaseResource resource = dao.readByPid(new ResourcePersistentId(theResourceTable.getId()), true); + IBaseResource resource = dao.readByPid(JpaPid.fromId(theResourceTable.getId()), true); if (resource == null) { throw new InternalErrorException(Msg.code(1171) + "Could not find resource version " + theResourceTable.getIdDt().toUnqualified().getValue() + " in database"); diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TermCodeSystemStorageSvcImpl.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TermCodeSystemStorageSvcImpl.java index 7675b39a562..1a2b87aad31 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TermCodeSystemStorageSvcImpl.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TermCodeSystemStorageSvcImpl.java @@ -40,6 +40,7 @@ import ca.uhn.fhir.jpa.entity.TermConcept; import ca.uhn.fhir.jpa.entity.TermConceptDesignation; import ca.uhn.fhir.jpa.entity.TermConceptParentChildLink; import ca.uhn.fhir.jpa.entity.TermConceptProperty; +import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.jpa.model.entity.ResourceTable; import ca.uhn.fhir.jpa.term.api.ITermCodeSystemStorageSvc; import ca.uhn.fhir.jpa.term.api.ITermDeferredStorageSvc; @@ -48,7 +49,7 @@ import ca.uhn.fhir.jpa.term.api.ITermVersionAdapterSvc; import ca.uhn.fhir.jpa.term.custom.CustomTerminologySet; import ca.uhn.fhir.rest.api.Constants; 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.IResourcePersistentId; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException; import ca.uhn.fhir.util.ObjectUtil; @@ -107,7 +108,7 @@ public class TermCodeSystemStorageSvcImpl implements ITermCodeSystemStorageSvc { @Autowired protected ITermConceptDesignationDao myConceptDesignationDao; @Autowired - protected IIdHelperService myIdHelperService; + protected IIdHelperService myIdHelperService; @Autowired private ITermConceptParentChildLinkDao myConceptParentChildLinkDao; @Autowired @@ -278,7 +279,7 @@ public class TermCodeSystemStorageSvcImpl implements ITermCodeSystemStorageSvc { Long pid = (Long)theCodeSystem.getUserData(RESOURCE_PID_KEY); assert pid != null; - ResourcePersistentId codeSystemResourcePid = new ResourcePersistentId(pid); + JpaPid codeSystemResourcePid = JpaPid.fromId(pid); /* * If this is a not-present codesystem and codesystem version already exists, we don't want to @@ -321,8 +322,8 @@ public class TermCodeSystemStorageSvcImpl implements ITermCodeSystemStorageSvc { // Note that this creates the TermCodeSystem and TermCodeSystemVersion entities if needed IIdType csId = myTerminologyVersionAdapterSvc.createOrUpdateCodeSystem(theCodeSystemResource, theRequest); - ResourcePersistentId codeSystemResourcePid = myIdHelperService.resolveResourcePersistentIds(RequestPartitionId.allPartitions(), csId.getResourceType(), csId.getIdPart()); - ResourceTable resource = myResourceTableDao.getOne(codeSystemResourcePid.getIdAsLong()); + JpaPid codeSystemResourcePid = myIdHelperService.resolveResourcePersistentIds(RequestPartitionId.allPartitions(), csId.getResourceType(), csId.getIdPart()); + ResourceTable resource = myResourceTableDao.getOne(codeSystemResourcePid.getId()); ourLog.info("CodeSystem resource has ID: {}", csId.getValue()); @@ -339,7 +340,7 @@ public class TermCodeSystemStorageSvcImpl implements ITermCodeSystemStorageSvc { @Override @Transactional - public void storeNewCodeSystemVersion(ResourcePersistentId theCodeSystemResourcePid, String theSystemUri, + public void storeNewCodeSystemVersion(IResourcePersistentId theCodeSystemResourcePid, String theSystemUri, String theSystemName, String theCodeSystemVersionId, TermCodeSystemVersion theCodeSystemVersion, ResourceTable theCodeSystemResourceTable, RequestDetails theRequestDetails) { assert TransactionSynchronizationManager.isActualTransactionActive(); @@ -352,7 +353,7 @@ public class TermCodeSystemStorageSvcImpl implements ITermCodeSystemStorageSvc { TermCodeSystem codeSystem = getOrCreateDistinctTermCodeSystem(theCodeSystemResourcePid, theSystemUri, theSystemName, theCodeSystemVersionId, theCodeSystemResourceTable); - List existing = myCodeSystemVersionDao.findByCodeSystemResourcePid(theCodeSystemResourcePid.getIdAsLong()); + List existing = myCodeSystemVersionDao.findByCodeSystemResourcePid(((JpaPid)theCodeSystemResourcePid).getId()); for (TermCodeSystemVersion next : existing) { if (Objects.equals(next.getCodeSystemVersionId(), theCodeSystemVersionId) && myConceptDao.countByCodeSystemVersion(next.getPid()) == 0) { @@ -629,10 +630,10 @@ public class TermCodeSystemStorageSvcImpl implements ITermCodeSystemStorageSvc { } @Nonnull - private TermCodeSystem getOrCreateDistinctTermCodeSystem(ResourcePersistentId theCodeSystemResourcePid, String theSystemUri, String theSystemName, String theSystemVersionId, ResourceTable theCodeSystemResourceTable) { + private TermCodeSystem getOrCreateDistinctTermCodeSystem(IResourcePersistentId theCodeSystemResourcePid, String theSystemUri, String theSystemName, String theSystemVersionId, ResourceTable theCodeSystemResourceTable) { TermCodeSystem codeSystem = myCodeSystemDao.findByCodeSystemUri(theSystemUri); if (codeSystem == null) { - codeSystem = myCodeSystemDao.findByResourcePid(theCodeSystemResourcePid.getIdAsLong()); + codeSystem = myCodeSystemDao.findByResourcePid(((JpaPid)theCodeSystemResourcePid).getId()); if (codeSystem == null) { codeSystem = new TermCodeSystem(); } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TermConceptMappingSvcImpl.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TermConceptMappingSvcImpl.java index bd1f42e37f2..90c2267ee89 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TermConceptMappingSvcImpl.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TermConceptMappingSvcImpl.java @@ -36,11 +36,11 @@ import ca.uhn.fhir.jpa.entity.TermConceptMap; import ca.uhn.fhir.jpa.entity.TermConceptMapGroup; import ca.uhn.fhir.jpa.entity.TermConceptMapGroupElement; import ca.uhn.fhir.jpa.entity.TermConceptMapGroupElementTarget; +import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.jpa.model.entity.ResourceTable; import ca.uhn.fhir.jpa.term.api.ITermConceptMappingSvc; import ca.uhn.fhir.jpa.util.MemoryCacheService; import ca.uhn.fhir.jpa.util.ScrollableResultsIterator; -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.exceptions.UnprocessableEntityException; @@ -107,7 +107,7 @@ public class TermConceptMappingSvcImpl implements ITermConceptMappingSvc { @Autowired private MemoryCacheService myMemoryCacheService; @Autowired - private IIdHelperService myIdHelperService; + private IIdHelperService myIdHelperService; @Override @Transactional @@ -362,8 +362,8 @@ public class TermConceptMappingSvcImpl implements ITermConceptMappingSvc { if (translationQuery.hasResourceId()) { IIdType resourceId = translationQuery.getResourceId(); - ResourcePersistentId resourcePid = myIdHelperService.getPidOrThrowException(RequestPartitionId.defaultPartition(), resourceId); - predicates.add(criteriaBuilder.equal(conceptMapJoin.get("myResourcePid"), resourcePid.getIdAsLong())); + JpaPid resourcePid = myIdHelperService.getPidOrThrowException(RequestPartitionId.defaultPartition(), resourceId); + predicates.add(criteriaBuilder.equal(conceptMapJoin.get("myResourcePid"), resourcePid.getId())); } Predicate outerPredicate = criteriaBuilder.and(predicates.toArray(new Predicate[0])); @@ -491,8 +491,8 @@ public class TermConceptMappingSvcImpl implements ITermConceptMappingSvc { if (translationQuery.hasResourceId()) { IIdType resourceId = translationQuery.getResourceId(); - ResourcePersistentId resourcePid = myIdHelperService.getPidOrThrowException(RequestPartitionId.defaultPartition(), resourceId); - predicates.add(criteriaBuilder.equal(conceptMapJoin.get("myResourcePid"), resourcePid.getIdAsLong())); + JpaPid resourcePid = myIdHelperService.getPidOrThrowException(RequestPartitionId.defaultPartition(), resourceId); + predicates.add(criteriaBuilder.equal(conceptMapJoin.get("myResourcePid"), resourcePid.getId())); } Predicate outerPredicate = criteriaBuilder.and(predicates.toArray(new Predicate[0])); diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TermReadSvcImpl.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TermReadSvcImpl.java index e5d2ed42eb3..89e9a13969b 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TermReadSvcImpl.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TermReadSvcImpl.java @@ -39,8 +39,6 @@ import ca.uhn.fhir.jpa.config.util.ConnectionPoolInfoProvider; import ca.uhn.fhir.jpa.config.util.IConnectionPoolInfoProvider; import ca.uhn.fhir.jpa.dao.IFulltextSearchSvc; import ca.uhn.fhir.jpa.dao.IJpaStorageResourceParser; -import ca.uhn.fhir.jpa.dao.IStorageResourceParser; -import ca.uhn.fhir.jpa.dao.JpaStorageResourceParser; import ca.uhn.fhir.jpa.dao.data.ITermCodeSystemDao; import ca.uhn.fhir.jpa.dao.data.ITermCodeSystemVersionDao; import ca.uhn.fhir.jpa.dao.data.ITermConceptDao; @@ -63,6 +61,7 @@ import ca.uhn.fhir.jpa.entity.TermConceptPropertyTypeEnum; import ca.uhn.fhir.jpa.entity.TermValueSet; import ca.uhn.fhir.jpa.entity.TermValueSetConcept; import ca.uhn.fhir.jpa.entity.TermValueSetPreExpansionStatusEnum; +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.model.sched.HapiJob; @@ -76,7 +75,6 @@ import ca.uhn.fhir.jpa.term.api.ReindexTerminologyResult; import ca.uhn.fhir.jpa.term.ex.ExpansionTooCostlyException; import ca.uhn.fhir.rest.api.Constants; 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.exceptions.ResourceNotFoundException; @@ -255,7 +253,7 @@ public class TermReadSvcImpl implements ITermReadSvc { @Autowired(required = false) private ITermDeferredStorageSvc myDeferredStorageSvc; @Autowired - private IIdHelperService myIdHelperService; + private IIdHelperService myIdHelperService; @Autowired private ApplicationContext myApplicationContext; private volatile IValidationSupport myJpaValidationSupport; @@ -1606,11 +1604,11 @@ public class TermReadSvcImpl implements ITermReadSvc { } private Optional fetchValueSetEntity(ValueSet theValueSet) { - ResourcePersistentId valueSetResourcePid = getValueSetResourcePersistentId(theValueSet); - return myTermValueSetDao.findByResourcePid(valueSetResourcePid.getIdAsLong()); + JpaPid valueSetResourcePid = getValueSetResourcePersistentId(theValueSet); + return myTermValueSetDao.findByResourcePid(valueSetResourcePid.getId()); } - private ResourcePersistentId getValueSetResourcePersistentId(ValueSet theValueSet) { + private JpaPid getValueSetResourcePersistentId(ValueSet theValueSet) { return myIdHelperService.resolveResourcePersistentIds(RequestPartitionId.allPartitions(), theValueSet.getIdElement().getResourceType(), theValueSet.getIdElement().getIdPart()); } @@ -1620,13 +1618,13 @@ public class TermReadSvcImpl implements ITermReadSvc { assert TransactionSynchronizationManager.isSynchronizationActive(); ValidateUtil.isNotNullOrThrowUnprocessableEntity(theValueSet.hasId(), "ValueSet.id is required"); - ResourcePersistentId valueSetResourcePid = getValueSetResourcePersistentId(theValueSet); + JpaPid valueSetResourcePid = getValueSetResourcePersistentId(theValueSet); List concepts = new ArrayList<>(); if (isNotBlank(theCode)) { if (theValidationOptions.isInferSystem()) { - concepts.addAll(myValueSetConceptDao.findByValueSetResourcePidAndCode(valueSetResourcePid.getIdAsLong(), theCode)); + concepts.addAll(myValueSetConceptDao.findByValueSetResourcePidAndCode(valueSetResourcePid.getId(), theCode)); } else if (isNotBlank(theSystem)) { concepts.addAll(findByValueSetResourcePidSystemAndCode(valueSetResourcePid, theSystem, theCode)); } @@ -1647,7 +1645,7 @@ public class TermReadSvcImpl implements ITermReadSvc { return null; } - TermValueSet valueSetEntity = myTermValueSetDao.findByResourcePid(valueSetResourcePid.getIdAsLong()).orElseThrow(IllegalStateException::new); + TermValueSet valueSetEntity = myTermValueSetDao.findByResourcePid(valueSetResourcePid.getId()).orElseThrow(IllegalStateException::new); String timingDescription = toHumanReadableExpansionTimestamp(valueSetEntity); String msg = myContext.getLocalizer().getMessage(TermReadSvcImpl.class, "validationPerformedAgainstPreExpansion", timingDescription); @@ -1696,7 +1694,7 @@ public class TermReadSvcImpl implements ITermReadSvc { .setMessage("Unable to validate code " + theSystem + "#" + theCode + theAppend); } - private List findByValueSetResourcePidSystemAndCode(ResourcePersistentId theResourcePid, String theSystem, String theCode) { + private List findByValueSetResourcePidSystemAndCode(JpaPid theResourcePid, String theSystem, String theCode) { assert TransactionSynchronizationManager.isSynchronizationActive(); List retVal = new ArrayList<>(); @@ -1705,9 +1703,11 @@ public class TermReadSvcImpl implements ITermReadSvc { if (versionIndex >= 0) { String systemUrl = theSystem.substring(0, versionIndex); String systemVersion = theSystem.substring(versionIndex + 1); - optionalTermValueSetConcept = myValueSetConceptDao.findByValueSetResourcePidSystemAndCodeWithVersion(theResourcePid.getIdAsLong(), systemUrl, systemVersion, theCode); + optionalTermValueSetConcept = myValueSetConceptDao.findByValueSetResourcePidSystemAndCodeWithVersion( + theResourcePid.getId(), systemUrl, systemVersion, theCode); } else { - optionalTermValueSetConcept = myValueSetConceptDao.findByValueSetResourcePidSystemAndCode(theResourcePid.getIdAsLong(), theSystem, theCode); + optionalTermValueSetConcept = myValueSetConceptDao.findByValueSetResourcePidSystemAndCode( + theResourcePid.getId(), theSystem, theCode); } optionalTermValueSetConcept.ifPresent(retVal::add); return retVal; diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/api/ITermCodeSystemStorageSvc.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/api/ITermCodeSystemStorageSvc.java index 0e08ff6c1dd..355b4aaad95 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/api/ITermCodeSystemStorageSvc.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/api/ITermCodeSystemStorageSvc.java @@ -26,12 +26,12 @@ import ca.uhn.fhir.jpa.model.entity.ResourceTable; import ca.uhn.fhir.jpa.term.UploadStatistics; import ca.uhn.fhir.jpa.term.custom.CustomTerminologySet; 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.IResourcePersistentId; import org.hl7.fhir.instance.model.api.IIdType; import org.hl7.fhir.r4.model.CodeSystem; import org.hl7.fhir.r4.model.ValueSet; - import org.springframework.transaction.annotation.Transactional; + import java.util.List; /** @@ -50,16 +50,16 @@ public interface ITermCodeSystemStorageSvc { (boolean) theRequestDetails.getUserData().getOrDefault(MAKE_LOADING_VERSION_CURRENT, Boolean.TRUE); } - void storeNewCodeSystemVersion(ResourcePersistentId theCodeSystemResourcePid, String theSystemUri, String theSystemName, - String theSystemVersionId, TermCodeSystemVersion theCodeSystemVersion, ResourceTable theCodeSystemResourceTable, - RequestDetails theRequestDetails); + void storeNewCodeSystemVersion(IResourcePersistentId theCodeSystemResourcePid, String theSystemUri, String theSystemName, + String theSystemVersionId, TermCodeSystemVersion theCodeSystemVersion, ResourceTable theCodeSystemResourceTable, + RequestDetails theRequestDetails); /** * Default implementation supports previous signature of method which was added RequestDetails parameter */ @Transactional - default void storeNewCodeSystemVersion(ResourcePersistentId theCodeSystemResourcePid, String theSystemUri, String theSystemName, - String theSystemVersionId, TermCodeSystemVersion theCodeSystemVersion, ResourceTable theCodeSystemResourceTable) { + default void storeNewCodeSystemVersion(IResourcePersistentId theCodeSystemResourcePid, String theSystemUri, String theSystemName, + String theSystemVersionId, TermCodeSystemVersion theCodeSystemVersion, ResourceTable theCodeSystemResourceTable) { storeNewCodeSystemVersion(theCodeSystemResourcePid, theSystemUri, theSystemName, theSystemVersionId, theCodeSystemVersion, theCodeSystemResourceTable, null); diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/util/QueryParameterUtils.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/util/QueryParameterUtils.java index ee3b2bd3419..6038ae6a0d1 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/util/QueryParameterUtils.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/util/QueryParameterUtils.java @@ -25,12 +25,12 @@ import ca.uhn.fhir.jpa.dao.predicate.SearchFilterParser; import ca.uhn.fhir.jpa.entity.Search; import ca.uhn.fhir.jpa.entity.SearchInclude; import ca.uhn.fhir.jpa.entity.SearchTypeEnum; +import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.jpa.model.entity.ResourceTable; 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; @@ -194,7 +194,7 @@ public class QueryParameterUtils { return lastUpdatedPredicates; } - public static List filterResourceIdsByLastUpdated(EntityManager theEntityManager, final DateRangeParam theLastUpdated, Collection thePids) { + public static List filterResourceIdsByLastUpdated(EntityManager theEntityManager, final DateRangeParam theLastUpdated, Collection thePids) { if (thePids.isEmpty()) { return Collections.emptyList(); } @@ -204,12 +204,13 @@ public class QueryParameterUtils { cq.select(from.get("myId").as(Long.class)); List lastUpdatedPredicates = createLastUpdatedPredicates(theLastUpdated, builder, from); - lastUpdatedPredicates.add(from.get("myId").as(Long.class).in(ResourcePersistentId.toLongList(thePids))); + List longIds = thePids.stream().map(JpaPid::getId).collect(Collectors.toList()); + lastUpdatedPredicates.add(from.get("myId").as(Long.class).in(longIds)); cq.where(toPredicateArray(lastUpdatedPredicates)); TypedQuery query = theEntityManager.createQuery(cq); - return ResourcePersistentId.fromLongList(query.getResultList()); + return query.getResultList().stream().map(JpaPid::fromId).collect(Collectors.toList()); } public static void verifySearchHasntFailedOrThrowInternalErrorException(Search theSearch) { diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/bulk/export/svc/JpaBulkExportProcessorTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/bulk/export/svc/JpaBulkExportProcessorTest.java index 730a4422f84..04b9233bf52 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/bulk/export/svc/JpaBulkExportProcessorTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/bulk/export/svc/JpaBulkExportProcessorTest.java @@ -13,6 +13,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; @@ -21,10 +22,8 @@ import ca.uhn.fhir.mdm.dao.IMdmLinkDao; 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 ca.uhn.fhir.rest.api.server.storage.BaseResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import org.hl7.fhir.instance.model.api.IIdType; import org.hl7.fhir.instance.model.api.IPrimitiveType; import org.hl7.fhir.r4.model.Group; @@ -34,7 +33,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; @@ -52,7 +50,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; @@ -60,9 +57,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; @@ -72,11 +67,11 @@ public class JpaBulkExportProcessorTest { private class ListResultIterator implements IResultIterator { - private List myList; + private List myList; private int index; - public ListResultIterator(List theList) { + public ListResultIterator(List theList) { myList = theList; } @@ -91,7 +86,7 @@ public class JpaBulkExportProcessorTest { } @Override - public Collection getNextResultBatch(long theBatchSize) { + public Collection getNextResultBatch(long theBatchSize) { return null; } @@ -106,7 +101,7 @@ public class JpaBulkExportProcessorTest { } @Override - public ResourcePersistentId next() { + public IResourcePersistentId next() { return myList.get(index++); } } @@ -163,17 +158,7 @@ public class JpaBulkExportProcessorTest { } private MdmPidTuple createTuple(long theGroupId, long theGoldenId) { - return new MdmPidTuple() { - @Override - public ResourcePersistentId getGoldenPid() { - return new ResourcePersistentId(theGoldenId); - } - - @Override - public ResourcePersistentId getSourcePid() { - return new ResourcePersistentId(theGroupId); - } - }; + return MdmPidTuple.fromGoldenAndSource(JpaPid.fromId(theGoldenId), JpaPid.fromId(theGroupId)); } @Test @@ -186,8 +171,8 @@ public class JpaBulkExportProcessorTest { List maps = new ArrayList<>(); maps.add(map); - ResourcePersistentId pid = new ResourcePersistentId("Patient/123"); - ResourcePersistentId pid2 = new ResourcePersistentId("Observation/123"); + JpaPid pid = JpaPid.fromId(123L); + JpaPid pid2 = JpaPid.fromId(456L); ListResultIterator resultIterator = new ListResultIterator( Arrays.asList(pid, pid2) ); @@ -215,7 +200,7 @@ public class JpaBulkExportProcessorTest { .thenReturn(resultIterator); // test - Iterator pidIterator = myProcessor.getResourcePidIterator(parameters); + Iterator pidIterator = myProcessor.getResourcePidIterator(parameters); // verify assertNotNull(pidIterator); @@ -252,19 +237,19 @@ public class JpaBulkExportProcessorTest { ExportPIDIteratorParameters parameters = createExportParameters(BulkDataExportOptions.ExportStyle.GROUP); parameters.setResourceType("Patient"); - ResourcePersistentId groupId = new ResourcePersistentId(Long.parseLong(parameters.getGroupId())); + JpaPid groupId = JpaPid.fromId(Long.parseLong(parameters.getGroupId())); long groupGoldenPid = 4567l; Group groupResource = new Group(); groupResource.setId(parameters.getGroupId()); List patientTypes = createPatientTypes(); - List pids = new ArrayList<>(); + List pids = new ArrayList<>(); for (IPrimitiveType type : patientTypes) { - pids.add(new ResourcePersistentId(((IdDt) type).getIdPartAsLong())); + pids.add(JpaPid.fromId(((IdDt) type).getIdPartAsLong())); } - MdmPidTuple tuple = createTuple(groupId.getIdAsLong(), groupGoldenPid); + MdmPidTuple tuple = createTuple(groupId.getId(), groupGoldenPid); IFhirResourceDao groupDao = mock(IFhirResourceDao.class); parameters.setExpandMdm(theMdm); // set mdm expansion @@ -297,32 +282,32 @@ public class JpaBulkExportProcessorTest { .thenReturn(groupResource); when(myIdHelperService.translatePidsToForcedIds(any(Set.class))) .thenAnswer(params -> { - Set uniqPids = params.getArgument(0); - HashMap> answer = new HashMap<>(); - for (ResourcePersistentId l : uniqPids) { + Set uniqPids = params.getArgument(0); + HashMap> answer = new HashMap<>(); + for (IResourcePersistentId l : uniqPids) { answer.put(l, Optional.empty()); } return new PersistentIdToForcedIdMap(answer); }); when(myIdHelperService.getPidOrNull(any(), any(Group.class))) .thenReturn(groupId); - when(myMdmLinkDao.expandPidsFromGroupPidGivenMatchResult(any(ResourcePersistentId.class), eq(MdmMatchResultEnum.MATCH))) + when(myMdmLinkDao.expandPidsFromGroupPidGivenMatchResult(any(BaseResourcePersistentId.class), eq(MdmMatchResultEnum.MATCH))) .thenReturn(Collections.singletonList(tuple)); when(myMdmExpansionCacheSvc.hasBeenPopulated()) .thenReturn(false); // does not matter, since if false, it then goes and populates } // test - Iterator pidIterator = myProcessor.getResourcePidIterator(parameters); + Iterator pidIterator = myProcessor.getResourcePidIterator(parameters); // verify assertNotNull(pidIterator); int count = 0; assertTrue(pidIterator.hasNext()); while (pidIterator.hasNext()) { - ResourcePersistentId pid = pidIterator.next(); - long idAsLong = pid.getIdAsLong(); - boolean existing = pids.contains(new ResourcePersistentId(idAsLong)); + JpaPid pid = pidIterator.next(); + long idAsLong = pid.getId(); + boolean existing = pids.contains(JpaPid.fromId(idAsLong)); if (!existing) { assertTrue(theMdm); assertEquals(groupGoldenPid, idAsLong); @@ -341,18 +326,18 @@ public class JpaBulkExportProcessorTest { ExportPIDIteratorParameters parameters = createExportParameters(BulkDataExportOptions.ExportStyle.GROUP); parameters.setResourceType("Observation"); - ResourcePersistentId groupId = new ResourcePersistentId(Long.parseLong(parameters.getGroupId())); + JpaPid groupId = JpaPid.fromId(Long.parseLong(parameters.getGroupId())); Group groupResource = new Group(); groupResource.setId(parameters.getGroupId()); long groupGoldenPid = 4567l; - ResourcePersistentId pid = new ResourcePersistentId("Patient/123"); - ResourcePersistentId pid2 = new ResourcePersistentId("Observation/123"); + JpaPid pid = JpaPid.fromId(123L); + JpaPid pid2 = JpaPid.fromId(456L); ListResultIterator resultIterator = new ListResultIterator( Arrays.asList(pid, pid2) ); - MdmPidTuple tuple = createTuple(groupId.getIdAsLong(), groupGoldenPid); + MdmPidTuple tuple = createTuple(groupId.getId(), groupGoldenPid); List patientTypes = createPatientTypes(); IFhirResourceDao groupDao = mock(IFhirResourceDao.class); @@ -387,13 +372,13 @@ public class JpaBulkExportProcessorTest { .thenReturn(resultIterator); if (theMdm) { - when(myMdmLinkDao.expandPidsFromGroupPidGivenMatchResult(any(ResourcePersistentId.class), eq(MdmMatchResultEnum.MATCH))) + when(myMdmLinkDao.expandPidsFromGroupPidGivenMatchResult(any(BaseResourcePersistentId.class), eq(MdmMatchResultEnum.MATCH))) .thenReturn(Collections.singletonList(tuple)); when(myIdHelperService.translatePidsToForcedIds(any(Set.class))) .thenAnswer(params -> { - Set uniqPids = params.getArgument(0); - HashMap> answer = new HashMap<>(); - for (ResourcePersistentId l : uniqPids) { + Set uniqPids = params.getArgument(0); + HashMap> answer = new HashMap<>(); + for (IResourcePersistentId l : uniqPids) { answer.put(l, Optional.empty()); } return new PersistentIdToForcedIdMap(answer); @@ -401,7 +386,7 @@ public class JpaBulkExportProcessorTest { } // test - Iterator pidIterator = myProcessor.getResourcePidIterator(parameters); + Iterator pidIterator = myProcessor.getResourcePidIterator(parameters); // verify assertNotNull(pidIterator, "PID iterator null for mdm = " + theMdm); @@ -414,8 +399,8 @@ public class JpaBulkExportProcessorTest { ExportPIDIteratorParameters parameters = createExportParameters(BulkDataExportOptions.ExportStyle.SYSTEM); parameters.setResourceType("Patient"); - ResourcePersistentId pid = new ResourcePersistentId("Patient/123"); - ResourcePersistentId pid2 = new ResourcePersistentId("Observation/123"); + JpaPid pid = JpaPid.fromId(123L); + JpaPid pid2 = JpaPid.fromId(456L); ListResultIterator resultIterator = new ListResultIterator( Arrays.asList(pid, pid2) ); @@ -444,14 +429,14 @@ public class JpaBulkExportProcessorTest { )).thenReturn(resultIterator); // test - Iterator iterator = myProcessor.getResourcePidIterator(parameters); + Iterator iterator = myProcessor.getResourcePidIterator(parameters); // verify assertNotNull(iterator); assertTrue(iterator.hasNext()); int count = 0; while (iterator.hasNext()) { - ResourcePersistentId ret = iterator.next(); + IResourcePersistentId ret = iterator.next(); assertTrue( ret.equals(pid) || ret.equals(pid2) ); diff --git a/hapi-fhir-jpaserver-cql/pom.xml b/hapi-fhir-jpaserver-cql/pom.xml index 5f2fbdca982..7e9d8063caa 100644 --- a/hapi-fhir-jpaserver-cql/pom.xml +++ b/hapi-fhir-jpaserver-cql/pom.xml @@ -7,7 +7,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-elastic-test-utilities/pom.xml b/hapi-fhir-jpaserver-elastic-test-utilities/pom.xml index f010b9a9d85..670cbb52a54 100644 --- a/hapi-fhir-jpaserver-elastic-test-utilities/pom.xml +++ b/hapi-fhir-jpaserver-elastic-test-utilities/pom.xml @@ -6,7 +6,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-elastic-test-utilities/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchLastNIT.java b/hapi-fhir-jpaserver-elastic-test-utilities/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchLastNIT.java index b201b487177..35dbde1ad16 100644 --- a/hapi-fhir-jpaserver-elastic-test-utilities/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchLastNIT.java +++ b/hapi-fhir-jpaserver-elastic-test-utilities/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchLastNIT.java @@ -1,10 +1,10 @@ package ca.uhn.fhir.jpa.dao.r4; import ca.uhn.fhir.jpa.api.config.DaoConfig; +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; @@ -135,10 +135,10 @@ public class FhirResourceDaoR4SearchLastNIT extends BaseR4SearchLastN { } void verifyResourcesLoadedFromElastic(List theObservationIds, List theResults) { - List expectedArgumentPids = ResourcePersistentId.fromLongList( + List expectedArgumentPids = JpaPid.fromLongList( theObservationIds.stream().map(IIdType::getIdPartAsLong).collect(Collectors.toList()) ); - ArgumentCaptor> actualPids = ArgumentCaptor.forClass(List.class); + ArgumentCaptor> actualPids = ArgumentCaptor.forClass(List.class); verify(myElasticsearchSvc, times(1)).getObservationResources(actualPids.capture()); assertThat(actualPids.getValue(), is(expectedArgumentPids)); diff --git a/hapi-fhir-jpaserver-elastic-test-utilities/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchWithElasticSearchIT.java b/hapi-fhir-jpaserver-elastic-test-utilities/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchWithElasticSearchIT.java index 8504bc880b8..b8744c0ab15 100644 --- a/hapi-fhir-jpaserver-elastic-test-utilities/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchWithElasticSearchIT.java +++ b/hapi-fhir-jpaserver-elastic-test-utilities/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchWithElasticSearchIT.java @@ -17,6 +17,7 @@ import ca.uhn.fhir.jpa.dao.data.IResourceTableDao; import ca.uhn.fhir.jpa.entity.TermCodeSystemVersion; import ca.uhn.fhir.jpa.entity.TermConcept; import ca.uhn.fhir.jpa.entity.TermConceptParentChildLink; +import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.jpa.model.entity.ModelConfig; import ca.uhn.fhir.jpa.model.entity.NormalizedQuantitySearchLevel; import ca.uhn.fhir.jpa.model.entity.ResourceTable; @@ -35,7 +36,7 @@ import ca.uhn.fhir.rest.api.Constants; import ca.uhn.fhir.rest.api.SearchTotalModeEnum; import ca.uhn.fhir.rest.api.SortSpec; import ca.uhn.fhir.rest.api.server.IBundleProvider; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import ca.uhn.fhir.rest.param.ReferenceParam; import ca.uhn.fhir.rest.param.StringOrListParam; import ca.uhn.fhir.rest.param.StringParam; @@ -880,7 +881,7 @@ public class FhirResourceDaoR4SearchWithElasticSearchIT extends BaseJpaTest impl TermConcept childCA = new TermConcept(cs, "childCA").setDisplay("Child CA"); parentC.addChild(childCA, TermConceptParentChildLink.RelationshipTypeEnum.ISA); - myTermCodeSystemStorageSvc.storeNewCodeSystemVersion(new ResourcePersistentId(table.getId()), URL_MY_CODE_SYSTEM, "SYSTEM NAME", "SYSTEM VERSION", cs, table); + myTermCodeSystemStorageSvc.storeNewCodeSystemVersion(JpaPid.fromId(table.getId()), URL_MY_CODE_SYSTEM, "SYSTEM NAME", "SYSTEM VERSION", cs, table); return codeSystem; } @@ -939,7 +940,7 @@ public class FhirResourceDaoR4SearchWithElasticSearchIT extends BaseJpaTest impl SearchParameterMap map = new SearchParameterMap(); map.add("code", new TokenParam().setSystem("http://example.com")); - List bp = myObservationDao.searchForIds(map, new ServletRequestDetails()); + List bp = myObservationDao.searchForIds(map, new ServletRequestDetails()); assertNotNull(bp); assertEquals(600, bp.size()); diff --git a/hapi-fhir-jpaserver-elastic-test-utilities/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4TerminologyElasticsearchIT.java b/hapi-fhir-jpaserver-elastic-test-utilities/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4TerminologyElasticsearchIT.java index 111204b4c12..f927253d212 100644 --- a/hapi-fhir-jpaserver-elastic-test-utilities/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4TerminologyElasticsearchIT.java +++ b/hapi-fhir-jpaserver-elastic-test-utilities/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4TerminologyElasticsearchIT.java @@ -11,11 +11,11 @@ import ca.uhn.fhir.jpa.config.TestR4ConfigWithElasticHSearch; import ca.uhn.fhir.jpa.dao.data.IResourceTableDao; import ca.uhn.fhir.jpa.entity.TermCodeSystemVersion; import ca.uhn.fhir.jpa.entity.TermConcept; +import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.jpa.model.entity.ResourceTable; import ca.uhn.fhir.jpa.search.reindex.IResourceReindexingSvc; import ca.uhn.fhir.jpa.term.api.ITermCodeSystemStorageSvc; import ca.uhn.fhir.jpa.test.BaseJpaTest; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails; import ca.uhn.fhir.rest.server.util.ISearchParamRegistry; import ca.uhn.fhir.test.utilities.docker.RequiresDocker; @@ -120,7 +120,7 @@ public class FhirResourceDaoR4TerminologyElasticsearchIT extends BaseJpaTest { concept = new TermConcept(cs, "LA9999-7"); cs.getConcepts().add(concept); - myTermCodeSystemStorageSvc.storeNewCodeSystemVersion(new ResourcePersistentId(table.getId()), URL_MY_CODE_SYSTEM, "SYSTEM NAME", "SYSTEM VERSION", cs, table); + myTermCodeSystemStorageSvc.storeNewCodeSystemVersion(JpaPid.fromId(table.getId()), URL_MY_CODE_SYSTEM, "SYSTEM NAME", "SYSTEM VERSION", cs, table); ValueSet valueSet = new ValueSet(); valueSet.setUrl(URL_MY_VALUE_SET); diff --git a/hapi-fhir-jpaserver-elastic-test-utilities/src/test/java/ca/uhn/fhir/jpa/term/ValueSetExpansionR4ElasticsearchIT.java b/hapi-fhir-jpaserver-elastic-test-utilities/src/test/java/ca/uhn/fhir/jpa/term/ValueSetExpansionR4ElasticsearchIT.java index 9f249adb74f..46ae39cb5f1 100644 --- a/hapi-fhir-jpaserver-elastic-test-utilities/src/test/java/ca/uhn/fhir/jpa/term/ValueSetExpansionR4ElasticsearchIT.java +++ b/hapi-fhir-jpaserver-elastic-test-utilities/src/test/java/ca/uhn/fhir/jpa/term/ValueSetExpansionR4ElasticsearchIT.java @@ -15,6 +15,7 @@ import ca.uhn.fhir.jpa.entity.TermConcept; import ca.uhn.fhir.jpa.entity.TermConceptParentChildLink; import ca.uhn.fhir.jpa.entity.TermValueSet; import ca.uhn.fhir.jpa.entity.TermValueSetPreExpansionStatusEnum; +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.search.reindex.IResourceReindexingSvc; @@ -23,7 +24,6 @@ import ca.uhn.fhir.jpa.term.api.ITermDeferredStorageSvc; import ca.uhn.fhir.jpa.term.api.ITermReadSvc; import ca.uhn.fhir.jpa.term.custom.CustomTerminologySet; import ca.uhn.fhir.jpa.test.BaseJpaTest; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails; import ca.uhn.fhir.rest.server.util.ISearchParamRegistry; @@ -171,7 +171,7 @@ public class ValueSetExpansionR4ElasticsearchIT extends BaseJpaTest { TermConcept parentB = new TermConcept(cs, "ParentB"); cs.getConcepts().add(parentB); - myTermCodeSystemStorageSvc.storeNewCodeSystemVersion(new ResourcePersistentId(table.getId()), CS_URL, "SYSTEM NAME", "SYSTEM VERSION", cs, table); + myTermCodeSystemStorageSvc.storeNewCodeSystemVersion(JpaPid.fromId(table.getId()), CS_URL, "SYSTEM NAME", "SYSTEM VERSION", cs, table); } diff --git a/hapi-fhir-jpaserver-mdm/pom.xml b/hapi-fhir-jpaserver-mdm/pom.xml index c8a1b5a549a..1d8a5df24fc 100644 --- a/hapi-fhir-jpaserver-mdm/pom.xml +++ b/hapi-fhir-jpaserver-mdm/pom.xml @@ -6,10 +6,11 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../hapi-deployable-pom/pom.xml + hapi-fhir-jpaserver-mdm jar @@ -25,17 +26,18 @@ org.springframework.data spring-data-jpa - - ca.uhn.hapi.fhir - hapi-fhir-jpaserver-base - ${project.version} - ca.uhn.hapi.fhir hapi-fhir-storage-mdm ${project.version} + + ca.uhn.hapi.fhir + hapi-fhir-jpaserver-base + ${project.version} + test + ca.uhn.hapi.fhir hapi-fhir-jpaserver-test-utilities @@ -117,6 +119,29 @@ + + org.apache.maven.plugins + maven-enforcer-plugin + + + enforce-banned-dependencies + + enforce + + + + + + + ca.uhn.hapi.fhir:hapi-fhir-jpaserver-base:${project.version}:jar:compile + + + + true + + + + diff --git a/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/config/MdmSubmitterConfig.java b/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/config/MdmSubmitterConfig.java index 5dde2a1f4d5..d87b1fdb766 100644 --- a/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/config/MdmSubmitterConfig.java +++ b/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/config/MdmSubmitterConfig.java @@ -21,17 +21,13 @@ package ca.uhn.fhir.jpa.mdm.config; */ import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.jpa.dao.mdm.MdmLinkDaoJpaImpl; -import ca.uhn.fhir.jpa.mdm.dao.JpaMdmLinkImplFactory; import ca.uhn.fhir.jpa.mdm.interceptor.MdmSubmitterInterceptorLoader; -import ca.uhn.fhir.mdm.dao.IMdmLinkImplFactory; -import ca.uhn.fhir.mdm.svc.MdmChannelSubmitterSvcImpl; -import ca.uhn.fhir.mdm.dao.IMdmLinkDao; -import ca.uhn.fhir.mdm.svc.MdmSearchParamSvc; -import ca.uhn.fhir.mdm.svc.MdmSubmitSvcImpl; import ca.uhn.fhir.jpa.subscription.channel.api.IChannelFactory; import ca.uhn.fhir.mdm.api.IMdmChannelSubmitterSvc; import ca.uhn.fhir.mdm.api.IMdmSubmitSvc; +import ca.uhn.fhir.mdm.svc.MdmChannelSubmitterSvcImpl; +import ca.uhn.fhir.mdm.svc.MdmSearchParamSvc; +import ca.uhn.fhir.mdm.svc.MdmSubmitSvcImpl; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; @@ -61,12 +57,4 @@ public class MdmSubmitterConfig { IMdmSubmitSvc mdmSubmitService() { return new MdmSubmitSvcImpl(); } - - @Bean - IMdmLinkDao mdmLinkDao(){ - return new MdmLinkDaoJpaImpl(); - } - - @Bean - IMdmLinkImplFactory mdmLinkImplFactory() {return new JpaMdmLinkImplFactory();} } diff --git a/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/dao/MdmLinkDaoSvc.java b/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/dao/MdmLinkDaoSvc.java index 8831ce6e4a8..a8adb68293f 100644 --- a/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/dao/MdmLinkDaoSvc.java +++ b/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/dao/MdmLinkDaoSvc.java @@ -34,7 +34,7 @@ import ca.uhn.fhir.mdm.dao.MdmLinkFactory; import ca.uhn.fhir.mdm.log.Logs; import ca.uhn.fhir.mdm.model.MdmTransactionContext; import ca.uhn.fhir.rest.api.Constants; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import org.hl7.fhir.instance.model.api.IAnyResource; import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IIdType; @@ -52,22 +52,22 @@ import java.util.Date; import java.util.List; import java.util.Optional; -public class MdmLinkDaoSvc { +public class MdmLinkDaoSvc

> { private static final Logger ourLog = Logs.getMdmTroubleshootingLog(); @Autowired - private IMdmLinkDao myMdmLinkDao; + private IMdmLinkDao myMdmLinkDao; @Autowired - private MdmLinkFactory myMdmLinkFactory; + private MdmLinkFactory myMdmLinkFactory; @Autowired - private IIdHelperService myIdHelperService; + private IIdHelperService

myIdHelperService; @Autowired private FhirContext myFhirContext; @Transactional - public IMdmLink createOrUpdateLinkEntity(IAnyResource theGoldenResource, IAnyResource theSourceResource, MdmMatchOutcome theMatchOutcome, MdmLinkSourceEnum theLinkSource, @Nullable MdmTransactionContext theMdmTransactionContext) { - IMdmLink mdmLink = getOrCreateMdmLinkByGoldenResourceAndSourceResource(theGoldenResource, theSourceResource); + public M createOrUpdateLinkEntity(IAnyResource theGoldenResource, IAnyResource theSourceResource, MdmMatchOutcome theMatchOutcome, MdmLinkSourceEnum theLinkSource, @Nullable MdmTransactionContext theMdmTransactionContext) { + M mdmLink = getOrCreateMdmLinkByGoldenResourceAndSourceResource(theGoldenResource, theSourceResource); mdmLink.setLinkSource(theLinkSource); mdmLink.setMatchResult(theMatchOutcome.getMatchResultEnum()); // Preserve these flags for link updates @@ -93,16 +93,16 @@ public class MdmLinkDaoSvc { } @Nonnull - public IMdmLink getOrCreateMdmLinkByGoldenResourceAndSourceResource( + public M getOrCreateMdmLinkByGoldenResourceAndSourceResource( IAnyResource theGoldenResource, IAnyResource theSourceResource ) { - ResourcePersistentId goldenResourcePid = myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), theGoldenResource); - ResourcePersistentId sourceResourcePid = myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), theSourceResource); - Optional oExisting = getLinkByGoldenResourcePidAndSourceResourcePid(goldenResourcePid, sourceResourcePid); + P goldenResourcePid = myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), theGoldenResource); + P sourceResourcePid = myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), theSourceResource); + Optional oExisting = getLinkByGoldenResourcePidAndSourceResourcePid(goldenResourcePid, sourceResourcePid); if (oExisting.isPresent()) { return oExisting.get(); } else { - IMdmLink newLink = myMdmLinkFactory.newMdmLink(); + M newLink = myMdmLinkFactory.newMdmLink(); newLink.setGoldenResourcePersistenceId(goldenResourcePid); newLink.setSourcePersistenceId(sourceResourcePid); return newLink; @@ -111,14 +111,15 @@ public class MdmLinkDaoSvc { /** * Given a golden resource Pid and source Pid, return the mdm link that matches these criterias if exists - * @deprecated This was deprecated in favour of using ResourcePersistenceId rather than longs + * * @param theGoldenResourcePid * @param theSourceResourcePid * @return + * @deprecated This was deprecated in favour of using ResourcePersistenceId rather than longs */ @Deprecated - public Optional getLinkByGoldenResourcePidAndSourceResourcePid(Long theGoldenResourcePid, Long theSourceResourcePid) { - return getLinkByGoldenResourcePidAndSourceResourcePid(new ResourcePersistentId(theGoldenResourcePid), new ResourcePersistentId(theSourceResourcePid)); + public Optional getLinkByGoldenResourcePidAndSourceResourcePid(Long theGoldenResourcePid, Long theSourceResourcePid) { + return getLinkByGoldenResourcePidAndSourceResourcePid(myIdHelperService.newPid(theGoldenResourcePid), myIdHelperService.newPid(theSourceResourcePid)); } /** @@ -128,16 +129,16 @@ public class MdmLinkDaoSvc { * @return The {@link IMdmLink} entity that matches these criteria if exists */ @SuppressWarnings("unchecked") - public Optional getLinkByGoldenResourcePidAndSourceResourcePid(ResourcePersistentId theGoldenResourcePid, ResourcePersistentId theSourceResourcePid) { + public Optional getLinkByGoldenResourcePidAndSourceResourcePid(P theGoldenResourcePid, P theSourceResourcePid) { if (theSourceResourcePid == null || theGoldenResourcePid == null) { return Optional.empty(); } - IMdmLink link = myMdmLinkFactory.newMdmLink(); + M link = myMdmLinkFactory.newMdmLink(); link.setSourcePersistenceId(theSourceResourcePid); link.setGoldenResourcePersistenceId(theGoldenResourcePid); //TODO - replace the use of example search - Example example = Example.of(link); + Example example = Example.of(link); return myMdmLinkDao.findOne(example); } @@ -149,11 +150,11 @@ public class MdmLinkDaoSvc { * @param theMatchResult the Match Result of the relationship * @return a list of {@link IMdmLink} entities matching these criteria. */ - public List getMdmLinksBySourcePidAndMatchResult(ResourcePersistentId theSourcePid, MdmMatchResultEnum theMatchResult) { - IMdmLink exampleLink = myMdmLinkFactory.newMdmLink(); + public List getMdmLinksBySourcePidAndMatchResult(P theSourcePid, MdmMatchResultEnum theMatchResult) { + M exampleLink = myMdmLinkFactory.newMdmLink(); exampleLink.setSourcePersistenceId(theSourcePid); exampleLink.setMatchResult(theMatchResult); - Example example = Example.of(exampleLink); + Example example = Example.of(exampleLink); return myMdmLinkDao.findAll(example); } @@ -166,7 +167,7 @@ public class MdmLinkDaoSvc { */ @Deprecated @Transactional - public Optional getMatchedLinkForSourcePid(ResourcePersistentId theSourcePid) { + public Optional getMatchedLinkForSourcePid(P theSourcePid) { return myMdmLinkDao.findBySourcePidAndMatchResult(theSourcePid, MdmMatchResultEnum.MATCH); } @@ -177,25 +178,25 @@ public class MdmLinkDaoSvc { * @param theSourceResource The IBaseResource representing the source you wish to find the matching link for. * @return the {@link IMdmLink} that contains the Match information for the source. */ - public Optional getMatchedLinkForSource(IBaseResource theSourceResource) { + public Optional getMatchedLinkForSource(IBaseResource theSourceResource) { return getMdmLinkWithMatchResult(theSourceResource, MdmMatchResultEnum.MATCH); } - public Optional getPossibleMatchedLinkForSource(IBaseResource theSourceResource) { + public Optional getPossibleMatchedLinkForSource(IBaseResource theSourceResource) { return getMdmLinkWithMatchResult(theSourceResource, MdmMatchResultEnum.POSSIBLE_MATCH); } @Nonnull - private Optional getMdmLinkWithMatchResult(IBaseResource theSourceResource, MdmMatchResultEnum theMatchResult) { - ResourcePersistentId pid = myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), theSourceResource); + private Optional getMdmLinkWithMatchResult(IBaseResource theSourceResource, MdmMatchResultEnum theMatchResult) { + P pid = myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), theSourceResource); if (pid == null) { return Optional.empty(); } - IMdmLink exampleLink = myMdmLinkFactory.newMdmLink(); + M exampleLink = myMdmLinkFactory.newMdmLink(); exampleLink.setSourcePersistenceId(pid); exampleLink.setMatchResult(theMatchResult); - Example example = Example.of(exampleLink); + Example example = Example.of(exampleLink); return myMdmLinkDao.findOne(example); } @@ -207,18 +208,18 @@ public class MdmLinkDaoSvc { * @param theMatchResult The MatchResult you are looking for. * @return an Optional {@link IMdmLink} containing the matched link if it exists. */ - public Optional getMdmLinksByGoldenResourcePidSourcePidAndMatchResult(Long theGoldenResourcePid, + public Optional getMdmLinksByGoldenResourcePidSourcePidAndMatchResult(Long theGoldenResourcePid, Long theSourcePid, MdmMatchResultEnum theMatchResult) { - return getMdmLinksByGoldenResourcePidSourcePidAndMatchResult(new ResourcePersistentId(theGoldenResourcePid), new ResourcePersistentId(theSourcePid), theMatchResult); + return getMdmLinksByGoldenResourcePidSourcePidAndMatchResult(myIdHelperService.newPid(theGoldenResourcePid), myIdHelperService.newPid(theSourcePid), theMatchResult); } - public Optional getMdmLinksByGoldenResourcePidSourcePidAndMatchResult(ResourcePersistentId theGoldenResourcePid, - ResourcePersistentId theSourcePid, MdmMatchResultEnum theMatchResult) { - IMdmLink exampleLink = myMdmLinkFactory.newMdmLink(); + public Optional getMdmLinksByGoldenResourcePidSourcePidAndMatchResult(P theGoldenResourcePid, + P theSourcePid, MdmMatchResultEnum theMatchResult) { + M exampleLink = myMdmLinkFactory.newMdmLink(); exampleLink.setGoldenResourcePersistenceId(theGoldenResourcePid); exampleLink.setSourcePersistenceId(theSourcePid); exampleLink.setMatchResult(theMatchResult); - Example example = Example.of(exampleLink); + Example example = Example.of(exampleLink); return myMdmLinkDao.findOne(example); } @@ -227,22 +228,22 @@ public class MdmLinkDaoSvc { * * @return A list of {@link IMdmLink} that hold potential duplicate golden resources. */ - public List getPossibleDuplicates() { - IMdmLink exampleLink = myMdmLinkFactory.newMdmLink(); + public List getPossibleDuplicates() { + M exampleLink = myMdmLinkFactory.newMdmLink(); exampleLink.setMatchResult(MdmMatchResultEnum.POSSIBLE_DUPLICATE); - Example example = Example.of(exampleLink); + Example example = Example.of(exampleLink); return myMdmLinkDao.findAll(example); } @Transactional - public Optional findMdmLinkBySource(IBaseResource theSourceResource) { - @Nullable ResourcePersistentId pid = myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), theSourceResource); + public Optional findMdmLinkBySource(IBaseResource theSourceResource) { + @Nullable P pid = myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), theSourceResource); if (pid == null) { return Optional.empty(); } - IMdmLink exampleLink = myMdmLinkFactory.newMdmLink(); + M exampleLink = myMdmLinkFactory.newMdmLink(); exampleLink.setSourcePersistenceId(pid); - Example example = Example.of(exampleLink); + Example example = Example.of(exampleLink); return myMdmLinkDao.findOne(example); } @@ -253,7 +254,7 @@ public class MdmLinkDaoSvc { * @param theMdmLink the {@link IMdmLink} to delete. */ @Transactional(propagation = Propagation.REQUIRES_NEW) - public void deleteLink(IMdmLink theMdmLink) { + public void deleteLink(M theMdmLink) { myMdmLinkDao.validateMdmLink(theMdmLink); myMdmLinkDao.delete(theMdmLink); } @@ -265,14 +266,14 @@ public class MdmLinkDaoSvc { * @return A list of all {@link IMdmLink} entities in which theGoldenResource is the source Golden Resource */ @Transactional - public List findMdmLinksByGoldenResource(IBaseResource theGoldenResource) { - ResourcePersistentId pid = myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), theGoldenResource); + public List findMdmLinksByGoldenResource(IBaseResource theGoldenResource) { + P pid = myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), theGoldenResource); if (pid == null) { return Collections.emptyList(); } - IMdmLink exampleLink = myMdmLinkFactory.newMdmLink(); + M exampleLink = myMdmLinkFactory.newMdmLink(); exampleLink.setGoldenResourcePersistenceId(pid); - Example example = Example.of(exampleLink); + Example example = Example.of(exampleLink); return myMdmLinkDao.findAll(example); } @@ -282,8 +283,8 @@ public class MdmLinkDaoSvc { * @param theMdmLink the link to save. * @return the persisted {@link IMdmLink} entity. */ - public IMdmLink save(IMdmLink theMdmLink) { - IMdmLink mdmLink = myMdmLinkDao.validateMdmLink(theMdmLink); + public M save(M theMdmLink) { + M mdmLink = myMdmLinkDao.validateMdmLink(theMdmLink); if (mdmLink.getCreated() == null) { mdmLink.setCreated(new Date()); } @@ -303,7 +304,7 @@ public class MdmLinkDaoSvc { * @param thePartitionId List of partitions ID being searched, where the link's partition must be in the list. * @return a list of {@link IMdmLink} entities which match the example. */ - public Page executeTypedQuery(IIdType theGoldenResourceId, IIdType theSourceId, MdmMatchResultEnum theMatchResult, MdmLinkSourceEnum theLinkSource, MdmPageRequest thePageRequest, List thePartitionId) { + public Page executeTypedQuery(IIdType theGoldenResourceId, IIdType theSourceId, MdmMatchResultEnum theMatchResult, MdmLinkSourceEnum theLinkSource, MdmPageRequest thePageRequest, List thePartitionId) { return myMdmLinkDao.search(theGoldenResourceId, theSourceId, theMatchResult, theLinkSource, thePageRequest, thePartitionId); } @@ -315,14 +316,14 @@ public class MdmLinkDaoSvc { * @return all links for the source. */ @Transactional - public List findMdmLinksBySourceResource(IBaseResource theSourceResource) { - ResourcePersistentId pid = myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), theSourceResource); + public List findMdmLinksBySourceResource(IBaseResource theSourceResource) { + P pid = myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), theSourceResource); if (pid == null) { return Collections.emptyList(); } - IMdmLink exampleLink = myMdmLinkFactory.newMdmLink(); + M exampleLink = myMdmLinkFactory.newMdmLink(); exampleLink.setSourcePersistenceId(pid); - Example example = Example.of(exampleLink); + Example example = Example.of(exampleLink); return myMdmLinkDao.findAll(example); } @@ -333,15 +334,15 @@ public class MdmLinkDaoSvc { * @param theGoldenResource the source resource to find links for. * @return all links for the source. */ - public List findMdmMatchLinksByGoldenResource(IBaseResource theGoldenResource) { - ResourcePersistentId pid = myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), theGoldenResource); + public List findMdmMatchLinksByGoldenResource(IBaseResource theGoldenResource) { + P pid = myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), theGoldenResource); if (pid == null) { return Collections.emptyList(); } - IMdmLink exampleLink = myMdmLinkFactory.newMdmLink(); + M exampleLink = myMdmLinkFactory.newMdmLink(); exampleLink.setGoldenResourcePersistenceId(pid); exampleLink.setMatchResult(MdmMatchResultEnum.MATCH); - Example example = Example.of(exampleLink); + Example example = Example.of(exampleLink); return myMdmLinkDao.findAll(example); } @@ -355,16 +356,16 @@ public class MdmLinkDaoSvc { return myMdmLinkFactory.newMdmLink(); } - public Optional getMatchedOrPossibleMatchedLinkForSource(IAnyResource theResource) { + public Optional getMatchedOrPossibleMatchedLinkForSource(IAnyResource theResource) { // TODO KHS instead of two queries, just do one query with an OR - Optional retval = getMatchedLinkForSource(theResource); + Optional retval = getMatchedLinkForSource(theResource); if (!retval.isPresent()) { retval = getPossibleMatchedLinkForSource(theResource); } return retval; } - public Optional getLinkByGoldenResourceAndSourceResource(@Nullable IAnyResource theGoldenResource, @Nullable IAnyResource theSourceResource) { + public Optional getLinkByGoldenResourceAndSourceResource(@Nullable IAnyResource theGoldenResource, @Nullable IAnyResource theSourceResource) { if (theGoldenResource == null || theSourceResource == null) { return Optional.empty(); } @@ -374,7 +375,7 @@ public class MdmLinkDaoSvc { } @Transactional(propagation = Propagation.MANDATORY) - public void deleteLinksWithAnyReferenceToPids(List theGoldenResourcePids) { + public void deleteLinksWithAnyReferenceToPids(List

theGoldenResourcePids) { myMdmLinkDao.deleteLinksWithAnyReferenceToPids(theGoldenResourcePids); } } diff --git a/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/GoldenResourceMergerSvcImpl.java b/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/GoldenResourceMergerSvcImpl.java index d849f9cbb78..380daf7d6da 100644 --- a/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/GoldenResourceMergerSvcImpl.java +++ b/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/GoldenResourceMergerSvcImpl.java @@ -36,7 +36,7 @@ import ca.uhn.fhir.mdm.model.MdmTransactionContext; import ca.uhn.fhir.mdm.util.GoldenResourceHelper; import ca.uhn.fhir.mdm.util.MdmResourceUtil; import ca.uhn.fhir.rest.api.Constants; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import org.hl7.fhir.instance.model.api.IAnyResource; import org.hl7.fhir.instance.model.api.IIdType; @@ -178,7 +178,7 @@ public class GoldenResourceMergerSvcImpl implements IGoldenResourceMergerSvc { List toLinks = myMdmLinkDaoSvc.findMdmLinksByGoldenResource(theToResource); List toDelete = new ArrayList<>(); - ResourcePersistentId goldenResourcePid = myIdHelperService.resolveResourcePersistentIds( + IResourcePersistentId goldenResourcePid = myIdHelperService.resolveResourcePersistentIds( getPartitionIdForResource(theToResource), theToResource.getIdElement().getResourceType(), theToResource.getIdElement().getIdPart() diff --git a/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/GoldenResourceSearchSvcImpl.java b/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/GoldenResourceSearchSvcImpl.java index 135509a70d4..3df77b5531c 100644 --- a/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/GoldenResourceSearchSvcImpl.java +++ b/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/GoldenResourceSearchSvcImpl.java @@ -35,7 +35,7 @@ import ca.uhn.fhir.mdm.api.MdmConstants; import ca.uhn.fhir.rest.api.Constants; import ca.uhn.fhir.rest.api.SortOrderEnum; import ca.uhn.fhir.rest.api.SortSpec; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import ca.uhn.fhir.rest.param.DateRangeParam; import ca.uhn.fhir.rest.param.TokenParam; import ca.uhn.fhir.util.DateRangeUtil; @@ -77,7 +77,7 @@ public class GoldenResourceSearchSvcImpl implements IGoldenResourceSearchSvc { IFhirResourceDao dao = myDaoRegistry.getResourceDao(theResourceType); SystemRequestDetails request = new SystemRequestDetails(); request.setRequestPartitionId(theRequestPartitionId); - List ids = dao.searchForIds(searchParamMap, request); + List ids = dao.searchForIds(searchParamMap, request); Date lastDate = null; if (ids.size() > 0) { diff --git a/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/IMdmModelConverterSvc.java b/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/IMdmModelConverterSvc.java index 48bcfa15075..4744ff16d1b 100644 --- a/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/IMdmModelConverterSvc.java +++ b/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/IMdmModelConverterSvc.java @@ -20,7 +20,6 @@ package ca.uhn.fhir.jpa.mdm.svc; * #L% */ -import ca.uhn.fhir.jpa.entity.MdmLink; import ca.uhn.fhir.mdm.api.IMdmLink; import ca.uhn.fhir.mdm.api.MdmLinkJson; diff --git a/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/MdmEidUpdateService.java b/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/MdmEidUpdateService.java index 214b8a98778..6cce478d2bc 100644 --- a/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/MdmEidUpdateService.java +++ b/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/MdmEidUpdateService.java @@ -20,7 +20,6 @@ package ca.uhn.fhir.jpa.mdm.svc; * #L% */ -import ca.uhn.fhir.jpa.entity.MdmLink; import ca.uhn.fhir.jpa.mdm.dao.MdmLinkDaoSvc; import ca.uhn.fhir.jpa.mdm.svc.candidate.MatchedGoldenResourceCandidate; import ca.uhn.fhir.jpa.mdm.svc.candidate.MdmGoldenResourceFindingSvc; @@ -35,7 +34,7 @@ import ca.uhn.fhir.mdm.model.CanonicalEID; import ca.uhn.fhir.mdm.model.MdmTransactionContext; import ca.uhn.fhir.mdm.util.EIDHelper; import ca.uhn.fhir.mdm.util.GoldenResourceHelper; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import org.hl7.fhir.instance.model.api.IAnyResource; import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; @@ -168,7 +167,7 @@ public class MdmEidUpdateService { if (theExistingMatchOrPossibleMatchLink.isPresent()) { IMdmLink mdmLink = theExistingMatchOrPossibleMatchLink.get(); - ResourcePersistentId existingGoldenResourcePid = mdmLink.getGoldenResourcePersistenceId(); + IResourcePersistentId existingGoldenResourcePid = mdmLink.getGoldenResourcePersistenceId(); myExistingGoldenResource = myMdmResourceDaoSvc.readGoldenResourceByPid(existingGoldenResourcePid, resourceType); myRemainsMatchedToSameGoldenResource = candidateIsSameAsMdmLinkGoldenResource(mdmLink, theMatchedGoldenResourceCandidate); } else { diff --git a/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/MdmLinkCreateSvcImpl.java b/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/MdmLinkCreateSvcImpl.java index 550813cb05c..4596151acff 100644 --- a/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/MdmLinkCreateSvcImpl.java +++ b/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/MdmLinkCreateSvcImpl.java @@ -37,7 +37,7 @@ import ca.uhn.fhir.mdm.model.MdmTransactionContext; import ca.uhn.fhir.mdm.util.MdmResourceUtil; import ca.uhn.fhir.mdm.util.MessageHelper; import ca.uhn.fhir.rest.api.Constants; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import org.hl7.fhir.instance.model.api.IAnyResource; import org.slf4j.Logger; @@ -71,8 +71,8 @@ public class MdmLinkCreateSvcImpl implements IMdmLinkCreateSvc { validateCreateLinkRequest(theGoldenResource, theSourceResource, sourceType); - ResourcePersistentId goldenResourceId = myIdHelperService.getPidOrThrowException(theGoldenResource); - ResourcePersistentId targetId = myIdHelperService.getPidOrThrowException(theSourceResource); + IResourcePersistentId goldenResourceId = myIdHelperService.getPidOrThrowException(theGoldenResource); + IResourcePersistentId targetId = myIdHelperService.getPidOrThrowException(theSourceResource); // check if the golden resource and the source resource are in the same partition, throw error if not myMdmPartitionHelper.validateResourcesInSamePartition(theGoldenResource, theSourceResource); diff --git a/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/MdmLinkSvcImpl.java b/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/MdmLinkSvcImpl.java index 58be3c1f607..1c277c46913 100644 --- a/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/MdmLinkSvcImpl.java +++ b/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/MdmLinkSvcImpl.java @@ -31,18 +31,17 @@ import ca.uhn.fhir.mdm.api.MdmMatchOutcome; import ca.uhn.fhir.mdm.api.MdmMatchResultEnum; import ca.uhn.fhir.mdm.log.Logs; import ca.uhn.fhir.mdm.model.MdmTransactionContext; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; import org.hl7.fhir.instance.model.api.IAnyResource; import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import javax.annotation.Nonnull; -import org.springframework.transaction.annotation.Transactional; import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; /** * This class is in charge of managing MdmLinks between Golden Resources and source resources @@ -79,8 +78,8 @@ public class MdmLinkSvcImpl implements IMdmLinkSvc { } private boolean goldenResourceLinkedAsNoMatch(IAnyResource theGoldenResource, IAnyResource theSourceResource) { - ResourcePersistentId goldenResourceId = myIdHelperService.getPidOrThrowException(theGoldenResource); - ResourcePersistentId sourceId = myIdHelperService.getPidOrThrowException(theSourceResource); + IResourcePersistentId goldenResourceId = myIdHelperService.getPidOrThrowException(theGoldenResource); + IResourcePersistentId sourceId = myIdHelperService.getPidOrThrowException(theSourceResource); // TODO perf collapse into one query return myMdmLinkDaoSvc.getMdmLinksByGoldenResourcePidSourcePidAndMatchResult(goldenResourceId, sourceId, MdmMatchResultEnum.NO_MATCH).isPresent() || myMdmLinkDaoSvc.getMdmLinksByGoldenResourcePidSourcePidAndMatchResult(sourceId, goldenResourceId, MdmMatchResultEnum.NO_MATCH).isPresent(); @@ -102,7 +101,7 @@ public class MdmLinkSvcImpl implements IMdmLinkSvc { @Override @Transactional - public void deleteLinksWithAnyReferenceTo(List theGoldenResourceIds) { + public void deleteLinksWithAnyReferenceTo(List theGoldenResourceIds) { myMdmLinkDaoSvc.deleteLinksWithAnyReferenceToPids(theGoldenResourceIds); } diff --git a/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/MdmLinkUpdaterSvcImpl.java b/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/MdmLinkUpdaterSvcImpl.java index 12f64860bf3..abede0664e4 100644 --- a/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/MdmLinkUpdaterSvcImpl.java +++ b/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/MdmLinkUpdaterSvcImpl.java @@ -38,7 +38,7 @@ import ca.uhn.fhir.mdm.model.MdmTransactionContext; import ca.uhn.fhir.mdm.util.MdmResourceUtil; import ca.uhn.fhir.mdm.util.MessageHelper; import ca.uhn.fhir.rest.api.Constants; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.provider.ProviderConstants; import org.hl7.fhir.instance.model.api.IAnyResource; @@ -80,8 +80,8 @@ public class MdmLinkUpdaterSvcImpl implements IMdmLinkUpdaterSvc { validateUpdateLinkRequest(theGoldenResource, theSourceResource, theMatchResult, sourceType); - ResourcePersistentId goldenResourceId = myIdHelperService.getPidOrThrowException(theGoldenResource); - ResourcePersistentId sourceResourceId = myIdHelperService.getPidOrThrowException(theSourceResource); + IResourcePersistentId goldenResourceId = myIdHelperService.getPidOrThrowException(theGoldenResource); + IResourcePersistentId sourceResourceId = myIdHelperService.getPidOrThrowException(theSourceResource); // check if the golden resource and the source resource are in the same partition, throw error if not myMdmPartitionHelper.validateResourcesInSamePartition(theGoldenResource, theSourceResource); @@ -130,12 +130,12 @@ public class MdmLinkUpdaterSvcImpl implements IMdmLinkUpdaterSvc { * doesn't exist, because a resource mustn't be a MATCH to more than one golden resource */ private void validateNoMatchPresentWhenAcceptingPossibleMatch(IAnyResource theSourceResource, - ResourcePersistentId theGoldenResourceId, MdmMatchResultEnum theMatchResult) { + IResourcePersistentId theGoldenResourceId, MdmMatchResultEnum theMatchResult) { // if theMatchResult != MATCH, we are not accepting POSSIBLE_MATCH so there is nothing to validate if (theMatchResult != MdmMatchResultEnum.MATCH) { return; } - ResourcePersistentId sourceResourceId = myIdHelperService.getPidOrThrowException(theSourceResource); + IResourcePersistentId sourceResourceId = myIdHelperService.getPidOrThrowException(theSourceResource); List mdmLinks = myMdmLinkDaoSvc .getMdmLinksBySourcePidAndMatchResult(sourceResourceId, MdmMatchResultEnum.MATCH); @@ -184,8 +184,8 @@ public class MdmLinkUpdaterSvcImpl implements IMdmLinkUpdaterSvc { public void notDuplicateGoldenResource(IAnyResource theGoldenResource, IAnyResource theTargetGoldenResource, MdmTransactionContext theMdmContext) { validateNotDuplicateGoldenResourceRequest(theGoldenResource, theTargetGoldenResource); - ResourcePersistentId goldenResourceId = myIdHelperService.getPidOrThrowException(theGoldenResource); - ResourcePersistentId targetId = myIdHelperService.getPidOrThrowException(theTargetGoldenResource); + IResourcePersistentId goldenResourceId = myIdHelperService.getPidOrThrowException(theGoldenResource); + IResourcePersistentId targetId = myIdHelperService.getPidOrThrowException(theTargetGoldenResource); Optional oMdmLink = myMdmLinkDaoSvc.getLinkByGoldenResourcePidAndSourceResourcePid(goldenResourceId, targetId); if (oMdmLink.isEmpty()) { diff --git a/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/MdmMatchLinkSvc.java b/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/MdmMatchLinkSvc.java index c667d4e0b50..6a5b22d95a6 100644 --- a/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/MdmMatchLinkSvc.java +++ b/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/MdmMatchLinkSvc.java @@ -30,14 +30,14 @@ import ca.uhn.fhir.mdm.log.Logs; import ca.uhn.fhir.mdm.model.MdmTransactionContext; import ca.uhn.fhir.mdm.util.GoldenResourceHelper; import ca.uhn.fhir.mdm.util.MdmResourceUtil; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import ca.uhn.fhir.rest.server.TransactionLogMessages; import org.hl7.fhir.instance.model.api.IAnyResource; import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; - import org.springframework.transaction.annotation.Transactional; + import java.util.ArrayList; import java.util.List; @@ -93,7 +93,7 @@ public class MdmMatchLinkSvc { private void handleMdmWithMultipleCandidates(IAnyResource theResource, CandidateList theCandidateList, MdmTransactionContext theMdmTransactionContext) { MatchedGoldenResourceCandidate firstMatch = theCandidateList.getFirstMatch(); - ResourcePersistentId sampleGoldenResourcePid = firstMatch.getCandidateGoldenResourcePid(); + IResourcePersistentId sampleGoldenResourcePid = firstMatch.getCandidateGoldenResourcePid(); boolean allSameGoldenResource = theCandidateList.stream() .allMatch(candidate -> candidate.getCandidateGoldenResourcePid().equals(sampleGoldenResourcePid)); diff --git a/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/MdmResourceDaoSvc.java b/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/MdmResourceDaoSvc.java index 92b6cf52d17..7fb1f32774d 100644 --- a/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/MdmResourceDaoSvc.java +++ b/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/MdmResourceDaoSvc.java @@ -20,8 +20,8 @@ package ca.uhn.fhir.jpa.mdm.svc; * #L% */ -import ca.uhn.fhir.interceptor.model.RequestPartitionId; import ca.uhn.fhir.i18n.Msg; +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.model.DaoMethodOutcome; @@ -33,7 +33,7 @@ import ca.uhn.fhir.mdm.api.MdmConstants; import ca.uhn.fhir.rest.api.Constants; 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.api.server.storage.IResourcePersistentId; import ca.uhn.fhir.rest.param.TokenParam; import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; import org.hl7.fhir.instance.model.api.IAnyResource; @@ -77,7 +77,7 @@ public class MdmResourceDaoSvc { resourceDao.removeTag(theGoldenResource.getIdElement(), TagTypeEnum.TAG, MdmConstants.SYSTEM_GOLDEN_RECORD_STATUS, MdmConstants.CODE_GOLDEN_RECORD, requestDetails); } - public IAnyResource readGoldenResourceByPid(ResourcePersistentId theGoldenResourcePid, String theResourceType) { + public IAnyResource readGoldenResourceByPid(IResourcePersistentId theGoldenResourcePid, String theResourceType) { IFhirResourceDao resourceDao = myDaoRegistry.getResourceDao(theResourceType); return (IAnyResource) resourceDao.readByPid(theGoldenResourcePid); } diff --git a/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/candidate/FindCandidateByEidSvc.java b/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/candidate/FindCandidateByEidSvc.java index ab7cb804138..69c8aea6f16 100644 --- a/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/candidate/FindCandidateByEidSvc.java +++ b/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/candidate/FindCandidateByEidSvc.java @@ -21,7 +21,6 @@ package ca.uhn.fhir.jpa.mdm.svc.candidate; */ import ca.uhn.fhir.interceptor.model.RequestPartitionId; -import ca.uhn.fhir.jpa.entity.MdmLink; import ca.uhn.fhir.jpa.mdm.dao.MdmLinkDaoSvc; import ca.uhn.fhir.jpa.mdm.svc.MdmResourceDaoSvc; import ca.uhn.fhir.mdm.api.IMdmLink; @@ -30,7 +29,7 @@ import ca.uhn.fhir.mdm.log.Logs; import ca.uhn.fhir.mdm.model.CanonicalEID; import ca.uhn.fhir.mdm.util.EIDHelper; import ca.uhn.fhir.rest.api.Constants; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import org.hl7.fhir.instance.model.api.IAnyResource; import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; @@ -66,7 +65,7 @@ public class FindCandidateByEidSvc extends BaseCandidateFinder { if (isNoMatch(foundGoldenResource, theIncomingResource)) { continue; } - ResourcePersistentId pidOrNull = myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), foundGoldenResource); + IResourcePersistentId pidOrNull = myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), foundGoldenResource); MatchedGoldenResourceCandidate mpc = new MatchedGoldenResourceCandidate(pidOrNull, MdmMatchOutcome.EID_MATCH); ourLog.debug("Incoming Resource {} matched Golden Resource {} by EID {}", theIncomingResource.getIdElement().toUnqualifiedVersionless(), foundGoldenResource.getIdElement().toUnqualifiedVersionless(), eid); @@ -82,7 +81,7 @@ public class FindCandidateByEidSvc extends BaseCandidateFinder { if (oLink.isEmpty()) { return false; } - MdmLink link = (MdmLink) oLink.get(); + IMdmLink link = oLink.get(); return link.isNoMatch(); } diff --git a/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/candidate/FindCandidateByExampleSvc.java b/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/candidate/FindCandidateByExampleSvc.java index aaa801ce30c..63ebe9516cf 100644 --- a/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/candidate/FindCandidateByExampleSvc.java +++ b/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/candidate/FindCandidateByExampleSvc.java @@ -30,7 +30,7 @@ import ca.uhn.fhir.mdm.api.MatchedTarget; import ca.uhn.fhir.mdm.api.MdmMatchResultEnum; import ca.uhn.fhir.mdm.log.Logs; import ca.uhn.fhir.rest.api.Constants; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import org.hl7.fhir.instance.model.api.IAnyResource; import org.hl7.fhir.instance.model.api.IBaseResource; import org.slf4j.Logger; @@ -43,14 +43,14 @@ import java.util.Optional; import java.util.stream.Collectors; @Service -public class FindCandidateByExampleSvc extends BaseCandidateFinder { +public class FindCandidateByExampleSvc

extends BaseCandidateFinder { private static final Logger ourLog = Logs.getMdmTroubleshootingLog(); @Autowired - IIdHelperService myIdHelperService; + IIdHelperService

myIdHelperService; @Autowired private FhirContext myFhirContext; @Autowired - private MdmLinkDaoSvc myMdmLinkDaoSvc; + private MdmLinkDaoSvc> myMdmLinkDaoSvc; @Autowired private IMdmMatchFinderSvc myMdmMatchFinderSvc; @@ -66,7 +66,7 @@ public class FindCandidateByExampleSvc extends BaseCandidateFinder { protected List findMatchGoldenResourceCandidates(IAnyResource theTarget) { List retval = new ArrayList<>(); - List goldenResourcePidsToExclude = getNoMatchGoldenResourcePids(theTarget); + List

goldenResourcePidsToExclude = getNoMatchGoldenResourcePids(theTarget); List matchedCandidates = myMdmMatchFinderSvc.getMatchedTargets(myFhirContext.getResourceType(theTarget), theTarget, (RequestPartitionId) theTarget.getUserData(Constants.RESOURCE_PARTITION_ID)); @@ -113,8 +113,8 @@ public class FindCandidateByExampleSvc extends BaseCandidateFinder { return retval; } - private List getNoMatchGoldenResourcePids(IBaseResource theBaseResource) { - ResourcePersistentId targetPid = myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), theBaseResource); + private List

getNoMatchGoldenResourcePids(IBaseResource theBaseResource) { + P targetPid = myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), theBaseResource); return myMdmLinkDaoSvc.getMdmLinksBySourcePidAndMatchResult(targetPid, MdmMatchResultEnum.NO_MATCH) .stream() .map(IMdmLink::getGoldenResourcePersistenceId) diff --git a/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/candidate/FindCandidateByLinkSvc.java b/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/candidate/FindCandidateByLinkSvc.java index 13cceae6cd4..f7b147932eb 100644 --- a/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/candidate/FindCandidateByLinkSvc.java +++ b/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/candidate/FindCandidateByLinkSvc.java @@ -21,10 +21,9 @@ package ca.uhn.fhir.jpa.mdm.svc.candidate; */ import ca.uhn.fhir.interceptor.model.RequestPartitionId; -import ca.uhn.fhir.jpa.entity.MdmLink; import ca.uhn.fhir.mdm.api.IMdmLink; import ca.uhn.fhir.mdm.log.Logs; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import org.hl7.fhir.instance.model.api.IAnyResource; import org.slf4j.Logger; import org.springframework.stereotype.Service; @@ -38,7 +37,7 @@ public class FindCandidateByLinkSvc extends BaseCandidateFinder { private static final Logger ourLog = Logs.getMdmTroubleshootingLog(); /** - * Attempt to find a currently matching Golden Resource, based on the presence of an {@link MdmLink} entity. + * Attempt to find a currently matching Golden Resource, based on the presence of an {@link IMdmLink} entity. * * @param theTarget the {@link IAnyResource} that we want to find candidate Golden Resources for. * @return an Optional list of {@link MatchedGoldenResourceCandidate} indicating matches. @@ -47,11 +46,11 @@ public class FindCandidateByLinkSvc extends BaseCandidateFinder { protected List findMatchGoldenResourceCandidates(IAnyResource theTarget) { List retval = new ArrayList<>(); - ResourcePersistentId targetPid = myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), theTarget); + IResourcePersistentId targetPid = myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), theTarget); if (targetPid != null) { Optional oLink = myMdmLinkDaoSvc.getMatchedLinkForSourcePid(targetPid); if (oLink.isPresent()) { - ResourcePersistentId goldenResourcePid = oLink.get().getGoldenResourcePersistenceId(); + IResourcePersistentId goldenResourcePid = oLink.get().getGoldenResourcePersistenceId(); ourLog.debug("Resource previously linked. Using existing link."); retval.add(new MatchedGoldenResourceCandidate(goldenResourcePid, oLink.get())); } diff --git a/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/candidate/MatchedGoldenResourceCandidate.java b/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/candidate/MatchedGoldenResourceCandidate.java index 2fd17ca7a13..5b246bf8f05 100644 --- a/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/candidate/MatchedGoldenResourceCandidate.java +++ b/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/candidate/MatchedGoldenResourceCandidate.java @@ -22,25 +22,24 @@ package ca.uhn.fhir.jpa.mdm.svc.candidate; import ca.uhn.fhir.mdm.api.IMdmLink; import ca.uhn.fhir.mdm.api.MdmMatchOutcome; -import ca.uhn.fhir.jpa.entity.MdmLink; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; public class MatchedGoldenResourceCandidate { - private final ResourcePersistentId myCandidateGoldenResourcePid; + private final IResourcePersistentId myCandidateGoldenResourcePid; private final MdmMatchOutcome myMdmMatchOutcome; - public MatchedGoldenResourceCandidate(ResourcePersistentId theCandidate, MdmMatchOutcome theMdmMatchOutcome) { + public MatchedGoldenResourceCandidate(IResourcePersistentId theCandidate, MdmMatchOutcome theMdmMatchOutcome) { myCandidateGoldenResourcePid = theCandidate; myMdmMatchOutcome = theMdmMatchOutcome; } - public MatchedGoldenResourceCandidate(ResourcePersistentId theGoldenResourcePid, IMdmLink theMdmLink) { + public MatchedGoldenResourceCandidate(IResourcePersistentId theGoldenResourcePid, IMdmLink theMdmLink) { myCandidateGoldenResourcePid = theGoldenResourcePid; myMdmMatchOutcome = new MdmMatchOutcome(theMdmLink.getVector(), theMdmLink.getScore()).setMatchResultEnum(theMdmLink.getMatchResult()); } - public ResourcePersistentId getCandidateGoldenResourcePid() { + public IResourcePersistentId getCandidateGoldenResourcePid() { return myCandidateGoldenResourcePid; } diff --git a/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/candidate/MdmCandidateSearchSvc.java b/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/candidate/MdmCandidateSearchSvc.java index fb5543eae1f..52779781b25 100644 --- a/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/candidate/MdmCandidateSearchSvc.java +++ b/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/candidate/MdmCandidateSearchSvc.java @@ -20,15 +20,15 @@ package ca.uhn.fhir.jpa.mdm.svc.candidate; * #L% */ +import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.interceptor.model.RequestPartitionId; import ca.uhn.fhir.jpa.api.svc.IIdHelperService; -import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.mdm.api.IMdmSettings; import ca.uhn.fhir.mdm.log.Logs; import ca.uhn.fhir.mdm.rules.json.MdmFilterSearchParamJson; import ca.uhn.fhir.mdm.rules.json.MdmResourceSearchParamJson; import ca.uhn.fhir.rest.api.server.IBundleProvider; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import org.hl7.fhir.instance.model.api.IAnyResource; import org.hl7.fhir.instance.model.api.IBaseResource; import org.slf4j.Logger; @@ -75,7 +75,7 @@ public class MdmCandidateSearchSvc { */ @Transactional public Collection findCandidates(String theResourceType, IAnyResource theResource, RequestPartitionId theRequestPartitionId) { - Map matchedPidsToResources = new HashMap<>(); + Map matchedPidsToResources = new HashMap<>(); List filterSearchParams = myMdmSettings.getMdmRules().getCandidateFilterSearchParams(); List filterCriteria = buildFilterQuery(filterSearchParams, theResourceType); List candidateSearchParams = myMdmSettings.getMdmRules().getCandidateSearchParams(); @@ -120,7 +120,7 @@ public class MdmCandidateSearchSvc { * 4. Store all results in `theMatchedPidsToResources` */ @SuppressWarnings("rawtypes") - private void searchForIdsAndAddToMap(String theResourceType, IAnyResource theResource, Map theMatchedPidsToResources, List theFilterCriteria, MdmResourceSearchParamJson resourceSearchParam, RequestPartitionId theRequestPartitionId) { + private void searchForIdsAndAddToMap(String theResourceType, IAnyResource theResource, Map theMatchedPidsToResources, List theFilterCriteria, MdmResourceSearchParamJson resourceSearchParam, RequestPartitionId theRequestPartitionId) { //1. Optional oResourceCriteria = myMdmCandidateSearchCriteriaBuilderSvc.buildResourceQueryString(theResourceType, theResource, theFilterCriteria, resourceSearchParam); if (!oResourceCriteria.isPresent()) { diff --git a/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/candidate/MdmGoldenResourceFindingSvc.java b/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/candidate/MdmGoldenResourceFindingSvc.java index d2040a76b97..9c06a48dcda 100644 --- a/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/candidate/MdmGoldenResourceFindingSvc.java +++ b/hapi-fhir-jpaserver-mdm/src/main/java/ca/uhn/fhir/jpa/mdm/svc/candidate/MdmGoldenResourceFindingSvc.java @@ -22,7 +22,7 @@ package ca.uhn.fhir.jpa.mdm.svc.candidate; import ca.uhn.fhir.jpa.mdm.svc.MdmResourceDaoSvc; import ca.uhn.fhir.mdm.log.Logs; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import org.hl7.fhir.instance.model.api.IAnyResource; import org.hl7.fhir.instance.model.api.IBaseResource; import org.slf4j.Logger; @@ -77,7 +77,7 @@ public class MdmGoldenResourceFindingSvc { } public IAnyResource getGoldenResourceFromMatchedGoldenResourceCandidate(MatchedGoldenResourceCandidate theMatchedGoldenResourceCandidate, String theResourceType) { - ResourcePersistentId goldenResourcePid = theMatchedGoldenResourceCandidate.getCandidateGoldenResourcePid(); + IResourcePersistentId goldenResourcePid = theMatchedGoldenResourceCandidate.getCandidateGoldenResourcePid(); return myMdmResourceDaoSvc.readGoldenResourceByPid(goldenResourcePid, theResourceType); } } diff --git a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/BaseMdmR4Test.java b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/BaseMdmR4Test.java index 5a12957e397..888fccf2f49 100644 --- a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/BaseMdmR4Test.java +++ b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/BaseMdmR4Test.java @@ -19,6 +19,7 @@ import ca.uhn.fhir.jpa.mdm.matcher.IsPossibleMatchWith; import ca.uhn.fhir.jpa.mdm.matcher.IsSameGoldenResourceAs; import ca.uhn.fhir.jpa.mdm.svc.MdmMatchLinkSvc; import ca.uhn.fhir.jpa.model.config.PartitionSettings; +import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.jpa.partition.IPartitionLookupSvc; import ca.uhn.fhir.jpa.partition.SystemRequestDetails; import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; @@ -38,7 +39,6 @@ import ca.uhn.fhir.mdm.util.MdmResourceUtil; import ca.uhn.fhir.model.api.TemporalPrecisionEnum; import ca.uhn.fhir.rest.api.Constants; import ca.uhn.fhir.rest.api.server.IBundleProvider; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; import ca.uhn.fhir.rest.param.TokenParam; import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails; import org.apache.commons.lang3.StringUtils; @@ -113,11 +113,11 @@ abstract public class BaseMdmR4Test extends BaseJpaR4Test { @Autowired protected MdmResourceMatcherSvc myMdmResourceMatcherSvc; @Autowired - protected IMdmLinkDao myMdmLinkDao; + protected IMdmLinkDao myMdmLinkDao; @Autowired - protected MdmLinkDaoSvc myMdmLinkDaoSvc; + protected MdmLinkDaoSvc myMdmLinkDaoSvc; @Autowired - protected IIdHelperService myIdHelperService; + protected IIdHelperService myIdHelperService; @Autowired protected IMdmSettings myMdmSettings; @Autowired @@ -361,10 +361,10 @@ abstract public class BaseMdmR4Test extends BaseJpaR4Test { String resourceType = theBaseResource.getIdElement().getResourceType(); IFhirResourceDao relevantDao = myDaoRegistry.getResourceDao(resourceType); - Optional matchedLinkForTargetPid = myMdmLinkDaoSvc.getMatchedLinkForSourcePid(runInTransaction(() -> myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), theBaseResource))); + Optional matchedLinkForTargetPid = myMdmLinkDaoSvc.getMatchedLinkForSourcePid(runInTransaction(() -> myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), theBaseResource))); if (matchedLinkForTargetPid.isPresent()) { - Long goldenResourcePid = matchedLinkForTargetPid.get().getGoldenResourcePersistenceId().getIdAsLong(); - return (T) relevantDao.readByPid(new ResourcePersistentId(goldenResourcePid)); + JpaPid jpaPid = matchedLinkForTargetPid.get().getGoldenResourcePersistenceId(); + return (T) relevantDao.readByPid(jpaPid); } else { return null; } @@ -372,7 +372,7 @@ abstract public class BaseMdmR4Test extends BaseJpaR4Test { protected T getTargetResourceFromMdmLink(IMdmLink theMdmLink, String theResourceType) { IFhirResourceDao resourceDao = myDaoRegistry.getResourceDao(theResourceType); - return (T) resourceDao.readByPid(new ResourcePersistentId(theMdmLink.getGoldenResourcePersistenceId().getIdAsLong())); + return (T) resourceDao.readByPid(theMdmLink.getGoldenResourcePersistenceId()); } protected Patient addExternalEID(Patient thePatient, String theEID) { diff --git a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/config/TestMdmConfigR4.java b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/config/TestMdmConfigR4.java index 1eca1188a91..97b708d98ba 100644 --- a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/config/TestMdmConfigR4.java +++ b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/config/TestMdmConfigR4.java @@ -1,10 +1,8 @@ package ca.uhn.fhir.jpa.mdm.config; -import ca.uhn.fhir.jpa.mdm.dao.JpaMdmLinkImplFactory; import ca.uhn.fhir.jpa.mdm.helper.MdmHelperR4; import ca.uhn.fhir.jpa.subscription.channel.config.SubscriptionChannelConfig; import ca.uhn.fhir.jpa.subscription.submit.config.SubscriptionSubmitterConfig; -import ca.uhn.fhir.mdm.dao.IMdmLinkImplFactory; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Import; diff --git a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/dao/MdmLinkDaoSvcTest.java b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/dao/MdmLinkDaoSvcTest.java index cdf261e6f30..49646c4e7ec 100644 --- a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/dao/MdmLinkDaoSvcTest.java +++ b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/dao/MdmLinkDaoSvcTest.java @@ -1,16 +1,15 @@ package ca.uhn.fhir.jpa.mdm.dao; import ca.uhn.fhir.interceptor.model.RequestPartitionId; -import ca.uhn.fhir.jpa.dao.data.IMdmLinkJpaRepository; import ca.uhn.fhir.jpa.entity.MdmLink; import ca.uhn.fhir.jpa.mdm.BaseMdmR4Test; +import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.jpa.util.TestUtil; import ca.uhn.fhir.mdm.api.IMdmLink; import ca.uhn.fhir.mdm.api.MdmLinkSourceEnum; import ca.uhn.fhir.mdm.api.MdmMatchResultEnum; import ca.uhn.fhir.mdm.model.MdmPidTuple; import ca.uhn.fhir.mdm.rules.json.MdmRulesJson; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; import org.hl7.fhir.r4.model.Patient; import org.junit.jupiter.api.Test; @@ -45,11 +44,11 @@ public class MdmLinkDaoSvcTest extends BaseMdmR4Test { @Test public void testUpdate() { - IMdmLink createdLink = myMdmLinkDaoSvc.save(createResourcesAndBuildTestMDMLink()); + MdmLink createdLink = myMdmLinkDaoSvc.save(createResourcesAndBuildTestMDMLink()); assertThat(createdLink.getLinkSource(), is(MdmLinkSourceEnum.MANUAL)); TestUtil.sleepOneClick(); createdLink.setLinkSource(MdmLinkSourceEnum.AUTO); - IMdmLink updatedLink = myMdmLinkDaoSvc.save(createdLink); + MdmLink updatedLink = myMdmLinkDaoSvc.save(createdLink); assertNotEquals(updatedLink.getCreated(), updatedLink.getUpdated()); } @@ -80,14 +79,14 @@ public class MdmLinkDaoSvcTest extends BaseMdmR4Test { List expectedExpandedPids = mdmLinks.stream().map(MdmLink::getSourcePid).collect(Collectors.toList()); //SUT - List lists = runInTransaction(()->myMdmLinkDao.expandPidsBySourcePidAndMatchResult(new ResourcePersistentId(mdmLinks.get(0).getSourcePid()), MdmMatchResultEnum.MATCH)); + List> lists = runInTransaction(() -> myMdmLinkDao.expandPidsBySourcePidAndMatchResult(JpaPid.fromId(mdmLinks.get(0).getSourcePid()), MdmMatchResultEnum.MATCH)); assertThat(lists, hasSize(10)); lists.stream() .forEach(tuple -> { - assertThat(tuple.getGoldenPid().getIdAsLong(), is(equalTo(golden.getIdElement().getIdPartAsLong()))); - assertThat(tuple.getSourcePid().getIdAsLong(), is(in(expectedExpandedPids))); + assertThat(tuple.getGoldenPid().getId(), is(equalTo(myIdHelperService.getPidOrThrowException(golden).getId()))); + assertThat(tuple.getSourcePid().getId(), is(in(expectedExpandedPids))); }); } @@ -99,9 +98,9 @@ public class MdmLinkDaoSvcTest extends BaseMdmR4Test { mdmLink.setMatchResult(theMdmMatchResultEnum); mdmLink.setCreated(new Date()); mdmLink.setUpdated(new Date()); - mdmLink.setGoldenResourcePersistenceId(new ResourcePersistentId(thePatientPid)); + mdmLink.setGoldenResourcePersistenceId(JpaPid.fromId(thePatientPid)); mdmLink.setSourcePersistenceId(runInTransaction(()->myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), patient))); - MdmLink saved= (MdmLink) myMdmLinkDao.save(mdmLink); + MdmLink saved= myMdmLinkDao.save(mdmLink); return saved; } } diff --git a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/helper/MdmLinkHelper.java b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/helper/MdmLinkHelper.java index da30f592880..28cfb69fd50 100644 --- a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/helper/MdmLinkHelper.java +++ b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/helper/MdmLinkHelper.java @@ -8,6 +8,7 @@ import ca.uhn.fhir.jpa.mdm.dao.MdmLinkDaoSvc; import ca.uhn.fhir.jpa.mdm.helper.testmodels.MDMLinkResults; import ca.uhn.fhir.jpa.mdm.helper.testmodels.MDMState; import ca.uhn.fhir.jpa.mdm.helper.testmodels.MdmTestLinkExpression; +import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.jpa.partition.SystemRequestDetails; import ca.uhn.fhir.mdm.api.MdmLinkSourceEnum; import ca.uhn.fhir.mdm.api.MdmMatchOutcome; @@ -16,7 +17,6 @@ import ca.uhn.fhir.mdm.dao.IMdmLinkDao; import ca.uhn.fhir.mdm.model.MdmTransactionContext; import ca.uhn.fhir.mdm.util.MdmResourceUtil; import ca.uhn.fhir.model.primitive.IdDt; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; import org.hl7.fhir.r4.model.Identifier; import org.hl7.fhir.r4.model.Patient; import org.slf4j.Logger; @@ -49,10 +49,10 @@ public class MdmLinkHelper { @Autowired private IFhirResourceDao myPatientDao; @Autowired - private MdmLinkDaoSvc myMdmLinkDaoSvc; + private MdmLinkDaoSvc myMdmLinkDaoSvc; @SuppressWarnings("rawtypes") @Autowired - private IMdmLinkDao myMdmLinkDao; + private IMdmLinkDao myMdmLinkDao; @Autowired private IdHelperService myIdHelperService; @@ -81,7 +81,7 @@ public class MdmLinkHelper { * These links will be returned in an MDMLinkResults object, in case * they are needed. */ - public MDMLinkResults setup(MDMState theState) { + public MDMLinkResults setup(MDMState theState) { MDMLinkResults results = new MDMLinkResults(); List inputExpressions = theState.getParsedInputState(); @@ -122,7 +122,7 @@ public class MdmLinkHelper { return results; } - private void createIfNeeded(MDMState theState, String thePatientId) { + private void createIfNeeded(MDMState theState, String thePatientId) { Patient patient = theState.getParameter(thePatientId); if (patient == null) { // if it doesn't exist, create it @@ -131,7 +131,7 @@ public class MdmLinkHelper { } } - private Patient createPatientAndTags(String theId, MDMState theState) { + private Patient createPatientAndTags(String theId, MDMState theState) { Patient patient = new Patient(); patient.setActive(true); // all mdm patients must be active @@ -150,11 +150,11 @@ public class MdmLinkHelper { DaoMethodOutcome outcome = myPatientDao.update(patient, SystemRequestDetails.forAllPartitions()); Patient outputPatient = (Patient) outcome.getResource(); - theState.addPID(theId, outcome.getPersistentId()); + theState.addPID(theId, (JpaPid) outcome.getPersistentId()); return outputPatient; } - public void validateResults(MDMState theState) { + public void validateResults(MDMState theState) { List expectedOutputStates = theState.getParsedOutputState(); StringBuilder outputStateSB = new StringBuilder(); @@ -222,9 +222,9 @@ public class MdmLinkHelper { MdmLink theLink, Patient theResource, Side theSide, - MDMState theState + MDMState theState ) { - ResourcePersistentId resourcePid = theState.getPID(theResource.getIdElement().getIdPart()); + JpaPid resourcePid = theState.getPID(theResource.getIdElement().getIdPart()); long linkPid; if (theSide == Side.LHS) { @@ -235,10 +235,10 @@ public class MdmLinkHelper { linkPid = theLink.getSourcePid(); } - return linkPid == resourcePid.getIdAsLong(); + return linkPid == resourcePid.getId(); } - private String createStateFromLink(MdmLink theLink, MDMState theState) { + private String createStateFromLink(MdmLink theLink, MDMState theState) { String LHS = ""; String RHS = ""; for (Map.Entry set : theState.getParameterToValue().entrySet()) { diff --git a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/helper/testmodels/MDMState.java b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/helper/testmodels/MDMState.java index 2ba1c90da30..0e1c32d08e5 100644 --- a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/helper/testmodels/MDMState.java +++ b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/helper/testmodels/MDMState.java @@ -1,7 +1,7 @@ package ca.uhn.fhir.jpa.mdm.helper.testmodels; import ca.uhn.fhir.jpa.entity.MdmLink; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import org.testcontainers.shaded.com.google.common.collect.HashMultimap; import org.testcontainers.shaded.com.google.common.collect.Multimap; @@ -10,7 +10,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -public class MDMState { +public class MDMState { /** * Collection of Parameter keys -> values to use * @@ -58,14 +58,14 @@ public class MDMState { /** * Map of forcedId -> resource persistent id for each resource created */ - private final Map myForcedIdToPID = new HashMap<>(); + private final Map myForcedIdToPID = new HashMap<>(); - public void addPID(String theForcedId, ResourcePersistentId thePid) { + public void addPID(String theForcedId, P thePid) { assert !myForcedIdToPID.containsKey(theForcedId); myForcedIdToPID.put(theForcedId, thePid); } - public ResourcePersistentId getPID(String theForcedId) { + public P getPID(String theForcedId) { return myForcedIdToPID.get(theForcedId); } @@ -76,7 +76,7 @@ public class MDMState { return myActualOutcomeLinks; } - public MDMState addLinksForResource(T theResource, MdmLink... theLinks) { + public MDMState addLinksForResource(T theResource, MdmLink... theLinks) { for (MdmLink link : theLinks) { getActualOutcomeLinks().put(theResource, link); } @@ -98,7 +98,7 @@ public class MDMState { return getParameterToValue().get(theKey); } - public MDMState addParameter(String myParamKey, T myValue) { + public MDMState addParameter(String myParamKey, T myValue) { getParameterToValue().put(myParamKey, myValue); return this; } @@ -111,7 +111,7 @@ public class MDMState { return myInputState; } - public MDMState setInputState(String theInputState) { + public MDMState setInputState(String theInputState) { myInputState = theInputState; return this; } @@ -143,7 +143,7 @@ public class MDMState { return myOutputLinks; } - public MDMState setOutputState(String theOutputState) { + public MDMState setOutputState(String theOutputState) { myOutputState = theOutputState; return this; } diff --git a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/interceptor/MdmSearchExpandingInterceptorIT.java b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/interceptor/MdmSearchExpandingInterceptorIT.java index c71e6017814..c2d0aca065e 100644 --- a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/interceptor/MdmSearchExpandingInterceptorIT.java +++ b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/interceptor/MdmSearchExpandingInterceptorIT.java @@ -1,19 +1,19 @@ package ca.uhn.fhir.jpa.mdm.interceptor; import ca.uhn.fhir.jpa.api.config.DaoConfig; -import ca.uhn.fhir.jpa.api.dao.PatientEverythingParameters; import ca.uhn.fhir.jpa.api.dao.IFhirResourceDaoPatient; +import ca.uhn.fhir.jpa.api.dao.PatientEverythingParameters; import ca.uhn.fhir.jpa.api.model.DaoMethodOutcome; import ca.uhn.fhir.jpa.entity.MdmLink; import ca.uhn.fhir.jpa.mdm.BaseMdmR4Test; import ca.uhn.fhir.jpa.mdm.helper.MdmHelperConfig; import ca.uhn.fhir.jpa.mdm.helper.MdmHelperR4; +import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; import ca.uhn.fhir.mdm.api.MdmConstants; import ca.uhn.fhir.model.primitive.IdDt; 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.param.ReferenceOrListParam; import ca.uhn.fhir.rest.param.ReferenceParam; import ca.uhn.fhir.rest.param.TokenOrListParam; @@ -147,7 +147,7 @@ public class MdmSearchExpandingInterceptorIT extends BaseMdmR4Test { assertThat(search.size(), is(equalTo(4))); List all = myMdmLinkDao.findAll(); Long goldenPid = all.get(0).getGoldenResourcePid(); - IIdType goldenId = myIdHelperService.translatePidIdToForcedId(myFhirContext, "Patient", new ResourcePersistentId(goldenPid)); + IIdType goldenId = myIdHelperService.translatePidIdToForcedId(myFhirContext, "Patient", JpaPid.fromId(goldenPid)); //Verify that expansion by the golden resource id resolves down to everything its links have. SearchParameterMap goldenSpMap = new SearchParameterMap(); @@ -182,7 +182,7 @@ public class MdmSearchExpandingInterceptorIT extends BaseMdmR4Test { assertThat(search.size(), is(equalTo(4))); List all = myMdmLinkDao.findAll(); Long goldenPid = all.get(0).getGoldenResourcePid(); - IIdType goldenId = myIdHelperService.translatePidIdToForcedId(myFhirContext, "Patient", new ResourcePersistentId(goldenPid)); + IIdType goldenId = myIdHelperService.translatePidIdToForcedId(myFhirContext, "Patient", JpaPid.fromId(goldenPid)); //Verify that expansion by the golden resource id resolves down to everything its links have. SearchParameterMap goldenSpMap = new SearchParameterMap(); diff --git a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/interceptor/MdmStorageInterceptorIT.java b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/interceptor/MdmStorageInterceptorIT.java index 33350a027c9..1d1bc46def4 100644 --- a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/interceptor/MdmStorageInterceptorIT.java +++ b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/interceptor/MdmStorageInterceptorIT.java @@ -7,12 +7,11 @@ import ca.uhn.fhir.jpa.entity.MdmLink; import ca.uhn.fhir.jpa.mdm.BaseMdmR4Test; import ca.uhn.fhir.jpa.mdm.helper.MdmHelperConfig; import ca.uhn.fhir.jpa.mdm.helper.MdmHelperR4; +import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; -import ca.uhn.fhir.mdm.api.IMdmLink; import ca.uhn.fhir.mdm.model.CanonicalEID; import ca.uhn.fhir.mdm.rules.config.MdmSettings; import ca.uhn.fhir.rest.api.server.IBundleProvider; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; import ca.uhn.fhir.rest.param.ReferenceParam; import ca.uhn.fhir.rest.server.TransactionLogMessages; import ca.uhn.fhir.rest.server.exceptions.ForbiddenOperationException; @@ -59,7 +58,7 @@ public class MdmStorageInterceptorIT extends BaseMdmR4Test { @Autowired public MdmHelperR4 myMdmHelper; @Autowired - private IIdHelperService myIdHelperService; + private IIdHelperService myIdHelperService; @Override @@ -212,9 +211,9 @@ public class MdmStorageInterceptorIT extends BaseMdmR4Test { patient.setId(patientId); // Updating a Golden Resource Patient who was created via MDM should fail. - IMdmLink mdmLink = runInTransaction(() -> myMdmLinkDaoSvc.getMatchedLinkForSourcePid(myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), patient)).orElseThrow(() -> new IllegalStateException())); - Long sourcePatientPid = mdmLink.getGoldenResourcePersistenceId().getIdAsLong(); - Patient goldenResourcePatient = myPatientDao.readByPid(new ResourcePersistentId(sourcePatientPid)); + MdmLink mdmLink = runInTransaction(() -> myMdmLinkDaoSvc.getMatchedLinkForSourcePid(myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), patient)).orElseThrow(() -> new IllegalStateException())); + Long sourcePatientPid = mdmLink.getGoldenResourcePersistenceId().getId(); + Patient goldenResourcePatient = myPatientDao.readByPid(JpaPid.fromId(sourcePatientPid)); goldenResourcePatient.setGender(Enumerations.AdministrativeGender.MALE); try { myMdmHelper.doUpdateResource(goldenResourcePatient, true); diff --git a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/matcher/BaseGoldenResourceMatcher.java b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/matcher/BaseGoldenResourceMatcher.java index 7bcbdab19f0..92cbc41a334 100644 --- a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/matcher/BaseGoldenResourceMatcher.java +++ b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/matcher/BaseGoldenResourceMatcher.java @@ -6,7 +6,7 @@ import ca.uhn.fhir.jpa.mdm.dao.MdmLinkDaoSvc; import ca.uhn.fhir.mdm.api.IMdmLink; import ca.uhn.fhir.mdm.api.MdmMatchResultEnum; import ca.uhn.fhir.mdm.util.MdmResourceUtil; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import org.hamcrest.TypeSafeMatcher; import org.hl7.fhir.instance.model.api.IAnyResource; import org.slf4j.Logger; @@ -35,8 +35,8 @@ public abstract class BaseGoldenResourceMatcher extends TypeSafeMatcher getPossibleMatchedGoldenResourcePidsFromTarget(IAnyResource theBaseResource) { + protected List getPossibleMatchedGoldenResourcePidsFromTarget(IAnyResource theBaseResource) { return getMdmLinksForTarget(theBaseResource, MdmMatchResultEnum.POSSIBLE_MATCH) .stream() .map(IMdmLink::getGoldenResourcePersistenceId).collect(Collectors.toList()); @@ -71,7 +71,7 @@ public abstract class BaseGoldenResourceMatcher extends TypeSafeMatcher getMdmLinksForTarget(IAnyResource theTargetResource, MdmMatchResultEnum theMatchResult) { - ResourcePersistentId pidOrNull = myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), theTargetResource); + IResourcePersistentId pidOrNull = myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), theTargetResource); List matchLinkForTarget = myMdmLinkDaoSvc.getMdmLinksBySourcePidAndMatchResult(pidOrNull, theMatchResult); if (!matchLinkForTarget.isEmpty()) { return matchLinkForTarget; diff --git a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/matcher/IsLinkedTo.java b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/matcher/IsLinkedTo.java index 18f9da94794..5c1568d11e4 100644 --- a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/matcher/IsLinkedTo.java +++ b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/matcher/IsLinkedTo.java @@ -2,7 +2,7 @@ package ca.uhn.fhir.jpa.mdm.matcher; import ca.uhn.fhir.jpa.api.svc.IIdHelperService; import ca.uhn.fhir.jpa.mdm.dao.MdmLinkDaoSvc; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import org.hamcrest.Description; import org.hamcrest.Matcher; import org.hl7.fhir.instance.model.api.IAnyResource; @@ -16,8 +16,8 @@ import java.util.stream.Collectors; */ public class IsLinkedTo extends BaseGoldenResourceMatcher { - private List baseResourceGoldenResourcePids; - private ResourcePersistentId incomingResourceGoldenResourcePid; + private List baseResourceGoldenResourcePids; + private IResourcePersistentId incomingResourceGoldenResourcePid; protected IsLinkedTo(IIdHelperService theIdHelperService, MdmLinkDaoSvc theMdmLinkDaoSvc, IAnyResource... theBaseResource) { super(theIdHelperService, theMdmLinkDaoSvc, theBaseResource); diff --git a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/matcher/IsPossibleDuplicateOf.java b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/matcher/IsPossibleDuplicateOf.java index bb811ef11c7..ce560cf4c4e 100644 --- a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/matcher/IsPossibleDuplicateOf.java +++ b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/matcher/IsPossibleDuplicateOf.java @@ -4,7 +4,7 @@ import ca.uhn.fhir.jpa.api.svc.IIdHelperService; import ca.uhn.fhir.jpa.mdm.dao.MdmLinkDaoSvc; import ca.uhn.fhir.mdm.api.IMdmLink; import ca.uhn.fhir.mdm.api.MdmMatchResultEnum; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import org.hamcrest.Description; import org.hamcrest.Matcher; import org.hl7.fhir.instance.model.api.IAnyResource; @@ -19,7 +19,7 @@ public class IsPossibleDuplicateOf extends BaseGoldenResourceMatcher { * Matcher with tells us if there is an MdmLink with between these two resources that are considered POSSIBLE DUPLICATE. * For use only on GoldenResource. */ - private ResourcePersistentId incomingGoldenResourcePid; + private IResourcePersistentId incomingGoldenResourcePid; protected IsPossibleDuplicateOf(IIdHelperService theIdHelperService, MdmLinkDaoSvc theMdmLinkDaoSvc, IAnyResource... theBaseResource) { super(theIdHelperService, theMdmLinkDaoSvc, theBaseResource); @@ -29,7 +29,7 @@ public class IsPossibleDuplicateOf extends BaseGoldenResourceMatcher { protected boolean matchesSafely(IAnyResource theIncomingResource) { incomingGoldenResourcePid = getMatchedResourcePidFromResource(theIncomingResource); - List goldenResourcePidsToMatch = myBaseResources.stream() + List goldenResourcePidsToMatch = myBaseResources.stream() .map(this::getMatchedResourcePidFromResource) .collect(Collectors.toList()); diff --git a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/matcher/IsPossibleLinkedTo.java b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/matcher/IsPossibleLinkedTo.java index f1bfd192f95..226f83b17dd 100644 --- a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/matcher/IsPossibleLinkedTo.java +++ b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/matcher/IsPossibleLinkedTo.java @@ -3,7 +3,7 @@ package ca.uhn.fhir.jpa.mdm.matcher; import ca.uhn.fhir.interceptor.model.RequestPartitionId; import ca.uhn.fhir.jpa.api.svc.IIdHelperService; import ca.uhn.fhir.jpa.mdm.dao.MdmLinkDaoSvc; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import org.hamcrest.Description; import org.hamcrest.Matcher; import org.hl7.fhir.instance.model.api.IAnyResource; @@ -17,8 +17,8 @@ import java.util.stream.Collectors; */ public class IsPossibleLinkedTo extends BaseGoldenResourceMatcher { - private List baseResourceGoldenResourcePids; - private ResourcePersistentId incomingResourceGoldenResourcePid; + private List baseResourceGoldenResourcePids; + private IResourcePersistentId incomingResourceGoldenResourcePid; protected IsPossibleLinkedTo(IIdHelperService theIdHelperService, MdmLinkDaoSvc theMdmLinkDaoSvc, IAnyResource... theTargetResources) { super(theIdHelperService, theMdmLinkDaoSvc, theTargetResources); diff --git a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/matcher/IsPossibleMatchWith.java b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/matcher/IsPossibleMatchWith.java index 4ccadbe2def..ecdae0a4f2d 100644 --- a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/matcher/IsPossibleMatchWith.java +++ b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/matcher/IsPossibleMatchWith.java @@ -4,7 +4,7 @@ import ca.uhn.fhir.jpa.api.svc.IIdHelperService; import ca.uhn.fhir.jpa.mdm.dao.MdmLinkDaoSvc; import ca.uhn.fhir.mdm.api.IMdmLink; import ca.uhn.fhir.mdm.api.MdmMatchResultEnum; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import org.hamcrest.Description; import org.hamcrest.Matcher; import org.hl7.fhir.instance.model.api.IAnyResource; @@ -26,7 +26,7 @@ public class IsPossibleMatchWith extends BaseGoldenResourceMatcher { protected boolean matchesSafely(IAnyResource theIncomingResource) { List mdmLinks = getMdmLinksForTarget(theIncomingResource, MdmMatchResultEnum.POSSIBLE_MATCH); - List goldenResourcePidsToMatch = myBaseResources.stream() + List goldenResourcePidsToMatch = myBaseResources.stream() .map(this::getMatchedResourcePidFromResource) .filter(Objects::nonNull) .collect(Collectors.toList()); @@ -37,7 +37,7 @@ public class IsPossibleMatchWith extends BaseGoldenResourceMatcher { .collect(Collectors.toList()); } - List mdmLinkGoldenResourcePids = mdmLinks + List mdmLinkGoldenResourcePids = mdmLinks .stream().map(IMdmLink::getGoldenResourcePersistenceId) .collect(Collectors.toList()); diff --git a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/matcher/IsSameGoldenResourceAs.java b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/matcher/IsSameGoldenResourceAs.java index 24ecc201afd..9493c511af2 100644 --- a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/matcher/IsSameGoldenResourceAs.java +++ b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/matcher/IsSameGoldenResourceAs.java @@ -2,7 +2,7 @@ package ca.uhn.fhir.jpa.mdm.matcher; import ca.uhn.fhir.jpa.api.svc.IIdHelperService; import ca.uhn.fhir.jpa.mdm.dao.MdmLinkDaoSvc; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import org.hamcrest.Description; import org.hamcrest.Matcher; import org.hl7.fhir.instance.model.api.IAnyResource; @@ -12,8 +12,8 @@ import java.util.stream.Collectors; public class IsSameGoldenResourceAs extends BaseGoldenResourceMatcher { - private List goldenResourcePidsToMatch; - private ResourcePersistentId incomingGoldenResourcePid; + private List goldenResourcePidsToMatch; + private IResourcePersistentId incomingGoldenResourcePid; public IsSameGoldenResourceAs(IIdHelperService theIdHelperService, MdmLinkDaoSvc theMdmLinkDaoSvc, IAnyResource... theBaseResource) { super(theIdHelperService, theMdmLinkDaoSvc, theBaseResource); diff --git a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/provider/MdmProviderQueryLinkR4Test.java b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/provider/MdmProviderQueryLinkR4Test.java index d5e4ad6d394..1a77dd4d3e0 100644 --- a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/provider/MdmProviderQueryLinkR4Test.java +++ b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/provider/MdmProviderQueryLinkR4Test.java @@ -3,11 +3,11 @@ package ca.uhn.fhir.jpa.mdm.provider; import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.interceptor.model.RequestPartitionId; import ca.uhn.fhir.jpa.entity.MdmLink; +import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.jpa.util.CircularQueueCaptureQueriesListener; import ca.uhn.fhir.mdm.api.MdmLinkSourceEnum; import ca.uhn.fhir.mdm.api.MdmMatchResultEnum; import ca.uhn.fhir.model.primitive.IdDt; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; import ca.uhn.fhir.util.StopWatch; @@ -58,10 +58,10 @@ public class MdmProviderQueryLinkR4Test extends BaseLinkR4Test { myLinkSource = new StringType(MdmLinkSourceEnum.AUTO.name()); Patient sourcePatient1 = createGoldenPatient(); myGoldenResource1Id = new StringType(sourcePatient1.getIdElement().toVersionless().getValue()); - ResourcePersistentId sourcePatient1Pid = runInTransaction(()->myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), sourcePatient1)); + JpaPid sourcePatient1Pid = runInTransaction(()->myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), sourcePatient1)); Patient sourcePatient2 = createGoldenPatient(); myGoldenResource2Id = new StringType(sourcePatient2.getIdElement().toVersionless().getValue()); - ResourcePersistentId sourcePatient2Pid = runInTransaction(()->myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), sourcePatient2)); + JpaPid sourcePatient2Pid = runInTransaction(()->myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), sourcePatient2)); MdmLink possibleDuplicateMdmLink = (MdmLink) myMdmLinkDaoSvc.newMdmLink(); possibleDuplicateMdmLink.setGoldenResourcePersistenceId(sourcePatient1Pid); diff --git a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/svc/MdmGoldenResourceMergerSvcTest.java b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/svc/MdmGoldenResourceMergerSvcTest.java index 1a3128dce00..25c0306c6b1 100644 --- a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/svc/MdmGoldenResourceMergerSvcTest.java +++ b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/svc/MdmGoldenResourceMergerSvcTest.java @@ -6,6 +6,7 @@ import ca.uhn.fhir.jpa.entity.MdmLink; import ca.uhn.fhir.jpa.mdm.BaseMdmR4Test; import ca.uhn.fhir.jpa.mdm.helper.MdmLinkHelper; import ca.uhn.fhir.jpa.mdm.helper.testmodels.MDMState; +import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.mdm.api.IGoldenResourceMergerSvc; import ca.uhn.fhir.mdm.api.IMdmLink; import ca.uhn.fhir.mdm.api.MdmLinkSourceEnum; @@ -134,7 +135,7 @@ public class MdmGoldenResourceMergerSvcTest extends BaseMdmR4Test { String inputState = """ GP1, AUTO, POSSIBLE_DUPLICATE, GP2 """; - MDMState state = new MDMState<>(); + MDMState state = new MDMState<>(); state.setInputState(inputState); myMdmLinkHelper.setup(state); @@ -159,7 +160,7 @@ public class MdmGoldenResourceMergerSvcTest extends BaseMdmR4Test { String inputState = """ GP1, AUTO, POSSIBLE_DUPLICATE, GP2 """; - MDMState state = new MDMState<>(); + MDMState state = new MDMState<>(); state.setInputState(inputState); myMdmLinkHelper.setup(state); @@ -259,7 +260,7 @@ public class MdmGoldenResourceMergerSvcTest extends BaseMdmR4Test { GP2, MANUAL, MATCH, P1 GP1, AUTO, POSSIBLE_MATCH, P1 """; - MDMState state = new MDMState<>(); + MDMState state = new MDMState<>(); state.setInputState(inputState); myMdmLinkHelper.setup(state); @@ -388,7 +389,7 @@ public class MdmGoldenResourceMergerSvcTest extends BaseMdmR4Test { GP1, AUTO, POSSIBLE_MATCH, P3 GP2, AUTO, POSSIBLE_MATCH, P1 """; - MDMState state = new MDMState<>(); + MDMState state = new MDMState<>(); state.setInputState(inputState); myMdmLinkHelper.setup(state); @@ -425,7 +426,7 @@ public class MdmGoldenResourceMergerSvcTest extends BaseMdmR4Test { GP2, AUTO, POSSIBLE_MATCH, P2 GP2, AUTO, POSSIBLE_MATCH, P3 """; - MDMState state = new MDMState<>(); + MDMState state = new MDMState<>(); state.setInputState(inputState); myMdmLinkHelper.setup(state); @@ -459,7 +460,7 @@ public class MdmGoldenResourceMergerSvcTest extends BaseMdmR4Test { GP2, AUTO, POSSIBLE_MATCH, P2 GP2, AUTO, POSSIBLE_MATCH, P3 """; - MDMState state = new MDMState<>(); + MDMState state = new MDMState<>(); state.setInputState(inputState); myMdmLinkHelper.setup(state); @@ -486,7 +487,7 @@ public class MdmGoldenResourceMergerSvcTest extends BaseMdmR4Test { GP2, AUTO, POSSIBLE_MATCH, P2 GP2, AUTO, POSSIBLE_MATCH, P3 """; - MDMState state = new MDMState<>(); + MDMState state = new MDMState<>(); state.setInputState(inputState); myMdmLinkHelper.setup(state); diff --git a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/svc/MdmLinkCreateSvcImplTest.java b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/svc/MdmLinkCreateSvcImplTest.java index 1c51a67aa8b..548c8662096 100644 --- a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/svc/MdmLinkCreateSvcImplTest.java +++ b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/svc/MdmLinkCreateSvcImplTest.java @@ -5,6 +5,7 @@ import ca.uhn.fhir.jpa.api.svc.IIdHelperService; import ca.uhn.fhir.jpa.entity.MdmLink; import ca.uhn.fhir.jpa.mdm.dao.MdmLinkDaoSvc; import ca.uhn.fhir.jpa.mdm.util.MdmPartitionHelper; +import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.mdm.api.IMdmLink; import ca.uhn.fhir.mdm.api.IMdmSettings; import ca.uhn.fhir.mdm.api.MdmLinkSourceEnum; @@ -12,7 +13,7 @@ import ca.uhn.fhir.mdm.api.MdmMatchResultEnum; import ca.uhn.fhir.mdm.model.MdmTransactionContext; import ca.uhn.fhir.mdm.util.MdmResourceUtil; import ca.uhn.fhir.mdm.util.MessageHelper; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.BaseResourcePersistentId; import org.hl7.fhir.r4.model.Patient; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -73,12 +74,12 @@ class MdmLinkCreateSvcImplTest { @BeforeEach public void setup() { - ResourcePersistentId goldenId = new ResourcePersistentId(1L); - ResourcePersistentId sourceId = new ResourcePersistentId(2L); + JpaPid goldenId = JpaPid.fromId(1L); + JpaPid sourceId = JpaPid.fromId(2L); when(myIdHelperService.getPidOrThrowException(any())) .thenReturn(goldenId, sourceId); - when(myMdmLinkDaoSvc.getLinkByGoldenResourcePidAndSourceResourcePid(any(ResourcePersistentId.class), any(ResourcePersistentId.class))).thenReturn(Optional.empty()); - when(myMdmLinkDaoSvc.getMdmLinksBySourcePidAndMatchResult(any(ResourcePersistentId.class), any())).thenReturn(new ArrayList<>()); + when(myMdmLinkDaoSvc.getLinkByGoldenResourcePidAndSourceResourcePid(any(BaseResourcePersistentId.class), any(BaseResourcePersistentId.class))).thenReturn(Optional.empty()); + when(myMdmLinkDaoSvc.getMdmLinksBySourcePidAndMatchResult(any(BaseResourcePersistentId.class), any())).thenReturn(new ArrayList<>()); MdmLink resultMdmLink = new MdmLink(); resultMdmLink.setGoldenResourcePersistenceId(goldenId).setSourcePersistenceId(sourceId); diff --git a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/svc/MdmLinkSvcTest.java b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/svc/MdmLinkSvcTest.java index fd4787210c5..3e96395dc6e 100644 --- a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/svc/MdmLinkSvcTest.java +++ b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/svc/MdmLinkSvcTest.java @@ -1,18 +1,17 @@ package ca.uhn.fhir.jpa.mdm.svc; -import ca.uhn.fhir.interceptor.model.RequestPartitionId; import ca.uhn.fhir.i18n.Msg; +import ca.uhn.fhir.interceptor.model.RequestPartitionId; import ca.uhn.fhir.jpa.dao.expunge.ExpungeEverythingService; -import ca.uhn.fhir.jpa.dao.expunge.IExpungeEverythingService; import ca.uhn.fhir.jpa.entity.MdmLink; import ca.uhn.fhir.jpa.mdm.BaseMdmR4Test; +import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.mdm.api.IMdmLink; import ca.uhn.fhir.mdm.api.IMdmLinkSvc; import ca.uhn.fhir.mdm.api.MdmLinkSourceEnum; import ca.uhn.fhir.mdm.api.MdmMatchOutcome; import ca.uhn.fhir.mdm.api.MdmMatchResultEnum; import ca.uhn.fhir.rest.api.Constants; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; import org.hamcrest.Matchers; import org.hl7.fhir.r4.model.IdType; @@ -90,10 +89,10 @@ public class MdmLinkSvcTest extends BaseMdmR4Test { Patient goldenPatient1 = createGoldenPatient(); Patient goldenPatient2 = createGoldenPatient(); - ResourcePersistentId goldenPatient1Pid = runInTransaction(()->myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), goldenPatient1)); - ResourcePersistentId goldenPatient2Pid = runInTransaction(()->myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), goldenPatient2)); - assertFalse(myMdmLinkDaoSvc.getLinkByGoldenResourcePidAndSourceResourcePid(goldenPatient1Pid.getIdAsLong(), goldenPatient2Pid.getIdAsLong()).isPresent()); - assertFalse(myMdmLinkDaoSvc.getLinkByGoldenResourcePidAndSourceResourcePid(goldenPatient2Pid.getIdAsLong(), goldenPatient1Pid.getIdAsLong()).isPresent()); + JpaPid goldenPatient1Pid = runInTransaction(()->myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), goldenPatient1)); + JpaPid goldenPatient2Pid = runInTransaction(()->myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), goldenPatient2)); + assertFalse(myMdmLinkDaoSvc.getLinkByGoldenResourcePidAndSourceResourcePid(goldenPatient1Pid.getId(), goldenPatient2Pid.getId()).isPresent()); + assertFalse(myMdmLinkDaoSvc.getLinkByGoldenResourcePidAndSourceResourcePid(goldenPatient2Pid.getId(), goldenPatient1Pid.getId()).isPresent()); saveNoMatchLink(goldenPatient1Pid, goldenPatient2Pid); @@ -108,10 +107,10 @@ public class MdmLinkSvcTest extends BaseMdmR4Test { Patient goldenPatient1 = createGoldenPatient(); Patient goldenPatient2 = createGoldenPatient(); - ResourcePersistentId goldenPatient1Pid = runInTransaction(()->myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), goldenPatient1)); - ResourcePersistentId goldenPatient2Pid = runInTransaction(()->myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), goldenPatient2)); - assertFalse(myMdmLinkDaoSvc.getLinkByGoldenResourcePidAndSourceResourcePid(goldenPatient1Pid.getIdAsLong(), goldenPatient2Pid.getIdAsLong()).isPresent()); - assertFalse(myMdmLinkDaoSvc.getLinkByGoldenResourcePidAndSourceResourcePid(goldenPatient2Pid.getIdAsLong(), goldenPatient1Pid.getIdAsLong()).isPresent()); + JpaPid goldenPatient1Pid = runInTransaction(()->myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), goldenPatient1)); + JpaPid goldenPatient2Pid = runInTransaction(()->myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), goldenPatient2)); + assertFalse(myMdmLinkDaoSvc.getLinkByGoldenResourcePidAndSourceResourcePid(goldenPatient1Pid.getId(), goldenPatient2Pid.getId()).isPresent()); + assertFalse(myMdmLinkDaoSvc.getLinkByGoldenResourcePidAndSourceResourcePid(goldenPatient2Pid.getId(), goldenPatient1Pid.getId()).isPresent()); saveNoMatchLink(goldenPatient2Pid, goldenPatient1Pid); @@ -120,7 +119,7 @@ public class MdmLinkSvcTest extends BaseMdmR4Test { assertLinkCount(1); } - private void saveNoMatchLink(ResourcePersistentId theGoldenResourcePid, ResourcePersistentId theTargetPid) { + private void saveNoMatchLink(JpaPid theGoldenResourcePid, JpaPid theTargetPid) { MdmLink noMatchLink = (MdmLink) myMdmLinkDaoSvc.newMdmLink(); noMatchLink.setGoldenResourcePersistenceId(theGoldenResourcePid); noMatchLink.setSourcePersistenceId(theTargetPid); @@ -166,7 +165,7 @@ public class MdmLinkSvcTest extends BaseMdmR4Test { myMdmLinkDaoSvc.createOrUpdateLinkEntity(goldenPatient, patient1, MdmMatchOutcome.NEW_GOLDEN_RESOURCE_MATCH, MdmLinkSourceEnum.MANUAL, createContextForCreate("Patient")); myMdmLinkDaoSvc.createOrUpdateLinkEntity(goldenPatient, patient2, MdmMatchOutcome.NO_MATCH, MdmLinkSourceEnum.MANUAL, createContextForCreate("Patient")); - List targets = myMdmLinkDaoSvc.findMdmLinksByGoldenResource(goldenPatient); + List targets = myMdmLinkDaoSvc.findMdmLinksByGoldenResource(goldenPatient); assertFalse(targets.isEmpty()); assertEquals(2, targets.size()); diff --git a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/svc/MdmMatchLinkSvcMultipleEidModeTest.java b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/svc/MdmMatchLinkSvcMultipleEidModeTest.java index 2c084f27a3f..4bb0614fe48 100644 --- a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/svc/MdmMatchLinkSvcMultipleEidModeTest.java +++ b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/svc/MdmMatchLinkSvcMultipleEidModeTest.java @@ -6,7 +6,7 @@ import ca.uhn.fhir.jpa.mdm.BaseMdmR4Test; import ca.uhn.fhir.mdm.api.MdmConstants; import ca.uhn.fhir.mdm.model.CanonicalEID; import ca.uhn.fhir.mdm.util.EIDHelper; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import org.hl7.fhir.instance.model.api.IAnyResource; import org.hl7.fhir.r4.model.Identifier; import org.hl7.fhir.r4.model.Patient; @@ -147,7 +147,7 @@ public class MdmMatchLinkSvcMultipleEidModeTest extends BaseMdmR4Test { Patient finalPatient1 = patient1; Patient finalPatient2 = patient2; - List duplicatePids = runInTransaction(()->Stream.of(finalPatient1, finalPatient2) + List duplicatePids = runInTransaction(()->Stream.of(finalPatient1, finalPatient2) .map(t -> myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), getGoldenResourceFromTargetResource(t))) .collect(Collectors.toList())); diff --git a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/svc/MdmMatchLinkSvcTest.java b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/svc/MdmMatchLinkSvcTest.java index 879b322d810..b98529ac34b 100644 --- a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/svc/MdmMatchLinkSvcTest.java +++ b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/jpa/mdm/svc/MdmMatchLinkSvcTest.java @@ -3,6 +3,7 @@ package ca.uhn.fhir.jpa.mdm.svc; import ca.uhn.fhir.interceptor.model.RequestPartitionId; import ca.uhn.fhir.jpa.entity.MdmLink; import ca.uhn.fhir.jpa.mdm.BaseMdmR4Test; +import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; import ca.uhn.fhir.mdm.api.IMdmLink; import ca.uhn.fhir.mdm.api.IMdmLinkSvc; @@ -16,7 +17,7 @@ import ca.uhn.fhir.mdm.util.EIDHelper; import ca.uhn.fhir.mdm.util.GoldenResourceHelper; import ca.uhn.fhir.mdm.util.MdmResourceUtil; import ca.uhn.fhir.rest.api.server.IBundleProvider; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import ca.uhn.fhir.rest.param.TokenParam; import org.hl7.fhir.instance.model.api.IAnyResource; import org.hl7.fhir.r4.model.HumanName; @@ -157,7 +158,7 @@ public class MdmMatchLinkSvcTest extends BaseMdmR4Test { Patient janePatient = addExternalEID(buildJanePatient(), sampleEID); janePatient = createPatientAndUpdateLinks(janePatient); - Optional mdmLink = myMdmLinkDaoSvc.getMatchedLinkForSourcePid(new ResourcePersistentId(janePatient.getIdElement().getIdPartAsLong())); + Optional mdmLink = myMdmLinkDaoSvc.getMatchedLinkForSourcePid(JpaPid.fromId(janePatient.getIdElement().getIdPartAsLong())); assertThat(mdmLink.isPresent(), is(true)); Patient patient = getTargetResourceFromMdmLink(mdmLink.get(), "Patient"); @@ -170,7 +171,7 @@ public class MdmMatchLinkSvcTest extends BaseMdmR4Test { @Test public void testWhenPatientIsCreatedWithoutAnEIDTheGoldenResourceGetsAutomaticallyAssignedOne() { Patient patient = createPatientAndUpdateLinks(buildJanePatient()); - IMdmLink mdmLink = myMdmLinkDaoSvc.getMatchedLinkForSourcePid(new ResourcePersistentId(patient.getIdElement().getIdPartAsLong())).get(); + IMdmLink mdmLink = myMdmLinkDaoSvc.getMatchedLinkForSourcePid(JpaPid.fromId(patient.getIdElement().getIdPartAsLong())).get(); Patient targetPatient = getTargetResourceFromMdmLink(mdmLink, "Patient"); Identifier identifierFirstRep = targetPatient.getIdentifierFirstRep(); @@ -182,7 +183,7 @@ public class MdmMatchLinkSvcTest extends BaseMdmR4Test { public void testPatientAttributesAreCopiedOverWhenGoldenResourceIsCreatedFromPatient() { Patient patient = createPatientAndUpdateLinks(buildPatientWithNameIdAndBirthday("Gary", "GARY_ID", new Date())); - Optional mdmLink = myMdmLinkDaoSvc.getMatchedLinkForSourcePid(new ResourcePersistentId(patient.getIdElement().getIdPartAsLong())); + Optional mdmLink = myMdmLinkDaoSvc.getMatchedLinkForSourcePid(JpaPid.fromId(patient.getIdElement().getIdPartAsLong())); Patient read = getTargetResourceFromMdmLink(mdmLink.get(), "Patient"); assertThat(read.getNameFirstRep().getFamily(), is(equalTo(patient.getNameFirstRep().getFamily()))); @@ -276,7 +277,7 @@ public class MdmMatchLinkSvcTest extends BaseMdmR4Test { Patient finalPatient1 = patient1; Patient finalPatient2 = patient2; - List duplicatePids = runInTransaction(()->Stream.of(finalPatient1, finalPatient2) + List duplicatePids = runInTransaction(()->Stream.of(finalPatient1, finalPatient2) .map(t -> myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), getGoldenResourceFromTargetResource(t))) .collect(Collectors.toList())); diff --git a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/mdm/batch2/clear/MdmClearStepTest.java b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/mdm/batch2/clear/MdmClearStepTest.java index 564c1cfac09..702377bf3fd 100644 --- a/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/mdm/batch2/clear/MdmClearStepTest.java +++ b/hapi-fhir-jpaserver-mdm/src/test/java/ca/uhn/fhir/mdm/batch2/clear/MdmClearStepTest.java @@ -53,8 +53,8 @@ class MdmClearStepTest extends BaseMdmR4Test { goldenPatient.setId(myGoldenId); myPatientDao.update(goldenPatient); - mySourcePid = myIdHelperService.getPidOrThrowException(sourcePatient).getIdAsLong(); - myGoldenPid = myIdHelperService.getPidOrThrowException(goldenPatient).getIdAsLong(); + mySourcePid = myIdHelperService.getPidOrThrowException(sourcePatient).getId(); + myGoldenPid = myIdHelperService.getPidOrThrowException(goldenPatient).getId(); myLink = buildMdmLink(mySourcePid, myGoldenPid); myMdmLinkDaoSvc.save(myLink); diff --git a/hapi-fhir-jpaserver-model/pom.xml b/hapi-fhir-jpaserver-model/pom.xml index c0bc3542616..c1370375312 100644 --- a/hapi-fhir-jpaserver-model/pom.xml +++ b/hapi-fhir-jpaserver-model/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/cross/IResourceLookup.java b/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/cross/IResourceLookup.java index ae1fff28c1a..6fca4dee67e 100644 --- a/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/cross/IResourceLookup.java +++ b/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/cross/IResourceLookup.java @@ -20,11 +20,11 @@ package ca.uhn.fhir.jpa.model.cross; * #L% */ -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import java.util.Date; -public interface IResourceLookup { +public interface IResourceLookup { String getResourceType(); /** @@ -32,6 +32,6 @@ public interface IResourceLookup { */ Date getDeleted(); - ResourcePersistentId getPersistentId(); + T getPersistentId(); } diff --git a/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/dao/JpaPid.java b/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/dao/JpaPid.java new file mode 100644 index 00000000000..d1dc51e07bd --- /dev/null +++ b/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/dao/JpaPid.java @@ -0,0 +1,92 @@ +package ca.uhn.fhir.jpa.model.dao; + +import ca.uhn.fhir.rest.api.server.storage.BaseResourcePersistentId; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Objects; + +/** + * JPA implementation of IResourcePersistentId. JPA uses a Long as the primary key. This class should be used in any + * context where the pid is known to be a Long. + */ +public class JpaPid extends BaseResourcePersistentId { + private final Long myId; + + private JpaPid(Long theId) { + super(null); + myId = theId; + } + + private JpaPid(Long theId, Long theVersion) { + super(theVersion, null); + myId = theId; + } + + private JpaPid(Long theId, String theResourceType) { + super(theResourceType); + myId = theId; + } + + private JpaPid(Long theId, Long theVersion, String theResourceType) { + super(theVersion, theResourceType); + myId = theId; + } + + public static List toLongList(Collection thePids) { + List retVal = new ArrayList<>(thePids.size()); + for (JpaPid next : thePids) { + retVal.add(next.getId()); + } + return retVal; + } + + public static List fromLongList(List theResultList) { + List retVal = new ArrayList<>(theResultList.size()); + for (Long next : theResultList) { + retVal.add(fromId(next)); + } + return retVal; + } + + public static JpaPid fromId(Long theId) { + return new JpaPid(theId); + } + + public static JpaPid fromIdAndVersion(Long theId, Long theVersion) { + return new JpaPid(theId, theVersion); + } + + public static JpaPid fromIdAndResourceType(Long theId, String theResourceType) { + return new JpaPid(theId, theResourceType); + } + + public static JpaPid fromIdAndVersionAndResourceType(Long theId, Long theVersion, String theResourceType) { + return new JpaPid(theId, theVersion, theResourceType); + } + + @Override + public boolean equals(Object theO) { + if (this == theO) return true; + if (theO == null || getClass() != theO.getClass()) return false; + if (!super.equals(theO)) return false; + JpaPid jpaPid = (JpaPid) theO; + return myId.equals(jpaPid.myId); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), myId); + } + + @Override + public Long getId() { + return myId; + } + + @Override + public String toString() { + return myId.toString(); + } +} diff --git a/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/ModelConfig.java b/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/ModelConfig.java index 77a5ac5b578..26a9dc2024d 100644 --- a/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/ModelConfig.java +++ b/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/ModelConfig.java @@ -20,8 +20,8 @@ package ca.uhn.fhir.jpa.model.entity; * #L% */ -import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.context.ParserOptions; +import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.model.api.TemporalPrecisionEnum; import ca.uhn.fhir.rest.server.interceptor.ResponseTerminologyTranslationSvc; import com.google.common.annotations.VisibleForTesting; diff --git a/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/ResourceHistoryTable.java b/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/ResourceHistoryTable.java index 9b6161704fd..a69bc89cb80 100644 --- a/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/ResourceHistoryTable.java +++ b/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/ResourceHistoryTable.java @@ -20,9 +20,9 @@ package ca.uhn.fhir.jpa.model.entity; * #L% */ +import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.model.primitive.IdDt; import ca.uhn.fhir.rest.api.Constants; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import org.hibernate.annotations.OptimisticLock; @@ -227,8 +227,8 @@ public class ResourceHistoryTable extends BaseHasResource implements Serializabl } @Override - public ResourcePersistentId getPersistentId() { - return new ResourcePersistentId(myResourceId); + public JpaPid getPersistentId() { + return JpaPid.fromId(myResourceId); } public ResourceTable getResourceTable() { diff --git a/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/ResourceTable.java b/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/ResourceTable.java index 441688b1158..3de415df929 100644 --- a/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/ResourceTable.java +++ b/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/ResourceTable.java @@ -23,12 +23,13 @@ package ca.uhn.fhir.jpa.model.entity; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.jpa.model.cross.IBasePersistedResource; import ca.uhn.fhir.jpa.model.cross.IResourceLookup; +import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.jpa.model.search.ExtendedHSearchIndexData; import ca.uhn.fhir.jpa.model.search.ResourceTableRoutingBinder; import ca.uhn.fhir.jpa.model.search.SearchParamTextPropertyBinder; import ca.uhn.fhir.model.primitive.IdDt; import ca.uhn.fhir.rest.api.Constants; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import org.hibernate.Session; @@ -767,8 +768,8 @@ public class ResourceTable extends BaseHasResource implements Serializable, IBas } @Override - public ResourcePersistentId getPersistentId() { - return new ResourcePersistentId(getId()); + public IResourcePersistentId getPersistentId() { + return JpaPid.fromId(getId()); } @Override diff --git a/hapi-fhir-jpaserver-searchparam/pom.xml b/hapi-fhir-jpaserver-searchparam/pom.xml index 89f8286a7ae..da2e3618b3f 100755 --- a/hapi-fhir-jpaserver-searchparam/pom.xml +++ b/hapi-fhir-jpaserver-searchparam/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/cache/ResourcePersistentIdMap.java b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/cache/ResourcePersistentIdMap.java index 777de773b96..9def1b99660 100644 --- a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/cache/ResourcePersistentIdMap.java +++ b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/cache/ResourcePersistentIdMap.java @@ -20,7 +20,7 @@ package ca.uhn.fhir.jpa.cache; * #L% */ -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import org.hl7.fhir.instance.model.api.IIdType; import java.util.HashMap; @@ -28,15 +28,15 @@ import java.util.List; import java.util.Map; public class ResourcePersistentIdMap { - private final Map myMap = new HashMap<>(); + private final Map myMap = new HashMap<>(); - public static ResourcePersistentIdMap fromResourcePersistentIds(List theResourcePersistentIds) { + public static ResourcePersistentIdMap fromResourcePersistentIds(List theResourcePersistentIds) { ResourcePersistentIdMap retval = new ResourcePersistentIdMap(); theResourcePersistentIds.forEach(retval::add); return retval; } - private void add(ResourcePersistentId theResourcePersistentId) { + private void add(IResourcePersistentId theResourcePersistentId) { IIdType id = theResourcePersistentId.getAssociatedResourceId(); myMap.put(id.toUnqualifiedVersionless(), theResourcePersistentId); } @@ -45,7 +45,7 @@ public class ResourcePersistentIdMap { return myMap.containsKey(theId.toUnqualifiedVersionless()); } - public ResourcePersistentId getResourcePersistentId(IIdType theId) { + public IResourcePersistentId getResourcePersistentId(IIdType theId) { return myMap.get(theId.toUnqualifiedVersionless()); } @@ -57,7 +57,7 @@ public class ResourcePersistentIdMap { return myMap.size(); } - public void put(IIdType theId, ResourcePersistentId thePid) { + public void put(IIdType theId, IResourcePersistentId thePid) { myMap.put(theId, thePid); } diff --git a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorService.java b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorService.java index 54d1880612a..23c6b7d9004 100644 --- a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorService.java +++ b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorService.java @@ -31,6 +31,7 @@ import ca.uhn.fhir.interceptor.api.Pointcut; import ca.uhn.fhir.interceptor.model.RequestPartitionId; 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.model.entity.BaseResourceIndexedSearchParam; import ca.uhn.fhir.jpa.model.entity.ModelConfig; import ca.uhn.fhir.jpa.model.entity.NormalizedQuantitySearchLevel; @@ -47,7 +48,6 @@ import ca.uhn.fhir.jpa.model.entity.ResourceTable; import ca.uhn.fhir.jpa.model.search.StorageProcessingMessage; import ca.uhn.fhir.parser.DataFormatException; 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.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails; @@ -67,7 +67,6 @@ import java.util.Collection; import java.util.Date; import java.util.HashSet; import java.util.List; -import java.util.Objects; import java.util.Optional; import static org.apache.commons.lang3.StringUtils.isBlank; @@ -401,7 +400,7 @@ public class SearchParamExtractorService { } IIdType referenceElement = thePathAndRef.getRef().getReferenceElement(); - ResourcePersistentId resolvedTargetId = theTransactionDetails.getResolvedResourceId(referenceElement); + JpaPid resolvedTargetId = (JpaPid) theTransactionDetails.getResolvedResourceId(referenceElement); ResourceLink resourceLink; Long targetVersionId = nextId.getVersionIdPartAsLong(); @@ -412,7 +411,7 @@ public class SearchParamExtractorService { * need to resolve it again */ myResourceLinkResolver.validateTypeOrThrowException(type); - resourceLink = ResourceLink.forLocalReference(thePathAndRef.getPath(), theEntity, typeString, resolvedTargetId.getIdAsLong(), targetId, transactionDate, targetVersionId); + resourceLink = ResourceLink.forLocalReference(thePathAndRef.getPath(), theEntity, typeString, resolvedTargetId.getId(), targetId, transactionDate, targetVersionId); } else if (theFailOnInvalidReference) { @@ -441,7 +440,7 @@ public class SearchParamExtractorService { return; } else { // Cache the outcome in the current transaction in case there are more references - ResourcePersistentId persistentId = new ResourcePersistentId(resourceLink.getTargetResourcePid()); + JpaPid persistentId = JpaPid.fromId(resourceLink.getTargetResourcePid()); theTransactionDetails.addResolvedResourceId(referenceElement, persistentId); } @@ -546,10 +545,10 @@ public class SearchParamExtractorService { private ResourceLink resolveTargetAndCreateResourceLinkOrReturnNull(@Nonnull RequestPartitionId theRequestPartitionId, String theSourceResourceName, PathAndRef thePathAndRef, ResourceTable theEntity, Date theUpdateTime, IIdType theNextId, RequestDetails theRequest, TransactionDetails theTransactionDetails) { assert theRequestPartitionId != null; - ResourcePersistentId resolvedResourceId = theTransactionDetails.getResolvedResourceId(theNextId); + JpaPid resolvedResourceId = (JpaPid) theTransactionDetails.getResolvedResourceId(theNextId); if (resolvedResourceId != null) { String targetResourceType = theNextId.getResourceType(); - Long targetResourcePid = resolvedResourceId.getIdAsLong(); + Long targetResourcePid = resolvedResourceId.getId(); String targetResourceIdPart = theNextId.getIdPart(); Long targetVersion = theNextId.getVersionIdPartAsLong(); return ResourceLink.forLocalReference(thePathAndRef.getPath(), theEntity, targetResourceType, targetResourcePid, targetResourceIdPart, theUpdateTime, targetVersion); @@ -574,7 +573,7 @@ public class SearchParamExtractorService { } String targetResourceType = targetResource.getResourceType(); - Long targetResourcePid = targetResource.getPersistentId().getIdAsLong(); + Long targetResourcePid = ((JpaPid) targetResource.getPersistentId()).getId(); String targetResourceIdPart = theNextId.getIdPart(); Long targetVersion = theNextId.getVersionIdPartAsLong(); return ResourceLink.forLocalReference(thePathAndRef.getPath(), theEntity, targetResourceType, targetResourcePid, targetResourceIdPart, theUpdateTime, targetVersion); diff --git a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/registry/SearchParameterCanonicalizer.java b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/registry/SearchParameterCanonicalizer.java index 9b17e9ba17b..69057c5caf1 100644 --- a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/registry/SearchParameterCanonicalizer.java +++ b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/registry/SearchParameterCanonicalizer.java @@ -20,11 +20,11 @@ package ca.uhn.fhir.jpa.searchparam.registry; * #L% */ -import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.context.ComboSearchParamType; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.RuntimeSearchParam; import ca.uhn.fhir.context.phonetic.IPhoneticEncoder; +import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.model.api.ExtensionDt; import ca.uhn.fhir.rest.api.RestSearchParameterTypeEnum; import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; diff --git a/hapi-fhir-jpaserver-subscription/pom.xml b/hapi-fhir-jpaserver-subscription/pom.xml index 41893251dcd..57220cf28be 100644 --- a/hapi-fhir-jpaserver-subscription/pom.xml +++ b/hapi-fhir-jpaserver-subscription/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/triggering/SubscriptionTriggeringSvcImpl.java b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/triggering/SubscriptionTriggeringSvcImpl.java index 2f96baac54e..b1daf2047c1 100644 --- a/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/triggering/SubscriptionTriggeringSvcImpl.java +++ b/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/triggering/SubscriptionTriggeringSvcImpl.java @@ -41,7 +41,7 @@ import ca.uhn.fhir.model.dstu2.valueset.ResourceTypeEnum; import ca.uhn.fhir.rest.annotation.IdParam; import ca.uhn.fhir.rest.api.CacheControlDirective; import ca.uhn.fhir.rest.api.server.IBundleProvider; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.exceptions.PreconditionFailedException; @@ -335,12 +335,12 @@ public class SubscriptionTriggeringSvcImpl implements ISubscriptionTriggeringSvc toIndex = Math.min(toIndex, theJobDetails.getCurrentSearchCount()); } ourLog.info("Triggering job[{}] search {} requesting resources {} - {}", theJobDetails.getJobId(), theJobDetails.getCurrentSearchUuid(), fromIndex, toIndex); - List resourceIds = mySearchCoordinatorSvc.getResources(theJobDetails.getCurrentSearchUuid(), fromIndex, toIndex, null); + List resourceIds = mySearchCoordinatorSvc.getResources(theJobDetails.getCurrentSearchUuid(), fromIndex, toIndex, null); ourLog.info("Triggering job[{}] delivering {} resources", theJobDetails.getJobId(), resourceIds.size()); int highestIndexSubmitted = theJobDetails.getCurrentSearchLastUploadedIndex(); - for (ResourcePersistentId next : resourceIds) { + for (IResourcePersistentId next : resourceIds) { IBaseResource nextResource = resourceDao.readByPid(next); Future future = submitResource(theJobDetails.getSubscriptionId(), nextResource); futures.add(Pair.of(nextResource.getIdElement().getIdPart(), future)); diff --git a/hapi-fhir-jpaserver-test-dstu2/pom.xml b/hapi-fhir-jpaserver-test-dstu2/pom.xml index 51e074993f9..9f5b7fb5555 100644 --- a/hapi-fhir-jpaserver-test-dstu2/pom.xml +++ b/hapi-fhir-jpaserver-test-dstu2/pom.xml @@ -6,7 +6,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoDstu2SearchNoFtTest.java b/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoDstu2SearchNoFtTest.java index dfb6fe1b254..f494f8cc8f6 100644 --- a/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoDstu2SearchNoFtTest.java +++ b/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoDstu2SearchNoFtTest.java @@ -56,7 +56,7 @@ import ca.uhn.fhir.rest.api.Constants; import ca.uhn.fhir.rest.api.SortOrderEnum; import ca.uhn.fhir.rest.api.SortSpec; import ca.uhn.fhir.rest.api.server.IBundleProvider; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import ca.uhn.fhir.rest.param.CompositeParam; import ca.uhn.fhir.rest.param.DateParam; import ca.uhn.fhir.rest.param.DateRangeParam; @@ -95,7 +95,6 @@ import static org.hamcrest.Matchers.containsInRelativeOrder; import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.endsWith; import static org.hamcrest.Matchers.hasItem; -import static org.hamcrest.Matchers.hasItems; import static org.hamcrest.Matchers.not; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -1616,7 +1615,7 @@ public class FhirResourceDaoDstu2SearchNoFtTest extends BaseJpaDstu2Test { String methodName = "testSearchValueQuantity"; QuantityParam param; - List found; + List found; param = new QuantityParam(ParamPrefixEnum.GREATERTHAN_OR_EQUALS, new BigDecimal("10"), null, null); found = myObservationDao.searchForIds(new SearchParameterMap("value-quantity", param), null); int initialSize = found.size(); diff --git a/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoDstu2Test.java b/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoDstu2Test.java index 7bceb99264b..e27cf046d6d 100644 --- a/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoDstu2Test.java +++ b/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoDstu2Test.java @@ -7,6 +7,7 @@ import ca.uhn.fhir.jpa.dao.BaseHapiFhirDao; import ca.uhn.fhir.jpa.dao.BaseStorageDao; 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; @@ -56,7 +57,7 @@ import ca.uhn.fhir.rest.api.SortOrderEnum; import ca.uhn.fhir.rest.api.SortSpec; import ca.uhn.fhir.rest.api.ValidationModeEnum; import ca.uhn.fhir.rest.api.server.IBundleProvider; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import ca.uhn.fhir.rest.param.DateParam; import ca.uhn.fhir.rest.param.DateRangeParam; import ca.uhn.fhir.rest.param.ParamPrefixEnum; @@ -287,8 +288,8 @@ public class FhirResourceDaoDstu2Test extends BaseJpaDstu2Test { assertThat(toUnqualifiedVersionlessIdValues(found), hasItem(id2.getValue())); } { - List found = myObservationDao.searchForIds(new SearchParameterMap(Observation.SP_DATE, new DateParam(">2016-01-02")), null); - assertThat(ResourcePersistentId.toLongList(found), not(hasItem(id2.getIdPartAsLong()))); + List found = myObservationDao.searchForIds(new SearchParameterMap(Observation.SP_DATE, new DateParam(">2016-01-02")), null); + assertThat(JpaPid.toLongList(found), not(hasItem(id2.getIdPartAsLong()))); } } @@ -1496,7 +1497,7 @@ public class FhirResourceDaoDstu2Test extends BaseJpaDstu2Test { "}\n"; //@formatter:on - List val = myOrganizationDao.searchForIds(new SearchParameterMap("name", new StringParam("P")), null); + List val = myOrganizationDao.searchForIds(new SearchParameterMap("name", new StringParam("P")), null); int initial = val.size(); Organization org = myFhirContext.newJsonParser().parseResource(Organization.class, inputStr); @@ -2687,7 +2688,7 @@ public class FhirResourceDaoDstu2Test extends BaseJpaDstu2Test { assertThat(str.length(), greaterThan(ResourceIndexedSearchParamString.MAX_LENGTH)); - List val = myOrganizationDao.searchForIds(new SearchParameterMap("name", new StringParam("P")), null); + List val = myOrganizationDao.searchForIds(new SearchParameterMap("name", new StringParam("P")), null); int initial = val.size(); myOrganizationDao.create(org, mySrd); @@ -2802,7 +2803,7 @@ public class FhirResourceDaoDstu2Test extends BaseJpaDstu2Test { String subStr1 = longStr1.substring(0, ResourceIndexedSearchParamString.MAX_LENGTH); String subStr2 = longStr2.substring(0, ResourceIndexedSearchParamString.MAX_LENGTH); - List val = myOrganizationDao.searchForIds(new SearchParameterMap("type", new IdentifierDt(subStr1, subStr2)), null); + List val = myOrganizationDao.searchForIds(new SearchParameterMap("type", new IdentifierDt(subStr1, subStr2)), null); int initial = val.size(); myOrganizationDao.create(org, mySrd); diff --git a/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoDstu2UpdateTest.java b/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoDstu2UpdateTest.java index b4ba13acde9..a779870745a 100644 --- a/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoDstu2UpdateTest.java +++ b/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirResourceDaoDstu2UpdateTest.java @@ -1,6 +1,7 @@ package ca.uhn.fhir.jpa.dao.dstu2; import ca.uhn.fhir.i18n.Msg; +import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum; import ca.uhn.fhir.model.api.Tag; @@ -13,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; @@ -168,9 +168,9 @@ public class FhirResourceDaoDstu2UpdateTest extends BaseJpaDstu2Test { p2.addName().addFamily("Tester").addGiven("testUpdateMaintainsSearchParamsDstu2BBB"); myPatientDao.create(p2, mySrd); - List ids = myPatientDao.searchForIds(new SearchParameterMap(Patient.SP_GIVEN, new StringDt("testUpdateMaintainsSearchParamsDstu2AAA")), null); + List ids = myPatientDao.searchForIds(new SearchParameterMap(Patient.SP_GIVEN, new StringDt("testUpdateMaintainsSearchParamsDstu2AAA")), null); assertEquals(1, ids.size()); - assertThat(ResourcePersistentId.toLongList(ids), contains(p1id.getIdPartAsLong())); + assertThat(JpaPid.toLongList(ids), contains(p1id.getIdPartAsLong())); // Update the name p1.getNameFirstRep().getGivenFirstRep().setValue("testUpdateMaintainsSearchParamsDstu2BBB"); diff --git a/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirSearchDaoDstu2Test.java b/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirSearchDaoDstu2Test.java index 3e01fde2b18..6614ee3a908 100644 --- a/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirSearchDaoDstu2Test.java +++ b/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/dao/dstu2/FhirSearchDaoDstu2Test.java @@ -1,11 +1,11 @@ package ca.uhn.fhir.jpa.dao.dstu2; import ca.uhn.fhir.jpa.dao.IFulltextSearchSvc; +import ca.uhn.fhir.jpa.model.dao.JpaPid; 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; @@ -59,8 +59,8 @@ public class FhirSearchDaoDstu2Test extends BaseJpaDstu2Test { content.addAnd(new StringOrListParam().addOr(new StringParam("AAAS"))); map.add(Constants.PARAM_CONTENT, content); - List found = mySearchDao.search(resourceName, map); - assertThat(ResourcePersistentId.toLongList(found), containsInAnyOrder(id1)); + List found = mySearchDao.search(resourceName, map); + assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1)); } // OR { @@ -68,8 +68,8 @@ public class FhirSearchDaoDstu2Test extends BaseJpaDstu2Test { content.addAnd(new StringOrListParam().addOr(new StringParam("AAAS")).addOr(new StringParam("AAAB"))); map.add(Constants.PARAM_CONTENT, content); - List found = mySearchDao.search(resourceName, map); - assertThat(ResourcePersistentId.toLongList(found), containsInAnyOrder(id1, id2)); + List found = mySearchDao.search(resourceName, map); + assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1, id2)); } // AND { @@ -78,8 +78,8 @@ public class FhirSearchDaoDstu2Test extends BaseJpaDstu2Test { content.addAnd(new StringOrListParam().addOr(new StringParam("CCC"))); map.add(Constants.PARAM_CONTENT, content); - List found = mySearchDao.search(resourceName, map); - assertThat(ResourcePersistentId.toLongList(found), containsInAnyOrder(id1)); + List found = mySearchDao.search(resourceName, map); + assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1)); } // AND OR { @@ -88,8 +88,8 @@ public class FhirSearchDaoDstu2Test extends BaseJpaDstu2Test { content.addAnd(new StringOrListParam().addOr(new StringParam("CCC"))); map.add(Constants.PARAM_CONTENT, content); - List found = mySearchDao.search(resourceName, map); - assertThat(ResourcePersistentId.toLongList(found), containsInAnyOrder(id1, id2)); + List found = mySearchDao.search(resourceName, map); + assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1, id2)); } // All Resource Types { @@ -97,8 +97,8 @@ public class FhirSearchDaoDstu2Test extends BaseJpaDstu2Test { content.addAnd(new StringOrListParam().addOr(new StringParam("CCC")).addOr(new StringParam("DDD"))); map.add(Constants.PARAM_CONTENT, content); - List found = mySearchDao.search(null, map); - assertThat(ResourcePersistentId.toLongList(found), containsInAnyOrder(id1, id2, id3)); + List found = mySearchDao.search(null, map); + assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1, id2, id3)); } } @@ -127,8 +127,8 @@ public class FhirSearchDaoDstu2Test extends BaseJpaDstu2Test { content.addAnd(new StringOrListParam().addOr(new StringParam("AAAS"))); map.add(Constants.PARAM_TEXT, content); - List found = mySearchDao.search(resourceName, map); - assertThat(ResourcePersistentId.toLongList(found), containsInAnyOrder(id1)); + List found = mySearchDao.search(resourceName, map); + assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1)); } // OR { @@ -136,8 +136,8 @@ public class FhirSearchDaoDstu2Test extends BaseJpaDstu2Test { content.addAnd(new StringOrListParam().addOr(new StringParam("AAAS")).addOr(new StringParam("AAAB"))); map.add(Constants.PARAM_TEXT, content); - List found = mySearchDao.search(resourceName, map); - assertThat(ResourcePersistentId.toLongList(found), containsInAnyOrder(id1, id2)); + List found = mySearchDao.search(resourceName, map); + assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1, id2)); } // AND { @@ -146,8 +146,8 @@ public class FhirSearchDaoDstu2Test extends BaseJpaDstu2Test { content.addAnd(new StringOrListParam().addOr(new StringParam("CCC"))); map.add(Constants.PARAM_TEXT, content); - List found = mySearchDao.search(resourceName, map); - assertThat(ResourcePersistentId.toLongList(found), containsInAnyOrder(id1)); + List found = mySearchDao.search(resourceName, map); + assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1)); } // AND OR { @@ -156,8 +156,8 @@ public class FhirSearchDaoDstu2Test extends BaseJpaDstu2Test { content.addAnd(new StringOrListParam().addOr(new StringParam("CCC"))); map.add(Constants.PARAM_TEXT, content); - List found = mySearchDao.search(resourceName, map); - assertThat(ResourcePersistentId.toLongList(found), containsInAnyOrder(id1, id2)); + List found = mySearchDao.search(resourceName, map); + assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1, id2)); } // Tag Contents { @@ -165,8 +165,8 @@ public class FhirSearchDaoDstu2Test extends BaseJpaDstu2Test { content.addAnd(new StringOrListParam().addOr(new StringParam("div"))); map.add(Constants.PARAM_TEXT, content); - List found = mySearchDao.search(resourceName, map); - assertThat(ResourcePersistentId.toLongList(found), empty()); + List found = mySearchDao.search(resourceName, map); + assertThat(JpaPid.toLongList(found), empty()); } } diff --git a/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/search/BaseSearchSvc.java b/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/search/BaseSearchSvc.java index 57dab9223f7..431428cbcdc 100644 --- a/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/search/BaseSearchSvc.java +++ b/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/search/BaseSearchSvc.java @@ -6,10 +6,11 @@ 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.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; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import org.hl7.fhir.instance.model.api.IBaseResource; import org.mockito.Mock; import org.mockito.Spy; @@ -29,7 +30,7 @@ import static org.mockito.Mockito.verify; public class BaseSearchSvc { protected int myExpectedNumberOfSearchBuildersCreated = 2; @Mock - protected SearchBuilderFactory mySearchBuilderFactory; + protected SearchBuilderFactory mySearchBuilderFactory; @Mock protected PlatformTransactionManager myTxManager; @@ -54,19 +55,19 @@ public class BaseSearchSvc { verify(mySearchBuilderFactory, atMost(myExpectedNumberOfSearchBuildersCreated)).newSearchBuilder(any(), any(), any()); } - protected List createPidSequence(int to) { - List pids = new ArrayList<>(); + protected List createPidSequence(int to) { + List pids = new ArrayList<>(); for (long i = 10; i < to; i++) { - pids.add(new ResourcePersistentId(i)); + pids.add(JpaPid.fromId(i)); } return pids; } protected Answer loadPids() { return theInvocation -> { - List pids = (List) theInvocation.getArguments()[0]; + List pids = (List) theInvocation.getArguments()[0]; List resources = (List) theInvocation.getArguments()[2]; - for (ResourcePersistentId nextPid : pids) { + for (IResourcePersistentId nextPid : pids) { Patient pt = new Patient(); pt.setId(nextPid.toString()); resources.add(pt); @@ -75,12 +76,12 @@ public class BaseSearchSvc { }; } - public static class ResultIterator extends BaseIterator implements IResultIterator { + public static class ResultIterator extends BaseIterator implements IResultIterator { - private final Iterator myWrap; + private final Iterator myWrap; private int myCount; - ResultIterator(Iterator theWrap) { + ResultIterator(Iterator theWrap) { myWrap = theWrap; } @@ -90,7 +91,7 @@ public class BaseSearchSvc { } @Override - public ResourcePersistentId next() { + public JpaPid next() { myCount++; return myWrap.next(); } @@ -106,8 +107,8 @@ public class BaseSearchSvc { } @Override - public Collection getNextResultBatch(long theBatchSize) { - Collection batch = new ArrayList<>(); + public Collection getNextResultBatch(long theBatchSize) { + Collection batch = new ArrayList<>(); while (this.hasNext() && batch.size() < theBatchSize) { batch.add(this.next()); } diff --git a/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/search/SearchCoordinatorSvcImplTest.java b/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/search/SearchCoordinatorSvcImplTest.java index 77fb47f1d45..e79c56a6c85 100644 --- a/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/search/SearchCoordinatorSvcImplTest.java +++ b/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/search/SearchCoordinatorSvcImplTest.java @@ -10,6 +10,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.search.SearchStatusEnum; import ca.uhn.fhir.jpa.partition.IRequestPartitionHelperSvc; import ca.uhn.fhir.jpa.search.builder.tasks.SearchContinuationTask; @@ -22,7 +23,7 @@ import ca.uhn.fhir.jpa.util.BaseIterator; import ca.uhn.fhir.rest.api.CacheControlDirective; 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.api.server.storage.IResourcePersistentId; import ca.uhn.fhir.rest.param.StringParam; import ca.uhn.fhir.rest.server.IPagingProvider; import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; @@ -93,7 +94,7 @@ public class SearchCoordinatorSvcImplTest extends BaseSearchSvc{ @Mock private IInterceptorBroadcaster myInterceptorBroadcaster; @Mock - private SearchBuilderFactory mySearchBuilderFactory; + private SearchBuilderFactory mySearchBuilderFactory; @Mock private PersistedJpaBundleProviderFactory myPersistedJpaBundleProviderFactory; @Mock @@ -150,8 +151,8 @@ public class SearchCoordinatorSvcImplTest extends BaseSearchSvc{ SearchParameterMap params = new SearchParameterMap(); params.add("name", new StringParam("ANAME")); - List pids = createPidSequence(800); - IResultIterator iter = new FailAfterNIterator(new SlowIterator(pids.iterator(), 2), 300); + List pids = createPidSequence(800); + IResultIterator iter = new FailAfterNIterator(new SlowIterator(pids.iterator(), 2), 300); when(mySearchBuilder.createQuery(same(params), any(), any(), nullable(RequestPartitionId.class))).thenReturn(iter); mockSearchTask(); @@ -169,10 +170,10 @@ public class SearchCoordinatorSvcImplTest extends BaseSearchSvc{ initSearches(); initAsyncSearches(); - List allResults = new ArrayList<>(); + List allResults = new ArrayList<>(); doAnswer(t -> { - List oldResults = t.getArgument(1, List.class); - List newResults = t.getArgument(2, List.class); + List oldResults = t.getArgument(1, List.class); + List newResults = t.getArgument(2, List.class); ourLog.info("Saving {} new results - have {} old results", newResults.size(), oldResults.size()); assertEquals(allResults.size(), oldResults.size()); allResults.addAll(newResults); @@ -182,7 +183,7 @@ public class SearchCoordinatorSvcImplTest extends BaseSearchSvc{ SearchParameterMap params = new SearchParameterMap(); params.add("name", new StringParam("ANAME")); - List pids = createPidSequence(800); + List pids = createPidSequence(800); SlowIterator iter = new SlowIterator(pids.iterator(), 1); when(mySearchBuilder.createQuery(any(), any(), any(), nullable(RequestPartitionId.class))).thenReturn(iter); doAnswer(loadPids()).when(mySearchBuilder).loadResourcesByPid(any(Collection.class), any(Collection.class), any(List.class), anyBoolean(), any()); @@ -210,8 +211,8 @@ public class SearchCoordinatorSvcImplTest extends BaseSearchSvc{ verify(mySearchCacheSvc, atLeastOnce()).save(searchCaptor.capture()); assertEquals(790, allResults.size()); - assertEquals(10, allResults.get(0).getIdAsLong().longValue()); - assertEquals(799, allResults.get(789).getIdAsLong().longValue()); + assertEquals(10, allResults.get(0).getId()); + assertEquals(799, allResults.get(789).getId()); myExpectedNumberOfSearchBuildersCreated = 4; } @@ -269,7 +270,7 @@ public class SearchCoordinatorSvcImplTest extends BaseSearchSvc{ SearchParameterMap params = new SearchParameterMap(); params.add("name", new StringParam("ANAME")); - List pids = createPidSequence(800); + List pids = createPidSequence(800); SlowIterator iter = new SlowIterator(pids.iterator(), 2); when(mySearchBuilder.createQuery(same(params), any(), any(), nullable(RequestPartitionId.class))).thenReturn(iter); mockSearchTask(); @@ -300,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 searchBuilder = t.getArgument(3, ISearchBuilder.class); PersistedJpaSearchFirstPageBundleProvider retVal = new PersistedJpaSearchFirstPageBundleProvider(search, searchTask, searchBuilder, requestDetails); retVal.setDaoConfigForUnitTest(new DaoConfig()); retVal.setTxManagerForUnitTest(myTxManager); @@ -316,7 +317,7 @@ public class SearchCoordinatorSvcImplTest extends BaseSearchSvc{ SearchParameterMap params = new SearchParameterMap(); params.add("name", new StringParam("ANAME")); - List pids = createPidSequence(800); + List pids = createPidSequence(800); SlowIterator iter = new SlowIterator(pids.iterator(), 500); when(mySearchBuilder.createQuery(same(params), any(), any(), nullable(RequestPartitionId.class))).thenReturn(iter); mockSearchTask(); @@ -325,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); @@ -333,7 +334,7 @@ public class SearchCoordinatorSvcImplTest extends BaseSearchSvc{ try { assertNotNull(searchId); ourLog.info("About to pull the first resource"); - List resources = mySvc.getResources(searchId, 0, 1, null); + List resources = mySvc.getResources(searchId, 0, 1, null); ourLog.info("Done pulling the first resource"); assertEquals(1, resources.size()); } finally { @@ -369,7 +370,7 @@ public class SearchCoordinatorSvcImplTest extends BaseSearchSvc{ SearchParameterMap params = new SearchParameterMap(); params.add("name", new StringParam("ANAME")); - List pids = createPidSequence(800); + List pids = createPidSequence(800); IResultIterator iter = new SlowIterator(pids.iterator(), 2); when(mySearchBuilder.createQuery(same(params), any(), any(), nullable(RequestPartitionId.class))).thenReturn(iter); when(mySearchCacheSvc.save(any())).thenAnswer(t ->{ @@ -410,7 +411,7 @@ public class SearchCoordinatorSvcImplTest extends BaseSearchSvc{ SearchParameterMap params = new SearchParameterMap(); params.add("name", new StringParam("ANAME")); - List pids = createPidSequence(100); + List pids = createPidSequence(100); SlowIterator iter = new SlowIterator(pids.iterator(), 2); when(mySearchBuilder.createQuery(same(params), any(), any(), nullable(RequestPartitionId.class))).thenReturn(iter); mockSearchTask(); @@ -462,10 +463,10 @@ public class SearchCoordinatorSvcImplTest extends BaseSearchSvc{ } when(mySearchResultCacheSvc.fetchResultPids(any(Search.class), anyInt(), anyInt())).thenAnswer(theInvocation -> { - ArrayList results = new ArrayList<>(); + ArrayList results = new ArrayList<>(); for (long i = theInvocation.getArgument(1, Integer.class); i < theInvocation.getArgument(2, Integer.class); i++) { Long nextPid = i + 10L; - results.add(new ResourcePersistentId(nextPid)); + results.add(JpaPid.fromId(nextPid)); } return results; @@ -609,10 +610,10 @@ public class SearchCoordinatorSvcImplTest extends BaseSearchSvc{ } - public static class FailAfterNIterator extends BaseIterator implements IResultIterator { + public static class FailAfterNIterator extends BaseIterator implements IResultIterator { private int myCount; - private final IResultIterator myWrap; + private final IResultIterator myWrap; FailAfterNIterator(IResultIterator theWrap, int theCount) { myWrap = theWrap; @@ -625,7 +626,7 @@ public class SearchCoordinatorSvcImplTest extends BaseSearchSvc{ } @Override - public ResourcePersistentId next() { + public JpaPid next() { myCount--; if (myCount == 0) { throw new NullPointerException("FAILED"); @@ -644,8 +645,8 @@ public class SearchCoordinatorSvcImplTest extends BaseSearchSvc{ } @Override - public Collection getNextResultBatch(long theBatchSize) { - Collection batch = new ArrayList<>(); + public Collection getNextResultBatch(long theBatchSize) { + Collection batch = new ArrayList<>(); while (this.hasNext() && batch.size() < theBatchSize) { batch.add(this.next()); } @@ -664,22 +665,22 @@ public class SearchCoordinatorSvcImplTest extends BaseSearchSvc{ *

* Don't use it in real code! */ - public static class SlowIterator extends BaseIterator implements IResultIterator { + public static class SlowIterator extends BaseIterator implements IResultIterator { private static final Logger ourLog = LoggerFactory.getLogger(SlowIterator.class); private final IResultIterator myResultIteratorWrap; private final int myDelay; - private final Iterator myWrap; - private final List myReturnedValues = new ArrayList<>(); + private final Iterator myWrap; + private final List myReturnedValues = new ArrayList<>(); private final AtomicInteger myCountReturned = new AtomicInteger(0); - SlowIterator(Iterator theWrap, int theDelay) { + SlowIterator(Iterator theWrap, int theDelay) { myWrap = theWrap; myDelay = theDelay; myResultIteratorWrap = null; } - List getReturnedValues() { + List getReturnedValues() { return myReturnedValues; } @@ -697,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; @@ -724,8 +725,8 @@ public class SearchCoordinatorSvcImplTest extends BaseSearchSvc{ } @Override - public Collection getNextResultBatch(long theBatchSize) { - Collection batch = new ArrayList<>(); + public Collection getNextResultBatch(long theBatchSize) { + Collection batch = new ArrayList<>(); while (this.hasNext() && batch.size() < theBatchSize) { batch.add(this.next()); } @@ -752,8 +753,7 @@ public class SearchCoordinatorSvcImplTest extends BaseSearchSvc{ invocation.getArgument(1), myTxManager, ourCtx, - mySearchStrategyFactory, - myInterceptorBroadcaster, + myInterceptorBroadcaster, mySearchBuilderFactory, mySearchResultCacheSvc, myDaoConfig, @@ -765,7 +765,6 @@ public class SearchCoordinatorSvcImplTest extends BaseSearchSvc{ invocation.getArgument(1), myTxManager, ourCtx, - mySearchStrategyFactory, myInterceptorBroadcaster, mySearchBuilderFactory, mySearchResultCacheSvc, diff --git a/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/search/SynchronousSearchSvcImplTest.java b/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/search/SynchronousSearchSvcImplTest.java index c93df425411..ed0d00aeb75 100644 --- a/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/search/SynchronousSearchSvcImplTest.java +++ b/hapi-fhir-jpaserver-test-dstu2/src/test/java/ca/uhn/fhir/jpa/search/SynchronousSearchSvcImplTest.java @@ -1,11 +1,11 @@ package ca.uhn.fhir.jpa.search; import ca.uhn.fhir.interceptor.model.RequestPartitionId; +import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; 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 org.hl7.fhir.instance.model.api.IBaseResource; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -22,6 +22,7 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNull; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; +import static org.mockito.ArgumentMatchers.argThat; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.nullable; import static org.mockito.ArgumentMatchers.same; @@ -47,7 +48,7 @@ public class SynchronousSearchSvcImplTest extends BaseSearchSvc{ SearchParameterMap params = new SearchParameterMap(); - List pids = createPidSequence(800); + List pids = createPidSequence(800); when(mySearchBuilder.createQuery(same(params), any(), any(), nullable(RequestPartitionId.class))).thenReturn(new BaseSearchSvc.ResultIterator(pids.iterator())); doAnswer(loadPids()).when(mySearchBuilder).loadResourcesByPid(any(Collection.class), any(Collection.class), any(List.class), anyBoolean(), any()); @@ -71,7 +72,7 @@ public class SynchronousSearchSvcImplTest extends BaseSearchSvc{ params.setOffset(10); params.setSearchTotalMode(SearchTotalModeEnum.ACCURATE); - List pids = createPidSequence(30); + List pids = createPidSequence(30); when(mySearchBuilder.createCountQuery(same(params), any(String.class),nullable(RequestDetails.class), nullable(RequestPartitionId.class))).thenReturn(20L); when(mySearchBuilder.createQuery(same(params), any(), nullable(RequestDetails.class), nullable(RequestPartitionId.class))).thenReturn(new BaseSearchSvc.ResultIterator(pids.subList(10, 20).iterator())); @@ -93,11 +94,12 @@ public class SynchronousSearchSvcImplTest extends BaseSearchSvc{ SearchParameterMap params = new SearchParameterMap(); params.setLoadSynchronousUpTo(100); - List pids = createPidSequence(800); + List pids = createPidSequence(800); when(mySearchBuilder.createQuery(same(params), any(), nullable(RequestDetails.class), nullable(RequestPartitionId.class))).thenReturn(new BaseSearchSvc.ResultIterator(pids.iterator())); pids = createPidSequence(110); - doAnswer(loadPids()).when(mySearchBuilder).loadResourcesByPid(eq(pids), any(Collection.class), any(List.class), anyBoolean(), nullable(RequestDetails.class)); + List finalPids = pids; + doAnswer(loadPids()).when(mySearchBuilder).loadResourcesByPid(argThat(ids -> ids.containsAll(finalPids)), any(Collection.class), any(List.class), anyBoolean(), nullable(RequestDetails.class)); IBundleProvider result = mySynchronousSearchSvc.executeQuery("Patient", params, RequestPartitionId.allPartitions()); diff --git a/hapi-fhir-jpaserver-test-dstu3/pom.xml b/hapi-fhir-jpaserver-test-dstu3/pom.xml index 713e990cb54..63ae54d4d19 100644 --- a/hapi-fhir-jpaserver-test-dstu3/pom.xml +++ b/hapi-fhir-jpaserver-test-dstu3/pom.xml @@ -6,7 +6,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-test-dstu3/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3TerminologyTest.java b/hapi-fhir-jpaserver-test-dstu3/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3TerminologyTest.java index 842d938fd9b..e3e8ca3a297 100644 --- a/hapi-fhir-jpaserver-test-dstu3/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3TerminologyTest.java +++ b/hapi-fhir-jpaserver-test-dstu3/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3TerminologyTest.java @@ -7,13 +7,13 @@ import ca.uhn.fhir.jpa.api.config.DaoConfig; import ca.uhn.fhir.jpa.entity.TermCodeSystemVersion; import ca.uhn.fhir.jpa.entity.TermConcept; import ca.uhn.fhir.jpa.entity.TermConceptParentChildLink.RelationshipTypeEnum; +import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.jpa.model.entity.ResourceTable; import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; import ca.uhn.fhir.jpa.term.TermReindexingSvcImpl; import ca.uhn.fhir.jpa.term.api.ITermDeferredStorageSvc; import ca.uhn.fhir.jpa.test.BaseJpaDstu3Test; import ca.uhn.fhir.parser.IParser; -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.InternalErrorException; @@ -120,7 +120,7 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test { TermConcept childCA = new TermConcept(cs, "childCA").setDisplay("Child CA"); parentC.addChild(childCA, RelationshipTypeEnum.ISA); - myTermCodeSystemStorageSvc.storeNewCodeSystemVersion(new ResourcePersistentId(table.getId()), URL_MY_CODE_SYSTEM, "SYSTEM NAME", "SYSTEM VERSION", cs, table); + myTermCodeSystemStorageSvc.storeNewCodeSystemVersion(JpaPid.fromId(table.getId()), URL_MY_CODE_SYSTEM, "SYSTEM NAME", "SYSTEM VERSION", cs, table); return codeSystem; } @@ -152,7 +152,7 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test { parentB.addChild(childI, RelationshipTypeEnum.ISA); } - myTermCodeSystemStorageSvc.storeNewCodeSystemVersion(new ResourcePersistentId(table.getId()), URL_MY_CODE_SYSTEM, "SYSTEM NAME", "SYSTEM VERSION", cs, table); + myTermCodeSystemStorageSvc.storeNewCodeSystemVersion(JpaPid.fromId(table.getId()), URL_MY_CODE_SYSTEM, "SYSTEM NAME", "SYSTEM VERSION", cs, table); myTermDeferredStorageSvc.saveAllDeferred(); } @@ -190,7 +190,7 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test { TermConcept beagle = new TermConcept(cs, "beagle").setDisplay("Beagle"); dogs.addChild(beagle, RelationshipTypeEnum.ISA); - myTermCodeSystemStorageSvc.storeNewCodeSystemVersion(new ResourcePersistentId(table.getId()), URL_MY_CODE_SYSTEM, "SYSTEM NAME", "SYSTEM VERSION", cs, table); + myTermCodeSystemStorageSvc.storeNewCodeSystemVersion(JpaPid.fromId(table.getId()), URL_MY_CODE_SYSTEM, "SYSTEM NAME", "SYSTEM VERSION", cs, table); return codeSystem; } @@ -693,7 +693,7 @@ public class FhirResourceDaoDstu3TerminologyTest extends BaseJpaDstu3Test { cs.setResource(table); TermConcept parentA = new TermConcept(cs, "ParentA").setDisplay("Parent A"); cs.getConcepts().add(parentA); - myTermCodeSystemStorageSvc.storeNewCodeSystemVersion(new ResourcePersistentId(table.getId()), "http://snomed.info/sct", "Snomed CT", "SYSTEM VERSION", cs, table); + myTermCodeSystemStorageSvc.storeNewCodeSystemVersion(JpaPid.fromId(table.getId()), "http://snomed.info/sct", "Snomed CT", "SYSTEM VERSION", cs, table); StringType code = new StringType("ParentA"); StringType system = new StringType("http://snomed.info/sct"); diff --git a/hapi-fhir-jpaserver-test-dstu3/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3Test.java b/hapi-fhir-jpaserver-test-dstu3/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3Test.java index d2ac3ab2086..73a8ca2dd02 100644 --- a/hapi-fhir-jpaserver-test-dstu3/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3Test.java +++ b/hapi-fhir-jpaserver-test-dstu3/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3Test.java @@ -10,6 +10,7 @@ import ca.uhn.fhir.jpa.api.model.HistoryCountModeEnum; import ca.uhn.fhir.jpa.dao.BaseHapiFhirDao; 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; @@ -26,7 +27,7 @@ import ca.uhn.fhir.rest.api.MethodOutcome; import ca.uhn.fhir.rest.api.SortOrderEnum; import ca.uhn.fhir.rest.api.SortSpec; import ca.uhn.fhir.rest.api.server.IBundleProvider; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import ca.uhn.fhir.rest.param.DateParam; import ca.uhn.fhir.rest.param.DateRangeParam; import ca.uhn.fhir.rest.param.ParamPrefixEnum; @@ -263,12 +264,12 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test { IIdType id2 = myObservationDao.create(o2, mySrd).getId(); { - List found = myObservationDao.searchForIds(new SearchParameterMap(Observation.SP_DATE, new DateParam(">2001-01-02")), null); - assertThat(ResourcePersistentId.toLongList(found), hasItem(id2.getIdPartAsLong())); + List found = myObservationDao.searchForIds(new SearchParameterMap(Observation.SP_DATE, new DateParam(">2001-01-02")), null); + assertThat(JpaPid.toLongList(found), hasItem(id2.getIdPartAsLong())); } { - List found = myObservationDao.searchForIds(new SearchParameterMap(Observation.SP_DATE, new DateParam(">2016-01-02")), null); - assertThat(ResourcePersistentId.toLongList(found), not(hasItem(id2.getIdPartAsLong()))); + List found = myObservationDao.searchForIds(new SearchParameterMap(Observation.SP_DATE, new DateParam(">2016-01-02")), null); + assertThat(JpaPid.toLongList(found), not(hasItem(id2.getIdPartAsLong()))); } } @@ -2036,7 +2037,7 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test { "}\n"; //@formatter:on - List val = myOrganizationDao.searchForIds(new SearchParameterMap("name", new StringParam("P")), null); + List val = myOrganizationDao.searchForIds(new SearchParameterMap("name", new StringParam("P")), null); int initial = val.size(); Organization org = myFhirContext.newJsonParser().parseResource(Organization.class, inputStr); @@ -3287,7 +3288,7 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test { assertThat(str.length(), greaterThan(ResourceIndexedSearchParamString.MAX_LENGTH)); - List val = myOrganizationDao.searchForIds(new SearchParameterMap("name", new StringParam("P")), null); + List val = myOrganizationDao.searchForIds(new SearchParameterMap("name", new StringParam("P")), null); int initial = val.size(); myOrganizationDao.create(org, mySrd); @@ -3466,7 +3467,7 @@ public class FhirResourceDaoDstu3Test extends BaseJpaDstu3Test { String subStr1 = longStr1.substring(0, ResourceIndexedSearchParamString.MAX_LENGTH); String subStr2 = longStr2.substring(0, ResourceIndexedSearchParamString.MAX_LENGTH); - List val = myOrganizationDao.searchForIds(new SearchParameterMap("type", new TokenParam(subStr1, subStr2)), null); + List val = myOrganizationDao.searchForIds(new SearchParameterMap("type", new TokenParam(subStr1, subStr2)), null); int initial = val.size(); myOrganizationDao.create(org, mySrd); diff --git a/hapi-fhir-jpaserver-test-dstu3/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3UpdateTest.java b/hapi-fhir-jpaserver-test-dstu3/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3UpdateTest.java index 17bc0f606ff..8f5f6cd5fc4 100644 --- a/hapi-fhir-jpaserver-test-dstu3/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3UpdateTest.java +++ b/hapi-fhir-jpaserver-test-dstu3/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3UpdateTest.java @@ -2,11 +2,11 @@ package ca.uhn.fhir.jpa.dao.dstu3; import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.jpa.api.config.DaoConfig; +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.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; @@ -467,9 +467,9 @@ public class FhirResourceDaoDstu3UpdateTest extends BaseJpaDstu3Test { p2.addName().setFamily("Tester").addGiven("testUpdateMaintainsSearchParamsDstu2BBB"); myPatientDao.create(p2, mySrd).getId(); - List ids = myPatientDao.searchForIds(new SearchParameterMap(Patient.SP_GIVEN, new StringParam("testUpdateMaintainsSearchParamsDstu2AAA")), null); + List ids = myPatientDao.searchForIds(new SearchParameterMap(Patient.SP_GIVEN, new StringParam("testUpdateMaintainsSearchParamsDstu2AAA")), null); assertEquals(1, ids.size()); - assertThat(ResourcePersistentId.toLongList(ids), contains(p1id.getIdPartAsLong())); + assertThat(JpaPid.toLongList(ids), contains(p1id.getIdPartAsLong())); // Update the name p1.getName().get(0).getGiven().get(0).setValue("testUpdateMaintainsSearchParamsDstu2BBB"); diff --git a/hapi-fhir-jpaserver-test-dstu3/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirSearchDaoDstu3Test.java b/hapi-fhir-jpaserver-test-dstu3/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirSearchDaoDstu3Test.java index 4ecd6a8f73b..b359996b8c2 100644 --- a/hapi-fhir-jpaserver-test-dstu3/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirSearchDaoDstu3Test.java +++ b/hapi-fhir-jpaserver-test-dstu3/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirSearchDaoDstu3Test.java @@ -1,10 +1,10 @@ package ca.uhn.fhir.jpa.dao.dstu3; import ca.uhn.fhir.jpa.dao.IFulltextSearchSvc; +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; @@ -60,8 +60,8 @@ public class FhirSearchDaoDstu3Test extends BaseJpaDstu3Test { content.addAnd(new StringOrListParam().addOr(new StringParam("AAAS"))); map.add(Constants.PARAM_CONTENT, content); - List found = mySearchDao.search(resourceName, map); - assertThat(ResourcePersistentId.toLongList(found), containsInAnyOrder(id1)); + List found = mySearchDao.search(resourceName, map); + assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1)); } // OR { @@ -69,8 +69,8 @@ public class FhirSearchDaoDstu3Test extends BaseJpaDstu3Test { content.addAnd(new StringOrListParam().addOr(new StringParam("AAAS")).addOr(new StringParam("AAAB"))); map.add(Constants.PARAM_CONTENT, content); - List found = mySearchDao.search(resourceName, map); - assertThat(ResourcePersistentId.toLongList(found), containsInAnyOrder(id1, id2)); + List found = mySearchDao.search(resourceName, map); + assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1, id2)); } // AND { @@ -79,8 +79,8 @@ public class FhirSearchDaoDstu3Test extends BaseJpaDstu3Test { content.addAnd(new StringOrListParam().addOr(new StringParam("CCC"))); map.add(Constants.PARAM_CONTENT, content); - List found = mySearchDao.search(resourceName, map); - assertThat(ResourcePersistentId.toLongList(found), containsInAnyOrder(id1)); + List found = mySearchDao.search(resourceName, map); + assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1)); } // AND OR { @@ -89,8 +89,8 @@ public class FhirSearchDaoDstu3Test extends BaseJpaDstu3Test { content.addAnd(new StringOrListParam().addOr(new StringParam("CCC"))); map.add(Constants.PARAM_CONTENT, content); - List found = mySearchDao.search(resourceName, map); - assertThat(ResourcePersistentId.toLongList(found), containsInAnyOrder(id1, id2)); + List found = mySearchDao.search(resourceName, map); + assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1, id2)); } // All Resource Types { @@ -98,8 +98,8 @@ public class FhirSearchDaoDstu3Test extends BaseJpaDstu3Test { content.addAnd(new StringOrListParam().addOr(new StringParam("CCC")).addOr(new StringParam("DDD"))); map.add(Constants.PARAM_CONTENT, content); - List found = mySearchDao.search(null, map); - assertThat(ResourcePersistentId.toLongList(found), containsInAnyOrder(id1, id2, id3)); + List found = mySearchDao.search(null, map); + assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1, id2, id3)); } } @@ -133,8 +133,8 @@ public class FhirSearchDaoDstu3Test extends BaseJpaDstu3Test { content.addAnd(new StringOrListParam().addOr(new StringParam("AAAS"))); map.add(Constants.PARAM_TEXT, content); - List found = mySearchDao.search(resourceName, map); - assertThat(ResourcePersistentId.toLongList(found), containsInAnyOrder(id1)); + List found = mySearchDao.search(resourceName, map); + assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1)); } // OR { @@ -142,8 +142,8 @@ public class FhirSearchDaoDstu3Test extends BaseJpaDstu3Test { content.addAnd(new StringOrListParam().addOr(new StringParam("AAAS")).addOr(new StringParam("AAAB"))); map.add(Constants.PARAM_TEXT, content); - List found = mySearchDao.search(resourceName, map); - assertThat(ResourcePersistentId.toLongList(found), containsInAnyOrder(id1, id2)); + List found = mySearchDao.search(resourceName, map); + assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1, id2)); } // AND { @@ -152,8 +152,8 @@ public class FhirSearchDaoDstu3Test extends BaseJpaDstu3Test { content.addAnd(new StringOrListParam().addOr(new StringParam("CCC"))); map.add(Constants.PARAM_TEXT, content); - List found = mySearchDao.search(resourceName, map); - assertThat(ResourcePersistentId.toLongList(found), containsInAnyOrder(id1)); + List found = mySearchDao.search(resourceName, map); + assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1)); } // AND OR { @@ -162,8 +162,8 @@ public class FhirSearchDaoDstu3Test extends BaseJpaDstu3Test { content.addAnd(new StringOrListParam().addOr(new StringParam("CCC"))); map.add(Constants.PARAM_TEXT, content); - List found = mySearchDao.search(resourceName, map); - assertThat(ResourcePersistentId.toLongList(found), containsInAnyOrder(id1, id2)); + List found = mySearchDao.search(resourceName, map); + assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1, id2)); } // Tag Contents { @@ -171,8 +171,8 @@ public class FhirSearchDaoDstu3Test extends BaseJpaDstu3Test { content.addAnd(new StringOrListParam().addOr(new StringParam("div"))); map.add(Constants.PARAM_TEXT, content); - List found = mySearchDao.search(resourceName, map); - assertThat(ResourcePersistentId.toLongList(found), empty()); + List found = mySearchDao.search(resourceName, map); + assertThat(JpaPid.toLongList(found), empty()); } } diff --git a/hapi-fhir-jpaserver-test-dstu3/src/test/java/ca/uhn/fhir/jpa/dao/expunge/ExpungeHookTest.java b/hapi-fhir-jpaserver-test-dstu3/src/test/java/ca/uhn/fhir/jpa/dao/expunge/ExpungeHookTest.java index 694b64af155..c337a3c6f05 100644 --- a/hapi-fhir-jpaserver-test-dstu3/src/test/java/ca/uhn/fhir/jpa/dao/expunge/ExpungeHookTest.java +++ b/hapi-fhir-jpaserver-test-dstu3/src/test/java/ca/uhn/fhir/jpa/dao/expunge/ExpungeHookTest.java @@ -6,8 +6,8 @@ import ca.uhn.fhir.interceptor.api.Pointcut; import ca.uhn.fhir.jpa.api.config.DaoConfig; import ca.uhn.fhir.jpa.api.dao.IFhirResourceDaoPatient; import ca.uhn.fhir.jpa.api.model.ExpungeOptions; +import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.jpa.test.BaseJpaDstu3Test; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; import ca.uhn.test.concurrency.PointcutLatch; import org.hl7.fhir.dstu3.model.Meta; @@ -125,7 +125,7 @@ public class ExpungeHookTest extends BaseJpaDstu3Test { options.setExpungeDeletedResources(true); myExpungeResourceLatch.setExpectedCount(2); - myExpungeService.expunge("Patient", new ResourcePersistentId(expungeId.getIdPartAsLong()), options, null); + myExpungeService.expunge("Patient", JpaPid.fromId(expungeId.getIdPartAsLong()), options, null); HookParams hookParams = myExpungeResourceLatch.awaitExpected().get(0); IIdType hookId = hookParams.get(IIdType.class); diff --git a/hapi-fhir-jpaserver-test-dstu3/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderDstu3ValueSetTest.java b/hapi-fhir-jpaserver-test-dstu3/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderDstu3ValueSetTest.java index a91bdc367bf..bd01813f5ea 100644 --- a/hapi-fhir-jpaserver-test-dstu3/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderDstu3ValueSetTest.java +++ b/hapi-fhir-jpaserver-test-dstu3/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderDstu3ValueSetTest.java @@ -7,10 +7,10 @@ import ca.uhn.fhir.jpa.dao.data.IResourceTableDao; import ca.uhn.fhir.jpa.entity.TermCodeSystemVersion; import ca.uhn.fhir.jpa.entity.TermConcept; import ca.uhn.fhir.jpa.entity.TermConceptParentChildLink.RelationshipTypeEnum; +import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.jpa.model.entity.ResourceTable; import ca.uhn.fhir.jpa.term.api.ITermCodeSystemStorageSvc; import ca.uhn.fhir.jpa.util.CircularQueueCaptureQueriesListener; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails; @@ -982,7 +982,7 @@ public class ResourceProviderDstu3ValueSetTest extends BaseResourceProviderDstu3 if (theCaptureQueriesListener != null) { theCaptureQueriesListener.clear(); } - theTermCodeSystemStorageSvc.storeNewCodeSystemVersion(new ResourcePersistentId(table.getId()), URL_MY_CODE_SYSTEM, "SYSTEM NAME", "SYSTEM VERSION", cs, table); + theTermCodeSystemStorageSvc.storeNewCodeSystemVersion(JpaPid.fromId(table.getId()), URL_MY_CODE_SYSTEM, "SYSTEM NAME", "SYSTEM VERSION", cs, table); if (theCaptureQueriesListener != null) { theCaptureQueriesListener.logAllQueries(); } diff --git a/hapi-fhir-jpaserver-test-dstu3/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderDstu3ValueSetVersionedTest.java b/hapi-fhir-jpaserver-test-dstu3/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderDstu3ValueSetVersionedTest.java index 5c8ab79c1bd..cd599c6befc 100644 --- a/hapi-fhir-jpaserver-test-dstu3/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderDstu3ValueSetVersionedTest.java +++ b/hapi-fhir-jpaserver-test-dstu3/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderDstu3ValueSetVersionedTest.java @@ -9,9 +9,9 @@ import ca.uhn.fhir.jpa.entity.TermConceptParentChildLink.RelationshipTypeEnum; import ca.uhn.fhir.jpa.entity.TermValueSet; import ca.uhn.fhir.jpa.entity.TermValueSetConcept; import ca.uhn.fhir.jpa.entity.TermValueSetPreExpansionStatusEnum; +import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.jpa.model.entity.ResourceTable; import ca.uhn.fhir.jpa.term.api.ITermCodeSystemStorageSvc; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException; import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails; @@ -1488,7 +1488,7 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv TermConcept parentB = new TermConcept(cs, "ParentB").setDisplay("Parent B"); cs.getConcepts().add(parentB); - theTermCodeSystemStorageSvc.storeNewCodeSystemVersion(new ResourcePersistentId(table.getId()), URL_MY_CODE_SYSTEM, "SYSTEM NAME", "SYSTEM VERSION", cs, table); + theTermCodeSystemStorageSvc.storeNewCodeSystemVersion(JpaPid.fromId(table.getId()), URL_MY_CODE_SYSTEM, "SYSTEM NAME", "SYSTEM VERSION", cs, table); return codeSystem; } @@ -1522,7 +1522,7 @@ public class ResourceProviderDstu3ValueSetVersionedTest extends BaseResourceProv TermConcept parentB = new TermConcept(cs, "ParentB").setDisplay("Parent B" + theCodeSystemVersion); cs.getConcepts().add(parentB); - theTermCodeSystemStorageSvc.storeNewCodeSystemVersion(new ResourcePersistentId(table.getId()), URL_MY_CODE_SYSTEM, "SYSTEM NAME", theCodeSystemVersion, cs, table); + theTermCodeSystemStorageSvc.storeNewCodeSystemVersion(JpaPid.fromId(table.getId()), URL_MY_CODE_SYSTEM, "SYSTEM NAME", theCodeSystemVersion, cs, table); return codeSystem; } diff --git a/hapi-fhir-jpaserver-test-dstu3/src/test/java/ca/uhn/fhir/jpa/term/TerminologySvcImplDstu3Test.java b/hapi-fhir-jpaserver-test-dstu3/src/test/java/ca/uhn/fhir/jpa/term/TerminologySvcImplDstu3Test.java index 3f018ec2696..490422d0589 100644 --- a/hapi-fhir-jpaserver-test-dstu3/src/test/java/ca/uhn/fhir/jpa/term/TerminologySvcImplDstu3Test.java +++ b/hapi-fhir-jpaserver-test-dstu3/src/test/java/ca/uhn/fhir/jpa/term/TerminologySvcImplDstu3Test.java @@ -10,9 +10,9 @@ import ca.uhn.fhir.jpa.entity.TermCodeSystemVersion; import ca.uhn.fhir.jpa.entity.TermConcept; import ca.uhn.fhir.jpa.entity.TermConceptParentChildLink; import ca.uhn.fhir.jpa.entity.TermConceptParentChildLink.RelationshipTypeEnum; +import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.jpa.model.entity.ResourceTable; import ca.uhn.fhir.jpa.test.BaseJpaDstu3Test; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; import ca.uhn.fhir.rest.api.server.storage.TransactionDetails; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException; @@ -108,7 +108,7 @@ public class TerminologySvcImplDstu3Test extends BaseJpaDstu3Test { TermConcept parentB = new TermConcept(cs, "ParentB"); cs.getConcepts().add(parentB); - myTermCodeSystemStorageSvc.storeNewCodeSystemVersion(new ResourcePersistentId(table.getId()), CS_URL, "SYSTEM NAME", null, cs, table); + myTermCodeSystemStorageSvc.storeNewCodeSystemVersion(JpaPid.fromId(table.getId()), CS_URL, "SYSTEM NAME", null, cs, table); myTerminologyDeferredStorageSvc.saveAllDeferred(); @@ -130,7 +130,7 @@ public class TerminologySvcImplDstu3Test extends BaseJpaDstu3Test { TermConcept parentA = new TermConcept(cs, "CS2"); cs.getConcepts().add(parentA); - myTermCodeSystemStorageSvc.storeNewCodeSystemVersion(new ResourcePersistentId(table.getId()), CS_URL_2, "SYSTEM NAME", "SYSTEM VERSION", cs, table); + myTermCodeSystemStorageSvc.storeNewCodeSystemVersion(JpaPid.fromId(table.getId()), CS_URL_2, "SYSTEM NAME", "SYSTEM VERSION", cs, table); } @@ -200,7 +200,7 @@ public class TerminologySvcImplDstu3Test extends BaseJpaDstu3Test { code2.getDisplay()); cs.getConcepts().add(code4); - myTermCodeSystemStorageSvc.storeNewCodeSystemVersion(new ResourcePersistentId(table.getId()), LOINC_URI, "SYSTEM NAME", "SYSTEM VERSION", cs, table); + myTermCodeSystemStorageSvc.storeNewCodeSystemVersion(JpaPid.fromId(table.getId()), LOINC_URI, "SYSTEM NAME", "SYSTEM VERSION", cs, table); }); } @@ -217,7 +217,7 @@ public class TerminologySvcImplDstu3Test extends BaseJpaDstu3Test { TermCodeSystemVersion cs = new TermCodeSystemVersion(); cs.setResource(table); - myTermCodeSystemStorageSvc.storeNewCodeSystemVersion(new ResourcePersistentId(table.getId()), CS_URL, "SYSTEM NAME", "SYSTEM VERSION", cs, table); + myTermCodeSystemStorageSvc.storeNewCodeSystemVersion(JpaPid.fromId(table.getId()), CS_URL, "SYSTEM NAME", "SYSTEM VERSION", cs, table); // Update cs = new TermCodeSystemVersion(); @@ -1968,7 +1968,7 @@ public class TerminologySvcImplDstu3Test extends BaseJpaDstu3Test { runInTransaction(() -> { ResourceTable resTable = myEntityManager.find(ResourceTable.class, csId.getIdPartAsLong()); version.setResource(resTable); - myTermCodeSystemStorageSvc.storeNewCodeSystemVersion(new ResourcePersistentId(csId.getIdPartAsLong()), cs.getUrl(), "My System", "SYSTEM VERSION", version, resTable); + myTermCodeSystemStorageSvc.storeNewCodeSystemVersion(JpaPid.fromId(csId.getIdPartAsLong()), cs.getUrl(), "My System", "SYSTEM VERSION", version, resTable); }); org.hl7.fhir.dstu3.model.ValueSet vs = new org.hl7.fhir.dstu3.model.ValueSet(); diff --git a/hapi-fhir-jpaserver-test-r4/pom.xml b/hapi-fhir-jpaserver-test-r4/pom.xml index 41156640b1f..858630ac78c 100644 --- a/hapi-fhir-jpaserver-test-r4/pom.xml +++ b/hapi-fhir-jpaserver-test-r4/pom.xml @@ -6,7 +6,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDaoTest.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDaoTest.java index ef3646d3543..6e91386546e 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDaoTest.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDaoTest.java @@ -12,12 +12,12 @@ import ca.uhn.fhir.jpa.api.config.DaoConfig; import ca.uhn.fhir.jpa.api.model.DaoMethodOutcome; import ca.uhn.fhir.jpa.api.model.DeleteConflictList; import ca.uhn.fhir.jpa.api.svc.IIdHelperService; +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.partition.IRequestPartitionHelperSvc; 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.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; @@ -40,11 +40,6 @@ import org.mockito.junit.jupiter.MockitoExtension; import javax.persistence.EntityManager; import java.util.List; - -import java.util.List; - -import java.util.List; - import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.fail; @@ -158,7 +153,7 @@ class BaseHapiFhirResourceDaoTest { TransactionDetails transactionDetails = new TransactionDetails(); RequestPartitionId partitionId = Mockito.mock(RequestPartitionId.class); - ResourcePersistentId resourcePersistentId = new ResourcePersistentId("Patient", 1l); + JpaPid jpaPid = JpaPid.fromIdAndVersion(123L, 1L); ResourceTable entity = new ResourceTable(); entity.setForcedId(new ForcedId()); @@ -172,10 +167,10 @@ class BaseHapiFhirResourceDaoTest { Mockito.any(RequestPartitionId.class), Mockito.anyString(), Mockito.anyString() - )).thenReturn(resourcePersistentId); + )).thenReturn(jpaPid); Mockito.when(myEntityManager.find( Mockito.any(Class.class), - Mockito.anyString() + Mockito.anyLong() )).thenReturn(entity); // we don't stub myConfig.getResourceClientIdStrategy() // because even a null return isn't ANY... diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/index/IdHelperServiceTest.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/index/IdHelperServiceTest.java index f6db0f54278..d88cf02a1d7 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/index/IdHelperServiceTest.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/index/IdHelperServiceTest.java @@ -5,8 +5,8 @@ import ca.uhn.fhir.jpa.api.config.DaoConfig; 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; @@ -25,6 +25,7 @@ import java.util.Date; import java.util.List; import java.util.Map; import java.util.function.Function; +import java.util.stream.Collectors; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.hasSize; @@ -65,7 +66,7 @@ public class IdHelperServiceTest { patientIdsToResolve.add("456"); // test - Map idToPid = myHelperService.resolveResourcePersistentIds(partitionId, + Map idToPid = myHelperService.resolveResourcePersistentIds(partitionId, resourceType, patientIdsToResolve); @@ -105,7 +106,7 @@ public class IdHelperServiceTest { .thenReturn(Collections.singletonList(blueView)); // test - Map map = myHelperService.resolveResourcePersistentIds( + Map map = myHelperService.resolveResourcePersistentIds( partitionId, resourceType, patientIdsToResolve); @@ -124,8 +125,8 @@ public class IdHelperServiceTest { patientIdsToResolve.add("RED"); patientIdsToResolve.add("BLUE"); - ResourcePersistentId red = new ResourcePersistentId("Patient", 123l); - ResourcePersistentId blue = new ResourcePersistentId("Patient", 456l); + JpaPid red = JpaPid.fromIdAndVersion(123L, 123L); + JpaPid blue = JpaPid.fromIdAndVersion(456L, 456L); // we will pretend the lookup value is in the cache when(myMemoryCacheService.getThenPutAfterCommit(any(MemoryCacheService.CacheEnum.class), @@ -135,7 +136,7 @@ public class IdHelperServiceTest { .thenReturn(blue); // test - Map map = myHelperService.resolveResourcePersistentIds( + Map map = myHelperService.resolveResourcePersistentIds( partitionId, resourceType, patientIdsToResolve @@ -165,7 +166,7 @@ public class IdHelperServiceTest { testForcedIdViews.add(forcedIdView); when(myForcedIdDao.findAndResolveByForcedIdWithNoTypeInPartition(any(), any(), any(), anyBoolean())).thenReturn(testForcedIdViews); - IResourceLookup result = myHelperService.resolveResourceIdentity(partitionId, resourceType, resourceForcedId); + IResourceLookup result = myHelperService.resolveResourceIdentity(partitionId, resourceType, resourceForcedId); assertEquals(forcedIdView[0], result.getResourceType()); assertEquals(forcedIdView[1], result.getPersistentId().getId()); assertEquals(forcedIdView[3], result.getDeleted()); @@ -177,29 +178,31 @@ public class IdHelperServiceTest { String resourceType = "Patient"; List ids = Arrays.asList("A", "B", "C"); - ResourcePersistentId resourcePersistentId1 = new ResourcePersistentId("TEST1"); - ResourcePersistentId resourcePersistentId2 = new ResourcePersistentId("TEST2"); - ResourcePersistentId resourcePersistentId3 = new ResourcePersistentId("TEST3"); + JpaPid resourcePersistentId1 = JpaPid.fromId(1L); + JpaPid resourcePersistentId2 = JpaPid.fromId(2L); + JpaPid resourcePersistentId3 = JpaPid.fromId(3L); when(myMemoryCacheService.getThenPutAfterCommit(any(), any(), any())) .thenReturn(resourcePersistentId1) .thenReturn(resourcePersistentId2) .thenReturn(resourcePersistentId3); - Map result = myHelperService.resolveResourcePersistentIds(partitionId, resourceType, ids); + Map result = myHelperService.resolveResourcePersistentIds(partitionId, resourceType, ids) + .entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue())); assertThat(result.keySet(), hasSize(3)); - assertEquals("TEST1", result.get("A").getId()); - assertEquals("TEST2", result.get("B").getId()); - assertEquals("TEST3", result.get("C").getId()); + assertEquals(1L, result.get("A").getId()); + assertEquals(2L, result.get("B").getId()); + assertEquals(3L, result.get("C").getId()); } @Test public void testResolveResourcePersistentIds_resourcePidDefaultFunctionality(){ RequestPartitionId partitionId = RequestPartitionId.fromPartitionIdAndName(1, "partition"); String resourceType = "Patient"; - String id = "A"; + Long id = 1L; - ResourcePersistentId resourcePersistentId1 = new ResourcePersistentId(id); - when(myMemoryCacheService.getThenPutAfterCommit(any(), any(), any())).thenReturn(resourcePersistentId1); - ResourcePersistentId result = myHelperService.resolveResourcePersistentIds(partitionId, resourceType, id); + JpaPid jpaPid1 = JpaPid.fromId(id); + when(myDaoConfig.getResourceClientIdStrategy()).thenReturn(DaoConfig.ClientIdStrategyEnum.ANY); + when(myMemoryCacheService.getThenPutAfterCommit(any(), any(), any())).thenReturn(jpaPid1); + JpaPid result = myHelperService.resolveResourcePersistentIds(partitionId, resourceType, id.toString()); assertEquals(id, result.getId()); } } diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4TerminologyTest.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4TerminologyTest.java index 9a1f40f415e..82fd0c7a0ce 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4TerminologyTest.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4TerminologyTest.java @@ -7,13 +7,13 @@ import ca.uhn.fhir.jpa.api.config.DaoConfig; import ca.uhn.fhir.jpa.entity.TermCodeSystemVersion; import ca.uhn.fhir.jpa.entity.TermConcept; import ca.uhn.fhir.jpa.entity.TermConceptParentChildLink.RelationshipTypeEnum; +import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.jpa.model.entity.ResourceTable; import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; import ca.uhn.fhir.jpa.term.TermReindexingSvcImpl; import ca.uhn.fhir.jpa.term.TermTestUtil; import ca.uhn.fhir.jpa.test.BaseJpaR4Test; import ca.uhn.fhir.parser.IParser; -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.InternalErrorException; @@ -118,7 +118,7 @@ public class FhirResourceDaoR4TerminologyTest extends BaseJpaR4Test { TermConcept childCA = new TermConcept(cs, "childCA").setDisplay("Child CA"); parentC.addChild(childCA, RelationshipTypeEnum.ISA); - myTermCodeSystemStorageSvc.storeNewCodeSystemVersion(new ResourcePersistentId(table.getId()), TermTestUtil.URL_MY_CODE_SYSTEM, "SYSTEM NAME", "SYSTEM VERSION", cs, table); + myTermCodeSystemStorageSvc.storeNewCodeSystemVersion(JpaPid.fromId(table.getId()), TermTestUtil.URL_MY_CODE_SYSTEM, "SYSTEM NAME", "SYSTEM VERSION", cs, table); return codeSystem; }); } @@ -157,7 +157,7 @@ public class FhirResourceDaoR4TerminologyTest extends BaseJpaR4Test { TermConcept beagle = new TermConcept(cs, "beagle").setDisplay("Beagle"); dogs.addChild(beagle, RelationshipTypeEnum.ISA); - myTermCodeSystemStorageSvc.storeNewCodeSystemVersion(new ResourcePersistentId(table.getId()), TermTestUtil.URL_MY_CODE_SYSTEM, "SYSTEM NAME", "SYSTEM VERSION", cs, table); + myTermCodeSystemStorageSvc.storeNewCodeSystemVersion(JpaPid.fromId(table.getId()), TermTestUtil.URL_MY_CODE_SYSTEM, "SYSTEM NAME", "SYSTEM VERSION", cs, table); return codeSystem; }); } @@ -190,7 +190,7 @@ public class FhirResourceDaoR4TerminologyTest extends BaseJpaR4Test { parentB.addChild(childI, RelationshipTypeEnum.ISA); } - myTermCodeSystemStorageSvc.storeNewCodeSystemVersion(new ResourcePersistentId(table.getId()), TermTestUtil.URL_MY_CODE_SYSTEM, "SYSTEM NAME", "SYSTEM VERSION", cs, table); + myTermCodeSystemStorageSvc.storeNewCodeSystemVersion(JpaPid.fromId(table.getId()), TermTestUtil.URL_MY_CODE_SYSTEM, "SYSTEM NAME", "SYSTEM VERSION", cs, table); myTerminologyDeferredStorageSvc.saveAllDeferred(); } @@ -525,7 +525,7 @@ public class FhirResourceDaoR4TerminologyTest extends BaseJpaR4Test { concept = new TermConcept(cs, "LA9999-7"); cs.getConcepts().add(concept); - myTermCodeSystemStorageSvc.storeNewCodeSystemVersion(new ResourcePersistentId(table.getId()), TermTestUtil.URL_MY_CODE_SYSTEM, "SYSTEM NAME", "SYSTEM VERSION", cs, table); + myTermCodeSystemStorageSvc.storeNewCodeSystemVersion(JpaPid.fromId(table.getId()), TermTestUtil.URL_MY_CODE_SYSTEM, "SYSTEM NAME", "SYSTEM VERSION", cs, table); ValueSet valueSet = new ValueSet(); valueSet.setUrl(TermTestUtil.URL_MY_VALUE_SET); @@ -836,7 +836,7 @@ public class FhirResourceDaoR4TerminologyTest extends BaseJpaR4Test { cs.setResource(table); TermConcept parentA = new TermConcept(cs, "ParentA").setDisplay("Parent A"); cs.getConcepts().add(parentA); - myTermCodeSystemStorageSvc.storeNewCodeSystemVersion(new ResourcePersistentId(table.getId()), "http://snomed.info/sct", "Snomed CT", "SYSTEM VERSION", cs, table); + myTermCodeSystemStorageSvc.storeNewCodeSystemVersion(JpaPid.fromId(table.getId()), "http://snomed.info/sct", "Snomed CT", "SYSTEM VERSION", cs, table); StringType code = new StringType("ParentA"); StringType system = new StringType("http://snomed.info/sct"); diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4Test.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4Test.java index 72c8c25b83a..7fc41c9a002 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4Test.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4Test.java @@ -9,6 +9,7 @@ import ca.uhn.fhir.jpa.dao.BaseHapiFhirDao; import ca.uhn.fhir.jpa.dao.BaseStorageDao; 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; @@ -31,7 +32,7 @@ import ca.uhn.fhir.rest.api.MethodOutcome; import ca.uhn.fhir.rest.api.SortOrderEnum; import ca.uhn.fhir.rest.api.SortSpec; import ca.uhn.fhir.rest.api.server.IBundleProvider; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import ca.uhn.fhir.rest.param.DateParam; import ca.uhn.fhir.rest.param.DateRangeParam; import ca.uhn.fhir.rest.param.HasParam; @@ -477,12 +478,12 @@ public class FhirResourceDaoR4Test extends BaseJpaR4Test { IIdType id2 = myObservationDao.create(o2, mySrd).getId(); { - List found = myObservationDao.searchForIds(new SearchParameterMap(Observation.SP_DATE, new DateParam(">2001-01-02")), null); - assertThat(ResourcePersistentId.toLongList(found), hasItem(id2.getIdPartAsLong())); + List found = myObservationDao.searchForIds(new SearchParameterMap(Observation.SP_DATE, new DateParam(">2001-01-02")), null); + assertThat(JpaPid.toLongList(found), hasItem(id2.getIdPartAsLong())); } { - List found = myObservationDao.searchForIds(new SearchParameterMap(Observation.SP_DATE, new DateParam(">2016-01-02")), null); - assertThat(ResourcePersistentId.toLongList(found), not(hasItem(id2.getIdPartAsLong()))); + List found = myObservationDao.searchForIds(new SearchParameterMap(Observation.SP_DATE, new DateParam(">2016-01-02")), null); + assertThat(JpaPid.toLongList(found), not(hasItem(id2.getIdPartAsLong()))); } } @@ -2485,7 +2486,7 @@ public class FhirResourceDaoR4Test extends BaseJpaR4Test { "}\n"; //@formatter:on - List val = myOrganizationDao.searchForIds(new SearchParameterMap("name", new StringParam("P")), null); + List val = myOrganizationDao.searchForIds(new SearchParameterMap("name", new StringParam("P")), null); int initial = val.size(); Organization org = myFhirContext.newJsonParser().parseResource(Organization.class, inputStr); @@ -3980,7 +3981,7 @@ public class FhirResourceDaoR4Test extends BaseJpaR4Test { assertThat(str.length(), greaterThan(ResourceIndexedSearchParamString.MAX_LENGTH)); - List val = myOrganizationDao.searchForIds(new SearchParameterMap("name", new StringParam("P")), null); + List val = myOrganizationDao.searchForIds(new SearchParameterMap("name", new StringParam("P")), null); int initial = val.size(); myOrganizationDao.create(org, mySrd); @@ -4159,7 +4160,7 @@ public class FhirResourceDaoR4Test extends BaseJpaR4Test { String subStr1 = longStr1.substring(0, ResourceIndexedSearchParamString.MAX_LENGTH); String subStr2 = longStr2.substring(0, ResourceIndexedSearchParamString.MAX_LENGTH); - List val = myOrganizationDao.searchForIds(new SearchParameterMap("type", new TokenParam(subStr1, subStr2)), null); + List val = myOrganizationDao.searchForIds(new SearchParameterMap("type", new TokenParam(subStr1, subStr2)), null); int initial = val.size(); myOrganizationDao.create(org, mySrd); diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4UpdateTest.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4UpdateTest.java index 849c909ff6f..a0204af9ca5 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4UpdateTest.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4UpdateTest.java @@ -2,6 +2,7 @@ package ca.uhn.fhir.jpa.dao.r4; import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.jpa.api.config.DaoConfig; +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.model.util.JpaConstants; @@ -11,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; @@ -21,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; @@ -698,9 +697,9 @@ public class FhirResourceDaoR4UpdateTest extends BaseJpaR4Test { p2.addName().setFamily("Tester").addGiven("testUpdateMaintainsSearchParamsDstu2BBB"); myPatientDao.create(p2, mySrd).getId(); - List ids = myPatientDao.searchForIds(new SearchParameterMap(Patient.SP_GIVEN, new StringParam("testUpdateMaintainsSearchParamsDstu2AAA")), null); + List ids = myPatientDao.searchForIds(new SearchParameterMap(Patient.SP_GIVEN, new StringParam("testUpdateMaintainsSearchParamsDstu2AAA")), null); assertEquals(1, ids.size()); - assertThat(ResourcePersistentId.toLongList(ids), contains(p1id.getIdPartAsLong())); + assertThat(JpaPid.toLongList(ids), contains(p1id.getIdPartAsLong())); // Update the name p1.getName().get(0).getGiven().get(0).setValue("testUpdateMaintainsSearchParamsDstu2BBB"); diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirSearchDaoR4Test.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirSearchDaoR4Test.java index df3fae38d9b..e92bd68d1e5 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirSearchDaoR4Test.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirSearchDaoR4Test.java @@ -1,12 +1,12 @@ package ca.uhn.fhir.jpa.dao.r4; import ca.uhn.fhir.jpa.dao.IFulltextSearchSvc; +import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; 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; @@ -63,12 +63,11 @@ public class FhirSearchDaoR4Test extends BaseJpaR4Test { params.add("_content", new StringParam(content)); // test - List ids = mySearchDao.search("Patient", - params); + List ids = mySearchDao.search("Patient", params); // verify results Assertions.assertEquals(1, ids.size()); - Assertions.assertEquals(id1, ids.get(0).getIdAsLong()); + Assertions.assertEquals(id1, ids.get(0).getId()); } @Test @@ -134,8 +133,8 @@ public class FhirSearchDaoR4Test extends BaseJpaR4Test { map = new SearchParameterMap(); map.add(Constants.PARAM_CONTENT, content); - List found = mySearchDao.search(resourceName, map); - assertThat(ResourcePersistentId.toLongList(found), containsInAnyOrder(id1)); + List found = mySearchDao.search(resourceName, map); + assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1)); } // OR { @@ -145,8 +144,8 @@ public class FhirSearchDaoR4Test extends BaseJpaR4Test { map = new SearchParameterMap(); map.add(Constants.PARAM_CONTENT, content); map.add(Constants.PARAM_CONTENT, content); - List found = mySearchDao.search(resourceName, map); - assertThat(ResourcePersistentId.toLongList(found), containsInAnyOrder(id1, id2)); + List found = mySearchDao.search(resourceName, map); + assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1, id2)); } // AND { @@ -156,8 +155,8 @@ public class FhirSearchDaoR4Test extends BaseJpaR4Test { map = new SearchParameterMap(); map.add(Constants.PARAM_CONTENT, content); - List found = mySearchDao.search(resourceName, map); - assertThat(ResourcePersistentId.toLongList(found), containsInAnyOrder(id1)); + List found = mySearchDao.search(resourceName, map); + assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1)); } // AND OR { @@ -167,8 +166,8 @@ public class FhirSearchDaoR4Test extends BaseJpaR4Test { map = new SearchParameterMap(); map.add(Constants.PARAM_CONTENT, content); - List found = mySearchDao.search(resourceName, map); - assertThat(ResourcePersistentId.toLongList(found), containsInAnyOrder(id1, id2)); + List found = mySearchDao.search(resourceName, map); + assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1, id2)); } // All Resource Types { @@ -177,8 +176,8 @@ public class FhirSearchDaoR4Test extends BaseJpaR4Test { map = new SearchParameterMap(); map.add(Constants.PARAM_CONTENT, content); - List found = mySearchDao.search(null, map); - assertThat(ResourcePersistentId.toLongList(found), containsInAnyOrder(id1, id2, id3)); + List found = mySearchDao.search(null, map); + assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1, id2, id3)); } } @@ -213,8 +212,8 @@ public class FhirSearchDaoR4Test extends BaseJpaR4Test { map = new SearchParameterMap(); map.add(Constants.PARAM_TEXT, content); - List found = mySearchDao.search(resourceName, map); - assertThat(ResourcePersistentId.toLongList(found), containsInAnyOrder(id1)); + List found = mySearchDao.search(resourceName, map); + assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1)); } // OR { @@ -223,8 +222,8 @@ public class FhirSearchDaoR4Test extends BaseJpaR4Test { map = new SearchParameterMap(); map.add(Constants.PARAM_TEXT, content); - List found = mySearchDao.search(resourceName, map); - assertThat(ResourcePersistentId.toLongList(found), containsInAnyOrder(id1, id2)); + List found = mySearchDao.search(resourceName, map); + assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1, id2)); } // AND { @@ -234,8 +233,8 @@ public class FhirSearchDaoR4Test extends BaseJpaR4Test { map = new SearchParameterMap(); map.add(Constants.PARAM_TEXT, content); - List found = mySearchDao.search(resourceName, map); - assertThat(ResourcePersistentId.toLongList(found), containsInAnyOrder(id1)); + List found = mySearchDao.search(resourceName, map); + assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1)); } // AND OR { @@ -245,8 +244,8 @@ public class FhirSearchDaoR4Test extends BaseJpaR4Test { map = new SearchParameterMap(); map.add(Constants.PARAM_TEXT, content); - List found = mySearchDao.search(resourceName, map); - assertThat(ResourcePersistentId.toLongList(found), containsInAnyOrder(id1, id2)); + List found = mySearchDao.search(resourceName, map); + assertThat(JpaPid.toLongList(found), containsInAnyOrder(id1, id2)); } // Tag Contents { @@ -255,8 +254,8 @@ public class FhirSearchDaoR4Test extends BaseJpaR4Test { map = new SearchParameterMap(); map.add(Constants.PARAM_TEXT, content); - List found = mySearchDao.search(resourceName, map); - assertThat(ResourcePersistentId.toLongList(found), empty()); + List found = mySearchDao.search(resourceName, map); + assertThat(JpaPid.toLongList(found), empty()); } } diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/HookInterceptorR4Test.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/HookInterceptorR4Test.java index befa5a0bb37..b9757dca51e 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/HookInterceptorR4Test.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/HookInterceptorR4Test.java @@ -4,6 +4,7 @@ import ca.uhn.fhir.interceptor.api.Pointcut; import ca.uhn.fhir.jpa.api.config.DaoConfig; import ca.uhn.fhir.jpa.api.dao.IDao; import ca.uhn.fhir.jpa.api.svc.IIdHelperService; +import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.jpa.provider.BaseResourceProviderR4Test; import ca.uhn.fhir.rest.api.MethodOutcome; import ca.uhn.fhir.rest.server.provider.ProviderConstants; @@ -21,6 +22,7 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import java.util.Collections; +import java.util.List; import java.util.concurrent.atomic.AtomicLong; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -31,7 +33,7 @@ public class HookInterceptorR4Test extends BaseResourceProviderR4Test { private static final Logger ourLog = LoggerFactory.getLogger(HookInterceptorR4Test.class); @Autowired - IIdHelperService myIdHelperService; + IIdHelperService myIdHelperService; @Override @BeforeEach @@ -113,7 +115,9 @@ public class HookInterceptorR4Test extends BaseResourceProviderR4Test { IIdType savedPatientId = myClient.create().resource(new Patient()).execute().getId(); runInTransaction(() -> { - Long savedPatientPid = myIdHelperService.resolveResourcePersistentIdsWithCache(null, Collections.singletonList(savedPatientId)).get(0).getIdAsLong(); + List pids = myIdHelperService.resolveResourcePersistentIdsWithCache(null, + Collections.singletonList(savedPatientId)); + Long savedPatientPid = pids.get(0).getId(); assertEquals(savedPatientPid.longValue(), pid.get()); }); } @@ -128,7 +132,7 @@ public class HookInterceptorR4Test extends BaseResourceProviderR4Test { pid.set(resourcePid); }); IIdType savedPatientId = myClient.create().resource(new Patient()).execute().getId(); - Long savedPatientPid = runInTransaction(() -> myIdHelperService.resolveResourcePersistentIdsWithCache(null, Collections.singletonList(savedPatientId)).get(0).getIdAsLong()); + Long savedPatientPid = runInTransaction(() -> myIdHelperService.resolveResourcePersistentIdsWithCache(null, Collections.singletonList(savedPatientId)).get(0).getId()); myClient.delete().resourceById(savedPatientId).execute(); Parameters parameters = new Parameters(); @@ -165,7 +169,7 @@ public class HookInterceptorR4Test extends BaseResourceProviderR4Test { patient.setActive(true); myClient.update().resource(patient).execute(); runInTransaction(() -> { - Long savedPatientPid = myIdHelperService.resolveResourcePersistentIdsWithCache(null, Collections.singletonList(savedPatientId)).get(0).getIdAsLong(); + Long savedPatientPid = myIdHelperService.resolveResourcePersistentIdsWithCache(null, Collections.singletonList(savedPatientId)).get(0).getId(); assertEquals(savedPatientPid.longValue(), pidOld.get()); assertEquals(savedPatientPid.longValue(), pidNew.get()); }); diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/PatientEverythingCompartmentExpansionTest.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/PatientEverythingCompartmentExpansionTest.java index f267e70e109..e23a41f7a1a 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/PatientEverythingCompartmentExpansionTest.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/PatientEverythingCompartmentExpansionTest.java @@ -10,7 +10,6 @@ import org.apache.http.client.methods.HttpGet; import org.hl7.fhir.r4.model.Bundle; import org.hl7.fhir.r4.model.Bundle.BundleEntryComponent; import org.hl7.fhir.r4.model.Device; -import org.hl7.fhir.r4.model.Location; import org.hl7.fhir.r4.model.Medication; import org.hl7.fhir.r4.model.MedicationAdministration; import org.hl7.fhir.r4.model.Organization; diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderMeaningfulOutcomeMessageR4Test.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderMeaningfulOutcomeMessageR4Test.java index c740cb191ee..5951f1b8cd6 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderMeaningfulOutcomeMessageR4Test.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderMeaningfulOutcomeMessageR4Test.java @@ -19,26 +19,11 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import static ca.uhn.fhir.util.TestUtil.sleepAtLeast; import static org.apache.commons.lang3.StringUtils.isNotBlank; import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.contains; -import static org.hamcrest.Matchers.containsInAnyOrder; -import static org.hamcrest.Matchers.containsInRelativeOrder; -import static org.hamcrest.Matchers.hasItem; -import static org.hamcrest.Matchers.hasItems; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.matchesPattern; -import static org.hamcrest.Matchers.not; -import static org.hamcrest.Matchers.stringContainsInOrder; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNotEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.junit.jupiter.api.Assertions.fail; @SuppressWarnings("Duplicates") public class ResourceProviderMeaningfulOutcomeMessageR4Test extends BaseResourceProviderR4Test { diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4Test.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4Test.java index f8fa65efae8..0b2fb75633e 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4Test.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4Test.java @@ -3,7 +3,6 @@ package ca.uhn.fhir.jpa.provider.r4; import ca.uhn.fhir.i18n.HapiLocalizer; import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.jpa.api.config.DaoConfig; -import ca.uhn.fhir.jpa.dao.BaseStorageDao; import ca.uhn.fhir.jpa.dao.data.ISearchDao; import ca.uhn.fhir.jpa.entity.Search; import ca.uhn.fhir.jpa.model.entity.ModelConfig; @@ -16,7 +15,6 @@ import ca.uhn.fhir.jpa.search.SearchCoordinatorSvcImpl; import ca.uhn.fhir.jpa.term.ZipCollectionBuilder; import ca.uhn.fhir.jpa.test.config.TestR4Config; import ca.uhn.fhir.jpa.util.QueryParameterUtils; -import ca.uhn.fhir.model.api.StorageResponseCodeEnum; import ca.uhn.fhir.model.api.TemporalPrecisionEnum; import ca.uhn.fhir.model.primitive.IdDt; import ca.uhn.fhir.model.primitive.InstantDt; @@ -49,7 +47,6 @@ import ca.uhn.fhir.rest.server.exceptions.PreconditionFailedException; import ca.uhn.fhir.rest.server.exceptions.ResourceGoneException; import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException; import ca.uhn.fhir.rest.server.interceptor.RequestValidatingInterceptor; -import ca.uhn.fhir.util.BundleBuilder; import ca.uhn.fhir.util.ClasspathUtil; import ca.uhn.fhir.util.StopWatch; import ca.uhn.fhir.util.UrlUtil; @@ -73,7 +70,6 @@ import org.apache.http.entity.ContentType; import org.apache.http.entity.StringEntity; import org.apache.http.message.BasicNameValuePair; import org.apache.http.util.EntityUtils; -import org.hamcrest.Matcher; import org.hamcrest.Matchers; import org.hl7.fhir.common.hapi.validation.validator.FhirInstanceValidator; import org.hl7.fhir.instance.model.api.IAnyResource; diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4ValueSetNoVerCSNoVerTest.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4ValueSetNoVerCSNoVerTest.java index 18c78ed3593..ab61de4caf3 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4ValueSetNoVerCSNoVerTest.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4ValueSetNoVerCSNoVerTest.java @@ -10,11 +10,11 @@ import ca.uhn.fhir.jpa.entity.TermConceptParentChildLink.RelationshipTypeEnum; import ca.uhn.fhir.jpa.entity.TermValueSet; import ca.uhn.fhir.jpa.entity.TermValueSetConcept; import ca.uhn.fhir.jpa.entity.TermValueSetPreExpansionStatusEnum; +import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.jpa.model.entity.ResourceTable; import ca.uhn.fhir.jpa.model.util.JpaConstants; import ca.uhn.fhir.jpa.provider.BaseResourceProviderR4Test; import ca.uhn.fhir.jpa.term.api.ITermCodeSystemStorageSvc; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; import ca.uhn.fhir.rest.server.provider.ProviderConstants; @@ -1576,7 +1576,7 @@ public class ResourceProviderR4ValueSetNoVerCSNoVerTest extends BaseResourceProv TermConcept parentB = new TermConcept(cs, "ParentB").setDisplay("Parent B"); cs.getConcepts().add(parentB); - theTermCodeSystemStorageSvc.storeNewCodeSystemVersion(new ResourcePersistentId(table.getId()), URL_MY_CODE_SYSTEM, "SYSTEM NAME", "SYSTEM VERSION", cs, table); + theTermCodeSystemStorageSvc.storeNewCodeSystemVersion(JpaPid.fromId(table.getId()), URL_MY_CODE_SYSTEM, "SYSTEM NAME", "SYSTEM VERSION", cs, table); return codeSystem; } diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4ValueSetVerCSNoVerTest.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4ValueSetVerCSNoVerTest.java index 065bc62a781..dac78d5ed4d 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4ValueSetVerCSNoVerTest.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4ValueSetVerCSNoVerTest.java @@ -10,11 +10,11 @@ import ca.uhn.fhir.jpa.entity.TermConceptParentChildLink.RelationshipTypeEnum; import ca.uhn.fhir.jpa.entity.TermValueSet; import ca.uhn.fhir.jpa.entity.TermValueSetConcept; import ca.uhn.fhir.jpa.entity.TermValueSetPreExpansionStatusEnum; +import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.jpa.model.entity.ResourceTable; import ca.uhn.fhir.jpa.provider.BaseResourceProviderR4Test; import ca.uhn.fhir.jpa.term.api.ITermCodeSystemStorageSvc; import ca.uhn.fhir.jpa.term.api.ITermReadSvc; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails; @@ -1051,7 +1051,7 @@ public class ResourceProviderR4ValueSetVerCSNoVerTest extends BaseResourceProvid TermConcept parentB = new TermConcept(cs, "ParentB").setDisplay("Parent B"); cs.getConcepts().add(parentB); - theTermCodeSystemStorageSvc.storeNewCodeSystemVersion(new ResourcePersistentId(table.getId()), URL_MY_CODE_SYSTEM, "SYSTEM NAME", "SYSTEM VERSION", cs, table); + theTermCodeSystemStorageSvc.storeNewCodeSystemVersion(JpaPid.fromId(table.getId()), URL_MY_CODE_SYSTEM, "SYSTEM NAME", "SYSTEM VERSION", cs, table); return codeSystem; } diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4ValueSetVerCSVerTest.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4ValueSetVerCSVerTest.java index 1653b74262b..43725a77e0d 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4ValueSetVerCSVerTest.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4ValueSetVerCSVerTest.java @@ -9,11 +9,11 @@ import ca.uhn.fhir.jpa.entity.TermConceptParentChildLink.RelationshipTypeEnum; import ca.uhn.fhir.jpa.entity.TermValueSet; import ca.uhn.fhir.jpa.entity.TermValueSetConcept; import ca.uhn.fhir.jpa.entity.TermValueSetPreExpansionStatusEnum; +import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.jpa.model.entity.ResourceTable; import ca.uhn.fhir.jpa.provider.BaseResourceProviderR4Test; import ca.uhn.fhir.jpa.term.api.ITermCodeSystemStorageSvc; import ca.uhn.fhir.jpa.term.api.ITermReadSvc; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException; import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails; @@ -1716,7 +1716,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider TermConcept parentB = new TermConcept(cs, "ParentB").setDisplay("Parent B"); cs.getConcepts().add(parentB); - theTermCodeSystemStorageSvc.storeNewCodeSystemVersion(new ResourcePersistentId(table.getId()), URL_MY_CODE_SYSTEM, "SYSTEM NAME", "SYSTEM VERSION", cs, table); + theTermCodeSystemStorageSvc.storeNewCodeSystemVersion(JpaPid.fromId(table.getId()), URL_MY_CODE_SYSTEM, "SYSTEM NAME", "SYSTEM VERSION", cs, table); return codeSystem; } @@ -1750,7 +1750,7 @@ public class ResourceProviderR4ValueSetVerCSVerTest extends BaseResourceProvider TermConcept parentB = new TermConcept(cs, "ParentB").setDisplay("Parent B" + theCodeSystemVersion); cs.getConcepts().add(parentB); - theTermCodeSystemStorageSvc.storeNewCodeSystemVersion(new ResourcePersistentId(table.getId()), URL_MY_CODE_SYSTEM, "SYSTEM NAME", theCodeSystemVersion, cs, table); + theTermCodeSystemStorageSvc.storeNewCodeSystemVersion(JpaPid.fromId(table.getId()), URL_MY_CODE_SYSTEM, "SYSTEM NAME", theCodeSystemVersion, cs, table); return codeSystem; } diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/search/reindex/ResourceReindexingSvcImplTest.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/search/reindex/ResourceReindexingSvcImplTest.java index 907b9176b46..a4ecbbcb476 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/search/reindex/ResourceReindexingSvcImplTest.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/search/reindex/ResourceReindexingSvcImplTest.java @@ -4,6 +4,7 @@ import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.jpa.api.dao.DaoRegistry; import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao; import ca.uhn.fhir.jpa.dao.BaseHapiFhirDao; +import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.jpa.dao.data.IForcedIdDao; import ca.uhn.fhir.jpa.dao.data.IResourceReindexJobDao; import ca.uhn.fhir.jpa.dao.data.IResourceTableDao; @@ -11,7 +12,6 @@ import ca.uhn.fhir.jpa.entity.ResourceReindexJobEntity; import ca.uhn.fhir.jpa.model.entity.ResourceTable; import ca.uhn.fhir.jpa.model.sched.ISchedulerService; import ca.uhn.fhir.jpa.test.BaseJpaTest; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; import ca.uhn.fhir.rest.server.util.ISearchParamRegistry; import org.apache.commons.lang3.time.DateUtils; import org.hl7.fhir.instance.model.api.IBaseResource; @@ -242,7 +242,7 @@ public class ResourceReindexingSvcImplTest extends BaseJpaTest { when(myDaoRegistry.getResourceDao(eq("Patient"))).thenReturn(myResourceDao); when(myDaoRegistry.getResourceDao(eq(Patient.class))).thenReturn(myResourceDao); when(myResourceDao.readByPid(any(), anyBoolean())).thenAnswer(t->{ - int idx = t.getArgument(0, ResourcePersistentId.class).getIdAsLong().intValue(); + int idx = t.getArgument(0, JpaPid.class).getId().intValue(); return resources.get(idx); }); @@ -350,7 +350,7 @@ public class ResourceReindexingSvcImplTest extends BaseJpaTest { when(myDaoRegistry.getResourceDao(eq("Observation"))).thenReturn(myResourceDao); when(myDaoRegistry.getResourceDao(eq(Observation.class))).thenReturn(myResourceDao); when(myResourceDao.readByPid(any(), anyBoolean())).thenAnswer(t->{ - int idx = t.getArgument(0, ResourcePersistentId.class).getIdAsLong().intValue(); + int idx = t.getArgument(0, JpaPid.class).getId().intValue(); return resources.get(idx); }); } diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/term/BaseTermR4Test.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/term/BaseTermR4Test.java index 4d6f115cd27..320705bc122 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/term/BaseTermR4Test.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/term/BaseTermR4Test.java @@ -4,9 +4,9 @@ import ca.uhn.fhir.jpa.api.config.DaoConfig; import ca.uhn.fhir.jpa.entity.TermCodeSystemVersion; import ca.uhn.fhir.jpa.entity.TermConcept; import ca.uhn.fhir.jpa.entity.TermConceptParentChildLink; +import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.jpa.model.entity.ResourceTable; import ca.uhn.fhir.jpa.test.BaseJpaR4Test; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; import org.hl7.fhir.instance.model.api.IIdType; import org.hl7.fhir.r4.model.CodeSystem; import org.hl7.fhir.r4.model.ValueSet; @@ -88,7 +88,7 @@ public abstract class BaseTermR4Test extends BaseJpaR4Test { TermConcept parentB = new TermConcept(cs, "ParentB"); cs.getConcepts().add(parentB); - myTermCodeSystemStorageSvc.storeNewCodeSystemVersion(new ResourcePersistentId(table.getId()), CS_URL, "SYSTEM NAME", "SYSTEM VERSION", cs, table); + myTermCodeSystemStorageSvc.storeNewCodeSystemVersion(JpaPid.fromId(table.getId()), CS_URL, "SYSTEM NAME", "SYSTEM VERSION", cs, table); return id; }); diff --git a/hapi-fhir-jpaserver-test-r4b/pom.xml b/hapi-fhir-jpaserver-test-r4b/pom.xml index c9a374220a0..fc1aebf89e1 100644 --- a/hapi-fhir-jpaserver-test-r4b/pom.xml +++ b/hapi-fhir-jpaserver-test-r4b/pom.xml @@ -6,7 +6,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-test-r5/pom.xml b/hapi-fhir-jpaserver-test-r5/pom.xml index 646ea335bc8..7d373842012 100644 --- a/hapi-fhir-jpaserver-test-r5/pom.xml +++ b/hapi-fhir-jpaserver-test-r5/pom.xml @@ -6,7 +6,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-test-r5/src/test/java/ca/uhn/fhir/jpa/provider/r5/ResourceProviderR5ValueSetTest.java b/hapi-fhir-jpaserver-test-r5/src/test/java/ca/uhn/fhir/jpa/provider/r5/ResourceProviderR5ValueSetTest.java index a4672dd70f9..755004f750f 100644 --- a/hapi-fhir-jpaserver-test-r5/src/test/java/ca/uhn/fhir/jpa/provider/r5/ResourceProviderR5ValueSetTest.java +++ b/hapi-fhir-jpaserver-test-r5/src/test/java/ca/uhn/fhir/jpa/provider/r5/ResourceProviderR5ValueSetTest.java @@ -10,10 +10,10 @@ import ca.uhn.fhir.jpa.entity.TermConceptParentChildLink.RelationshipTypeEnum; import ca.uhn.fhir.jpa.entity.TermValueSet; import ca.uhn.fhir.jpa.entity.TermValueSetConcept; import ca.uhn.fhir.jpa.entity.TermValueSetPreExpansionStatusEnum; +import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.jpa.model.entity.ResourceTable; import ca.uhn.fhir.jpa.term.api.ITermCodeSystemStorageSvc; import ca.uhn.fhir.jpa.term.api.ITermReadSvc; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails; @@ -1475,7 +1475,7 @@ public class ResourceProviderR5ValueSetTest extends BaseResourceProviderR5Test { TermConcept parentB = new TermConcept(cs, "ParentB").setDisplay("Parent B"); cs.getConcepts().add(parentB); - theTermCodeSystemStorageSvc.storeNewCodeSystemVersion(new ResourcePersistentId(table.getId()), URL_MY_CODE_SYSTEM, "SYSTEM NAME", "SYSTEM VERSION", cs, table); + theTermCodeSystemStorageSvc.storeNewCodeSystemVersion(JpaPid.fromId(table.getId()), URL_MY_CODE_SYSTEM, "SYSTEM NAME", "SYSTEM VERSION", cs, table); return codeSystem; } diff --git a/hapi-fhir-jpaserver-test-r5/src/test/java/ca/uhn/fhir/jpa/provider/r5/ResourceProviderR5ValueSetVersionedTest.java b/hapi-fhir-jpaserver-test-r5/src/test/java/ca/uhn/fhir/jpa/provider/r5/ResourceProviderR5ValueSetVersionedTest.java index b7f782abc76..251d284e28b 100644 --- a/hapi-fhir-jpaserver-test-r5/src/test/java/ca/uhn/fhir/jpa/provider/r5/ResourceProviderR5ValueSetVersionedTest.java +++ b/hapi-fhir-jpaserver-test-r5/src/test/java/ca/uhn/fhir/jpa/provider/r5/ResourceProviderR5ValueSetVersionedTest.java @@ -9,9 +9,9 @@ import ca.uhn.fhir.jpa.entity.TermConceptParentChildLink.RelationshipTypeEnum; import ca.uhn.fhir.jpa.entity.TermValueSet; import ca.uhn.fhir.jpa.entity.TermValueSetConcept; import ca.uhn.fhir.jpa.entity.TermValueSetPreExpansionStatusEnum; +import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.jpa.model.entity.ResourceTable; import ca.uhn.fhir.jpa.term.api.ITermCodeSystemStorageSvc; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException; import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails; @@ -1478,7 +1478,7 @@ public class ResourceProviderR5ValueSetVersionedTest extends BaseResourceProvide TermConcept parentB = new TermConcept(cs, "ParentB").setDisplay("Parent B"); cs.getConcepts().add(parentB); - theTermCodeSystemStorageSvc.storeNewCodeSystemVersion(new ResourcePersistentId(table.getId()), URL_MY_CODE_SYSTEM, "SYSTEM NAME", "SYSTEM VERSION", cs, table); + theTermCodeSystemStorageSvc.storeNewCodeSystemVersion(JpaPid.fromId(table.getId()), URL_MY_CODE_SYSTEM, "SYSTEM NAME", "SYSTEM VERSION", cs, table); return codeSystem; } @@ -1512,7 +1512,7 @@ public class ResourceProviderR5ValueSetVersionedTest extends BaseResourceProvide TermConcept parentB = new TermConcept(cs, "ParentB").setDisplay("Parent B" + theCodeSystemVersion); cs.getConcepts().add(parentB); - theTermCodeSystemStorageSvc.storeNewCodeSystemVersion(new ResourcePersistentId(table.getId()), URL_MY_CODE_SYSTEM, "SYSTEM NAME", theCodeSystemVersion, cs, table); + theTermCodeSystemStorageSvc.storeNewCodeSystemVersion(JpaPid.fromId(table.getId()), URL_MY_CODE_SYSTEM, "SYSTEM NAME", theCodeSystemVersion, cs, table); return codeSystem; } diff --git a/hapi-fhir-jpaserver-test-utilities/pom.xml b/hapi-fhir-jpaserver-test-utilities/pom.xml index 7c61d62309d..b7e09269feb 100644 --- a/hapi-fhir-jpaserver-test-utilities/pom.xml +++ b/hapi-fhir-jpaserver-test-utilities/pom.xml @@ -6,7 +6,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/BaseValueSetHSearchExpansionR4Test.java b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/BaseValueSetHSearchExpansionR4Test.java index 491dee780e0..3a0a57b995b 100644 --- a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/BaseValueSetHSearchExpansionR4Test.java +++ b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/BaseValueSetHSearchExpansionR4Test.java @@ -34,6 +34,7 @@ import ca.uhn.fhir.jpa.dao.data.ITermCodeSystemVersionDao; import ca.uhn.fhir.jpa.entity.TermCodeSystemVersion; import ca.uhn.fhir.jpa.entity.TermConcept; import ca.uhn.fhir.jpa.entity.TermConceptParentChildLink.RelationshipTypeEnum; +import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.jpa.model.entity.ResourceTable; import ca.uhn.fhir.jpa.search.reindex.IResourceReindexingSvc; import ca.uhn.fhir.jpa.term.IValueSetConceptAccumulator; @@ -46,7 +47,6 @@ import ca.uhn.fhir.jpa.term.api.ITermDeferredStorageSvc; import ca.uhn.fhir.jpa.term.api.ITermReadSvc; import ca.uhn.fhir.jpa.term.custom.CustomTerminologySet; import ca.uhn.fhir.parser.StrictErrorHandler; -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; @@ -1883,7 +1883,7 @@ public abstract class BaseValueSetHSearchExpansionR4Test extends BaseJpaTest { code2.getDisplay()); termCodeSystemVersion.getConcepts().add(code4); - myTermCodeSystemStorageSvc.storeNewCodeSystemVersion(new ResourcePersistentId(table.getId()), LOINC_URI, "SYSTEM NAME", "SYSTEM VERSION", termCodeSystemVersion, table); + myTermCodeSystemStorageSvc.storeNewCodeSystemVersion(JpaPid.fromId(table.getId()), LOINC_URI, "SYSTEM NAME", "SYSTEM VERSION", termCodeSystemVersion, table); return csId.getIdPartAsLong(); } @@ -1939,7 +1939,7 @@ public abstract class BaseValueSetHSearchExpansionR4Test extends BaseJpaTest { TermConcept parentB = new TermConcept(cs, "ParentB"); cs.getConcepts().add(parentB); - myTermCodeSystemStorageSvc.storeNewCodeSystemVersion(new ResourcePersistentId(table.getId()), CS_URL, "SYSTEM NAME", null, cs, table); + myTermCodeSystemStorageSvc.storeNewCodeSystemVersion(JpaPid.fromId(table.getId()), CS_URL, "SYSTEM NAME", null, cs, table); myTerminologyDeferredStorageSvc.saveAllDeferred(); @@ -1961,7 +1961,7 @@ public abstract class BaseValueSetHSearchExpansionR4Test extends BaseJpaTest { TermConcept parentA = new TermConcept(cs, "CS2"); cs.getConcepts().add(parentA); - myTermCodeSystemStorageSvc.storeNewCodeSystemVersion(new ResourcePersistentId(table.getId()), CS_URL_2, "SYSTEM NAME", "SYSTEM VERSION", cs, table); + myTermCodeSystemStorageSvc.storeNewCodeSystemVersion(JpaPid.fromId(table.getId()), CS_URL_2, "SYSTEM NAME", "SYSTEM VERSION", cs, table); } @@ -2029,7 +2029,7 @@ public abstract class BaseValueSetHSearchExpansionR4Test extends BaseJpaTest { TermConcept parentB = new TermConcept(cs, "ParentB"); cs.getConcepts().add(parentB); - myTermCodeSystemStorageSvc.storeNewCodeSystemVersion(new ResourcePersistentId(table.getId()), CS_URL, "SYSTEM NAME", null, cs, table); + myTermCodeSystemStorageSvc.storeNewCodeSystemVersion(JpaPid.fromId(table.getId()), CS_URL, "SYSTEM NAME", null, cs, table); myTerminologyDeferredStorageSvc.saveAllDeferred(); diff --git a/hapi-fhir-jpaserver-test-utilities/src/test/java/ca/uhn/fhir/jpa/dao/expunge/PartitionRunnerTest.java b/hapi-fhir-jpaserver-test-utilities/src/test/java/ca/uhn/fhir/jpa/dao/expunge/PartitionRunnerTest.java index 3e5b1d26884..439ca02fb52 100644 --- a/hapi-fhir-jpaserver-test-utilities/src/test/java/ca/uhn/fhir/jpa/dao/expunge/PartitionRunnerTest.java +++ b/hapi-fhir-jpaserver-test-utilities/src/test/java/ca/uhn/fhir/jpa/dao/expunge/PartitionRunnerTest.java @@ -2,7 +2,8 @@ package ca.uhn.fhir.jpa.dao.expunge; import ca.uhn.fhir.interceptor.api.HookParams; import ca.uhn.fhir.jpa.api.config.DaoConfig; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.jpa.model.dao.JpaPid; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import ca.uhn.test.concurrency.PointcutLatch; import com.google.common.collect.Sets; import org.apache.commons.lang3.builder.ToStringBuilder; @@ -35,8 +36,8 @@ public class PartitionRunnerTest { @Test public void emptyList() { - List resourceIds = buildPidList(0); - Consumer> partitionConsumer = buildPartitionConsumer(myLatch); + List resourceIds = buildPidList(0); + Consumer> partitionConsumer = buildPartitionConsumer(myLatch); myLatch.setExpectedCount(0); getPartitionRunner().runInPartitionedThreads(resourceIds, partitionConsumer); @@ -55,19 +56,19 @@ public class PartitionRunnerTest { return new PartitionRunner("TEST", "test", theBatchSize, theThreadCount); } - private List buildPidList(int size) { - List list = new ArrayList<>(); + private List buildPidList(int size) { + List list = new ArrayList<>(); for (long i = 0; i < size; ++i) { - list.add(new ResourcePersistentId(i + 1)); + list.add(JpaPid.fromId(i + 1)); } return list; } @Test public void oneItem() throws InterruptedException { - List resourceIds = buildPidList(1); + List resourceIds = buildPidList(1); - Consumer> partitionConsumer = buildPartitionConsumer(myLatch); + Consumer> partitionConsumer = buildPartitionConsumer(myLatch); myLatch.setExpectedCount(1); getPartitionRunner().runInPartitionedThreads(resourceIds, partitionConsumer); PartitionCall partitionCall = (PartitionCall) PointcutLatch.getLatchInvocationParameter(myLatch.awaitExpected()); @@ -78,9 +79,9 @@ public class PartitionRunnerTest { @Test public void twoItems() throws InterruptedException { - List resourceIds = buildPidList(2); + List resourceIds = buildPidList(2); - Consumer> partitionConsumer = buildPartitionConsumer(myLatch); + Consumer> partitionConsumer = buildPartitionConsumer(myLatch); myLatch.setExpectedCount(1); getPartitionRunner().runInPartitionedThreads(resourceIds, partitionConsumer); PartitionCall partitionCall = (PartitionCall) PointcutLatch.getLatchInvocationParameter(myLatch.awaitExpected()); @@ -90,9 +91,9 @@ public class PartitionRunnerTest { @Test public void tenItemsBatch5() throws InterruptedException { - List resourceIds = buildPidList(10); + List resourceIds = buildPidList(10); - Consumer> partitionConsumer = buildPartitionConsumer(myLatch); + Consumer> partitionConsumer = buildPartitionConsumer(myLatch); myLatch.setExpectedCount(2); getPartitionRunner(5).runInPartitionedThreads(resourceIds, partitionConsumer); List calls = myLatch.awaitExpected(); @@ -107,13 +108,13 @@ public class PartitionRunnerTest { @Test public void nineItemsBatch5() throws InterruptedException { - List resourceIds = buildPidList(9); + List resourceIds = buildPidList(9); // We don't care in which order, but one partition size should be // 5 and one should be 4 Set nums = Sets.newHashSet(5, 4); - Consumer> partitionConsumer = buildPartitionConsumer(myLatch); + Consumer> partitionConsumer = buildPartitionConsumer(myLatch); myLatch.setExpectedCount(2); getPartitionRunner(5).runInPartitionedThreads(resourceIds, partitionConsumer); List calls = myLatch.awaitExpected(); @@ -128,9 +129,9 @@ public class PartitionRunnerTest { @Test public void tenItemsOneThread() throws InterruptedException { - List resourceIds = buildPidList(10); + List resourceIds = buildPidList(10); - Consumer> partitionConsumer = buildPartitionConsumer(myLatch); + Consumer> partitionConsumer = buildPartitionConsumer(myLatch); myLatch.setExpectedCount(2); getPartitionRunner(5, 1).runInPartitionedThreads(resourceIds, partitionConsumer); List calls = myLatch.awaitExpected(); @@ -146,7 +147,7 @@ public class PartitionRunnerTest { } } - private Consumer> buildPartitionConsumer(PointcutLatch latch) { + private Consumer> buildPartitionConsumer(PointcutLatch latch) { return list -> latch.call(new PartitionCall(Thread.currentThread().getName(), list.size())); } diff --git a/hapi-fhir-jpaserver-test-utilities/src/test/java/ca/uhn/fhir/jpa/dao/index/ResourceVersionSvcTest.java b/hapi-fhir-jpaserver-test-utilities/src/test/java/ca/uhn/fhir/jpa/dao/index/ResourceVersionSvcTest.java index 7d4e10d4de7..9c37bce5cf0 100644 --- a/hapi-fhir-jpaserver-test-utilities/src/test/java/ca/uhn/fhir/jpa/dao/index/ResourceVersionSvcTest.java +++ b/hapi-fhir-jpaserver-test-utilities/src/test/java/ca/uhn/fhir/jpa/dao/index/ResourceVersionSvcTest.java @@ -7,9 +7,10 @@ import ca.uhn.fhir.jpa.cache.ResourcePersistentIdMap; import ca.uhn.fhir.jpa.cache.ResourceVersionSvcDaoImpl; import ca.uhn.fhir.jpa.dao.data.IResourceTableDao; import ca.uhn.fhir.jpa.model.config.PartitionSettings; +import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.jpa.model.entity.ForcedId; import ca.uhn.fhir.model.primitive.IdDt; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import org.hl7.fhir.instance.model.api.IIdType; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -87,20 +88,20 @@ public class ResourceVersionSvcTest { * @param theResourcePacks */ private void mockReturnsFor_getIdsOfExistingResources(ResourceIdPackage... theResourcePacks) { - List resourcePersistentIds = new ArrayList<>(); + List resourcePersistentIds = new ArrayList<>(); List matches = new ArrayList<>(); for (ResourceIdPackage pack : theResourcePacks) { - resourcePersistentIds.add(pack.MyPid); + resourcePersistentIds.add(pack.myPid); matches.add(getResourceTableRecordForResourceTypeAndPid( pack.MyResourceId.getResourceType(), - pack.MyPid.getIdAsLong(), + pack.myPid.getId(), pack.MyVersion )); } - ResourcePersistentId first = resourcePersistentIds.remove(0); + IResourcePersistentId first = resourcePersistentIds.remove(0); if (resourcePersistentIds.isEmpty()) { when(myIdHelperService.resolveResourcePersistentIdsWithCache(any(), any())).thenReturn(Collections.singletonList(first)); } else { @@ -111,11 +112,11 @@ public class ResourceVersionSvcTest { @Test public void getLatestVersionIdsForResourceIds_whenResourceExists_returnsMapWithPIDAndVersion() { IIdType type = new IdDt("Patient/RED"); - ResourcePersistentId pid = new ResourcePersistentId(1L); - pid.setAssociatedResourceId(type); - HashMap map = new HashMap<>(); - map.put(type, pid); - ResourceIdPackage pack = new ResourceIdPackage(type, pid, 2L); + JpaPid jpaPid = JpaPid.fromId(1L); + jpaPid.setAssociatedResourceId(type); + HashMap map = new HashMap<>(); + map.put(type, jpaPid); + ResourceIdPackage pack = new ResourceIdPackage(type, jpaPid, 2L); // when mockReturnsFor_getIdsOfExistingResources(pack); @@ -125,7 +126,7 @@ public class ResourceVersionSvcTest { Collections.singletonList(type)); Assertions.assertTrue(retMap.containsKey(type)); - Assertions.assertEquals(pid.getVersion(), map.get(type).getVersion()); + Assertions.assertEquals(jpaPid.getVersion(), map.get(type).getVersion()); } @Test @@ -146,9 +147,9 @@ public class ResourceVersionSvcTest { public void getLatestVersionIdsForResourceIds_whenSomeResourcesDoNotExist_returnsOnlyExistingElements() { // resource to be found IIdType type = new IdDt("Patient/RED"); - ResourcePersistentId pid = new ResourcePersistentId(1L); - pid.setAssociatedResourceId(type); - ResourceIdPackage pack = new ResourceIdPackage(type, pid, 2L); + JpaPid jpaPid = JpaPid.fromId(1L); + jpaPid.setAssociatedResourceId(type); + ResourceIdPackage pack = new ResourceIdPackage(type, jpaPid, 2L); // resource that won't be found IIdType type2 = new IdDt("Patient/BLUE"); @@ -196,14 +197,14 @@ public class ResourceVersionSvcTest { // helper class to package up data for helper methods private class ResourceIdPackage { public IIdType MyResourceId; - public ResourcePersistentId MyPid; + public JpaPid myPid; public Long MyVersion; public ResourceIdPackage(IIdType id, - ResourcePersistentId pid, + JpaPid pid, Long version) { MyResourceId = id; - MyPid = pid; + myPid = pid; MyVersion = version; } } diff --git a/hapi-fhir-jpaserver-test-utilities/src/test/java/ca/uhn/fhir/jpa/term/LoincFullLoadR4SandboxIT.java b/hapi-fhir-jpaserver-test-utilities/src/test/java/ca/uhn/fhir/jpa/term/LoincFullLoadR4SandboxIT.java index 6a3e342753e..67ad68cba3b 100644 --- a/hapi-fhir-jpaserver-test-utilities/src/test/java/ca/uhn/fhir/jpa/term/LoincFullLoadR4SandboxIT.java +++ b/hapi-fhir-jpaserver-test-utilities/src/test/java/ca/uhn/fhir/jpa/term/LoincFullLoadR4SandboxIT.java @@ -3,7 +3,6 @@ package ca.uhn.fhir.jpa.term; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.jpa.api.dao.IFhirResourceDaoValueSet; import ca.uhn.fhir.jpa.dao.IJpaStorageResourceParser; -import ca.uhn.fhir.jpa.dao.IStorageResourceParser; import ca.uhn.fhir.jpa.dao.data.ITermCodeSystemDao; import ca.uhn.fhir.jpa.dao.data.ITermCodeSystemVersionDao; import ca.uhn.fhir.jpa.dao.data.ITermConceptDao; diff --git a/hapi-fhir-jpaserver-uhnfhirtest/pom.xml b/hapi-fhir-jpaserver-uhnfhirtest/pom.xml index 89e64e9ff83..adb5a011791 100644 --- a/hapi-fhir-jpaserver-uhnfhirtest/pom.xml +++ b/hapi-fhir-jpaserver-uhnfhirtest/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../pom.xml diff --git a/hapi-fhir-server-mdm/pom.xml b/hapi-fhir-server-mdm/pom.xml index 3850ac69145..19dc5c13b36 100644 --- a/hapi-fhir-server-mdm/pom.xml +++ b/hapi-fhir-server-mdm/pom.xml @@ -7,7 +7,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-server-mdm/src/main/java/ca/uhn/fhir/mdm/api/IMdmLink.java b/hapi-fhir-server-mdm/src/main/java/ca/uhn/fhir/mdm/api/IMdmLink.java index af07438005f..c1861854109 100644 --- a/hapi-fhir-server-mdm/src/main/java/ca/uhn/fhir/mdm/api/IMdmLink.java +++ b/hapi-fhir-server-mdm/src/main/java/ca/uhn/fhir/mdm/api/IMdmLink.java @@ -21,26 +21,26 @@ package ca.uhn.fhir.mdm.api; */ import ca.uhn.fhir.jpa.model.entity.PartitionablePartitionId; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import java.util.Date; -public interface IMdmLink { - ResourcePersistentId getId(); +public interface IMdmLink { + T getId(); - IMdmLink setId(ResourcePersistentId theId); + IMdmLink setId(T theId); - ResourcePersistentId getGoldenResourcePersistenceId(); + T getGoldenResourcePersistenceId(); - IMdmLink setGoldenResourcePersistenceId(ResourcePersistentId theGoldenResourcePid); + IMdmLink setGoldenResourcePersistenceId(T theGoldenResourcePid); - ResourcePersistentId getSourcePersistenceId(); + T getSourcePersistenceId(); - IMdmLink setSourcePersistenceId(ResourcePersistentId theSourcePid); + IMdmLink setSourcePersistenceId(T theSourcePid); MdmMatchResultEnum getMatchResult(); - IMdmLink setMatchResult(MdmMatchResultEnum theMatchResult); + IMdmLink setMatchResult(MdmMatchResultEnum theMatchResult); default boolean isNoMatch() { return getMatchResult() == MdmMatchResultEnum.NO_MATCH; @@ -64,7 +64,7 @@ public interface IMdmLink { MdmLinkSourceEnum getLinkSource(); - IMdmLink setLinkSource(MdmLinkSourceEnum theLinkSource); + IMdmLink setLinkSource(MdmLinkSourceEnum theLinkSource); default boolean isAuto() { return getLinkSource() == MdmLinkSourceEnum.AUTO; @@ -76,41 +76,41 @@ public interface IMdmLink { Date getCreated(); - IMdmLink setCreated(Date theCreated); + IMdmLink setCreated(Date theCreated); Date getUpdated(); - IMdmLink setUpdated(Date theUpdated); + IMdmLink setUpdated(Date theUpdated); String getVersion(); - IMdmLink setVersion(String theVersion); + IMdmLink setVersion(String theVersion); Boolean getEidMatch(); Boolean isEidMatchPresent(); - IMdmLink setEidMatch(Boolean theEidMatch); + IMdmLink setEidMatch(Boolean theEidMatch); Boolean getHadToCreateNewGoldenResource(); - IMdmLink setHadToCreateNewGoldenResource(Boolean theHadToCreateNewGoldenResource); + IMdmLink setHadToCreateNewGoldenResource(Boolean theHadToCreateNewGoldenResource); Long getVector(); - IMdmLink setVector(Long theVector); + IMdmLink setVector(Long theVector); Double getScore(); - IMdmLink setScore(Double theScore); + IMdmLink setScore(Double theScore); Long getRuleCount(); - IMdmLink setRuleCount(Long theRuleCount); + IMdmLink setRuleCount(Long theRuleCount); String getMdmSourceType(); - IMdmLink setMdmSourceType(String theMdmSourceType); + IMdmLink setMdmSourceType(String theMdmSourceType); void setPartitionId(PartitionablePartitionId thePartitionablePartitionId); diff --git a/hapi-fhir-server-mdm/src/main/java/ca/uhn/fhir/mdm/api/IMdmLinkExpandSvc.java b/hapi-fhir-server-mdm/src/main/java/ca/uhn/fhir/mdm/api/IMdmLinkExpandSvc.java index 41c6139ba0e..ec43ccd1630 100644 --- a/hapi-fhir-server-mdm/src/main/java/ca/uhn/fhir/mdm/api/IMdmLinkExpandSvc.java +++ b/hapi-fhir-server-mdm/src/main/java/ca/uhn/fhir/mdm/api/IMdmLinkExpandSvc.java @@ -21,7 +21,7 @@ package ca.uhn.fhir.mdm.api; */ import ca.uhn.fhir.model.primitive.IdDt; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IIdType; @@ -32,11 +32,11 @@ public interface IMdmLinkExpandSvc { Set expandMdmBySourceResourceId(IIdType theId); - Set expandMdmBySourceResourcePid(ResourcePersistentId theSourceResourcePid); + Set expandMdmBySourceResourcePid(IResourcePersistentId theSourceResourcePid); - Set expandMdmByGoldenResourceId(ResourcePersistentId theGoldenResourcePid); + Set expandMdmByGoldenResourceId(IResourcePersistentId theGoldenResourcePid); - Set expandMdmByGoldenResourcePid(ResourcePersistentId theGoldenResourcePid); + Set expandMdmByGoldenResourcePid(IResourcePersistentId theGoldenResourcePid); Set expandMdmByGoldenResourceId(IdDt theId); } diff --git a/hapi-fhir-server-mdm/src/main/java/ca/uhn/fhir/mdm/api/IMdmLinkSvc.java b/hapi-fhir-server-mdm/src/main/java/ca/uhn/fhir/mdm/api/IMdmLinkSvc.java index 853f7e3d19e..9a36acc6383 100644 --- a/hapi-fhir-server-mdm/src/main/java/ca/uhn/fhir/mdm/api/IMdmLinkSvc.java +++ b/hapi-fhir-server-mdm/src/main/java/ca/uhn/fhir/mdm/api/IMdmLinkSvc.java @@ -21,7 +21,7 @@ package ca.uhn.fhir.mdm.api; */ import ca.uhn.fhir.mdm.model.MdmTransactionContext; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import org.hl7.fhir.instance.model.api.IAnyResource; import java.util.List; @@ -53,5 +53,5 @@ public interface IMdmLinkSvc { * Delete all link records whose source or target points to the provided pids. * @param thePersistentIds */ - void deleteLinksWithAnyReferenceTo(List thePersistentIds); + void deleteLinksWithAnyReferenceTo(List thePersistentIds); } diff --git a/hapi-fhir-server-mdm/src/main/java/ca/uhn/fhir/mdm/dao/IMdmLinkDao.java b/hapi-fhir-server-mdm/src/main/java/ca/uhn/fhir/mdm/dao/IMdmLinkDao.java index 4214826a454..c277e9034ad 100644 --- a/hapi-fhir-server-mdm/src/main/java/ca/uhn/fhir/mdm/dao/IMdmLinkDao.java +++ b/hapi-fhir-server-mdm/src/main/java/ca/uhn/fhir/mdm/dao/IMdmLinkDao.java @@ -25,7 +25,7 @@ import ca.uhn.fhir.mdm.api.MdmLinkSourceEnum; import ca.uhn.fhir.mdm.api.MdmMatchResultEnum; import ca.uhn.fhir.mdm.api.paging.MdmPageRequest; import ca.uhn.fhir.mdm.model.MdmPidTuple; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException; import org.hl7.fhir.instance.model.api.IIdType; import org.springframework.data.domain.Example; @@ -36,46 +36,47 @@ import java.util.Date; import java.util.List; import java.util.Optional; -public interface IMdmLinkDao { - int deleteWithAnyReferenceToPid(ResourcePersistentId thePid); +public interface IMdmLinkDao

> { + int deleteWithAnyReferenceToPid(P thePid); - int deleteWithAnyReferenceToPidAndMatchResultNot(ResourcePersistentId thePid, MdmMatchResultEnum theMatchResult); + int deleteWithAnyReferenceToPidAndMatchResultNot(P thePid, MdmMatchResultEnum theMatchResult); - List expandPidsFromGroupPidGivenMatchResult(ResourcePersistentId theGroupPid, MdmMatchResultEnum theMdmMatchResultEnum); + List> expandPidsFromGroupPidGivenMatchResult(P theGroupPid, MdmMatchResultEnum theMdmMatchResultEnum); - List expandPidsBySourcePidAndMatchResult(ResourcePersistentId theSourcePid, MdmMatchResultEnum theMdmMatchResultEnum); + List> expandPidsBySourcePidAndMatchResult(P theSourcePid, MdmMatchResultEnum theMdmMatchResultEnum); - List expandPidsByGoldenResourcePidAndMatchResult(ResourcePersistentId theSourcePid, MdmMatchResultEnum theMdmMatchResultEnum); + List> expandPidsByGoldenResourcePidAndMatchResult(P theSourcePid, MdmMatchResultEnum theMdmMatchResultEnum); - List findPidByResourceNameAndThreshold(String theResourceName, Date theHighThreshold, Pageable thePageable); + List

findPidByResourceNameAndThreshold(String theResourceName, Date theHighThreshold, Pageable thePageable); - List findPidByResourceNameAndThresholdAndPartitionId(String theResourceName, Date theHighThreshold,List thePartitionIds, Pageable thePageable); + List

findPidByResourceNameAndThresholdAndPartitionId(String theResourceName, Date theHighThreshold, List thePartitionIds, Pageable thePageable); - List findAllById(List thePids); + List findAllById(List

thePids); - Optional findById(ResourcePersistentId thePid); + Optional findById(P thePid); - void deleteAll(List theLinks); + void deleteAll(List theLinks); - List findAll(Example theExample); + List findAll(Example theExample); - List findAll(); + List findAll(); Long count(); void deleteAll(); - T save(T theMdmLink); + M save(M theMdmLink); - Optional findOne(Example theExample); + Optional findOne(Example theExample); - void delete(T theMdmLink); + void delete(M theMdmLink); - T validateMdmLink(IMdmLink theMdmLink) throws UnprocessableEntityException; + // TODO KHS is this method still required? Probably not? But leaving it in for now... + M validateMdmLink(IMdmLink theMdmLink) throws UnprocessableEntityException; - Page search(IIdType theGoldenResourceId, IIdType theSourceId, MdmMatchResultEnum theMatchResult, MdmLinkSourceEnum theLinkSource, MdmPageRequest thePageRequest, List thePartitionId); + Page search(IIdType theGoldenResourceId, IIdType theSourceId, MdmMatchResultEnum theMatchResult, MdmLinkSourceEnum theLinkSource, MdmPageRequest thePageRequest, List thePartitionId); - Optional findBySourcePidAndMatchResult(ResourcePersistentId theSourcePid, MdmMatchResultEnum theMatch); + Optional findBySourcePidAndMatchResult(P theSourcePid, MdmMatchResultEnum theMatch); - void deleteLinksWithAnyReferenceToPids(List theResourcePersistentIds); + void deleteLinksWithAnyReferenceToPids(List

theResourcePersistentIds); } diff --git a/hapi-fhir-server-mdm/src/main/java/ca/uhn/fhir/mdm/dao/IMdmLinkImplFactory.java b/hapi-fhir-server-mdm/src/main/java/ca/uhn/fhir/mdm/dao/IMdmLinkImplFactory.java index f774286ccdc..c07906e5a3d 100644 --- a/hapi-fhir-server-mdm/src/main/java/ca/uhn/fhir/mdm/dao/IMdmLinkImplFactory.java +++ b/hapi-fhir-server-mdm/src/main/java/ca/uhn/fhir/mdm/dao/IMdmLinkImplFactory.java @@ -22,6 +22,6 @@ package ca.uhn.fhir.mdm.dao; import ca.uhn.fhir.mdm.api.IMdmLink; -public interface IMdmLinkImplFactory { - public IMdmLink newMdmLinkImpl(); +public interface IMdmLinkImplFactory { + public M newMdmLinkImpl(); } diff --git a/hapi-fhir-server-mdm/src/main/java/ca/uhn/fhir/mdm/dao/MdmLinkFactory.java b/hapi-fhir-server-mdm/src/main/java/ca/uhn/fhir/mdm/dao/MdmLinkFactory.java index 659f7df5be5..2d23780debe 100644 --- a/hapi-fhir-server-mdm/src/main/java/ca/uhn/fhir/mdm/dao/MdmLinkFactory.java +++ b/hapi-fhir-server-mdm/src/main/java/ca/uhn/fhir/mdm/dao/MdmLinkFactory.java @@ -24,9 +24,9 @@ import ca.uhn.fhir.mdm.api.IMdmLink; import ca.uhn.fhir.mdm.api.IMdmSettings; import org.springframework.beans.factory.annotation.Autowired; -public class MdmLinkFactory { +public class MdmLinkFactory { private final IMdmSettings myMdmSettings; - private final IMdmLinkImplFactory myMdmLinkImplFactory; + private final IMdmLinkImplFactory myMdmLinkImplFactory; @Autowired public MdmLinkFactory(IMdmSettings theMdmSettings, IMdmLinkImplFactory theMdmLinkImplFactory) { @@ -39,7 +39,9 @@ public class MdmLinkFactory { * * @return the new {@link IMdmLink} */ - public IMdmLink newMdmLink() { - return myMdmLinkImplFactory.newMdmLinkImpl().setVersion(myMdmSettings.getRuleVersion()); + public M newMdmLink() { + M retval = myMdmLinkImplFactory.newMdmLinkImpl(); + retval.setVersion(myMdmSettings.getRuleVersion()); + return retval; } } diff --git a/hapi-fhir-server-mdm/src/main/java/ca/uhn/fhir/mdm/model/MdmPidTuple.java b/hapi-fhir-server-mdm/src/main/java/ca/uhn/fhir/mdm/model/MdmPidTuple.java index 3390d7bdea2..eddfab1d8d3 100644 --- a/hapi-fhir-server-mdm/src/main/java/ca/uhn/fhir/mdm/model/MdmPidTuple.java +++ b/hapi-fhir-server-mdm/src/main/java/ca/uhn/fhir/mdm/model/MdmPidTuple.java @@ -20,43 +20,26 @@ package ca.uhn.fhir.mdm.model; * #L% */ -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; -public class MdmPidTuple { - private ResourcePersistentId myGoldenPid; - private ResourcePersistentId mySourcePid; +public class MdmPidTuple { + private final T myGoldenPid; + private final T mySourcePid; - public ResourcePersistentId getGoldenPid(){ + private MdmPidTuple(T theGoldenPid, T theSourcePid) { + myGoldenPid = theGoldenPid; + mySourcePid = theSourcePid; + } + + public static

MdmPidTuple

fromGoldenAndSource(P theGoldenPid, P theSourcePid) { + return new MdmPidTuple<>(theGoldenPid, theSourcePid); + } + + public T getGoldenPid(){ return myGoldenPid; } - public MdmPidTuple setGoldenPid(ResourcePersistentId theGoldenPid) { - myGoldenPid = theGoldenPid; - return this; - } - - public MdmPidTuple setSourcePid(ResourcePersistentId theSourcePid) { - mySourcePid = theSourcePid; - return this; - } - - public ResourcePersistentId getSourcePid(){ + public T getSourcePid(){ return mySourcePid; } - - public Long getGoldenPidAsLong() { - return myGoldenPid.getIdAsLong(); - } - - public Long getSourcePidAsLong() { - return mySourcePid.getIdAsLong(); - } - - public String getGoldenPidAsString() { - return (String) myGoldenPid.getId(); - } - - public String getSourcePidAsString() { - return (String) mySourcePid.getId(); - } } diff --git a/hapi-fhir-server-mdm/src/main/java/ca/uhn/fhir/mdm/svc/MdmLinkDeleteSvc.java b/hapi-fhir-server-mdm/src/main/java/ca/uhn/fhir/mdm/svc/MdmLinkDeleteSvc.java index d1f40ef7d01..be12ef490e4 100644 --- a/hapi-fhir-server-mdm/src/main/java/ca/uhn/fhir/mdm/svc/MdmLinkDeleteSvc.java +++ b/hapi-fhir-server-mdm/src/main/java/ca/uhn/fhir/mdm/svc/MdmLinkDeleteSvc.java @@ -24,7 +24,7 @@ import ca.uhn.fhir.interceptor.model.RequestPartitionId; import ca.uhn.fhir.jpa.api.svc.IIdHelperService; import ca.uhn.fhir.mdm.api.MdmMatchResultEnum; import ca.uhn.fhir.mdm.dao.IMdmLinkDao; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import org.hl7.fhir.instance.model.api.IBaseResource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -47,7 +47,7 @@ public class MdmLinkDeleteSvc { * @return the number of records deleted */ public int deleteWithAnyReferenceTo(IBaseResource theResource) { - ResourcePersistentId pid = myIdHelperService.getPidOrThrowException(RequestPartitionId.allPartitions(), theResource.getIdElement()); + IResourcePersistentId pid = myIdHelperService.getPidOrThrowException(RequestPartitionId.allPartitions(), theResource.getIdElement()); int removed = myMdmLinkDao.deleteWithAnyReferenceToPid(pid); if (removed > 0) { ourLog.info("Removed {} MDM links with references to {}", removed, theResource.getIdElement().toVersionless()); @@ -56,7 +56,7 @@ public class MdmLinkDeleteSvc { } public int deleteNonRedirectWithAnyReferenceTo(IBaseResource theResource) { - ResourcePersistentId pid = myIdHelperService.getPidOrThrowException(RequestPartitionId.allPartitions(), theResource.getIdElement()); + IResourcePersistentId pid = myIdHelperService.getPidOrThrowException(RequestPartitionId.allPartitions(), theResource.getIdElement()); int removed = myMdmLinkDao.deleteWithAnyReferenceToPidAndMatchResultNot(pid, MdmMatchResultEnum.REDIRECT); if (removed > 0) { ourLog.info("Removed {} non-redirect MDM links with references to {}", removed, theResource.getIdElement().toVersionless()); diff --git a/hapi-fhir-server-mdm/src/main/java/ca/uhn/fhir/mdm/svc/MdmLinkExpandSvc.java b/hapi-fhir-server-mdm/src/main/java/ca/uhn/fhir/mdm/svc/MdmLinkExpandSvc.java index fccb955aa33..1397f1a0c05 100644 --- a/hapi-fhir-server-mdm/src/main/java/ca/uhn/fhir/mdm/svc/MdmLinkExpandSvc.java +++ b/hapi-fhir-server-mdm/src/main/java/ca/uhn/fhir/mdm/svc/MdmLinkExpandSvc.java @@ -22,13 +22,13 @@ package ca.uhn.fhir.mdm.svc; import ca.uhn.fhir.interceptor.model.RequestPartitionId; import ca.uhn.fhir.jpa.api.svc.IIdHelperService; +import ca.uhn.fhir.mdm.api.IMdmLinkExpandSvc; import ca.uhn.fhir.mdm.api.MdmMatchResultEnum; import ca.uhn.fhir.mdm.dao.IMdmLinkDao; import ca.uhn.fhir.mdm.log.Logs; import ca.uhn.fhir.mdm.model.MdmPidTuple; -import ca.uhn.fhir.mdm.api.IMdmLinkExpandSvc; import ca.uhn.fhir.model.primitive.IdDt; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IIdType; import org.slf4j.Logger; @@ -40,7 +40,6 @@ import javax.annotation.Nonnull; import java.util.HashSet; import java.util.List; import java.util.Set; -import java.util.stream.Collectors; @Service @Transactional @@ -89,7 +88,7 @@ public class MdmLinkExpandSvc implements IMdmLinkExpandSvc { * @return A set of strings representing the FHIR ids of the expanded resources. */ @Override - public Set expandMdmBySourceResourcePid(ResourcePersistentId theSourceResourcePid) { + public Set expandMdmBySourceResourcePid(IResourcePersistentId theSourceResourcePid) { ourLog.debug("About to expand source resource with PID {}", theSourceResourcePid); List goldenPidSourcePidTuples = myMdmLinkDao.expandPidsBySourcePidAndMatchResult(theSourceResourcePid, MdmMatchResultEnum.MATCH); return flattenPidTuplesToSet(theSourceResourcePid, goldenPidSourcePidTuples); @@ -103,7 +102,7 @@ public class MdmLinkExpandSvc implements IMdmLinkExpandSvc { * @return A set of strings representing the FHIR ids of the expanded resources. */ @Override - public Set expandMdmByGoldenResourceId(ResourcePersistentId theGoldenResourcePid) { + public Set expandMdmByGoldenResourceId(IResourcePersistentId theGoldenResourcePid) { ourLog.debug("About to expand golden resource with PID {}", theGoldenResourcePid); List goldenPidSourcePidTuples = myMdmLinkDao.expandPidsByGoldenResourcePidAndMatchResult(theGoldenResourcePid, MdmMatchResultEnum.MATCH); return flattenPidTuplesToSet(theGoldenResourcePid, goldenPidSourcePidTuples); @@ -118,7 +117,7 @@ public class MdmLinkExpandSvc implements IMdmLinkExpandSvc { * @return A set of strings representing the FHIR ids of the expanded resources. */ @Override - public Set expandMdmByGoldenResourcePid(ResourcePersistentId theGoldenResourcePid) { + public Set expandMdmByGoldenResourcePid(IResourcePersistentId theGoldenResourcePid) { ourLog.debug("About to expand golden resource with PID {}", theGoldenResourcePid); List goldenPidSourcePidTuples = myMdmLinkDao.expandPidsByGoldenResourcePidAndMatchResult(theGoldenResourcePid, MdmMatchResultEnum.MATCH); return flattenPidTuplesToSet(theGoldenResourcePid, goldenPidSourcePidTuples); @@ -127,13 +126,13 @@ public class MdmLinkExpandSvc implements IMdmLinkExpandSvc { @Override public Set expandMdmByGoldenResourceId(IdDt theId) { ourLog.debug("About to expand golden resource with golden resource id {}", theId); - ResourcePersistentId pidOrThrowException = myIdHelperService.getPidOrThrowException(RequestPartitionId.allPartitions(), theId); + IResourcePersistentId pidOrThrowException = myIdHelperService.getPidOrThrowException(RequestPartitionId.allPartitions(), theId); return expandMdmByGoldenResourcePid(pidOrThrowException); } @Nonnull - public Set flattenPidTuplesToSet(ResourcePersistentId initialPid, List goldenPidSourcePidTuples) { - Set flattenedPids = new HashSet<>(); + public Set flattenPidTuplesToSet(IResourcePersistentId initialPid, List goldenPidSourcePidTuples) { + Set flattenedPids = new HashSet<>(); goldenPidSourcePidTuples.forEach(tuple -> { flattenedPids.add(tuple.getSourcePid()); flattenedPids.add(tuple.getGoldenPid()); diff --git a/hapi-fhir-server-mdm/src/main/java/ca/uhn/fhir/mdm/svc/MdmSubmitSvcImpl.java b/hapi-fhir-server-mdm/src/main/java/ca/uhn/fhir/mdm/svc/MdmSubmitSvcImpl.java index 512d1b413fa..b4903ca98b3 100644 --- a/hapi-fhir-server-mdm/src/main/java/ca/uhn/fhir/mdm/svc/MdmSubmitSvcImpl.java +++ b/hapi-fhir-server-mdm/src/main/java/ca/uhn/fhir/mdm/svc/MdmSubmitSvcImpl.java @@ -34,7 +34,7 @@ import ca.uhn.fhir.mdm.api.IMdmSettings; import ca.uhn.fhir.mdm.api.IMdmSubmitSvc; import ca.uhn.fhir.mdm.log.Logs; 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.IResourcePersistentId; import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.provider.ProviderConstants; @@ -112,7 +112,7 @@ public class MdmSubmitSvcImpl implements IMdmSubmitSvc { SearchRuntimeDetails searchRuntimeDetails = new SearchRuntimeDetails(null, UUID.randomUUID().toString()); long total = 0; try (IResultIterator query = theSearchBuilder.createQuery(theSpMap, searchRuntimeDetails, null, theRequestPartitionId)) { - Collection pidBatch; + Collection pidBatch; do { pidBatch = query.getNextResultBatch(myBufferSize); total += loadPidsAndSubmitToMdmChannel(theSearchBuilder, pidBatch); @@ -125,7 +125,7 @@ public class MdmSubmitSvcImpl implements IMdmSubmitSvc { } /** - * Given a collection of ResourcePersistentId objects, and a search builder, load the IBaseResources and submit them to + * Given a collection of IResourcePersistentId objects, and a search builder, load the IBaseResources and submit them to * the MDM channel for processing. * * @param theSearchBuilder the related DAO search builder. @@ -133,7 +133,7 @@ public class MdmSubmitSvcImpl implements IMdmSubmitSvc { * * @return The total count of submitted resources. */ - private long loadPidsAndSubmitToMdmChannel(ISearchBuilder theSearchBuilder, Collection thePidsToSubmit) { + private long loadPidsAndSubmitToMdmChannel(ISearchBuilder theSearchBuilder, Collection thePidsToSubmit) { List resourcesToSubmit = new ArrayList<>(); theSearchBuilder.loadResourcesByPid(thePidsToSubmit, Collections.emptyList(), resourcesToSubmit, false, null); ourLog.info("Submitting {} resources to MDM", resourcesToSubmit.size()); diff --git a/hapi-fhir-server-openapi/pom.xml b/hapi-fhir-server-openapi/pom.xml index bfc77612bd4..d3b755b5857 100644 --- a/hapi-fhir-server-openapi/pom.xml +++ b/hapi-fhir-server-openapi/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-server/pom.xml b/hapi-fhir-server/pom.xml index 51cd8dc0cb2..e113bfc9d6a 100644 --- a/hapi-fhir-server/pom.xml +++ b/hapi-fhir-server/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/api/server/storage/BaseResourcePersistentId.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/api/server/storage/BaseResourcePersistentId.java new file mode 100644 index 00000000000..76368a95fd9 --- /dev/null +++ b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/api/server/storage/BaseResourcePersistentId.java @@ -0,0 +1,89 @@ +package ca.uhn.fhir.rest.api.server.storage; + +/*- + * #%L + * HAPI FHIR - Server Framework + * %% + * Copyright (C) 2014 - 2022 Smile CDR, Inc. + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + +import org.hl7.fhir.instance.model.api.IIdType; + +import java.util.Objects; + +/** + * This class is an abstraction for however primary keys are stored in the underlying storage engine. This might be + * a Long, a String, or something else. The generic type T represents the primary key type. + */ +public abstract class BaseResourcePersistentId implements IResourcePersistentId { + private Long myVersion; + private final String myResourceType; + private IIdType myAssociatedResourceId; + + + protected BaseResourcePersistentId(String theResourceType) { + myResourceType = theResourceType; + } + + protected BaseResourcePersistentId(Long theVersion, String theResourceType) { + myVersion = theVersion; + myResourceType = theResourceType; + } + + @Override + public IIdType getAssociatedResourceId() { + return myAssociatedResourceId; + } + + @Override + public IResourcePersistentId setAssociatedResourceId(IIdType theAssociatedResourceId) { + myAssociatedResourceId = theAssociatedResourceId; + return this; + } + + @Override + public boolean equals(Object theO) { + if (this == theO) return true; + if (theO == null || getClass() != theO.getClass()) return false; + BaseResourcePersistentId that = (BaseResourcePersistentId) theO; + return Objects.equals(myVersion, that.myVersion); + } + + @Override + public int hashCode() { + return Objects.hash(myVersion); + } + + + @Override + public Long getVersion() { + return myVersion; + } + + /** + * @param theVersion This should only be populated if a specific version is needed. If you want the current version, + * leave this as null + */ + @Override + public void setVersion(Long theVersion) { + myVersion = theVersion; + } + + @Override + public String getResourceType() { + return myResourceType; + } +} diff --git a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/api/server/storage/IResourcePersistentId.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/api/server/storage/IResourcePersistentId.java new file mode 100644 index 00000000000..fd1a162709f --- /dev/null +++ b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/api/server/storage/IResourcePersistentId.java @@ -0,0 +1,29 @@ +package ca.uhn.fhir.rest.api.server.storage; + +import org.hl7.fhir.instance.model.api.IIdType; + +public interface IResourcePersistentId { + IResourcePersistentId NOT_FOUND = new NotFoundPid(); + + IIdType getAssociatedResourceId(); + + IResourcePersistentId setAssociatedResourceId(IIdType theAssociatedResourceId); + + T getId(); + + Long getVersion(); + /** + * @param theVersion This should only be populated if a specific version is needed. If you want the current version, + * leave this as null + */ + + void setVersion(Long theVersion); + + /** + * Note that, like Version, ResourceType is usually not populated. It is only populated in scenarios where it + * is needed downstream. + */ + + // TODO KHS this is only used by batch. Consider moving this to a new interface just for batch resource ids. + String getResourceType(); +} diff --git a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/api/server/storage/NotFoundPid.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/api/server/storage/NotFoundPid.java new file mode 100644 index 00000000000..8598ce49c71 --- /dev/null +++ b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/api/server/storage/NotFoundPid.java @@ -0,0 +1,12 @@ +package ca.uhn.fhir.rest.api.server.storage; + +public class NotFoundPid extends BaseResourcePersistentId { + public NotFoundPid() { + super(null); + } + + @Override + public Long getId() { + return -1L; + } +} diff --git a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/api/server/storage/ResourcePersistentId.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/api/server/storage/ResourcePersistentId.java deleted file mode 100644 index 9c665acca7f..00000000000 --- a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/api/server/storage/ResourcePersistentId.java +++ /dev/null @@ -1,143 +0,0 @@ -package ca.uhn.fhir.rest.api.server.storage; - -/*- - * #%L - * HAPI FHIR - Server Framework - * %% - * Copyright (C) 2014 - 2022 Smile CDR, Inc. - * %% - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * #L% - */ - -import ca.uhn.fhir.util.ObjectUtil; -import org.hl7.fhir.instance.model.api.IIdType; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Optional; - -/** - * This class is an abstraction for however primary keys are stored in the underlying storage engine. This might be - * a Long, a String, or something else. - * - * @param myId This is the only required field that needs to be populated, other fields can be populated for specific use cases. - */ -public class ResourcePersistentId { - private Object myId; - private Long myVersion; - private String myResourceType; - private IIdType myAssociatedResourceId; - - public ResourcePersistentId(Object theId) { - this(theId, null); - } - - /** - * @param theVersion This should only be populated if a specific version is needed. If you want the current version, - * leave this as null - */ - public ResourcePersistentId(Object theId, Long theVersion) { - assert !(theId instanceof Optional); - assert !(theId instanceof ResourcePersistentId); - myId = theId; - myVersion = theVersion; - } - - public IIdType getAssociatedResourceId() { - return myAssociatedResourceId; - } - - public ResourcePersistentId setAssociatedResourceId(IIdType theAssociatedResourceId) { - myAssociatedResourceId = theAssociatedResourceId; - return this; - } - - @Override - public boolean equals(Object theO) { - if (!(theO instanceof ResourcePersistentId)) { - return false; - } - ResourcePersistentId that = (ResourcePersistentId) theO; - - boolean retVal = ObjectUtil.equals(myId, that.myId); - retVal &= ObjectUtil.equals(myVersion, that.myVersion); - return retVal; - } - - @Override - public int hashCode() { - int retVal = myId.hashCode(); - if (myVersion != null) { - retVal += myVersion.hashCode(); - } - return retVal; - } - - public Object getId() { - return myId; - } - - public void setId(Object theId) { - myId = theId; - } - - public Long getIdAsLong() { - if (myId instanceof String) { - return Long.parseLong((String) myId); - } - return (Long) myId; - } - - @Override - public String toString() { - return myId.toString(); - } - - public Long getVersion() { - return myVersion; - } - - /** - * @param theVersion This should only be populated if a specific version is needed. If you want the current version, - * leave this as null - */ - public void setVersion(Long theVersion) { - myVersion = theVersion; - } - - public String getResourceType() { - return myResourceType; - } - - public void setResourceType(String theResourceType) { - myResourceType = theResourceType; - } - - public static List toLongList(Collection thePids) { - List retVal = new ArrayList<>(thePids.size()); - for (ResourcePersistentId next : thePids) { - retVal.add(next.getIdAsLong()); - } - return retVal; - } - - public static List fromLongList(List theResultList) { - List retVal = new ArrayList<>(theResultList.size()); - for (Long next : theResultList) { - retVal.add(new ResourcePersistentId(next)); - } - return retVal; - } -} diff --git a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/api/server/storage/TransactionDetails.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/api/server/storage/TransactionDetails.java index f08bcd7f209..bfe60b9b20d 100644 --- a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/api/server/storage/TransactionDetails.java +++ b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/api/server/storage/TransactionDetails.java @@ -54,12 +54,12 @@ import java.util.function.Supplier; */ public class TransactionDetails { - public static final ResourcePersistentId NOT_FOUND = new ResourcePersistentId(-1L); + public static final IResourcePersistentId NOT_FOUND = IResourcePersistentId.NOT_FOUND; private final Date myTransactionDate; private List myRollbackUndoActions = Collections.emptyList(); - private Map myResolvedResourceIds = Collections.emptyMap(); - private Map myResolvedMatchUrls = Collections.emptyMap(); + private Map myResolvedResourceIds = Collections.emptyMap(); + private Map myResolvedMatchUrls = Collections.emptyMap(); private Map myUserData; private ListMultimap myDeferredInterceptorBroadcasts; private EnumSet myDeferredInterceptorBroadcastPointcuts; @@ -118,7 +118,7 @@ public class TransactionDetails { * the TransactionDetails if they are known to exist and be valid targets for other resources to link to. */ @Nullable - public ResourcePersistentId getResolvedResourceId(IIdType theId) { + public IResourcePersistentId getResolvedResourceId(IIdType theId) { String idValue = theId.toUnqualifiedVersionless().getValue(); return myResolvedResourceIds.get(idValue); } @@ -141,7 +141,7 @@ public class TransactionDetails { * "Observation/123") and a storage ID for that resource. Resources should only be placed within * the TransactionDetails if they are known to exist and be valid targets for other resources to link to. */ - public void addResolvedResourceId(IIdType theResourceId, @Nullable ResourcePersistentId thePersistentId) { + public void addResolvedResourceId(IIdType theResourceId, @Nullable IResourcePersistentId thePersistentId) { assert theResourceId != null; if (myResolvedResourceIds.isEmpty()) { @@ -150,7 +150,7 @@ public class TransactionDetails { myResolvedResourceIds.put(theResourceId.toVersionless().getValue(), thePersistentId); } - public Map getResolvedMatchUrls() { + public Map getResolvedMatchUrls() { return myResolvedMatchUrls; } @@ -159,7 +159,7 @@ public class TransactionDetails { * "Observation/123") and a storage ID for that resource. Resources should only be placed within * the TransactionDetails if they are known to exist and be valid targets for other resources to link to. */ - public void addResolvedMatchUrl(String theConditionalUrl, @Nonnull ResourcePersistentId thePersistentId) { + public void addResolvedMatchUrl(String theConditionalUrl, @Nonnull IResourcePersistentId thePersistentId) { Validate.notBlank(theConditionalUrl); Validate.notNull(thePersistentId); @@ -172,7 +172,7 @@ public class TransactionDetails { myResolvedMatchUrls.put(theConditionalUrl, thePersistentId); } - private boolean matchUrlWithDiffIdExists(String theConditionalUrl, @Nonnull ResourcePersistentId thePersistentId) { + private boolean matchUrlWithDiffIdExists(String theConditionalUrl, @Nonnull IResourcePersistentId thePersistentId) { if (myResolvedMatchUrls.containsKey(theConditionalUrl) && myResolvedMatchUrls.get(theConditionalUrl) != NOT_FOUND) { return myResolvedMatchUrls.get(theConditionalUrl).getId() != thePersistentId.getId(); } diff --git a/hapi-fhir-serviceloaders/hapi-fhir-caching-api/pom.xml b/hapi-fhir-serviceloaders/hapi-fhir-caching-api/pom.xml index 41f33d8043c..dabd220f512 100644 --- a/hapi-fhir-serviceloaders/hapi-fhir-caching-api/pom.xml +++ b/hapi-fhir-serviceloaders/hapi-fhir-caching-api/pom.xml @@ -7,7 +7,7 @@ hapi-fhir-serviceloaders ca.uhn.hapi.fhir - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../pom.xml diff --git a/hapi-fhir-serviceloaders/hapi-fhir-caching-caffeine/pom.xml b/hapi-fhir-serviceloaders/hapi-fhir-caching-caffeine/pom.xml index 4991094fb74..ed2370468ec 100644 --- a/hapi-fhir-serviceloaders/hapi-fhir-caching-caffeine/pom.xml +++ b/hapi-fhir-serviceloaders/hapi-fhir-caching-caffeine/pom.xml @@ -7,7 +7,7 @@ hapi-fhir-serviceloaders ca.uhn.hapi.fhir - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../pom.xml @@ -20,7 +20,7 @@ ca.uhn.hapi.fhir hapi-fhir-caching-api - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT com.github.ben-manes.caffeine diff --git a/hapi-fhir-serviceloaders/hapi-fhir-caching-guava/pom.xml b/hapi-fhir-serviceloaders/hapi-fhir-caching-guava/pom.xml index 9c6914ff64d..e5710a11927 100644 --- a/hapi-fhir-serviceloaders/hapi-fhir-caching-guava/pom.xml +++ b/hapi-fhir-serviceloaders/hapi-fhir-caching-guava/pom.xml @@ -7,7 +7,7 @@ hapi-fhir-serviceloaders ca.uhn.hapi.fhir - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../pom.xml diff --git a/hapi-fhir-serviceloaders/hapi-fhir-caching-testing/pom.xml b/hapi-fhir-serviceloaders/hapi-fhir-caching-testing/pom.xml index 6d897a66caf..0a9eb618110 100644 --- a/hapi-fhir-serviceloaders/hapi-fhir-caching-testing/pom.xml +++ b/hapi-fhir-serviceloaders/hapi-fhir-caching-testing/pom.xml @@ -7,7 +7,7 @@ hapi-fhir ca.uhn.hapi.fhir - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../../pom.xml diff --git a/hapi-fhir-serviceloaders/pom.xml b/hapi-fhir-serviceloaders/pom.xml index 73b6bb4a201..4458cafe7e1 100644 --- a/hapi-fhir-serviceloaders/pom.xml +++ b/hapi-fhir-serviceloaders/pom.xml @@ -5,7 +5,7 @@ hapi-fhir ca.uhn.hapi.fhir - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../pom.xml diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-autoconfigure/pom.xml b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-autoconfigure/pom.xml index fbac1fe3288..c83da1b039a 100644 --- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-autoconfigure/pom.xml +++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-autoconfigure/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-apache/pom.xml b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-apache/pom.xml index 24c99d01a8c..c00ad729142 100644 --- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-apache/pom.xml +++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-apache/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir-spring-boot-samples - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT hapi-fhir-spring-boot-sample-client-apache diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-okhttp/pom.xml b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-okhttp/pom.xml index 0bb0ebbe371..3aaa8164621 100644 --- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-okhttp/pom.xml +++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-okhttp/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir-spring-boot-samples - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT hapi-fhir-spring-boot-sample-client-okhttp diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-server-jersey/pom.xml b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-server-jersey/pom.xml index 561d3d9d61a..83ef324508f 100644 --- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-server-jersey/pom.xml +++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-server-jersey/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir-spring-boot-samples - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT hapi-fhir-spring-boot-sample-server-jersey diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/pom.xml b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/pom.xml index 4b5863459bf..f5ffcfdc2df 100644 --- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/pom.xml +++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir-spring-boot - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT hapi-fhir-spring-boot-samples diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-starter/pom.xml b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-starter/pom.xml index 5ca1f2f6acd..a282c8d7d70 100644 --- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-starter/pom.xml +++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-starter/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-spring-boot/pom.xml b/hapi-fhir-spring-boot/pom.xml index fc06349e39f..396c2bbcf05 100644 --- a/hapi-fhir-spring-boot/pom.xml +++ b/hapi-fhir-spring-boot/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../pom.xml diff --git a/hapi-fhir-sql-migrate/pom.xml b/hapi-fhir-sql-migrate/pom.xml index 7c68308f295..19003570306 100644 --- a/hapi-fhir-sql-migrate/pom.xml +++ b/hapi-fhir-sql-migrate/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-storage-batch2-jobs/pom.xml b/hapi-fhir-storage-batch2-jobs/pom.xml index f209458fedf..76cca0f2aaa 100644 --- a/hapi-fhir-storage-batch2-jobs/pom.xml +++ b/hapi-fhir-storage-batch2-jobs/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../hapi-deployable-pom/pom.xml 4.0.0 diff --git a/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/export/ExpandResourcesStep.java b/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/export/ExpandResourcesStep.java index c50246c5aa0..a36518f4627 100644 --- a/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/export/ExpandResourcesStep.java +++ b/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/export/ExpandResourcesStep.java @@ -25,17 +25,17 @@ 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.jobs.export.models.BulkExportJobParameters; import ca.uhn.fhir.batch2.jobs.export.models.ExpandedResourcesList; import ca.uhn.fhir.batch2.jobs.export.models.ResourceIdList; -import ca.uhn.fhir.batch2.jobs.export.models.BulkExportJobParameters; -import ca.uhn.fhir.batch2.jobs.models.Id; +import ca.uhn.fhir.batch2.jobs.models.BatchResourceId; import ca.uhn.fhir.context.FhirContext; 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.bulk.export.api.IBulkExportProcessor; import ca.uhn.fhir.jpa.model.entity.ModelConfig; import ca.uhn.fhir.parser.IParser; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; import ca.uhn.fhir.rest.server.interceptor.ResponseTerminologyTranslationSvc; import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.ListMultimap; @@ -45,7 +45,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import javax.annotation.Nonnull; -import javax.annotation.PostConstruct; import java.util.ArrayList; import java.util.List; @@ -69,6 +68,9 @@ public class ExpandResourcesStep implements IJobStepWorker fetchAllResources(ResourceIdList theIds) { List resources = new ArrayList<>(); - for (Id id : theIds.getIds()) { - String value = id.getId(); - IFhirResourceDao dao = myDaoRegistry.getResourceDao(id.getResourceType()); + for (BatchResourceId batchResourceId : theIds.getIds()) { + IFhirResourceDao dao = myDaoRegistry.getResourceDao(batchResourceId.getResourceType()); // This should be a query, but we have PIDs, and we don't have a _pid search param. TODO GGG, figure out how to make this search by pid. - resources.add(dao.readByPid(new ResourcePersistentId(value))); + resources.add(dao.readByPid(myIdHelperService.newPidFromStringIdAndResourceName(batchResourceId.getId(), batchResourceId.getResourceType()))); } return resources; diff --git a/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/export/FetchResourceIdsStep.java b/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/export/FetchResourceIdsStep.java index a76b0b77987..59f4784f904 100644 --- a/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/export/FetchResourceIdsStep.java +++ b/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/export/FetchResourceIdsStep.java @@ -28,13 +28,12 @@ import ca.uhn.fhir.batch2.api.StepExecutionDetails; import ca.uhn.fhir.batch2.api.VoidModel; import ca.uhn.fhir.batch2.jobs.export.models.BulkExportJobParameters; import ca.uhn.fhir.batch2.jobs.export.models.ResourceIdList; -import ca.uhn.fhir.batch2.jobs.models.Id; +import ca.uhn.fhir.batch2.jobs.models.BatchResourceId; import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.jpa.api.config.DaoConfig; -import ca.uhn.fhir.jpa.api.dao.DaoRegistry; import ca.uhn.fhir.jpa.bulk.export.api.IBulkExportProcessor; import ca.uhn.fhir.jpa.bulk.export.model.ExportPIDIteratorParameters; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -74,34 +73,34 @@ public class FetchResourceIdsStep implements IFirstJobStepWorker submittedIds = new HashSet<>(); + Set submittedBatchResourceIds = new HashSet<>(); for (String resourceType : params.getResourceTypes()) { providerParams.setResourceType(resourceType); // filters are the filters for searching ourLog.info("Running FetchResourceIdsStep for resource type: {} with params: {}", resourceType, providerParams); - Iterator pidIterator = myBulkExportProcessor.getResourcePidIterator(providerParams); - List idsToSubmit = new ArrayList<>(); + Iterator pidIterator = myBulkExportProcessor.getResourcePidIterator(providerParams); + List idsToSubmit = new ArrayList<>(); if (!pidIterator.hasNext()) { ourLog.debug("Bulk Export generated an iterator with no results!"); } while (pidIterator.hasNext()) { - ResourcePersistentId pid = pidIterator.next(); + IResourcePersistentId pid = pidIterator.next(); - Id id; + BatchResourceId batchResourceId; if (pid.getResourceType() != null) { - id = Id.getIdFromPID(pid, pid.getResourceType()); + batchResourceId = BatchResourceId.getIdFromPID(pid, pid.getResourceType()); } else { - id = Id.getIdFromPID(pid, resourceType); + batchResourceId = BatchResourceId.getIdFromPID(pid, resourceType); } - if (!submittedIds.add(id)) { + if (!submittedBatchResourceIds.add(batchResourceId)) { continue; } - idsToSubmit.add(id); + idsToSubmit.add(batchResourceId); // Make sure resources stored in each batch does not go over the max capacity if (idsToSubmit.size() >= myDaoConfig.getBulkExportFileMaximumCapacity()) { @@ -129,13 +128,13 @@ public class FetchResourceIdsStep implements IFirstJobStepWorker theIds, + private void submitWorkChunk(List theBatchResourceIds, String theResourceType, BulkExportJobParameters theParams, IJobDataSink theDataSink) { ResourceIdList idList = new ResourceIdList(); - idList.setIds(theIds); + idList.setIds(theBatchResourceIds); idList.setResourceType(theResourceType); diff --git a/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/export/models/ResourceIdList.java b/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/export/models/ResourceIdList.java index 7c497ee6c03..a6faf1e8525 100644 --- a/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/export/models/ResourceIdList.java +++ b/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/export/models/ResourceIdList.java @@ -20,7 +20,7 @@ package ca.uhn.fhir.batch2.jobs.export.models; * #L% */ -import ca.uhn.fhir.batch2.jobs.models.Id; +import ca.uhn.fhir.batch2.jobs.models.BatchResourceId; import com.fasterxml.jackson.annotation.JsonProperty; import java.util.List; @@ -31,17 +31,17 @@ public class ResourceIdList extends BulkExportJobBase { * List of Id objects for serialization */ @JsonProperty("ids") - private List myIds; + private List myBatchResourceIds; @JsonProperty("resourceType") private String myResourceType; - public List getIds() { - return myIds; + public List getIds() { + return myBatchResourceIds; } - public void setIds(List theIds) { - myIds = theIds; + public void setIds(List theBatchResourceIds) { + myBatchResourceIds = theBatchResourceIds; } public String getResourceType() { diff --git a/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/expunge/DeleteExpungeAppCtx.java b/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/expunge/DeleteExpungeAppCtx.java index 5bea5b3ad82..e8b664006af 100644 --- a/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/expunge/DeleteExpungeAppCtx.java +++ b/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/expunge/DeleteExpungeAppCtx.java @@ -29,6 +29,7 @@ import ca.uhn.fhir.batch2.model.JobDefinition; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.jpa.api.svc.IBatch2DaoSvc; import ca.uhn.fhir.jpa.api.svc.IDeleteExpungeSvc; +import ca.uhn.fhir.jpa.api.svc.IIdHelperService; import ca.uhn.fhir.jpa.dao.tx.HapiTransactionService; import ca.uhn.fhir.rest.api.server.storage.IDeleteExpungeJobSubmitter; import ca.uhn.fhir.rest.server.provider.ProviderConstants; @@ -45,8 +46,8 @@ public class DeleteExpungeAppCtx { public JobDefinition expungeJobDefinition( IBatch2DaoSvc theBatch2DaoSvc, HapiTransactionService theHapiTransactionService, - IDeleteExpungeSvc theDeleteExpungeSvc - ) { + IDeleteExpungeSvc theDeleteExpungeSvc, + IIdHelperService theIdHelperService) { return JobDefinition .newBuilder() .setJobDefinitionId(JOB_DELETE_EXPUNGE) @@ -67,7 +68,7 @@ public class DeleteExpungeAppCtx { new LoadIdsStep(theBatch2DaoSvc)) .addLastStep("expunge", "Perform the resource expunge", - expungeStep(theHapiTransactionService, theDeleteExpungeSvc) + expungeStep(theHapiTransactionService, theDeleteExpungeSvc, theIdHelperService) ) .build(); } @@ -78,8 +79,8 @@ public class DeleteExpungeAppCtx { } @Bean - public DeleteExpungeStep expungeStep(HapiTransactionService theHapiTransactionService, IDeleteExpungeSvc theDeleteExpungeSvc) { - return new DeleteExpungeStep(theHapiTransactionService, theDeleteExpungeSvc); + public DeleteExpungeStep expungeStep(HapiTransactionService theHapiTransactionService, IDeleteExpungeSvc theDeleteExpungeSvc, IIdHelperService theIdHelperService) { + return new DeleteExpungeStep(theHapiTransactionService, theDeleteExpungeSvc, theIdHelperService); } @Bean diff --git a/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/expunge/DeleteExpungeStep.java b/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/expunge/DeleteExpungeStep.java index 9aa0a9f4738..9e351ae375f 100644 --- a/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/expunge/DeleteExpungeStep.java +++ b/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/expunge/DeleteExpungeStep.java @@ -29,12 +29,12 @@ 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.jpa.api.svc.IDeleteExpungeSvc; +import ca.uhn.fhir.jpa.api.svc.IIdHelperService; 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; @@ -48,10 +48,12 @@ public class DeleteExpungeStep implements IJobStepWorker persistentIds = myData.getResourcePersistentIds(); + List persistentIds = myData.getResourcePersistentIds(myIdHelperService); + + if (persistentIds.isEmpty()) { + ourLog.info("Starting delete expunge work chunk. Ther are no resources to delete expunge - Instance[{}] Chunk[{}]", myInstanceId, myChunkId); + return null; + } + ourLog.info("Starting delete expunge work chunk with {} resources - Instance[{}] Chunk[{}]", persistentIds.size(), myInstanceId, myChunkId); diff --git a/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/imprt/ConsumeFilesStep.java b/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/imprt/ConsumeFilesStep.java index fe8f3281e90..9adce196395 100644 --- a/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/imprt/ConsumeFilesStep.java +++ b/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/imprt/ConsumeFilesStep.java @@ -38,7 +38,7 @@ import ca.uhn.fhir.jpa.partition.SystemRequestDetails; import ca.uhn.fhir.parser.DataFormatException; import ca.uhn.fhir.parser.IParser; 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.IResourcePersistentId; import ca.uhn.fhir.rest.api.server.storage.TransactionDetails; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.exceptions.PreconditionFailedException; @@ -123,8 +123,8 @@ public class ConsumeFilesStep implements ILastJobStepWorker idsList = new ArrayList<>(ids.keySet()); - List resolvedIds = myIdHelperService.resolveResourcePersistentIdsWithCache(RequestPartitionId.allPartitions(), idsList, true); - for (ResourcePersistentId next : resolvedIds) { + List resolvedIds = myIdHelperService.resolveResourcePersistentIdsWithCache(RequestPartitionId.allPartitions(), idsList, true); + for (IResourcePersistentId next : resolvedIds) { IIdType resId = next.getAssociatedResourceId(); theTransactionDetails.addResolvedResourceId(resId, next); ids.remove(resId); diff --git a/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/models/Id.java b/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/models/BatchResourceId.java similarity index 70% rename from hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/models/Id.java rename to hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/models/BatchResourceId.java index 9fdc07c39dd..2ae5dee72c4 100644 --- a/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/models/Id.java +++ b/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/models/BatchResourceId.java @@ -21,13 +21,12 @@ package ca.uhn.fhir.batch2.jobs.models; */ import ca.uhn.fhir.model.api.IModelJson; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import com.fasterxml.jackson.annotation.JsonProperty; import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; -import org.hl7.fhir.r4.model.IdType; -public class Id implements IModelJson { +public class BatchResourceId implements IModelJson { @JsonProperty("type") private String myResourceType; @@ -45,7 +44,7 @@ public class Id implements IModelJson { return myResourceType; } - public Id setResourceType(String theResourceType) { + public BatchResourceId setResourceType(String theResourceType) { myResourceType = theResourceType; return this; } @@ -54,7 +53,7 @@ public class Id implements IModelJson { return myId; } - public Id setId(String theId) { + public BatchResourceId setId(String theId) { myId = theId; return this; } @@ -65,9 +64,9 @@ public class Id implements IModelJson { if (theO == null || getClass() != theO.getClass()) return false; - Id id = (Id) theO; + BatchResourceId batchResourceId = (BatchResourceId) theO; - return new EqualsBuilder().append(myResourceType, id.myResourceType).append(myId, id.myId).isEquals(); + return new EqualsBuilder().append(myResourceType, batchResourceId.myResourceType).append(myId, batchResourceId.myId).isEquals(); } @Override @@ -75,10 +74,10 @@ public class Id implements IModelJson { return new HashCodeBuilder(17, 37).append(myResourceType).append(myId).toHashCode(); } - public static Id getIdFromPID(ResourcePersistentId thePID, String theResourceType) { - Id id = new Id(); - id.setId(thePID.getId().toString()); - id.setResourceType(theResourceType); - return id; + public static BatchResourceId getIdFromPID(IResourcePersistentId thePID, String theResourceType) { + BatchResourceId batchResourceId = new BatchResourceId(); + batchResourceId.setId(thePID.getId().toString()); + batchResourceId.setResourceType(theResourceType); + return batchResourceId; } } diff --git a/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/ReindexStep.java b/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/ReindexStep.java index 9d950e0ab82..7deeebe6436 100644 --- a/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/ReindexStep.java +++ b/hapi-fhir-storage-batch2-jobs/src/main/java/ca/uhn/fhir/batch2/jobs/reindex/ReindexStep.java @@ -35,7 +35,7 @@ import ca.uhn.fhir.jpa.dao.tx.HapiTransactionService; import ca.uhn.fhir.jpa.partition.SystemRequestDetails; import ca.uhn.fhir.parser.DataFormatException; 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.IResourcePersistentId; import ca.uhn.fhir.rest.api.server.storage.TransactionDetails; import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException; import ca.uhn.fhir.util.StopWatch; @@ -61,7 +61,7 @@ public class ReindexStep implements IJobStepWorker myIdHelperService; @Nonnull @Override @@ -103,7 +103,7 @@ public class ReindexStep implements IJobStepWorker persistentIds = myData.getResourcePersistentIds(); + List persistentIds = myData.getResourcePersistentIds(myIdHelperService); ourLog.info("Starting reindex work chunk with {} resources - Instance[{}] Chunk[{}]", persistentIds.size(), myInstanceId, myChunkId); StopWatch sw = new StopWatch(); @@ -120,7 +120,7 @@ public class ReindexStep implements IJobStepWorker dao = myDaoRegistry.getResourceDao(nextResourceType); - ResourcePersistentId resourcePersistentId = persistentIds.get(i); + IResourcePersistentId resourcePersistentId = persistentIds.get(i); try { dao.reindex(resourcePersistentId, myRequestDetails, myTransactionDetails); } catch (BaseServerResponseException | DataFormatException e) { diff --git a/hapi-fhir-storage-batch2-jobs/src/test/java/ca/uhn/fhir/batch2/jobs/export/ExpandResourcesStepTest.java b/hapi-fhir-storage-batch2-jobs/src/test/java/ca/uhn/fhir/batch2/jobs/export/ExpandResourcesStepTest.java index 4b205215525..1994ca85a81 100644 --- a/hapi-fhir-storage-batch2-jobs/src/test/java/ca/uhn/fhir/batch2/jobs/export/ExpandResourcesStepTest.java +++ b/hapi-fhir-storage-batch2-jobs/src/test/java/ca/uhn/fhir/batch2/jobs/export/ExpandResourcesStepTest.java @@ -4,18 +4,20 @@ package ca.uhn.fhir.batch2.jobs.export; import ca.uhn.fhir.batch2.api.IJobDataSink; import ca.uhn.fhir.batch2.api.RunOutcome; import ca.uhn.fhir.batch2.api.StepExecutionDetails; +import ca.uhn.fhir.batch2.jobs.export.models.BulkExportJobParameters; import ca.uhn.fhir.batch2.jobs.export.models.ExpandedResourcesList; import ca.uhn.fhir.batch2.jobs.export.models.ResourceIdList; -import ca.uhn.fhir.batch2.jobs.export.models.BulkExportJobParameters; -import ca.uhn.fhir.batch2.jobs.models.Id; +import ca.uhn.fhir.batch2.jobs.models.BatchResourceId; import ca.uhn.fhir.batch2.model.JobInstance; import ca.uhn.fhir.context.FhirContext; 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.bulk.export.api.IBulkExportProcessor; +import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.jpa.model.entity.ModelConfig; import ca.uhn.fhir.rest.api.server.bulk.BulkDataExportOptions; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.BaseResourcePersistentId; import ca.uhn.fhir.rest.server.interceptor.ResponseTerminologyTranslationSvc; import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.r4.model.Patient; @@ -33,7 +35,6 @@ import java.util.Date; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.mock; @@ -52,6 +53,9 @@ public class ExpandResourcesStepTest { @Mock private ResponseTerminologyTranslationSvc myResponseTerminologyTranslationSvc; + @Mock + IIdHelperService myIdHelperService; + @Spy private FhirContext myFhirContext = FhirContext.forR4Cached(); @@ -99,19 +103,19 @@ public class ExpandResourcesStepTest { ResourceIdList idList = new ResourceIdList(); idList.setResourceType("Patient"); ArrayList resources = new ArrayList<>(); - ArrayList ids = new ArrayList<>(); + ArrayList batchResourceIds = new ArrayList<>(); for (int i = 0; i < 100; i++) { - String stringId = "Patient/" + i; - Id id = new Id(); - id.setResourceType("Patient"); - id.setId(stringId); - ids.add(id); + String stringId = String.valueOf(i); + BatchResourceId batchResourceId = new BatchResourceId(); + batchResourceId.setResourceType("Patient"); + batchResourceId.setId(stringId); + batchResourceIds.add(batchResourceId); Patient patient = new Patient(); patient.setId(stringId); resources.add(patient); } - idList.setIds(ids); + idList.setIds(batchResourceIds); StepExecutionDetails input = createInput( idList, @@ -119,8 +123,8 @@ public class ExpandResourcesStepTest { instance ); ArrayList clone = new ArrayList<>(resources); - when(patientDao.readByPid(any(ResourcePersistentId.class))).thenAnswer(i -> clone.remove(0)); - + when(patientDao.readByPid(any(BaseResourcePersistentId.class))).thenAnswer(i -> clone.remove(0)); + when(myIdHelperService.newPidFromStringIdAndResourceName(anyString(), anyString())).thenReturn(JpaPid.fromId(1L)); // test RunOutcome outcome = mySecondStep.run(input, sink); diff --git a/hapi-fhir-storage-batch2-jobs/src/test/java/ca/uhn/fhir/batch2/jobs/export/FetchResourceIdsStepTest.java b/hapi-fhir-storage-batch2-jobs/src/test/java/ca/uhn/fhir/batch2/jobs/export/FetchResourceIdsStepTest.java index a085d65adc6..1f385d443bb 100644 --- a/hapi-fhir-storage-batch2-jobs/src/test/java/ca/uhn/fhir/batch2/jobs/export/FetchResourceIdsStepTest.java +++ b/hapi-fhir-storage-batch2-jobs/src/test/java/ca/uhn/fhir/batch2/jobs/export/FetchResourceIdsStepTest.java @@ -4,15 +4,16 @@ import ca.uhn.fhir.batch2.api.IJobDataSink; 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.export.models.ResourceIdList; import ca.uhn.fhir.batch2.jobs.export.models.BulkExportJobParameters; -import ca.uhn.fhir.batch2.jobs.models.Id; +import ca.uhn.fhir.batch2.jobs.export.models.ResourceIdList; +import ca.uhn.fhir.batch2.jobs.models.BatchResourceId; import ca.uhn.fhir.batch2.model.JobInstance; import ca.uhn.fhir.jpa.api.config.DaoConfig; import ca.uhn.fhir.jpa.bulk.export.api.IBulkExportProcessor; import ca.uhn.fhir.jpa.bulk.export.model.ExportPIDIteratorParameters; +import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.rest.api.server.bulk.BulkDataExportOptions; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import ch.qos.logback.classic.Level; import ch.qos.logback.classic.Logger; import ch.qos.logback.classic.spi.ILoggingEvent; @@ -97,18 +98,18 @@ public class FetchResourceIdsStepTest { instance.setInstanceId("1"); StepExecutionDetails input = createInput(parameters, instance); ourLog.setLevel(Level.INFO); - List patientIds = new ArrayList<>(); - List observationIds = new ArrayList<>(); + List patientIds = new ArrayList<>(); + List observationIds = new ArrayList<>(); { - ResourcePersistentId id1 = new ResourcePersistentId("Patient/123"); - ResourcePersistentId id2 = new ResourcePersistentId("Patient/234"); + JpaPid id1 = JpaPid.fromId(123L); + JpaPid id2 = JpaPid.fromId(234L); patientIds.add(id1); patientIds.add(id2); } { - ResourcePersistentId id1 = new ResourcePersistentId("Observation/123"); - ResourcePersistentId id2 = new ResourcePersistentId("Observation/234"); + JpaPid id1 = JpaPid.fromId(345L); + JpaPid id2 = JpaPid.fromId(456L); observationIds.add(id1); observationIds.add(id2); } @@ -172,14 +173,14 @@ public class FetchResourceIdsStepTest { parameters.setResourceTypes(Collections.singletonList("Patient")); StepExecutionDetails input = createInput(parameters, instance); ourLog.setLevel(Level.INFO); - List patientIds = new ArrayList<>(); + List patientIds = new ArrayList<>(); // when int maxFileCapacity = 5; when(myDaoConfig.getBulkExportFileMaximumCapacity()).thenReturn(maxFileCapacity); for (int i = 0; i <= maxFileCapacity; i++) { - ResourcePersistentId id = new ResourcePersistentId("Patient/RED" + i); + JpaPid id = JpaPid.fromId((long) i); patientIds.add(id); } @@ -201,10 +202,10 @@ public class FetchResourceIdsStepTest { // verify all submitted ids are there boolean found = false; - for (ResourcePersistentId pid : patientIds) { - Id id = Id.getIdFromPID(pid, "Patient"); + for (IResourcePersistentId pid : patientIds) { + BatchResourceId batchResourceId = BatchResourceId.getIdFromPID(pid, "Patient"); for (ResourceIdList idList : listIds) { - found = idList.getIds().contains(id); + found = idList.getIds().contains(batchResourceId); if (found) { break; } diff --git a/hapi-fhir-storage-batch2/pom.xml b/hapi-fhir-storage-batch2/pom.xml index 080187baec1..0940e8eb799 100644 --- a/hapi-fhir-storage-batch2/pom.xml +++ b/hapi-fhir-storage-batch2/pom.xml @@ -6,7 +6,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-storage-batch2/src/main/java/ca/uhn/fhir/batch2/jobs/chunk/ResourceIdListWorkChunkJson.java b/hapi-fhir-storage-batch2/src/main/java/ca/uhn/fhir/batch2/jobs/chunk/ResourceIdListWorkChunkJson.java index 005e97f78c6..37ca2d208f1 100644 --- a/hapi-fhir-storage-batch2/src/main/java/ca/uhn/fhir/batch2/jobs/chunk/ResourceIdListWorkChunkJson.java +++ b/hapi-fhir-storage-batch2/src/main/java/ca/uhn/fhir/batch2/jobs/chunk/ResourceIdListWorkChunkJson.java @@ -20,8 +20,9 @@ package ca.uhn.fhir.batch2.jobs.chunk; * #L% */ +import ca.uhn.fhir.jpa.api.svc.IIdHelperService; import ca.uhn.fhir.model.api.IModelJson; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import com.fasterxml.jackson.annotation.JsonProperty; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; @@ -57,7 +58,7 @@ public class ResourceIdListWorkChunkJson implements IModelJson { .toString(); } - public List getResourcePersistentIds() { + public List getResourcePersistentIds(IIdHelperService theIdHelperService) { if (myTypedPids.isEmpty()) { return Collections.emptyList(); } @@ -65,8 +66,7 @@ public class ResourceIdListWorkChunkJson implements IModelJson { return myTypedPids .stream() .map(t -> { - ResourcePersistentId retval = new ResourcePersistentId(t.getPid()); - retval.setResourceType(t.getResourceType()); + T retval = theIdHelperService.newPidFromStringIdAndResourceName(t.getPid(), t.getResourceType()); return retval; }) .collect(Collectors.toList()); diff --git a/hapi-fhir-storage-batch2/src/test/java/ca/uhn/fhir/batch2/jobs/step/LoadIdsStepTest.java b/hapi-fhir-storage-batch2/src/test/java/ca/uhn/fhir/batch2/jobs/step/LoadIdsStepTest.java index 1e510b578ba..3a89c75f828 100644 --- a/hapi-fhir-storage-batch2/src/test/java/ca/uhn/fhir/batch2/jobs/step/LoadIdsStepTest.java +++ b/hapi-fhir-storage-batch2/src/test/java/ca/uhn/fhir/batch2/jobs/step/LoadIdsStepTest.java @@ -10,7 +10,8 @@ import ca.uhn.fhir.jpa.api.pid.EmptyResourcePidList; import ca.uhn.fhir.jpa.api.pid.HomogeneousResourcePidList; import ca.uhn.fhir.jpa.api.pid.IResourcePidList; import ca.uhn.fhir.jpa.api.svc.IBatch2DaoSvc; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.jpa.model.dao.JpaPid; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import org.hl7.fhir.r4.model.InstantType; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -103,10 +104,10 @@ public class LoadIdsStepTest { @Nonnull private IResourcePidList createIdChunk(long idLow, long idHigh, Date lastDate) { - List ids = new ArrayList<>(); + List ids = new ArrayList<>(); List resourceTypes = new ArrayList<>(); for (long i = idLow; i < idHigh; i++) { - ids.add(new ResourcePersistentId(i)); + ids.add(JpaPid.fromId(i)); } IResourcePidList chunk = new HomogeneousResourcePidList("Patient", ids, lastDate); return chunk; diff --git a/hapi-fhir-storage-mdm/pom.xml b/hapi-fhir-storage-mdm/pom.xml index eaf6ce16a5e..6bd74912ca8 100644 --- a/hapi-fhir-storage-mdm/pom.xml +++ b/hapi-fhir-storage-mdm/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../hapi-deployable-pom/pom.xml 4.0.0 diff --git a/hapi-fhir-storage-mdm/src/main/java/ca/uhn/fhir/mdm/batch2/clear/MdmClearStep.java b/hapi-fhir-storage-mdm/src/main/java/ca/uhn/fhir/mdm/batch2/clear/MdmClearStep.java index 606b09ce816..5dbf497226d 100644 --- a/hapi-fhir-storage-mdm/src/main/java/ca/uhn/fhir/mdm/batch2/clear/MdmClearStep.java +++ b/hapi-fhir-storage-mdm/src/main/java/ca/uhn/fhir/mdm/batch2/clear/MdmClearStep.java @@ -34,11 +34,10 @@ import ca.uhn.fhir.jpa.api.model.DeleteConflictList; 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.model.dao.JpaPid; 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; import ca.uhn.fhir.rest.api.server.storage.TransactionDetails; import ca.uhn.fhir.rest.server.provider.ProviderConstants; import ca.uhn.fhir.util.StopWatch; @@ -100,7 +99,7 @@ public class MdmClearStep implements IJobStepWorker persistentIds = myData.getResourcePersistentIds(); + List persistentIds = myData.getResourcePersistentIds(myIdHelperService); if (persistentIds.isEmpty()) { return null; } diff --git a/hapi-fhir-storage-mdm/src/main/java/ca/uhn/fhir/mdm/batch2/submit/MdmInflateAndSubmitResourcesStep.java b/hapi-fhir-storage-mdm/src/main/java/ca/uhn/fhir/mdm/batch2/submit/MdmInflateAndSubmitResourcesStep.java index ba6f1257633..a216d736732 100644 --- a/hapi-fhir-storage-mdm/src/main/java/ca/uhn/fhir/mdm/batch2/submit/MdmInflateAndSubmitResourcesStep.java +++ b/hapi-fhir-storage-mdm/src/main/java/ca/uhn/fhir/mdm/batch2/submit/MdmInflateAndSubmitResourcesStep.java @@ -20,13 +20,19 @@ 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; +import ca.uhn.fhir.jpa.api.svc.IIdHelperService; import ca.uhn.fhir.jpa.batch.log.Logs; import ca.uhn.fhir.mdm.api.IMdmChannelSubmitterSvc; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; import ca.uhn.fhir.rest.server.interceptor.ResponseTerminologyTranslationSvc; import org.hl7.fhir.instance.model.api.IBaseResource; @@ -48,6 +54,7 @@ public class MdmInflateAndSubmitResourcesStep implements IJobStepWorker myIdHelperService; @Nonnull @Override @@ -56,10 +63,10 @@ public class MdmInflateAndSubmitResourcesStep implements IJobStepWorker allResources = fetchAllResources(idList.getResourcePersistentIds()); + List allResources = fetchAllResources(idList.getResourcePersistentIds(myIdHelperService)); //Replace the terminology if (myResponseTerminologyTranslationSvc != null) { @@ -75,9 +82,9 @@ public class MdmInflateAndSubmitResourcesStep implements IJobStepWorker fetchAllResources(List theIds) { + private List fetchAllResources(List theIds) { List resources = new ArrayList<>(); - for (ResourcePersistentId id : theIds) { + for (IResourcePersistentId id : theIds) { assert id.getResourceType() != null; IFhirResourceDao dao = myDaoRegistry.getResourceDao(id.getResourceType()); // This should be a query, but we have PIDs, and we don't have a _pid search param. TODO GGG, figure out how to make this search by pid. diff --git a/hapi-fhir-storage-test-utilities/pom.xml b/hapi-fhir-storage-test-utilities/pom.xml index b96b56d36b5..deeb7ddf51d 100644 --- a/hapi-fhir-storage-test-utilities/pom.xml +++ b/hapi-fhir-storage-test-utilities/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../hapi-deployable-pom/pom.xml 4.0.0 diff --git a/hapi-fhir-storage/pom.xml b/hapi-fhir-storage/pom.xml index 1499436d0e4..0231009ab40 100644 --- a/hapi-fhir-storage/pom.xml +++ b/hapi-fhir-storage/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/config/DaoConfig.java b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/config/DaoConfig.java index bc60a0e04cc..afe91bb8657 100644 --- a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/config/DaoConfig.java +++ b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/config/DaoConfig.java @@ -533,6 +533,7 @@ public class DaoConfig { * @since 5.3.0 * @deprecated in 6.1.0, this toggle will be removed in 6.2.0 as the Legacy Search Builder has been removed. */ + @Deprecated public void setUseLegacySearchBuilder(boolean theUseLegacySearchBuilder) { //Nop } diff --git a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/dao/IFhirResourceDao.java b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/dao/IFhirResourceDao.java index a8c93fc8786..48a6b60312b 100644 --- a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/dao/IFhirResourceDao.java +++ b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/dao/IFhirResourceDao.java @@ -38,7 +38,7 @@ import ca.uhn.fhir.rest.api.PatchTypeEnum; import ca.uhn.fhir.rest.api.ValidationModeEnum; 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.api.server.storage.IResourcePersistentId; import ca.uhn.fhir.rest.api.server.storage.TransactionDetails; import ca.uhn.fhir.rest.param.HistorySearchDateRangeParam; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; @@ -191,7 +191,7 @@ public interface IFhirResourceDao extends IDao { * @throws ResourceNotFoundException If the ID is not known to the server * @throws ResourceGoneException If the resource has been deleted */ - T readByPid(ResourcePersistentId thePid); + T readByPid(IResourcePersistentId thePid); /** * Read a resource by its internal PID @@ -199,7 +199,7 @@ public interface IFhirResourceDao extends IDao { * @throws ResourceGoneException If the resource has been deleted and theDeletedOk is true * */ - default T readByPid(ResourcePersistentId thePid, boolean theDeletedOk) { + default T readByPid(IResourcePersistentId thePid, boolean theDeletedOk) { throw new UnsupportedOperationException(Msg.code(571)); } @@ -248,7 +248,7 @@ public interface IFhirResourceDao extends IDao { /** * Search for IDs for processing a match URLs, etc. */ - default List searchForIds(SearchParameterMap theParams, RequestDetails theRequest) { + default List searchForIds(SearchParameterMap theParams, RequestDetails theRequest) { return searchForIds(theParams, theRequest, null); } @@ -259,7 +259,7 @@ public interface IFhirResourceDao extends IDao { * create/update, this is the resource being searched for * @since 5.5.0 */ - default List searchForIds(SearchParameterMap theParams, RequestDetails theRequest, @Nullable IBaseResource theConditionalOperationTargetOrNull) { + default List searchForIds(SearchParameterMap theParams, RequestDetails theRequest, @Nullable IBaseResource theConditionalOperationTargetOrNull) { return searchForIds(theParams, theRequest); } @@ -329,7 +329,7 @@ public interface IFhirResourceDao extends IDao { * @param theRequest the request that initiated the request * @return response back to the client */ - DeleteMethodOutcome deletePidList(String theUrl, Collection theResourceIds, DeleteConflictList theDeleteConflicts, RequestDetails theRequest); +

DeleteMethodOutcome deletePidList(String theUrl, Collection

theResourceIds, DeleteConflictList theDeleteConflicts, RequestDetails theRequest); /** * @deprecated use #read(IIdType, RequestDetails) instead @@ -343,5 +343,5 @@ public interface IFhirResourceDao extends IDao { * * @param theResourcePersistentId The ID */ - void reindex(ResourcePersistentId theResourcePersistentId, RequestDetails theRequest, TransactionDetails theTransactionDetails); + void reindex(IResourcePersistentId theResourcePersistentId, RequestDetails theRequest, TransactionDetails theTransactionDetails); } diff --git a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/dao/IFhirSystemDao.java b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/dao/IFhirSystemDao.java index bc909f426b2..748e146f3d6 100644 --- a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/dao/IFhirSystemDao.java +++ b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/dao/IFhirSystemDao.java @@ -25,7 +25,7 @@ import ca.uhn.fhir.jpa.api.model.ExpungeOptions; import ca.uhn.fhir.jpa.api.model.ExpungeOutcome; 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.api.server.storage.IResourcePersistentId; import org.hl7.fhir.instance.model.api.IBaseBundle; import org.springframework.transaction.annotation.Transactional; @@ -90,7 +90,7 @@ public interface IFhirSystemDao 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 theResolvedIds) { + default

void preFetchResources(List

theResolvedIds) { // nothing by default } } diff --git a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/dao/MetadataKeyCurrentlyReindexing.java b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/dao/MetadataKeyCurrentlyReindexing.java index 008c459aad8..69a8bf62e5c 100644 --- a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/dao/MetadataKeyCurrentlyReindexing.java +++ b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/dao/MetadataKeyCurrentlyReindexing.java @@ -22,9 +22,6 @@ package ca.uhn.fhir.jpa.api.dao; import ca.uhn.fhir.model.api.IResource; import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum; -import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum.ResourceMetadataKeySupportingAnyResource; -import org.hl7.fhir.instance.model.api.IAnyResource; -import org.hl7.fhir.instance.model.api.IBaseResource; public final class MetadataKeyCurrentlyReindexing extends ResourceMetadataKeyEnum { private static final long serialVersionUID = 1L; diff --git a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/model/DaoMethodOutcome.java b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/model/DaoMethodOutcome.java index ae14d1bf7cd..b75a8c5806c 100644 --- a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/model/DaoMethodOutcome.java +++ b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/model/DaoMethodOutcome.java @@ -23,7 +23,7 @@ package ca.uhn.fhir.jpa.api.model; import ca.uhn.fhir.jpa.model.cross.IBasePersistedResource; import ca.uhn.fhir.rest.api.MethodOutcome; import ca.uhn.fhir.rest.api.RestOperationTypeEnum; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import org.hl7.fhir.instance.model.api.IBaseResource; public class DaoMethodOutcome extends MethodOutcome { @@ -31,7 +31,7 @@ public class DaoMethodOutcome extends MethodOutcome { private IBasePersistedResource myEntity; private IBaseResource myPreviousResource; private boolean myNop; - private ResourcePersistentId myResourcePersistentId; + private IResourcePersistentId myResourcePersistentId; private RestOperationTypeEnum myOperationType; private String myMatchUrl; @@ -104,11 +104,11 @@ public class DaoMethodOutcome extends MethodOutcome { return this; } - public ResourcePersistentId getPersistentId() { + public IResourcePersistentId getPersistentId() { return myResourcePersistentId; } - public DaoMethodOutcome setPersistentId(ResourcePersistentId theResourcePersistentId) { + public DaoMethodOutcome setPersistentId(IResourcePersistentId theResourcePersistentId) { myResourcePersistentId = theResourcePersistentId; return this; } diff --git a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/model/LazyDaoMethodOutcome.java b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/model/LazyDaoMethodOutcome.java index 51e78814610..d595935f98f 100644 --- a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/model/LazyDaoMethodOutcome.java +++ b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/model/LazyDaoMethodOutcome.java @@ -21,7 +21,7 @@ package ca.uhn.fhir.jpa.api.model; */ import ca.uhn.fhir.jpa.model.cross.IBasePersistedResource; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IIdType; @@ -36,7 +36,7 @@ public class LazyDaoMethodOutcome extends DaoMethodOutcome { /** * Constructor */ - public LazyDaoMethodOutcome(ResourcePersistentId theResourcePersistentId) { + public LazyDaoMethodOutcome(IResourcePersistentId theResourcePersistentId) { setPersistentId(theResourcePersistentId); } diff --git a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/model/PersistentIdToForcedIdMap.java b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/model/PersistentIdToForcedIdMap.java index 50a43aef4c3..02283a5c6b4 100644 --- a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/model/PersistentIdToForcedIdMap.java +++ b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/model/PersistentIdToForcedIdMap.java @@ -20,17 +20,17 @@ package ca.uhn.fhir.jpa.api.model; * #L% */ -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import java.util.Map; import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; -public class PersistentIdToForcedIdMap { - private final Map> myResourcePersistentIdOptionalMap; +public class PersistentIdToForcedIdMap

{ + private final Map> myResourcePersistentIdOptionalMap; - public PersistentIdToForcedIdMap(Map> theResourcePersistentIdOptionalMap){ + public PersistentIdToForcedIdMap(Map> theResourcePersistentIdOptionalMap){ myResourcePersistentIdOptionalMap = theResourcePersistentIdOptionalMap; } @@ -41,16 +41,16 @@ public class PersistentIdToForcedIdMap { .collect(Collectors.toSet()); } - private String getResolvedPid(Map.Entry> entry) { + private String getResolvedPid(Map.Entry> 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 get(ResourcePersistentId theResourcePersistentId) { + public Optional get(P theResourcePersistentId) { return myResourcePersistentIdOptionalMap.get(theResourcePersistentId); } - public Map> getResourcePersistentIdOptionalMap(){ + public Map> getResourcePersistentIdOptionalMap(){ return myResourcePersistentIdOptionalMap; } } diff --git a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/pid/BaseResourcePidList.java b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/pid/BaseResourcePidList.java index bccb3974948..76a54bfdd7f 100644 --- a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/pid/BaseResourcePidList.java +++ b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/pid/BaseResourcePidList.java @@ -20,7 +20,7 @@ package ca.uhn.fhir.jpa.api.pid; * #L% */ -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -32,12 +32,12 @@ import java.util.List; abstract public class BaseResourcePidList implements IResourcePidList { - final List myIds = new ArrayList<>(); + final List myIds = new ArrayList<>(); @Nullable final Date myLastDate; - BaseResourcePidList(Collection theIds, Date theLastDate) { + BaseResourcePidList(Collection theIds, Date theLastDate) { myIds.addAll(theIds); myLastDate = theLastDate; } @@ -68,11 +68,11 @@ abstract public class BaseResourcePidList implements IResourcePidList { } @Override - public List getIds() { + public List getIds() { return Collections.unmodifiableList(myIds); } - public ResourcePersistentId getId(int theIndex) { + public IResourcePersistentId getId(int theIndex) { return myIds.get(theIndex); } } diff --git a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/pid/EmptyResourcePidList.java b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/pid/EmptyResourcePidList.java index 6f62f603596..e642c31db61 100644 --- a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/pid/EmptyResourcePidList.java +++ b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/pid/EmptyResourcePidList.java @@ -21,7 +21,7 @@ package ca.uhn.fhir.jpa.api.pid; */ import ca.uhn.fhir.i18n.Msg; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import javax.annotation.Nonnull; import java.util.Collections; @@ -54,7 +54,7 @@ public class EmptyResourcePidList implements IResourcePidList { } @Override - public List getIds() { + public List getIds() { return Collections.emptyList(); } diff --git a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/pid/HomogeneousResourcePidList.java b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/pid/HomogeneousResourcePidList.java index 24db9fc166b..2b5dd19bc7d 100644 --- a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/pid/HomogeneousResourcePidList.java +++ b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/pid/HomogeneousResourcePidList.java @@ -20,7 +20,7 @@ package ca.uhn.fhir.jpa.api.pid; * #L% */ -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import javax.annotation.Nonnull; import java.util.Collection; @@ -33,7 +33,7 @@ public class HomogeneousResourcePidList extends BaseResourcePidList { @Nonnull final String myResourceType; - public HomogeneousResourcePidList(String theResourceType, Collection theIds, Date theLastDate) { + public HomogeneousResourcePidList(String theResourceType, Collection theIds, Date theLastDate) { super(theIds, theLastDate); myResourceType = theResourceType; } diff --git a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/pid/IResourcePidList.java b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/pid/IResourcePidList.java index 95d1dfbb829..9c1a6407857 100644 --- a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/pid/IResourcePidList.java +++ b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/pid/IResourcePidList.java @@ -20,14 +20,14 @@ package ca.uhn.fhir.jpa.api.pid; * #L% */ -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import javax.annotation.Nonnull; import java.util.Date; import java.util.List; /** - * List of ResourcePersistentId along with a resource type each id + * List of IResourcePersistentId along with a resource type each id */ public interface IResourcePidList { @@ -40,7 +40,7 @@ public interface IResourcePidList { String getResourceType(int i); - List getIds(); + List getIds(); boolean isEmpty(); } diff --git a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/pid/MixedResourcePidList.java b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/pid/MixedResourcePidList.java index 696204126b1..52ed101c784 100644 --- a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/pid/MixedResourcePidList.java +++ b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/pid/MixedResourcePidList.java @@ -20,7 +20,7 @@ package ca.uhn.fhir.jpa.api.pid; * #L% */ -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import javax.annotation.Nonnull; import java.util.Collection; @@ -34,7 +34,7 @@ public class MixedResourcePidList extends BaseResourcePidList { @Nonnull final List myResourceTypes; - public MixedResourcePidList(List theResourceTypes, Collection theIds, Date theLastDate) { + public MixedResourcePidList(List theResourceTypes, Collection theIds, Date theLastDate) { super(theIds, theLastDate); myResourceTypes = theResourceTypes; } diff --git a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/pid/ResourcePidListBuilder.java b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/pid/ResourcePidListBuilder.java index a0022c465b1..9ad8a795635 100644 --- a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/pid/ResourcePidListBuilder.java +++ b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/pid/ResourcePidListBuilder.java @@ -20,7 +20,7 @@ package ca.uhn.fhir.jpa.api.pid; * #L% */ -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import java.util.ArrayList; import java.util.Date; @@ -37,7 +37,7 @@ public class ResourcePidListBuilder { return empty(); } - Set ids = new LinkedHashSet<>(); + Set ids = new LinkedHashSet<>(); Date endDate = null; Set resourceTypes = new HashSet<>(); diff --git a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/pid/TypedResourcePid.java b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/pid/TypedResourcePid.java index 7fa08d4b28b..e029d07f8d0 100644 --- a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/pid/TypedResourcePid.java +++ b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/pid/TypedResourcePid.java @@ -20,22 +20,23 @@ package ca.uhn.fhir.jpa.api.pid; * #L% */ -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.jpa.model.dao.JpaPid; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import java.util.Objects; public class TypedResourcePid { public final String resourceType; - public final ResourcePersistentId id; + public final IResourcePersistentId id; - public TypedResourcePid(String theResourceType, ResourcePersistentId theId) { + public TypedResourcePid(String theResourceType, IResourcePersistentId theId) { this.resourceType = theResourceType; this.id = theId; } public TypedResourcePid(String theResourceType, Long theId) { this.resourceType = theResourceType; - this.id = new ResourcePersistentId(theId); + this.id = JpaPid.fromId(theId); } @Override diff --git a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/svc/IDeleteExpungeSvc.java b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/svc/IDeleteExpungeSvc.java index 7dce4d424b3..d715fd2a010 100644 --- a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/svc/IDeleteExpungeSvc.java +++ b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/svc/IDeleteExpungeSvc.java @@ -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 thePersistentIds); + void deleteExpunge(List thePersistentIds); } diff --git a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/svc/IIdHelperService.java b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/svc/IIdHelperService.java index 9394580fd7b..d08dd5ebc95 100644 --- a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/svc/IIdHelperService.java +++ b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/svc/IIdHelperService.java @@ -24,7 +24,7 @@ import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.interceptor.model.RequestPartitionId; import ca.uhn.fhir.jpa.api.model.PersistentIdToForcedIdMap; import ca.uhn.fhir.jpa.model.cross.IResourceLookup; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; import org.hl7.fhir.instance.model.api.IAnyResource; import org.hl7.fhir.instance.model.api.IBaseResource; @@ -39,10 +39,10 @@ import java.util.Optional; import java.util.Set; /** - * This interface is used to translate between {@link ResourcePersistentId} + * This interface is used to translate between {@link IResourcePersistentId} * and actual resource IDs. */ -public interface IIdHelperService { +public interface IIdHelperService { /** * Given a collection of resource IDs (resource type + id), resolves the internal persistent IDs. @@ -53,7 +53,7 @@ public interface IIdHelperService { * @param theOnlyForcedIds If true, resources which are not existing forced IDs will not be resolved */ @Nonnull - List resolveResourcePersistentIdsWithCache(@Nonnull RequestPartitionId theRequestPartitionId, List theIds, boolean theOnlyForcedIds); + List resolveResourcePersistentIdsWithCache(@Nonnull RequestPartitionId theRequestPartitionId, List theIds, boolean theOnlyForcedIds); /** * Given a resource type and ID, determines the internal persistent ID for the resource. @@ -61,7 +61,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. @@ -70,29 +70,29 @@ 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. + * Returns a mapping of Id -> IResourcePersistentId. * If any resource is not found, it will throw ResourceNotFound exception * (and no map will be returned) */ @Nonnull - Map resolveResourcePersistentIds(@Nonnull RequestPartitionId theRequestPartitionId, String theResourceType, List theIds); + Map resolveResourcePersistentIds(@Nonnull RequestPartitionId theRequestPartitionId, String theResourceType, List theIds); /** - * Returns a mapping of Id -> ResourcePersistentId. + * Returns a mapping of Id -> IResourcePersistentId. * If any resource is not found, it will throw ResourceNotFound exception (and no map will be returned) * Optionally filters out deleted resources. */ @Nonnull - Map resolveResourcePersistentIds(@Nonnull RequestPartitionId theRequestPartitionId, String theResourceType, List theIds, boolean theExcludeDeleted); + Map resolveResourcePersistentIds(@Nonnull RequestPartitionId theRequestPartitionId, String theResourceType, List 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 @@ -129,30 +129,30 @@ public interface IIdHelperService { * are deleted (but note that forced IDs can't change, so the cache can't return incorrect results) */ @Nonnull - List resolveResourcePersistentIdsWithCache(RequestPartitionId theRequestPartitionId, List theIds); + List resolveResourcePersistentIdsWithCache(RequestPartitionId theRequestPartitionId, List theIds); - Optional translatePidIdToForcedIdWithCache(ResourcePersistentId theResourcePersistentId); + Optional translatePidIdToForcedIdWithCache(T theResourcePersistentId); - PersistentIdToForcedIdMap translatePidsToForcedIds(Set theResourceIds); + PersistentIdToForcedIdMap translatePidsToForcedIds(Set 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 getPidsOrThrowException(RequestPartitionId theRequestPartitionId, List theIds); + List getPidsOrThrowException(RequestPartitionId theRequestPartitionId, List 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. @@ -165,7 +165,9 @@ 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 translatePidsToFhirResourceIds(Set thePids); + Set translatePidsToFhirResourceIds(Set thePids); + T newPid(Object thePid); + T newPidFromStringIdAndResourceName(String thePid, String theResourceType); } diff --git a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/svc/ISearchCoordinatorSvc.java b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/svc/ISearchCoordinatorSvc.java index 5929f64c13c..ec8ea910368 100644 --- a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/svc/ISearchCoordinatorSvc.java +++ b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/svc/ISearchCoordinatorSvc.java @@ -26,17 +26,17 @@ import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; import ca.uhn.fhir.rest.api.CacheControlDirective; 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.api.server.storage.IResourcePersistentId; import javax.annotation.Nullable; import java.util.List; import java.util.Optional; -public interface ISearchCoordinatorSvc { +public interface ISearchCoordinatorSvc { void cancelAllActiveSearches(); - List getResources(String theUuid, int theFrom, int theTo, @Nullable RequestDetails theRequestDetails); + List 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); diff --git a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/bulk/export/api/IBulkExportProcessor.java b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/bulk/export/api/IBulkExportProcessor.java index 0dd874a25c7..ddf7382f856 100644 --- a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/bulk/export/api/IBulkExportProcessor.java +++ b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/bulk/export/api/IBulkExportProcessor.java @@ -21,20 +21,20 @@ package ca.uhn.fhir.jpa.bulk.export.api; */ import ca.uhn.fhir.jpa.bulk.export.model.ExportPIDIteratorParameters; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import org.hl7.fhir.instance.model.api.IBaseResource; import java.util.Iterator; import java.util.List; -public interface IBulkExportProcessor { +public interface IBulkExportProcessor { /** * For fetching PIDs of resources * @param theParams * @return */ - Iterator getResourcePidIterator(ExportPIDIteratorParameters theParams); + Iterator getResourcePidIterator(ExportPIDIteratorParameters theParams); /** * Does the MDM expansion of resources if necessary diff --git a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/BaseStorageDao.java b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/BaseStorageDao.java index 531105a446f..552b985d7a2 100644 --- a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/BaseStorageDao.java +++ b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/BaseStorageDao.java @@ -39,6 +39,7 @@ import ca.uhn.fhir.jpa.model.entity.ResourceTable; import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; import ca.uhn.fhir.jpa.searchparam.util.JpaParamUtil; import ca.uhn.fhir.model.api.IQueryParameterAnd; +import ca.uhn.fhir.model.api.StorageResponseCodeEnum; import ca.uhn.fhir.rest.api.QualifiedParamList; import ca.uhn.fhir.rest.api.RestOperationTypeEnum; import ca.uhn.fhir.rest.api.server.IPreResourceAccessDetails; @@ -46,7 +47,7 @@ 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.api.server.storage.IResourcePersistentId; import ca.uhn.fhir.rest.api.server.storage.TransactionDetails; import ca.uhn.fhir.rest.param.QualifierDetails; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; @@ -61,7 +62,6 @@ import ca.uhn.fhir.util.BundleUtil; import ca.uhn.fhir.util.FhirTerser; import ca.uhn.fhir.util.OperationOutcomeUtil; import ca.uhn.fhir.util.ResourceReferenceInfo; -import ca.uhn.fhir.model.api.StorageResponseCodeEnum; import ca.uhn.fhir.util.StopWatch; import ca.uhn.fhir.util.UrlUtil; import com.google.common.annotations.VisibleForTesting; @@ -237,7 +237,7 @@ public abstract class BaseStorageDao { Long version; if (resourceVersionMap.containsKey(referenceElement)) { // the resource exists... latest id - // will be the value in the ResourcePersistentId + // will be the value in the IResourcePersistentId version = resourceVersionMap.getResourcePersistentId(referenceElement).getVersion(); } else if (myDaoConfig.isAutoCreatePlaceholderReferenceTargets()) { // if idToPID doesn't contain object @@ -318,7 +318,7 @@ public abstract class BaseStorageDao { return outcome; } - protected DaoMethodOutcome toMethodOutcomeLazy(RequestDetails theRequest, ResourcePersistentId theResourcePersistentId, @Nonnull final Supplier theEntity, Supplier theIdSupplier) { + protected DaoMethodOutcome toMethodOutcomeLazy(RequestDetails theRequest, IResourcePersistentId theResourcePersistentId, @Nonnull final Supplier theEntity, Supplier theIdSupplier) { LazyDaoMethodOutcome outcome = new LazyDaoMethodOutcome(theResourcePersistentId); outcome.setEntitySupplier(theEntity); diff --git a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/BaseStorageResourceDao.java b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/BaseStorageResourceDao.java index ffd3ec75623..c582895f893 100644 --- a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/BaseStorageResourceDao.java +++ b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/BaseStorageResourceDao.java @@ -33,7 +33,7 @@ import ca.uhn.fhir.parser.StrictErrorHandler; import ca.uhn.fhir.rest.api.PatchTypeEnum; import ca.uhn.fhir.rest.api.RestOperationTypeEnum; 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.IResourcePersistentId; import ca.uhn.fhir.rest.api.server.storage.TransactionDetails; import ca.uhn.fhir.rest.server.exceptions.PreconditionFailedException; import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; @@ -76,12 +76,12 @@ public abstract class BaseStorageResourceDao extends Ba IIdType resourceId; if (isNotBlank(theConditionalUrl)) { - Set match = getMatchResourceUrlService().processMatchUrl(theConditionalUrl, getResourceType(), theTransactionDetails, theRequestDetails); + Set 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(); + IResourcePersistentId pid = match.iterator().next(); entityToUpdate = readEntityLatestVersion(pid, theRequestDetails, theTransactionDetails); resourceId = entityToUpdate.getIdDt(); } else { @@ -140,7 +140,7 @@ public abstract class BaseStorageResourceDao extends Ba @Nonnull protected abstract String getResourceName(); - protected abstract IBasePersistedResource readEntityLatestVersion(ResourcePersistentId thePersistentId, RequestDetails theRequestDetails, TransactionDetails theTransactionDetails); + protected abstract IBasePersistedResource readEntityLatestVersion(IResourcePersistentId thePersistentId, RequestDetails theRequestDetails, TransactionDetails theTransactionDetails); protected abstract IBasePersistedResource readEntityLatestVersion(IIdType theId, RequestDetails theRequestDetails, TransactionDetails theTransactionDetails); diff --git a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/IResultIterator.java b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/IResultIterator.java index ea660933178..3ac2cd14820 100644 --- a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/IResultIterator.java +++ b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/IResultIterator.java @@ -20,18 +20,18 @@ package ca.uhn.fhir.jpa.dao; * #L% */ -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import java.io.Closeable; import java.util.Collection; import java.util.Iterator; -public interface IResultIterator extends Iterator, Closeable { +public interface IResultIterator extends Iterator, Closeable { int getSkippedCount(); int getNonSkippedCount(); - Collection getNextResultBatch(long theBatchSize); + Collection getNextResultBatch(long theBatchSize); } diff --git a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/ISearchBuilder.java b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/ISearchBuilder.java index 42041bb3974..b54d553f739 100644 --- a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/ISearchBuilder.java +++ b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/ISearchBuilder.java @@ -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.IResourcePersistentId; 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 { 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 thePids, Collection theIncludedPids, List theResourceListToPopulate, boolean theForHistoryOperation, RequestDetails theDetails); + void loadResourcesByPid(Collection thePids, Collection theIncludedPids, List theResourceListToPopulate, boolean theForHistoryOperation, RequestDetails theDetails); - Set loadIncludes(FhirContext theContext, EntityManager theEntityManager, Collection theMatches, Collection theRevIncludes, boolean theReverseMode, + Set loadIncludes(FhirContext theContext, EntityManager theEntityManager, Collection theMatches, Collection 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 thePreviouslyAddedResourcePids); + void setPreviouslyAddedResourcePids(List thePreviouslyAddedResourcePids); } diff --git a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/MatchResourceUrlService.java b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/MatchResourceUrlService.java index 51694b47b87..0569acfff4d 100644 --- a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/MatchResourceUrlService.java +++ b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/MatchResourceUrlService.java @@ -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; @@ -36,7 +36,7 @@ import ca.uhn.fhir.jpa.util.MemoryCacheService; import ca.uhn.fhir.rest.api.server.IPreResourceShowDetails; import ca.uhn.fhir.rest.api.server.RequestDetails; import ca.uhn.fhir.rest.api.server.SimplePreResourceShowDetails; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import ca.uhn.fhir.rest.api.server.storage.TransactionDetails; import ca.uhn.fhir.rest.server.exceptions.ForbiddenOperationException; import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; @@ -60,7 +60,7 @@ import java.util.Set; import java.util.stream.Collectors; @Service -public class MatchResourceUrlService { +public class MatchResourceUrlService { 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 Set processMatchUrl(String theMatchUrl, Class theResourceType, TransactionDetails theTransactionDetails, RequestDetails theRequest) { + public Set processMatchUrl(String theMatchUrl, Class theResourceType, TransactionDetails theTransactionDetails, RequestDetails theRequest) { return processMatchUrl(theMatchUrl, theResourceType, theTransactionDetails, theRequest, null); } /** * Note that this will only return a maximum of 2 results!! */ - public Set processMatchUrl(String theMatchUrl, Class theResourceType, TransactionDetails theTransactionDetails, RequestDetails theRequest, IBaseResource theConditionalOperationTargetOrNull) { - Set retVal = null; + public Set processMatchUrl(String theMatchUrl, Class theResourceType, TransactionDetails theTransactionDetails, RequestDetails theRequest, IBaseResource theConditionalOperationTargetOrNull) { + Set 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 resourceToPidMap = new HashMap<>(); + Map resourceToPidMap = new HashMap<>(); IFhirResourceDao 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 Set search(SearchParameterMap theParamMap, Class theResourceType, RequestDetails theRequest, @Nullable IBaseResource theConditionalOperationTargetOrNull) { + public Set search(SearchParameterMap theParamMap, Class theResourceType, RequestDetails theRequest, @Nullable IBaseResource theConditionalOperationTargetOrNull) { StopWatch sw = new StopWatch(); IFhirResourceDao dao = getResourceDao(theResourceType); - List retVal = dao.searchForIds(theParamMap, theRequest, theConditionalOperationTargetOrNull); + List 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); diff --git a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/SearchBuilderFactory.java b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/SearchBuilderFactory.java index 4d4cd54138e..41abe7509cd 100644 --- a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/SearchBuilderFactory.java +++ b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/SearchBuilderFactory.java @@ -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.IResourcePersistentId; 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> { @Autowired private ApplicationContext myApplicationContext; @Autowired private DaoConfig myDaoConfig; - public ISearchBuilder newSearchBuilder(IDao theDao, String theResourceName, Class theResourceType) { - return (ISearchBuilder) myApplicationContext.getBean(ISearchBuilder.SEARCH_BUILDER_BEAN_NAME, theDao, theResourceName, theResourceType, myDaoConfig); + public ISearchBuilder newSearchBuilder(IDao theDao, String theResourceName, Class theResourceType) { + return (ISearchBuilder) myApplicationContext.getBean(ISearchBuilder.SEARCH_BUILDER_BEAN_NAME, theDao, theResourceName, theResourceType, myDaoConfig); } } diff --git a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/expunge/ExpungeOperation.java b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/expunge/ExpungeOperation.java index 393dfa92ff8..79dfd8aa1ea 100644 --- a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/expunge/ExpungeOperation.java +++ b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/expunge/ExpungeOperation.java @@ -24,7 +24,7 @@ import ca.uhn.fhir.jpa.api.config.DaoConfig; import ca.uhn.fhir.jpa.api.model.ExpungeOptions; import ca.uhn.fhir.jpa.api.model.ExpungeOutcome; 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.IResourcePersistentId; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -48,12 +48,12 @@ public class ExpungeOperation implements Callable { private DaoConfig myDaoConfig; private final String myResourceName; - private final ResourcePersistentId myResourceId; + private final IResourcePersistentId myResourceId; private final ExpungeOptions myExpungeOptions; private final RequestDetails myRequestDetails; private final AtomicInteger myRemainingCount; - public ExpungeOperation(String theResourceName, ResourcePersistentId theResourceId, ExpungeOptions theExpungeOptions, RequestDetails theRequestDetails) { + public ExpungeOperation(String theResourceName, IResourcePersistentId theResourceId, ExpungeOptions theExpungeOptions, RequestDetails theRequestDetails) { myResourceName = theResourceName; myResourceId = theResourceId; myExpungeOptions = theExpungeOptions; @@ -81,7 +81,7 @@ public class ExpungeOperation implements Callable { } private void expungeDeletedResources() { - List resourceIds = findHistoricalVersionsOfDeletedResources(); + List resourceIds = findHistoricalVersionsOfDeletedResources(); deleteHistoricalVersions(resourceIds); if (expungeLimitReached()) { @@ -91,13 +91,13 @@ public class ExpungeOperation implements Callable { deleteCurrentVersionsOfDeletedResources(resourceIds); } - private List findHistoricalVersionsOfDeletedResources() { - List retVal = myExpungeDaoService.findHistoricalVersionsOfDeletedResources(myResourceName, myResourceId, myRemainingCount.get()); + private List findHistoricalVersionsOfDeletedResources() { + List retVal = myExpungeDaoService.findHistoricalVersionsOfDeletedResources(myResourceName, myResourceId, myRemainingCount.get()); ourLog.debug("Found {} historical versions", retVal.size()); return retVal; } - private List findHistoricalVersionsOfNonDeletedResources() { + private List findHistoricalVersionsOfNonDeletedResources() { return myExpungeDaoService.findHistoricalVersionsOfNonDeletedResources(myResourceName, myResourceId, myRemainingCount.get()); } @@ -110,7 +110,7 @@ public class ExpungeOperation implements Callable { } private void expungeOldVersions() { - List historicalIds = findHistoricalVersionsOfNonDeletedResources(); + List historicalIds = findHistoricalVersionsOfNonDeletedResources(); getPartitionRunner().runInPartitionedThreads(historicalIds, partition -> myExpungeDaoService.expungeHistoricalVersions(myRequestDetails, partition, myRemainingCount)); } @@ -119,11 +119,11 @@ public class ExpungeOperation implements Callable { return new PartitionRunner(PROCESS_NAME, THREAD_PREFIX, myDaoConfig.getExpungeBatchSize(), myDaoConfig.getExpungeThreadCount()); } - private void deleteCurrentVersionsOfDeletedResources(List theResourceIds) { + private void deleteCurrentVersionsOfDeletedResources(List theResourceIds) { getPartitionRunner().runInPartitionedThreads(theResourceIds, partition -> myExpungeDaoService.expungeCurrentVersionOfResources(myRequestDetails, partition, myRemainingCount)); } - private void deleteHistoricalVersions(List theResourceIds) { + private void deleteHistoricalVersions(List theResourceIds) { getPartitionRunner().runInPartitionedThreads(theResourceIds, partition -> myExpungeDaoService.expungeHistoricalVersionsOfIds(myRequestDetails, partition, myRemainingCount)); } diff --git a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/expunge/ExpungeService.java b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/expunge/ExpungeService.java index a4d64d7bdcb..258d1d6b681 100644 --- a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/expunge/ExpungeService.java +++ b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/expunge/ExpungeService.java @@ -24,7 +24,7 @@ import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.jpa.api.model.ExpungeOptions; import ca.uhn.fhir.jpa.api.model.ExpungeOutcome; 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.IResourcePersistentId; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -43,11 +43,11 @@ public class ExpungeService { @Autowired private ApplicationContext myApplicationContext; - protected ExpungeOperation getExpungeOperation(String theResourceName, ResourcePersistentId theResourceId, ExpungeOptions theExpungeOptions, RequestDetails theRequestDetails) { + protected ExpungeOperation getExpungeOperation(String theResourceName, IResourcePersistentId theResourceId, ExpungeOptions theExpungeOptions, RequestDetails theRequestDetails) { return myApplicationContext.getBean(ExpungeOperation.class, theResourceName, theResourceId, theExpungeOptions, theRequestDetails); } - public ExpungeOutcome expunge(String theResourceName, ResourcePersistentId theResourceId, ExpungeOptions theExpungeOptions, RequestDetails theRequest) { + public ExpungeOutcome expunge(String theResourceName, IResourcePersistentId theResourceId, ExpungeOptions theExpungeOptions, RequestDetails theRequest) { ourLog.info("Expunge: ResourceName[{}] Id[{}] Version[{}] Options[{}]", theResourceName, theResourceId != null ? theResourceId.getId() : null, theResourceId != null ? theResourceId.getVersion() : null, theExpungeOptions); ExpungeOperation expungeOperation = getExpungeOperation(theResourceName, theResourceId, theExpungeOptions, theRequest); @@ -65,7 +65,7 @@ public class ExpungeService { return expungeOperation.call(); } - public void deleteAllSearchParams(ResourcePersistentId theResourceId) { + public void deleteAllSearchParams(IResourcePersistentId theResourceId) { myExpungeDaoService.deleteAllSearchParams(theResourceId); } } diff --git a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/expunge/IResourceExpungeService.java b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/expunge/IResourceExpungeService.java index 3eedc6f0964..2f8ad480d8a 100644 --- a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/expunge/IResourceExpungeService.java +++ b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/expunge/IResourceExpungeService.java @@ -21,21 +21,21 @@ package ca.uhn.fhir.jpa.dao.expunge; */ 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.IResourcePersistentId; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; -public interface IResourceExpungeService { - List findHistoricalVersionsOfDeletedResources(String theResourceName, ResourcePersistentId theResourceId, int theI); +public interface IResourceExpungeService { + List findHistoricalVersionsOfDeletedResources(String theResourceName, T theResourceId, int theI); - List findHistoricalVersionsOfNonDeletedResources(String theResourceName, ResourcePersistentId theResourceId, int theI); + List findHistoricalVersionsOfNonDeletedResources(String theResourceName, T theResourceId, int theI); - void expungeHistoricalVersions(RequestDetails theRequestDetails, List thePartition, AtomicInteger theRemainingCount); + void expungeHistoricalVersions(RequestDetails theRequestDetails, List thePartition, AtomicInteger theRemainingCount); - void expungeCurrentVersionOfResources(RequestDetails theRequestDetails, List theResourceIds, AtomicInteger theRemainingCount); + void expungeCurrentVersionOfResources(RequestDetails theRequestDetails, List theResourceIds, AtomicInteger theRemainingCount); - void expungeHistoricalVersionsOfIds(RequestDetails theRequestDetails, List theResourceIds, AtomicInteger theRemainingCount); + void expungeHistoricalVersionsOfIds(RequestDetails theRequestDetails, List theResourceIds, AtomicInteger theRemainingCount); - void deleteAllSearchParams(ResourcePersistentId theResourceId); + void deleteAllSearchParams(T theResourceId); } diff --git a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/expunge/PartitionRunner.java b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/expunge/PartitionRunner.java index 99430100c10..42d0613cc67 100644 --- a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/expunge/PartitionRunner.java +++ b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/expunge/PartitionRunner.java @@ -21,7 +21,7 @@ package ca.uhn.fhir.jpa.dao.expunge; */ import ca.uhn.fhir.i18n.Msg; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId; import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; import ca.uhn.fhir.util.StopWatch; import com.google.common.collect.Lists; @@ -58,7 +58,7 @@ public class PartitionRunner { myThreadCount = theThreadCount; } - public void runInPartitionedThreads(List theResourceIds, Consumer> partitionConsumer) { + public void runInPartitionedThreads(List theResourceIds, Consumer> partitionConsumer) { List> callableTasks = buildCallableTasks(theResourceIds, partitionConsumer); if (callableTasks.size() == 0) { @@ -93,7 +93,7 @@ public class PartitionRunner { } } - private List> buildCallableTasks(List theResourceIds, Consumer> partitionConsumer) { + private List> buildCallableTasks(List theResourceIds, Consumer> partitionConsumer) { List> retval = new ArrayList<>(); if (myBatchSize > theResourceIds.size()) { @@ -101,9 +101,9 @@ public class PartitionRunner { } else { ourLog.info("Creating batch job of {} entries", theResourceIds.size()); } - List> partitions = Lists.partition(theResourceIds, myBatchSize); + List> partitions = Lists.partition(theResourceIds, myBatchSize); - for (List nextPartition : partitions) { + for (List nextPartition : partitions) { if (nextPartition.size() > 0) { Callable callableTask = () -> { ourLog.info(myProcessName + " {} resources", nextPartition.size()); diff --git a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/index/DaoResourceLinkResolver.java b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/index/DaoResourceLinkResolver.java index ffa2c7f8df5..29731196b00 100644 --- a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/index/DaoResourceLinkResolver.java +++ b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/dao/index/DaoResourceLinkResolver.java @@ -37,7 +37,7 @@ import ca.uhn.fhir.jpa.model.cross.IResourceLookup; import ca.uhn.fhir.jpa.searchparam.extractor.IResourceLinkResolver; import ca.uhn.fhir.jpa.searchparam.extractor.PathAndRef; 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.IResourcePersistentId; import ca.uhn.fhir.rest.api.server.storage.TransactionDetails; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; @@ -64,14 +64,14 @@ import java.util.Date; import java.util.List; import java.util.Optional; -public class DaoResourceLinkResolver implements IResourceLinkResolver { +public class DaoResourceLinkResolver implements IResourceLinkResolver { private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(DaoResourceLinkResolver.class); @Autowired private DaoConfig myDaoConfig; @Autowired private FhirContext myContext; @Autowired - private IIdHelperService myIdHelperService; + private IIdHelperService myIdHelperService; @Autowired private DaoRegistry myDaoRegistry; @Autowired @@ -94,10 +94,10 @@ public class DaoResourceLinkResolver implements IResourceLinkResolver { RuntimeSearchParam searchParam = mySearchParamRegistry.getActiveSearchParam(theSourceResourceName, thePathAndRef.getSearchParamName()); - ResourcePersistentId persistentId = null; + T persistentId = null; if (theTransactionDetails != null) { - ResourcePersistentId resolvedResourceId = theTransactionDetails.getResolvedResourceId(targetResourceId); - if (resolvedResourceId != null && resolvedResourceId.getIdAsLong() != null && resolvedResourceId.getAssociatedResourceId() != null) { + T resolvedResourceId = (T) theTransactionDetails.getResolvedResourceId(targetResourceId); + if (resolvedResourceId != null && resolvedResourceId.getId() != null && resolvedResourceId.getAssociatedResourceId() != null) { persistentId = resolvedResourceId; } } @@ -140,7 +140,7 @@ public class DaoResourceLinkResolver implements IResourceLinkResolver { } if (persistentId == null) { - persistentId = new ResourcePersistentId(resolvedResource.getPersistentId().getId()); + persistentId = myIdHelperService.newPid(resolvedResource.getPersistentId().getId()); persistentId.setAssociatedResourceId(targetResourceId); if (theTransactionDetails != null) { theTransactionDetails.addResolvedResourceId(targetResourceId, persistentId); @@ -183,7 +183,8 @@ public class DaoResourceLinkResolver implements IResourceLinkResolver { valueOf = placeholderResourceDao.create(newResource, theRequest).getEntity(); } - ResourcePersistentId persistentId = new ResourcePersistentId(valueOf.getPersistentId().getId(), 1L); + IResourcePersistentId persistentId = valueOf.getPersistentId(); + persistentId = myIdHelperService.newPid(persistentId.getId()); persistentId.setAssociatedResourceId(valueOf.getIdDt()); theTransactionDetails.addResolvedResourceId(persistentId.getAssociatedResourceId(), persistentId); } @@ -305,10 +306,10 @@ public class DaoResourceLinkResolver implements IResourceLinkResolver { myDaoRegistry.getDaoOrThrowException(theType); } - private static class ResourceLookupPersistentIdWrapper implements IResourceLookup { - private final ResourcePersistentId myPersistentId; + private static class ResourceLookupPersistentIdWrapper

implements IResourceLookup { + private final P myPersistentId; - public ResourceLookupPersistentIdWrapper(ResourcePersistentId thePersistentId) { + public ResourceLookupPersistentIdWrapper(P thePersistentId) { myPersistentId = thePersistentId; } @@ -323,7 +324,7 @@ public class DaoResourceLinkResolver implements IResourceLinkResolver { } @Override - public ResourcePersistentId getPersistentId() { + public P getPersistentId() { return myPersistentId; } } diff --git a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/searchparam/submit/interceptor/SearchParamValidatingInterceptor.java b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/searchparam/submit/interceptor/SearchParamValidatingInterceptor.java index 74bd16c5657..feea97930b0 100644 --- a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/searchparam/submit/interceptor/SearchParamValidatingInterceptor.java +++ b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/searchparam/submit/interceptor/SearchParamValidatingInterceptor.java @@ -31,27 +31,20 @@ import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao; import ca.uhn.fhir.jpa.api.svc.IIdHelperService; import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; import ca.uhn.fhir.jpa.searchparam.registry.SearchParameterCanonicalizer; -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.api.server.storage.IResourcePersistentId; import ca.uhn.fhir.rest.param.TokenAndListParam; import ca.uhn.fhir.rest.param.TokenOrListParam; import ca.uhn.fhir.rest.param.TokenParam; import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException; -import org.apache.commons.lang3.Validate; -import org.hl7.fhir.instance.model.api.IBaseExtension; -import org.hl7.fhir.instance.model.api.IBaseHasExtensions; import org.hl7.fhir.instance.model.api.IBaseResource; -import org.hl7.fhir.instance.model.api.IPrimitiveType; import org.springframework.beans.factory.annotation.Autowired; -import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; -import java.util.stream.Collectors; import static org.apache.commons.collections4.CollectionUtils.isNotEmpty; import static org.apache.commons.lang3.StringUtils.isBlank; @@ -97,7 +90,7 @@ public class SearchParamValidatingInterceptor { } private void validateStandardSpOnCreate(RequestDetails theRequestDetails, SearchParameterMap searchParameterMap) { - List persistedIdList = getDao().searchForIds(searchParameterMap, theRequestDetails); + List persistedIdList = getDao().searchForIds(searchParameterMap, theRequestDetails); if( isNotEmpty(persistedIdList) ) { throw new UnprocessableEntityException(Msg.code(2196) + "Can't process submitted SearchParameter as it is overlapping an existing one."); } @@ -125,7 +118,7 @@ public class SearchParamValidatingInterceptor { } private void validateStandardSpOnUpdate(RequestDetails theRequestDetails, RuntimeSearchParam runtimeSearchParam, SearchParameterMap searchParameterMap) { - List pidList = getDao().searchForIds(searchParameterMap, theRequestDetails); + List pidList = getDao().searchForIds(searchParameterMap, theRequestDetails); if(isNotEmpty(pidList)){ Set resolvedResourceIds = myIdHelperService.translatePidsToFhirResourceIds(new HashSet<>(pidList)); if(isNewSearchParam(runtimeSearchParam, resolvedResourceIds)) { diff --git a/hapi-fhir-storage/src/test/java/ca/uhn/fhir/jpa/api/pid/ResourcePidListBuilderTest.java b/hapi-fhir-storage/src/test/java/ca/uhn/fhir/jpa/api/pid/ResourcePidListBuilderTest.java index e00a9ad3830..06c069c61ef 100644 --- a/hapi-fhir-storage/src/test/java/ca/uhn/fhir/jpa/api/pid/ResourcePidListBuilderTest.java +++ b/hapi-fhir-storage/src/test/java/ca/uhn/fhir/jpa/api/pid/ResourcePidListBuilderTest.java @@ -1,6 +1,6 @@ package ca.uhn.fhir.jpa.api.pid; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; +import ca.uhn.fhir.jpa.model.dao.JpaPid; import org.junit.jupiter.api.Test; import java.util.ArrayList; @@ -18,12 +18,12 @@ import static org.junit.jupiter.api.Assertions.fail; class ResourcePidListBuilderTest { - public static final ResourcePersistentId PID_1 = new ResourcePersistentId(1L); - public static final ResourcePersistentId PID_2 = new ResourcePersistentId(2L); - public static final ResourcePersistentId PID_3 = new ResourcePersistentId(3L); - public static final ResourcePersistentId PID_4 = new ResourcePersistentId(4L); - public static final ResourcePersistentId PID_5 = new ResourcePersistentId(5L); - public static final ResourcePersistentId PID_6 = new ResourcePersistentId(6L); + public static final JpaPid PID_1 = JpaPid.fromId(1L); + public static final JpaPid PID_2 = JpaPid.fromId(2L); + public static final JpaPid PID_3 = JpaPid.fromId(3L); + public static final JpaPid PID_4 = JpaPid.fromId(4L); + public static final JpaPid PID_5 = JpaPid.fromId(5L); + public static final JpaPid PID_6 = JpaPid.fromId(6L); public static final String RESOURCE_TYPE = "Patient"; public static final String OTHER_RESOURCE_TYPE = "Observation"; public static final TypedResourcePid TRP_1 = new TypedResourcePid(RESOURCE_TYPE, PID_1); diff --git a/hapi-fhir-storage/src/test/java/ca/uhn/fhir/jpa/dao/index/DaoResourceLinkResolverTest.java b/hapi-fhir-storage/src/test/java/ca/uhn/fhir/jpa/dao/index/DaoResourceLinkResolverTest.java index 5ed1ebf2174..54612782555 100644 --- a/hapi-fhir-storage/src/test/java/ca/uhn/fhir/jpa/dao/index/DaoResourceLinkResolverTest.java +++ b/hapi-fhir-storage/src/test/java/ca/uhn/fhir/jpa/dao/index/DaoResourceLinkResolverTest.java @@ -1,15 +1,17 @@ package ca.uhn.fhir.jpa.dao.index; +import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.util.CanonicalIdentifier; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; class DaoResourceLinkResolverTest { @Test public void testLinkResolution() { - DaoResourceLinkResolver resolver = new DaoResourceLinkResolver(); + DaoResourceLinkResolver resolver = new DaoResourceLinkResolver(); CanonicalIdentifier canonicalIdentifier = resolver.extractIdentifierFromUrl("Patient?_patient?" + "identifier=http://hapifhir.io/fhir/namingsystem/my_id|123456"); assertEquals("http://hapifhir.io/fhir/namingsystem/my_id", canonicalIdentifier.getSystemElement().getValueAsString()); diff --git a/hapi-fhir-storage/src/test/java/ca/uhn/fhir/jpa/interceptor/validation/SearchParameterValidatingInterceptorTest.java b/hapi-fhir-storage/src/test/java/ca/uhn/fhir/jpa/interceptor/validation/SearchParameterValidatingInterceptorTest.java index 8fbfe3c99d4..36890926a1a 100644 --- a/hapi-fhir-storage/src/test/java/ca/uhn/fhir/jpa/interceptor/validation/SearchParameterValidatingInterceptorTest.java +++ b/hapi-fhir-storage/src/test/java/ca/uhn/fhir/jpa/interceptor/validation/SearchParameterValidatingInterceptorTest.java @@ -4,15 +4,13 @@ import ca.uhn.fhir.context.FhirContext; 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.searchparam.registry.SearchParameterCanonicalizer; import ca.uhn.fhir.jpa.searchparam.submit.interceptor.SearchParamValidatingInterceptor; 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.api.server.storage.IResourcePersistentId; import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException; -import org.hl7.fhir.r4.model.CodeType; import org.hl7.fhir.r4.model.Enumerations; -import org.hl7.fhir.r4.model.Extension; import org.hl7.fhir.r4.model.Patient; import org.hl7.fhir.r4.model.SearchParameter; import org.junit.jupiter.api.BeforeEach; @@ -21,9 +19,9 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import javax.annotation.Nonnull; import java.util.List; import java.util.Set; +import java.util.concurrent.atomic.AtomicLong; import java.util.stream.Collectors; import static java.util.Arrays.asList; @@ -147,10 +145,11 @@ public class SearchParameterValidatingInterceptorTest { } private void setPersistedSearchParameterIds(List theSearchParams) { - List resourcePersistentIds = theSearchParams + final AtomicLong counter = new AtomicLong(); + List resourcePersistentIds = theSearchParams .stream() .map(SearchParameter::getId) - .map(theS -> new ResourcePersistentId(theS)) + .map(s -> JpaPid.fromId(counter.incrementAndGet())) .collect(Collectors.toList()); when(myIFhirResourceDao.searchForIds(any(), any())).thenReturn(resourcePersistentIds); } diff --git a/hapi-fhir-structures-dstu2.1/pom.xml b/hapi-fhir-structures-dstu2.1/pom.xml index 0ff8f8f4537..9f921723cf6 100644 --- a/hapi-fhir-structures-dstu2.1/pom.xml +++ b/hapi-fhir-structures-dstu2.1/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-structures-dstu2/pom.xml b/hapi-fhir-structures-dstu2/pom.xml index d0484a238ad..e5c55cb8731 100644 --- a/hapi-fhir-structures-dstu2/pom.xml +++ b/hapi-fhir-structures-dstu2/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-structures-dstu3/pom.xml b/hapi-fhir-structures-dstu3/pom.xml index b78eb382d59..d5c2b1360bd 100644 --- a/hapi-fhir-structures-dstu3/pom.xml +++ b/hapi-fhir-structures-dstu3/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-structures-hl7org-dstu2/pom.xml b/hapi-fhir-structures-hl7org-dstu2/pom.xml index e2935ed5663..95feb7f511f 100644 --- a/hapi-fhir-structures-hl7org-dstu2/pom.xml +++ b/hapi-fhir-structures-hl7org-dstu2/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-structures-r4/pom.xml b/hapi-fhir-structures-r4/pom.xml index 53ad8024c57..b79d9f143ae 100644 --- a/hapi-fhir-structures-r4/pom.xml +++ b/hapi-fhir-structures-r4/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-structures-r4b/pom.xml b/hapi-fhir-structures-r4b/pom.xml index 4f44d1210ea..3edd4a1a0b6 100644 --- a/hapi-fhir-structures-r4b/pom.xml +++ b/hapi-fhir-structures-r4b/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-structures-r5/pom.xml b/hapi-fhir-structures-r5/pom.xml index 5ff1042fde3..255cd012bb3 100644 --- a/hapi-fhir-structures-r5/pom.xml +++ b/hapi-fhir-structures-r5/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-structures-r5/src/main/java/org/hl7/fhir/r5/hapi/ctx/HapiWorkerContext.java b/hapi-fhir-structures-r5/src/main/java/org/hl7/fhir/r5/hapi/ctx/HapiWorkerContext.java index 2c6a6a3863c..0860043f5d0 100644 --- a/hapi-fhir-structures-r5/src/main/java/org/hl7/fhir/r5/hapi/ctx/HapiWorkerContext.java +++ b/hapi-fhir-structures-r5/src/main/java/org/hl7/fhir/r5/hapi/ctx/HapiWorkerContext.java @@ -14,9 +14,7 @@ import org.fhir.ucum.UcumService; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.TerminologyServiceException; import org.hl7.fhir.r5.context.IWorkerContext; - import org.hl7.fhir.r5.context.IWorkerContextManager; -import org.hl7.fhir.r5.model.CanonicalResource; import org.hl7.fhir.r5.model.CodeSystem; import org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent; import org.hl7.fhir.r5.model.CodeableConcept; diff --git a/hapi-fhir-test-utilities/pom.xml b/hapi-fhir-test-utilities/pom.xml index 0f749e0f8d6..ca5107ce334 100644 --- a/hapi-fhir-test-utilities/pom.xml +++ b/hapi-fhir-test-utilities/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-testpage-overlay/pom.xml b/hapi-fhir-testpage-overlay/pom.xml index 7e6c5fff8e2..97fa8e30453 100644 --- a/hapi-fhir-testpage-overlay/pom.xml +++ b/hapi-fhir-testpage-overlay/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-fhir - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../pom.xml diff --git a/hapi-fhir-validation-resources-dstu2.1/pom.xml b/hapi-fhir-validation-resources-dstu2.1/pom.xml index 0096030acfe..a2536bd3347 100644 --- a/hapi-fhir-validation-resources-dstu2.1/pom.xml +++ b/hapi-fhir-validation-resources-dstu2.1/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-validation-resources-dstu2/pom.xml b/hapi-fhir-validation-resources-dstu2/pom.xml index 77986685fa1..4f32c64bb20 100644 --- a/hapi-fhir-validation-resources-dstu2/pom.xml +++ b/hapi-fhir-validation-resources-dstu2/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-validation-resources-dstu3/pom.xml b/hapi-fhir-validation-resources-dstu3/pom.xml index cbe92e1cabb..0cfca5e727b 100644 --- a/hapi-fhir-validation-resources-dstu3/pom.xml +++ b/hapi-fhir-validation-resources-dstu3/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-validation-resources-r4/pom.xml b/hapi-fhir-validation-resources-r4/pom.xml index 1f564de3054..dd0d4dde52f 100644 --- a/hapi-fhir-validation-resources-r4/pom.xml +++ b/hapi-fhir-validation-resources-r4/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-validation-resources-r5/pom.xml b/hapi-fhir-validation-resources-r5/pom.xml index 2a49023dd6e..9b3dc5018fb 100644 --- a/hapi-fhir-validation-resources-r5/pom.xml +++ b/hapi-fhir-validation-resources-r5/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-validation/pom.xml b/hapi-fhir-validation/pom.xml index 157510c0567..39d88b0809c 100644 --- a/hapi-fhir-validation/pom.xml +++ b/hapi-fhir-validation/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/validator/VersionSpecificWorkerContextWrapper.java b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/validator/VersionSpecificWorkerContextWrapper.java index 21f5128e0d6..1973482b947 100644 --- a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/validator/VersionSpecificWorkerContextWrapper.java +++ b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/validator/VersionSpecificWorkerContextWrapper.java @@ -19,7 +19,6 @@ import org.hl7.fhir.exceptions.TerminologyServiceException; import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.r5.context.IWorkerContext; import org.hl7.fhir.r5.context.IWorkerContextManager; -import org.hl7.fhir.r5.model.CanonicalResource; import org.hl7.fhir.r5.model.CodeSystem; import org.hl7.fhir.r5.model.Coding; import org.hl7.fhir.r5.model.NamingSystem; diff --git a/hapi-tinder-plugin/pom.xml b/hapi-tinder-plugin/pom.xml index a365bf600ca..1b955a53cf0 100644 --- a/hapi-tinder-plugin/pom.xml +++ b/hapi-tinder-plugin/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../pom.xml diff --git a/hapi-tinder-test/pom.xml b/hapi-tinder-test/pom.xml index 38e69b52f4a..1a15bde5023 100644 --- a/hapi-tinder-test/pom.xml +++ b/hapi-tinder-test/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-fhir - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../pom.xml diff --git a/pom.xml b/pom.xml index 30e39d2aa94..5b35715588e 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ ca.uhn.hapi.fhir hapi-fhir pom - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT HAPI-FHIR An open-source implementation of the FHIR specification in Java. https://hapifhir.io @@ -2105,7 +2105,7 @@ ca.uhn.hapi.fhir hapi-fhir-checkstyle - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT diff --git a/tests/hapi-fhir-base-test-jaxrsserver-kotlin/pom.xml b/tests/hapi-fhir-base-test-jaxrsserver-kotlin/pom.xml index f71a785ac41..7f8c23b2a4a 100644 --- a/tests/hapi-fhir-base-test-jaxrsserver-kotlin/pom.xml +++ b/tests/hapi-fhir-base-test-jaxrsserver-kotlin/pom.xml @@ -6,7 +6,7 @@ ca.uhn.hapi.fhir hapi-fhir - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../../pom.xml diff --git a/tests/hapi-fhir-base-test-mindeps-client/pom.xml b/tests/hapi-fhir-base-test-mindeps-client/pom.xml index 911b7af6db1..13a18652f71 100644 --- a/tests/hapi-fhir-base-test-mindeps-client/pom.xml +++ b/tests/hapi-fhir-base-test-mindeps-client/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-fhir - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../../pom.xml diff --git a/tests/hapi-fhir-base-test-mindeps-server/pom.xml b/tests/hapi-fhir-base-test-mindeps-server/pom.xml index 04bfb203c6b..b0484a6e43d 100644 --- a/tests/hapi-fhir-base-test-mindeps-server/pom.xml +++ b/tests/hapi-fhir-base-test-mindeps-server/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir - 6.3.2-SNAPSHOT + 6.3.3-SNAPSHOT ../../pom.xml