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 733f41d2005..7459219e1b9 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 @@ -53,6 +53,7 @@ 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; @@ -299,7 +300,7 @@ public class JpaConfig { @Bean @Primary public IResourceLinkResolver daoResourceLinkResolver() { - return new DaoResourceLinkResolver(); + return new DaoResourceLinkResolver(); } @Bean @@ -791,5 +792,4 @@ public class JpaConfig { return new ObservationLastNIndexPersistSvc(); } - } 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 33ed569919d..105456e4a76 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,7 +30,7 @@ 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; @@ -517,7 +517,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<>()); } @@ -580,7 +580,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)) { @@ -654,7 +654,7 @@ public class IdHelperService implements IIdHelperService { } if (!myDaoConfig.isDeleteEnabled()) { - ResourceLookup lookup = new ResourceLookup(theResourceType, jpaPid.getId(), theDeletedAt); + JpaResourceLookup lookup = new JpaResourceLookup(theResourceType, jpaPid.getId(), theDeletedAt); String nextKey = theResourcePersistentId.toString(); myMemoryCacheService.putAfterCommit(MemoryCacheService.CacheEnum.RESOURCE_LOOKUP, nextKey, lookup); } @@ -750,4 +750,14 @@ public class IdHelperService implements IIdHelperService { return pidToForcedIdMap.getResolvedResourceIds(); } + + @Override + public JpaPid newPid(Object thePid) { + return new JpaPid((Long) thePid); + } + + @Override + public JpaPid newPidFromString(String thePid) { + return new JpaPid(Long.parseLong(thePid)); + } } 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 e97c9e09780..fea7229ad3f 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 @@ -100,7 +100,7 @@ public class SearchParamWithInlineReferencesExtractor { @Autowired private SearchParamExtractorService mySearchParamExtractorService; @Autowired - private DaoResourceLinkResolver myDaoResourceLinkResolver; + private DaoResourceLinkResolver myDaoResourceLinkResolver; @Autowired private DaoSearchParamSynchronizer myDaoSearchParamSynchronizer; @Autowired 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 75% 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 af281137918..02612f3fd71 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 @@ -21,16 +21,15 @@ package ca.uhn.fhir.jpa.model.cross; */ import ca.uhn.fhir.jpa.model.dao.JpaPid; -import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; 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,9 +45,8 @@ public class ResourceLookup implements IResourceLookup { return myDeletedAt; } - //TODO KM Should I rename the method and change the returned type here? (ResourceHistoryTable and ResourceTable also have the same method) @Override - public ResourcePersistentId getPersistentId() { + public JpaPid getPersistentId() { return new JpaPid(myResourcePid); } } 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 228c4641218..69bd26c0fa4 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 @@ -23,7 +23,6 @@ package ca.uhn.fhir.jpa.model.entity; 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; @@ -228,7 +227,7 @@ public class ResourceHistoryTable extends BaseHasResource implements Serializabl } @Override - public ResourcePersistentId getPersistentId() { + public JpaPid getPersistentId() { return new JpaPid(myResourceId); } 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 index 4cbdf64cf75..bc0a7488c2d 100644 --- 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 @@ -32,6 +32,7 @@ import java.util.Optional; * @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 { + public static final ResourcePersistentId NOT_FOUND = new ResourcePersistentId(-1L); private T myId; private Long myVersion; private String myResourceType; 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..71df25b9b28 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,7 +54,7 @@ import java.util.function.Supplier; */ public class TransactionDetails { - public static final ResourcePersistentId NOT_FOUND = new ResourcePersistentId(-1L); + public static final ResourcePersistentId NOT_FOUND = ResourcePersistentId.NOT_FOUND; private final Date myTransactionDate; private List myRollbackUndoActions = Collections.emptyList(); 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 3fc77f28591..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,6 +29,7 @@ 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; @@ -47,10 +48,12 @@ public class DeleteExpungeStep implements IJobStepWorker persistentIds = myData.getJpaPids(); + 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); 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 8293e68b7eb..5a6e65c6224 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 @@ -32,7 +32,6 @@ import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao; import ca.uhn.fhir.jpa.api.dao.IFhirSystemDao; 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.parser.DataFormatException; import ca.uhn.fhir.rest.api.server.RequestDetails; @@ -104,7 +103,7 @@ public class ReindexStep implements IJobStepWorker persistentIds = myData.getJpaPids(); + List persistentIds = myData.getResourcePersistentIds(myIdHelperService); ourLog.info("Starting reindex work chunk with {} resources - Instance[{}] Chunk[{}]", persistentIds.size(), myInstanceId, myChunkId); StopWatch sw = new StopWatch(); 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 68fc594ef8b..9cc88e11adb 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.model.dao.JpaPid; +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 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 getJpaPids() { + public List getResourcePersistentIds(IIdHelperService theIdHelperService) { if (myTypedPids.isEmpty()) { return Collections.emptyList(); } @@ -65,7 +66,7 @@ public class ResourceIdListWorkChunkJson implements IModelJson { return myTypedPids .stream() .map(t -> { - JpaPid retval = t.asJpaPid(); + T retval = theIdHelperService.newPidFromString(t.getPid()); retval.setResourceType(t.getResourceType()); return retval; }) diff --git a/hapi-fhir-storage-batch2/src/main/java/ca/uhn/fhir/batch2/jobs/chunk/TypedPidJson.java b/hapi-fhir-storage-batch2/src/main/java/ca/uhn/fhir/batch2/jobs/chunk/TypedPidJson.java index 55e78a5a758..e56c6340de7 100644 --- a/hapi-fhir-storage-batch2/src/main/java/ca/uhn/fhir/batch2/jobs/chunk/TypedPidJson.java +++ b/hapi-fhir-storage-batch2/src/main/java/ca/uhn/fhir/batch2/jobs/chunk/TypedPidJson.java @@ -21,7 +21,6 @@ package ca.uhn.fhir.batch2.jobs.chunk; */ import ca.uhn.fhir.jpa.api.pid.TypedResourcePid; -import ca.uhn.fhir.jpa.model.dao.JpaPid; import ca.uhn.fhir.model.api.IModelJson; import com.fasterxml.jackson.annotation.JsonProperty; import org.apache.commons.lang3.builder.EqualsBuilder; @@ -87,8 +86,4 @@ public class TypedPidJson implements IModelJson { public int hashCode() { return new HashCodeBuilder(17, 37).append(myResourceType).append(myPid).toHashCode(); } - - public JpaPid asJpaPid() { - return new JpaPid(Long.parseLong(myPid)); - } } 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 60a30768557..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 @@ -99,7 +99,7 @@ public class MdmClearStep implements IJobStepWorker persistentIds = myData.getJpaPids(); + 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 b9fff38f23b..ca03456fa12 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 @@ -29,6 +29,7 @@ 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; @@ -53,6 +54,7 @@ public class MdmInflateAndSubmitResourcesStep implements IJobStepWorker myIdHelperService; @Nonnull @Override @@ -61,10 +63,10 @@ public class MdmInflateAndSubmitResourcesStep implements IJobStepWorker allResources = fetchAllResources(idList.getJpaPids()); + List allResources = fetchAllResources(idList.getResourcePersistentIds(myIdHelperService)); //Replace the terminology if (myResponseTerminologyTranslationSvc != null) { 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 68903afb89c..f14fb5f1ca9 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 @@ -168,5 +168,7 @@ public interface IIdHelperService { */ Set translatePidsToFhirResourceIds(Set thePids); + T newPid(Object thePid); + T newPidFromString(String thePid); } 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 48aef065986..b7fc17c3597 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 @@ -65,14 +65,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 @@ -95,9 +95,9 @@ public class DaoResourceLinkResolver implements IResourceLinkResolver { RuntimeSearchParam searchParam = mySearchParamRegistry.getActiveSearchParam(theSourceResourceName, thePathAndRef.getSearchParamName()); - ResourcePersistentId persistentId = null; + T persistentId = null; if (theTransactionDetails != null) { - JpaPid resolvedResourceId = (JpaPid) theTransactionDetails.getResolvedResourceId(targetResourceId); + T resolvedResourceId = (T) theTransactionDetails.getResolvedResourceId(targetResourceId); if (resolvedResourceId != null && resolvedResourceId.getId() != null && resolvedResourceId.getAssociatedResourceId() != null) { persistentId = resolvedResourceId; } @@ -141,7 +141,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); @@ -307,10 +307,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; } @@ -325,7 +325,7 @@ public class DaoResourceLinkResolver implements IResourceLinkResolver { } @Override - public ResourcePersistentId getPersistentId() { + public P getPersistentId() { return myPersistentId; } } 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());