Make reference extractor more reusable (#4205)

* Refactor

* Make reference extractor more reusable

* Test fix

* Test fix

* Headers

* Small refactor
This commit is contained in:
James Agnew 2022-10-27 21:31:39 -04:00 committed by GitHub
parent d8dd42ced5
commit 7a39f8cbaf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
86 changed files with 168 additions and 163 deletions

View File

@ -4,7 +4,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId> <artifactId>hapi-fhir</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId> <artifactId>hapi-deployable-pom</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath> <relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent> </parent>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId> <artifactId>hapi-deployable-pom</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath> <relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent> </parent>

View File

@ -6,7 +6,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId> <artifactId>hapi-deployable-pom</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath> <relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent> </parent>

View File

@ -3,14 +3,14 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-bom</artifactId> <artifactId>hapi-fhir-bom</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>HAPI FHIR BOM</name> <name>HAPI FHIR BOM</name>
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId> <artifactId>hapi-deployable-pom</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath> <relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent> </parent>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId> <artifactId>hapi-fhir</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -4,7 +4,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId> <artifactId>hapi-deployable-pom</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../../hapi-deployable-pom/pom.xml</relativePath> <relativePath>../../hapi-deployable-pom/pom.xml</relativePath>
</parent> </parent>

View File

@ -6,7 +6,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-cli</artifactId> <artifactId>hapi-fhir-cli</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -6,7 +6,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId> <artifactId>hapi-deployable-pom</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../../hapi-deployable-pom</relativePath> <relativePath>../../hapi-deployable-pom</relativePath>
</parent> </parent>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId> <artifactId>hapi-fhir</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -4,7 +4,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId> <artifactId>hapi-deployable-pom</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath> <relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent> </parent>

View File

@ -4,7 +4,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId> <artifactId>hapi-deployable-pom</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath> <relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent> </parent>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId> <artifactId>hapi-deployable-pom</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath> <relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent> </parent>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId> <artifactId>hapi-fhir</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId> <artifactId>hapi-deployable-pom</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath> <relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent> </parent>

View File

@ -11,7 +11,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId> <artifactId>hapi-deployable-pom</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath> <relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent> </parent>

View File

@ -4,7 +4,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId> <artifactId>hapi-deployable-pom</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath> <relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent> </parent>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId> <artifactId>hapi-deployable-pom</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath> <relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId> <artifactId>hapi-deployable-pom</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath> <relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent> </parent>

View File

@ -397,7 +397,7 @@ public class JpaBulkExportProcessor implements IBulkExportProcessor {
// } // }
Map<String, String> sourceResourceIdToGoldenResourceIdMap = new HashMap<>(); Map<String, String> sourceResourceIdToGoldenResourceIdMap = new HashMap<>();
goldenResourceToSourcePidMap.forEach((key, value) -> { goldenResourceToSourcePidMap.forEach((key, value) -> {
String goldenResourceId = myIdHelperService.translatePidIdToForcedIdWithCache(new ResourcePersistentId(key)).orElse(key.toString()); String goldenResourceId = myIdHelperService.translatePidIdToForcedIdWithCache(key).orElse(key.toString());
PersistentIdToForcedIdMap pidsToForcedIds = myIdHelperService.translatePidsToForcedIds(value); PersistentIdToForcedIdMap pidsToForcedIds = myIdHelperService.translatePidsToForcedIds(value);
Set<String> sourceResourceIds = pidsToForcedIds.getResolvedResourceIds(); Set<String> sourceResourceIds = pidsToForcedIds.getResolvedResourceIds();

View File

@ -137,7 +137,6 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import javax.persistence.NoResultException; import javax.persistence.NoResultException;
import javax.persistence.Parameter;
import javax.persistence.TypedQuery; import javax.persistence.TypedQuery;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
@ -514,30 +513,6 @@ public abstract class BaseHapiFhirResourceDao<T extends IBaseResource> extends B
}); });
} }
/**
* Creates a base method outcome for a delete request for the provided ID.
* <p>
* Additional information may be set on the outcome.
*
* @param theId - the id of the object being deleted. Eg: Patient/123
*/
private DaoMethodOutcome createMethodOutcomeForDelete(String theId, String theKey) {
DaoMethodOutcome outcome = new DaoMethodOutcome();
IIdType id = getContext().getVersion().newIdType();
id.setValue(theId);
outcome.setId(id);
IBaseOperationOutcome oo = OperationOutcomeUtil.newInstance(getContext());
String message = getContext().getLocalizer().getMessage(BaseStorageDao.class, theKey, id);
String severity = "information";
String code = "informational";
OperationOutcomeUtil.addIssue(getContext(), oo, severity, message, null, code);
outcome.setOperationOutcome(oo);
return outcome;
}
@Override @Override
public DaoMethodOutcome delete(IIdType theId, public DaoMethodOutcome delete(IIdType theId,
DeleteConflictList theDeleteConflicts, DeleteConflictList theDeleteConflicts,
@ -554,7 +529,7 @@ public abstract class BaseHapiFhirResourceDao<T extends IBaseResource> extends B
// if not found, return an outcome anyways. // if not found, return an outcome anyways.
// Because no object actually existed, we'll // Because no object actually existed, we'll
// just set the id and nothing else // just set the id and nothing else
DaoMethodOutcome outcome = createMethodOutcomeForDelete(theId.getValue(), "deleteResourceNotExisting"); DaoMethodOutcome outcome = createMethodOutcomeForResourceId(theId.getValue(), MESSAGE_KEY_DELETE_RESOURCE_NOT_EXISTING);
return outcome; return outcome;
} }
@ -564,7 +539,7 @@ public abstract class BaseHapiFhirResourceDao<T extends IBaseResource> extends B
// Don't delete again if it's already deleted // Don't delete again if it's already deleted
if (isDeleted(entity)) { if (isDeleted(entity)) {
DaoMethodOutcome outcome = createMethodOutcomeForDelete(entity.getIdDt().getValue(), "deleteResourceAlreadyDeleted"); DaoMethodOutcome outcome = createMethodOutcomeForResourceId(entity.getIdDt().getValue(), MESSAGE_KEY_DELETE_RESOURCE_ALREADY_DELETED);
// used to exist, so we'll set the persistent id // used to exist, so we'll set the persistent id
outcome.setPersistentId(new ResourcePersistentId(entity.getResourceId())); outcome.setPersistentId(new ResourcePersistentId(entity.getResourceId()));

View File

@ -209,7 +209,7 @@ public class IdHelperService implements IIdHelperService {
// is a forced id // is a forced id
// we must resolve! // we must resolve!
if (myDaoConfig.isDeleteEnabled()) { if (myDaoConfig.isDeleteEnabled()) {
retVal = new ResourcePersistentId(resolveResourceIdentity(theRequestPartitionId, theResourceType, id, theExcludeDeleted).getResourceId()); retVal = resolveResourceIdentity(theRequestPartitionId, theResourceType, id, theExcludeDeleted).getPersistentId();
retVals.put(id, retVal); retVals.put(id, retVal);
} else { } else {
// fetch from cache... adding to cache if not available // fetch from cache... adding to cache if not available
@ -248,6 +248,7 @@ public class IdHelperService implements IIdHelperService {
* *
* @throws ResourceNotFoundException If the ID can not be found * @throws ResourceNotFoundException If the ID can not be found
*/ */
@Override
public ResourcePersistentId resolveResourcePersistentIds(@Nonnull RequestPartitionId theRequestPartitionId, String theResourceType, String theId, boolean theExcludeDeleted){ public ResourcePersistentId resolveResourcePersistentIds(@Nonnull RequestPartitionId theRequestPartitionId, String theResourceType, String theId, boolean theExcludeDeleted){
Validate.notNull(theId, "theId must not be null"); Validate.notNull(theId, "theId must not be null");
@ -578,13 +579,13 @@ public class IdHelperService implements IIdHelperService {
.stream() .stream()
.map(t -> new ResourceLookup((String) t[0], (Long) t[1], (Date) t[2])) .map(t -> new ResourceLookup((String) t[0], (Long) t[1], (Date) t[2]))
.forEach(t -> { .forEach(t -> {
String id = t.getResourceId().toString(); String id = t.getPersistentId().toString();
if (!theTargets.containsKey(id)) { if (!theTargets.containsKey(id)) {
theTargets.put(id, new ArrayList<>()); theTargets.put(id, new ArrayList<>());
} }
theTargets.get(id).add(t); theTargets.get(id).add(t);
if (!myDaoConfig.isDeleteEnabled()) { if (!myDaoConfig.isDeleteEnabled()) {
String nextKey = Long.toString(t.getResourceId()); String nextKey = t.getPersistentId().toString();
myMemoryCacheService.putAfterCommit(MemoryCacheService.CacheEnum.RESOURCE_LOOKUP, nextKey, t); myMemoryCacheService.putAfterCommit(MemoryCacheService.CacheEnum.RESOURCE_LOOKUP, nextKey, t);
} }
}); });

View File

@ -33,6 +33,7 @@ import ca.uhn.fhir.jpa.dao.BaseStorageDao;
import ca.uhn.fhir.jpa.dao.MatchResourceUrlService; import ca.uhn.fhir.jpa.dao.MatchResourceUrlService;
import ca.uhn.fhir.jpa.dao.data.IResourceIndexedComboStringUniqueDao; import ca.uhn.fhir.jpa.dao.data.IResourceIndexedComboStringUniqueDao;
import ca.uhn.fhir.jpa.model.config.PartitionSettings; import ca.uhn.fhir.jpa.model.config.PartitionSettings;
import ca.uhn.fhir.jpa.model.cross.IBasePersistedResource;
import ca.uhn.fhir.jpa.model.entity.BaseResourceIndexedSearchParam; import ca.uhn.fhir.jpa.model.entity.BaseResourceIndexedSearchParam;
import ca.uhn.fhir.jpa.model.entity.ResourceIndexedComboStringUnique; import ca.uhn.fhir.jpa.model.entity.ResourceIndexedComboStringUnique;
import ca.uhn.fhir.jpa.model.entity.ResourceIndexedComboTokenNonUnique; import ca.uhn.fhir.jpa.model.entity.ResourceIndexedComboTokenNonUnique;
@ -354,10 +355,10 @@ public class SearchParamWithInlineReferencesExtractor {
ResourcePersistentId match; ResourcePersistentId match;
if (matches.isEmpty()) { if (matches.isEmpty()) {
Optional<ResourceTable> placeholderOpt = myDaoResourceLinkResolver.createPlaceholderTargetIfConfiguredToDoSo(matchResourceType, nextRef, null, theRequest, theTransactionDetails); Optional<IBasePersistedResource> placeholderOpt = myDaoResourceLinkResolver.createPlaceholderTargetIfConfiguredToDoSo(matchResourceType, nextRef, null, theRequest, theTransactionDetails);
if (placeholderOpt.isPresent()) { if (placeholderOpt.isPresent()) {
match = new ResourcePersistentId(placeholderOpt.get().getResourceId()); match = placeholderOpt.get().getPersistentId();
match.setAssociatedResourceId(placeholderOpt.get().getIdType(myContext)); match.setAssociatedResourceId(placeholderOpt.get().getIdDt());
theTransactionDetails.addResolvedMatchUrl(nextIdText, match); theTransactionDetails.addResolvedMatchUrl(nextIdText, match);
myMemoryCacheService.putAfterCommit(MemoryCacheService.CacheEnum.MATCH_URL, nextIdText, match); myMemoryCacheService.putAfterCommit(MemoryCacheService.CacheEnum.MATCH_URL, nextIdText, match);
} else { } else {

View File

@ -2,7 +2,7 @@ package ca.uhn.fhir.jpa.util;
/*- /*-
* #%L * #%L
* HAPI FHIR Storage api * HAPI FHIR JPA Server
* %% * %%
* Copyright (C) 2014 - 2022 Smile CDR, Inc. * Copyright (C) 2014 - 2022 Smile CDR, Inc.
* %% * %%

View File

@ -7,7 +7,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId> <artifactId>hapi-deployable-pom</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath> <relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent> </parent>

View File

@ -6,7 +6,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId> <artifactId>hapi-deployable-pom</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath> <relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent> </parent>

View File

@ -6,7 +6,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId> <artifactId>hapi-deployable-pom</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath> <relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent> </parent>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId> <artifactId>hapi-deployable-pom</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath> <relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent> </parent>

View File

@ -21,19 +21,13 @@ package ca.uhn.fhir.jpa.model.cross;
*/ */
import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.instance.model.api.IIdType; import org.hl7.fhir.instance.model.api.IIdType;
import java.util.Date; import java.util.Date;
public interface IBasePersistedResource { public interface IBasePersistedResource extends IResourceLookup {
IIdType getIdDt(); IIdType getIdDt();
/**
* If the resource is deleted, returns the date/time that the resource was deleted at. Otherwise, returns <code>null</code>
*/
Date getDeleted();
ResourcePersistentId getPersistentId();
} }

View File

@ -20,12 +20,18 @@ package ca.uhn.fhir.jpa.model.cross;
* #L% * #L%
*/ */
import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId;
import java.util.Date; import java.util.Date;
public interface IResourceLookup { public interface IResourceLookup {
String getResourceType(); String getResourceType();
Long getResourceId(); /**
* If the resource is deleted, returns the date/time that the resource was deleted at. Otherwise, returns <code>null</code>
*/
Date getDeleted(); Date getDeleted();
ResourcePersistentId getPersistentId();
} }

View File

@ -20,6 +20,8 @@ package ca.uhn.fhir.jpa.model.cross;
* #L% * #L%
*/ */
import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId;
import java.util.Date; import java.util.Date;
public class ResourceLookup implements IResourceLookup { public class ResourceLookup implements IResourceLookup {
@ -38,13 +40,13 @@ public class ResourceLookup implements IResourceLookup {
return myResourceType; return myResourceType;
} }
@Override
public Long getResourceId() {
return myResourcePid;
}
@Override @Override
public Date getDeleted() { public Date getDeleted() {
return myDeletedAt; return myDeletedAt;
} }
@Override
public ResourcePersistentId getPersistentId() {
return new ResourcePersistentId(myResourcePid);
}
} }

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId> <artifactId>hapi-deployable-pom</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath> <relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent> </parent>

View File

@ -525,7 +525,7 @@ public class SearchParamExtractorService {
} }
String targetResourceType = targetResource.getResourceType(); String targetResourceType = targetResource.getResourceType();
Long targetResourcePid = targetResource.getResourceId(); Long targetResourcePid = targetResource.getPersistentId().getIdAsLong();
String targetResourceIdPart = theNextId.getIdPart(); String targetResourceIdPart = theNextId.getIdPart();
Long targetVersion = theNextId.getVersionIdPartAsLong(); Long targetVersion = theNextId.getVersionIdPartAsLong();
return ResourceLink.forLocalReference(nextPathAndRef.getPath(), theEntity, targetResourceType, targetResourcePid, targetResourceIdPart, theUpdateTime, targetVersion); return ResourceLink.forLocalReference(nextPathAndRef.getPath(), theEntity, targetResourceType, targetResourcePid, targetResourceIdPart, theUpdateTime, targetVersion);

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId> <artifactId>hapi-deployable-pom</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath> <relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent> </parent>

View File

@ -6,7 +6,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId> <artifactId>hapi-deployable-pom</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath> <relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent> </parent>

View File

@ -6,7 +6,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId> <artifactId>hapi-deployable-pom</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath> <relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent> </parent>

View File

@ -6,7 +6,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId> <artifactId>hapi-deployable-pom</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath> <relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent> </parent>

View File

@ -85,13 +85,13 @@ public class IdHelperServiceTest {
Object[] redView = new Object[] { Object[] redView = new Object[] {
"Patient", "Patient",
new Long(123l), 123l,
"RED", "RED",
new Date() new Date()
}; };
Object[] blueView = new Object[] { Object[] blueView = new Object[] {
"Patient", "Patient",
new Long(456l), 456l,
"BLUE", "BLUE",
new Date() new Date()
}; };
@ -124,8 +124,8 @@ public class IdHelperServiceTest {
patientIdsToResolve.add("RED"); patientIdsToResolve.add("RED");
patientIdsToResolve.add("BLUE"); patientIdsToResolve.add("BLUE");
ResourcePersistentId red = new ResourcePersistentId("Patient", new Long(123l)); ResourcePersistentId red = new ResourcePersistentId("Patient", 123l);
ResourcePersistentId blue = new ResourcePersistentId("Patient", new Long(456l)); ResourcePersistentId blue = new ResourcePersistentId("Patient", 456l);
// we will pretend the lookup value is in the cache // we will pretend the lookup value is in the cache
when(myMemoryCacheService.getThenPutAfterCommit(any(MemoryCacheService.CacheEnum.class), when(myMemoryCacheService.getThenPutAfterCommit(any(MemoryCacheService.CacheEnum.class),
@ -167,7 +167,7 @@ public class IdHelperServiceTest {
IResourceLookup result = myHelperService.resolveResourceIdentity(partitionId, resourceType, resourceForcedId); IResourceLookup result = myHelperService.resolveResourceIdentity(partitionId, resourceType, resourceForcedId);
assertEquals(forcedIdView[0], result.getResourceType()); assertEquals(forcedIdView[0], result.getResourceType());
assertEquals(forcedIdView[1], result.getResourceId()); assertEquals(forcedIdView[1], result.getPersistentId().getId());
assertEquals(forcedIdView[3], result.getDeleted()); assertEquals(forcedIdView[3], result.getDeleted());
} }

View File

@ -6,7 +6,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId> <artifactId>hapi-deployable-pom</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath> <relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent> </parent>

View File

@ -6,7 +6,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId> <artifactId>hapi-deployable-pom</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath> <relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent> </parent>

View File

@ -6,7 +6,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId> <artifactId>hapi-deployable-pom</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath> <relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent> </parent>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId> <artifactId>hapi-fhir</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -7,7 +7,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId> <artifactId>hapi-deployable-pom</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath> <relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent> </parent>

View File

@ -21,7 +21,7 @@ package ca.uhn.fhir.mdm.rules.matcher;
*/ */
import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.mdm.util.CanonicalIdentifier; import ca.uhn.fhir.util.CanonicalIdentifier;
import ca.uhn.fhir.mdm.util.IdentifierUtil; import ca.uhn.fhir.mdm.util.IdentifierUtil;
import ca.uhn.fhir.model.primitive.StringDt; import ca.uhn.fhir.model.primitive.StringDt;
import org.hl7.fhir.instance.model.api.IBase; import org.hl7.fhir.instance.model.api.IBase;

View File

@ -24,6 +24,7 @@ import ca.uhn.fhir.i18n.Msg;
import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.mdm.model.CanonicalEID; import ca.uhn.fhir.mdm.model.CanonicalEID;
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
import ca.uhn.fhir.util.CanonicalIdentifier;
import org.hl7.fhir.instance.model.api.IBase; import org.hl7.fhir.instance.model.api.IBase;
public final class IdentifierUtil { public final class IdentifierUtil {

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId> <artifactId>hapi-deployable-pom</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath> <relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent> </parent>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId> <artifactId>hapi-deployable-pom</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath> <relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent> </parent>

View File

@ -50,6 +50,7 @@ public class ResourcePersistentId {
*/ */
public ResourcePersistentId(Object theId, Long theVersion) { public ResourcePersistentId(Object theId, Long theVersion) {
assert !(theId instanceof Optional); assert !(theId instanceof Optional);
assert !(theId instanceof ResourcePersistentId);
myId = theId; myId = theId;
myVersion = theVersion; myVersion = theVersion;
} }

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId> <artifactId>hapi-deployable-pom</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../../hapi-deployable-pom/pom.xml</relativePath> <relativePath>../../hapi-deployable-pom/pom.xml</relativePath>
</parent> </parent>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-spring-boot-samples</artifactId> <artifactId>hapi-fhir-spring-boot-samples</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
</parent> </parent>
<artifactId>hapi-fhir-spring-boot-sample-client-apache</artifactId> <artifactId>hapi-fhir-spring-boot-sample-client-apache</artifactId>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-spring-boot-samples</artifactId> <artifactId>hapi-fhir-spring-boot-samples</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
</parent> </parent>
<artifactId>hapi-fhir-spring-boot-sample-client-okhttp</artifactId> <artifactId>hapi-fhir-spring-boot-sample-client-okhttp</artifactId>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-spring-boot-samples</artifactId> <artifactId>hapi-fhir-spring-boot-samples</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
</parent> </parent>
<artifactId>hapi-fhir-spring-boot-sample-server-jersey</artifactId> <artifactId>hapi-fhir-spring-boot-sample-server-jersey</artifactId>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-spring-boot</artifactId> <artifactId>hapi-fhir-spring-boot</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
</parent> </parent>
<artifactId>hapi-fhir-spring-boot-samples</artifactId> <artifactId>hapi-fhir-spring-boot-samples</artifactId>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId> <artifactId>hapi-deployable-pom</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../../hapi-deployable-pom/pom.xml</relativePath> <relativePath>../../hapi-deployable-pom/pom.xml</relativePath>
</parent> </parent>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId> <artifactId>hapi-fhir</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId> <artifactId>hapi-deployable-pom</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath> <relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent> </parent>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId> <artifactId>hapi-deployable-pom</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath> <relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@ -6,7 +6,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId> <artifactId>hapi-deployable-pom</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath> <relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent> </parent>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId> <artifactId>hapi-deployable-pom</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath> <relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId> <artifactId>hapi-deployable-pom</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath> <relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId> <artifactId>hapi-deployable-pom</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath> <relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent> </parent>

View File

@ -90,6 +90,9 @@ public abstract class BaseStorageDao {
public static final String OO_SEVERITY_WARN = "warning"; public static final String OO_SEVERITY_WARN = "warning";
private static final String PROCESSING_SUB_REQUEST = "BaseStorageDao.processingSubRequest"; private static final String PROCESSING_SUB_REQUEST = "BaseStorageDao.processingSubRequest";
protected static final String MESSAGE_KEY_DELETE_RESOURCE_NOT_EXISTING = "deleteResourceNotExisting";
protected static final String MESSAGE_KEY_DELETE_RESOURCE_ALREADY_DELETED = "deleteResourceAlreadyDeleted";
@Autowired @Autowired
protected ISearchParamRegistry mySearchParamRegistry; protected ISearchParamRegistry mySearchParamRegistry;
@Autowired @Autowired
@ -367,6 +370,30 @@ public abstract class BaseStorageDao {
return oo; return oo;
} }
/**
* Creates a base method outcome for a delete request for the provided ID.
* <p>
* Additional information may be set on the outcome.
*
* @param theResourceId - the id of the object being deleted. Eg: Patient/123
*/
protected DaoMethodOutcome createMethodOutcomeForResourceId(String theResourceId, String theMessageKey) {
DaoMethodOutcome outcome = new DaoMethodOutcome();
IIdType id = getContext().getVersion().newIdType();
id.setValue(theResourceId);
outcome.setId(id);
IBaseOperationOutcome oo = OperationOutcomeUtil.newInstance(getContext());
String message = getContext().getLocalizer().getMessage(BaseStorageDao.class, theMessageKey, id);
String severity = "information";
String code = "informational";
OperationOutcomeUtil.addIssue(getContext(), oo, severity, message, null, code);
outcome.setOperationOutcome(oo);
return outcome;
}
@Nonnull @Nonnull
protected ResourceGoneException createResourceGoneException(IBasePersistedResource theResourceEntity) { protected ResourceGoneException createResourceGoneException(IBasePersistedResource theResourceEntity) {
StringBuilder b = new StringBuilder(); StringBuilder b = new StringBuilder();

View File

@ -2,7 +2,7 @@ package ca.uhn.fhir.jpa.dao.index;
/*- /*-
* #%L * #%L
* HAPI FHIR JPA Server * HAPI FHIR Storage api
* %% * %%
* Copyright (C) 2014 - 2022 Smile CDR, Inc. * Copyright (C) 2014 - 2022 Smile CDR, Inc.
* %% * %%
@ -32,10 +32,10 @@ import ca.uhn.fhir.jpa.api.config.DaoConfig;
import ca.uhn.fhir.jpa.api.dao.DaoRegistry; import ca.uhn.fhir.jpa.api.dao.DaoRegistry;
import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao; import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao;
import ca.uhn.fhir.jpa.api.svc.IIdHelperService; import ca.uhn.fhir.jpa.api.svc.IIdHelperService;
import ca.uhn.fhir.jpa.model.cross.IBasePersistedResource;
import ca.uhn.fhir.jpa.model.cross.IResourceLookup; import ca.uhn.fhir.jpa.model.cross.IResourceLookup;
import ca.uhn.fhir.jpa.model.entity.ResourceTable;
import ca.uhn.fhir.jpa.searchparam.extractor.IResourceLinkResolver; import ca.uhn.fhir.jpa.searchparam.extractor.IResourceLinkResolver;
import ca.uhn.fhir.mdm.util.CanonicalIdentifier; import ca.uhn.fhir.util.CanonicalIdentifier;
import ca.uhn.fhir.rest.api.server.RequestDetails; 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.ResourcePersistentId;
import ca.uhn.fhir.rest.api.server.storage.TransactionDetails; import ca.uhn.fhir.rest.api.server.storage.TransactionDetails;
@ -57,9 +57,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.PersistenceContextType;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -67,8 +64,6 @@ 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); private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(DaoResourceLinkResolver.class);
@PersistenceContext(type = PersistenceContextType.TRANSACTION)
protected EntityManager myEntityManager;
@Autowired @Autowired
private DaoConfig myDaoConfig; private DaoConfig myDaoConfig;
@Autowired @Autowired
@ -99,7 +94,7 @@ public class DaoResourceLinkResolver implements IResourceLinkResolver {
} }
} catch (ResourceNotFoundException e) { } catch (ResourceNotFoundException e) {
Optional<ResourceTable> createdTableOpt = createPlaceholderTargetIfConfiguredToDoSo(theType, theReference, idPart, theRequest, theTransactionDetails); Optional<IBasePersistedResource> createdTableOpt = createPlaceholderTargetIfConfiguredToDoSo(theType, theReference, idPart, theRequest, theTransactionDetails);
if (!createdTableOpt.isPresent()) { if (!createdTableOpt.isPresent()) {
if (myDaoConfig.isEnforceReferentialIntegrityOnWrite() == false) { if (myDaoConfig.isEnforceReferentialIntegrityOnWrite() == false) {
@ -114,9 +109,9 @@ public class DaoResourceLinkResolver implements IResourceLinkResolver {
resolvedResource = createdTableOpt.get(); resolvedResource = createdTableOpt.get();
} }
ourLog.trace("Resolved resource of type {} as PID: {}", resolvedResource.getResourceType(), resolvedResource.getResourceId()); ourLog.trace("Resolved resource of type {} as PID: {}", resolvedResource.getResourceType(), resolvedResource.getPersistentId());
if (!theResourceType.equals(resolvedResource.getResourceType())) { if (!theResourceType.equals(resolvedResource.getResourceType())) {
ourLog.error("Resource with PID {} was of type {} and wanted {}", resolvedResource.getResourceId(), theResourceType, resolvedResource.getResourceType()); ourLog.error("Resource with PID {} was of type {} and wanted {}", resolvedResource.getPersistentId(), theResourceType, resolvedResource.getResourceType());
throw new UnprocessableEntityException(Msg.code(1095) + "Resource contains reference to unknown resource ID " + theSourceResourceId.getValue()); throw new UnprocessableEntityException(Msg.code(1095) + "Resource contains reference to unknown resource ID " + theSourceResourceId.getValue());
} }
@ -126,9 +121,11 @@ public class DaoResourceLinkResolver implements IResourceLinkResolver {
} }
if (persistentId == null) { if (persistentId == null) {
persistentId = new ResourcePersistentId(resolvedResource.getResourceId()); persistentId = new ResourcePersistentId(resolvedResource.getPersistentId().getId());
persistentId.setAssociatedResourceId(theSourceResourceId); persistentId.setAssociatedResourceId(theSourceResourceId);
theTransactionDetails.addResolvedResourceId(theSourceResourceId, persistentId); if (theTransactionDetails != null) {
theTransactionDetails.addResolvedResourceId(theSourceResourceId, persistentId);
}
} }
if (!theSearchParam.hasTargets() && theSearchParam.getTargets().contains(theResourceType)) { if (!theSearchParam.hasTargets() && theSearchParam.getTargets().contains(theResourceType)) {
@ -141,8 +138,8 @@ public class DaoResourceLinkResolver implements IResourceLinkResolver {
/** /**
* @param theIdToAssignToPlaceholder If specified, the placeholder resource created will be given a specific ID * @param theIdToAssignToPlaceholder If specified, the placeholder resource created will be given a specific ID
*/ */
public <T extends IBaseResource> Optional<ResourceTable> createPlaceholderTargetIfConfiguredToDoSo(Class<T> theType, IBaseReference theReference, @Nullable String theIdToAssignToPlaceholder, RequestDetails theRequest, TransactionDetails theTransactionDetails) { public <T extends IBaseResource> Optional<IBasePersistedResource> createPlaceholderTargetIfConfiguredToDoSo(Class<T> theType, IBaseReference theReference, @Nullable String theIdToAssignToPlaceholder, RequestDetails theRequest, TransactionDetails theTransactionDetails) {
ResourceTable valueOf = null; IBasePersistedResource valueOf = null;
if (myDaoConfig.isAutoCreatePlaceholderReferenceTargets()) { if (myDaoConfig.isAutoCreatePlaceholderReferenceTargets()) {
RuntimeResourceDefinition missingResourceDef = myContext.getResourceDefinition(theType); RuntimeResourceDefinition missingResourceDef = myContext.getResourceDefinition(theType);
@ -162,13 +159,13 @@ public class DaoResourceLinkResolver implements IResourceLinkResolver {
if (theIdToAssignToPlaceholder != null) { if (theIdToAssignToPlaceholder != null) {
newResource.setId(resName + "/" + theIdToAssignToPlaceholder); newResource.setId(resName + "/" + theIdToAssignToPlaceholder);
valueOf = ((ResourceTable) placeholderResourceDao.update(newResource, theRequest).getEntity()); valueOf = placeholderResourceDao.update(newResource, theRequest).getEntity();
} else { } else {
valueOf = ((ResourceTable) placeholderResourceDao.create(newResource, theRequest).getEntity()); valueOf = placeholderResourceDao.create(newResource, theRequest).getEntity();
} }
ResourcePersistentId persistentId = new ResourcePersistentId(valueOf.getResourceId(), 1L); ResourcePersistentId persistentId = new ResourcePersistentId(valueOf.getPersistentId().getId(), 1L);
persistentId.setAssociatedResourceId(valueOf.getIdType(myContext)); persistentId.setAssociatedResourceId(valueOf.getIdDt());
theTransactionDetails.addResolvedResourceId(persistentId.getAssociatedResourceId(), persistentId); theTransactionDetails.addResolvedResourceId(persistentId.getAssociatedResourceId(), persistentId);
} }
@ -301,14 +298,14 @@ public class DaoResourceLinkResolver implements IResourceLinkResolver {
return myPersistentId.getAssociatedResourceId().getResourceType(); return myPersistentId.getAssociatedResourceId().getResourceType();
} }
@Override
public Long getResourceId() {
return myPersistentId.getIdAsLong();
}
@Override @Override
public Date getDeleted() { public Date getDeleted() {
return null; return null;
} }
@Override
public ResourcePersistentId getPersistentId() {
return myPersistentId;
}
} }
} }

View File

@ -1,8 +1,8 @@
package ca.uhn.fhir.mdm.util; package ca.uhn.fhir.util;
/*- /*-
* #%L * #%L
* HAPI FHIR - Master Data Management * HAPI FHIR Storage api
* %% * %%
* Copyright (C) 2014 - 2022 Smile CDR, Inc. * Copyright (C) 2014 - 2022 Smile CDR, Inc.
* %% * %%

View File

@ -1,6 +1,6 @@
package ca.uhn.fhir.jpa.dao.index; package ca.uhn.fhir.jpa.dao.index;
import ca.uhn.fhir.mdm.util.CanonicalIdentifier; import ca.uhn.fhir.util.CanonicalIdentifier;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.*;

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId> <artifactId>hapi-deployable-pom</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath> <relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent> </parent>

View File

@ -4,7 +4,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId> <artifactId>hapi-deployable-pom</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath> <relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent> </parent>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId> <artifactId>hapi-deployable-pom</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath> <relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent> </parent>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId> <artifactId>hapi-deployable-pom</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath> <relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent> </parent>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId> <artifactId>hapi-deployable-pom</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath> <relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent> </parent>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId> <artifactId>hapi-deployable-pom</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath> <relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent> </parent>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId> <artifactId>hapi-deployable-pom</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath> <relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent> </parent>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId> <artifactId>hapi-deployable-pom</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath> <relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent> </parent>

View File

@ -4,7 +4,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId> <artifactId>hapi-fhir</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -4,7 +4,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId> <artifactId>hapi-deployable-pom</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath> <relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent> </parent>

View File

@ -4,7 +4,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId> <artifactId>hapi-deployable-pom</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath> <relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent> </parent>

View File

@ -4,7 +4,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId> <artifactId>hapi-deployable-pom</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath> <relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent> </parent>

View File

@ -4,7 +4,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId> <artifactId>hapi-deployable-pom</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath> <relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent> </parent>

View File

@ -4,7 +4,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId> <artifactId>hapi-deployable-pom</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath> <relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent> </parent>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId> <artifactId>hapi-deployable-pom</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath> <relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent> </parent>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId> <artifactId>hapi-fhir</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
@ -65,42 +65,42 @@
<dependency> <dependency>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-dstu3</artifactId> <artifactId>hapi-fhir-structures-dstu3</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-hl7org-dstu2</artifactId> <artifactId>hapi-fhir-structures-hl7org-dstu2</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-r4</artifactId> <artifactId>hapi-fhir-structures-r4</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-r4b</artifactId> <artifactId>hapi-fhir-structures-r4b</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-structures-r5</artifactId> <artifactId>hapi-fhir-structures-r5</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-validation-resources-dstu2</artifactId> <artifactId>hapi-fhir-validation-resources-dstu2</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-validation-resources-dstu3</artifactId> <artifactId>hapi-fhir-validation-resources-dstu3</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-validation-resources-r4</artifactId> <artifactId>hapi-fhir-validation-resources-r4</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>

View File

@ -4,7 +4,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId> <artifactId>hapi-fhir</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -6,7 +6,7 @@
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId> <artifactId>hapi-fhir</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<name>HAPI-FHIR</name> <name>HAPI-FHIR</name>
<description>An open-source implementation of the FHIR specification in Java.</description> <description>An open-source implementation of the FHIR specification in Java.</description>
<url>https://hapifhir.io</url> <url>https://hapifhir.io</url>
@ -1998,7 +1998,7 @@
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-checkstyle</artifactId> <artifactId>hapi-fhir-checkstyle</artifactId>
<!-- Remember to bump this when you upgrade the version --> <!-- Remember to bump this when you upgrade the version -->
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
</dependency> </dependency>
</dependencies> </dependencies>
</plugin> </plugin>

View File

@ -6,7 +6,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId> <artifactId>hapi-fhir</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>

View File

@ -4,7 +4,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId> <artifactId>hapi-fhir</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId> <artifactId>hapi-fhir</artifactId>
<version>6.2.0-PRE17-SNAPSHOT</version> <version>6.2.0-PRE18-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath> <relativePath>../../pom.xml</relativePath>
</parent> </parent>