From daa3bc773eb7ee96dcff8f3370727f6677992d49 Mon Sep 17 00:00:00 2001 From: Tadgh Date: Tue, 10 Aug 2021 16:46:03 -0400 Subject: [PATCH] remove dummy test --- .../fhir/jpa/dao/BaseHapiFhirResourceDao.java | 4 +- .../jpa/dao/BaseTransactionProcessor.java | 4 +- .../fhir/jpa/dao/TransactionProcessor.java | 13 +- ...rchParamWithInlineReferencesExtractor.java | 1 - .../ca/uhn/fhir/jpa/dao/r4/FhirDummyTest.java | 206 ------------------ .../extractor/BaseSearchParamExtractor.java | 2 +- 6 files changed, 8 insertions(+), 222 deletions(-) delete mode 100644 hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirDummyTest.java 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 2c4c9497d5e..1efdf533534 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 @@ -278,7 +278,7 @@ public abstract class BaseHapiFhirResourceDao extends B }; Supplier idSupplier = () -> { - myTxTemplate.execute(tx -> { + 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()); @@ -1626,8 +1626,6 @@ public abstract class BaseHapiFhirResourceDao extends B entity = myEntityManager.find(ResourceTable.class, pid.getId()); resourceId = entity.getIdDt(); } else { - //FIXME JUAN: This is where the actual resource is replaced with a contained version in the create test. The update test correctly - //keeps this as a URN:UUID reference for now. DaoMethodOutcome outcome = create(resource, null, thePerformIndexing, theTransactionDetails, theRequest); // Pre-cache the match URL diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseTransactionProcessor.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseTransactionProcessor.java index 905b10e0280..dd1c80c7b71 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseTransactionProcessor.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseTransactionProcessor.java @@ -791,7 +791,6 @@ public abstract class BaseTransactionProcessor { String matchUrl = myVersionAdapter.getEntryRequestIfNoneExist(nextReqEntry); matchUrl = performIdSubstitutionsInMatchUrl(theIdSubstitutions, matchUrl); outcome = resourceDao.create(res, matchUrl, false, theTransactionDetails, theRequest); - // IS THIS THE MAGIC SAUCE? res.setId(outcome.getId()); if (nextResourceId != null) { handleTransactionCreateOrUpdateOutcome(theIdSubstitutions, theIdToPersistedOutcome, nextResourceId, outcome, nextRespEntry, resourceType, res, theRequest); @@ -1013,7 +1012,7 @@ public abstract class BaseTransactionProcessor { for (IIdType next : theAllIds) { IIdType replacement = theIdSubstitutions.get(next); - if (replacement != null && replacement.equals(next)) { + if (replacement != null && !replacement.equals(next)) { ourLog.debug("Placeholder resource ID \"{}\" was replaced with permanent ID \"{}\"", next, replacement); } } @@ -1123,7 +1122,6 @@ public abstract class BaseTransactionProcessor { IIdType targetId = resourceReference.getResource().getIdElement(); if (targetId.getValue() == null || targetId.getValue().startsWith("#")) { // This means it's a contained resource - ourLog.error("THIS THING ISN'T CONTAINED! WHY IS IT CONTAINED!!! "); continue; } else if (theIdSubstitutions.containsValue(targetId)) { newId = targetId; 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 95a9f9d78b8..fa232f2bdc9 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 @@ -41,7 +41,6 @@ import ca.uhn.fhir.rest.param.TokenParam; import ca.uhn.fhir.util.StopWatch; import com.google.common.annotations.VisibleForTesting; import org.apache.commons.lang3.Validate; -import org.apache.jena.ext.com.google.common.base.Optional; import org.hibernate.internal.SessionImpl; import org.hl7.fhir.instance.model.api.IBase; import org.hl7.fhir.instance.model.api.IBaseBundle; @@ -68,6 +67,7 @@ import java.util.HashSet; import java.util.IdentityHashMap; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.Set; import java.util.regex.Pattern; import java.util.stream.Collectors; @@ -223,7 +223,6 @@ public class TransactionProcessor extends BaseTransactionProcessor { if (param instanceof TokenParam) { Predicate hashPredicate = buildHashPredicateFromTokenParam((TokenParam)param, requestPartitionId, cb, from, next); - //Some partition witchcraft if (hashPredicate != null) { if (myPartitionSettings.isPartitioningEnabled() && !myPartitionSettings.isIncludePartitionInSearchHashes()) { if (requestPartitionId.isDefaultPartition()) { @@ -251,13 +250,11 @@ public class TransactionProcessor extends BaseTransactionProcessor { List results = query.getResultList(); for (ResourceIndexedSearchParamToken nextResult : results) { - Optional matchedSearch = Optional - .fromNullable(hashToSearchMap.get(nextResult.getHashSystemAndValue())) - .or(Optional.fromNullable(hashToSearchMap.get(nextResult.getHashValue()))); - - if (matchedSearch.isPresent()) { - setSearchToResolvedAndPrefetchFoundResourcePid(theTransactionDetails, idsToPreFetch, nextResult, matchedSearch.get()); + Optional matchedSearch = Optional.ofNullable(hashToSearchMap.get(nextResult.getHashSystemAndValue())); + if (!matchedSearch.isPresent()) { + matchedSearch = Optional.ofNullable(hashToSearchMap.get(nextResult.getHashValue())); } + matchedSearch.ifPresent(matchUrlToResolve -> setSearchToResolvedAndPrefetchFoundResourcePid(theTransactionDetails, idsToPreFetch, nextResult, matchUrlToResolve)); } //For each SP Map which did not return a result, tag it as not found. searchParameterMapsToResolve.stream() 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 6feb25c47e2..d057fb4c7cf 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 @@ -129,7 +129,6 @@ public class SearchParamWithInlineReferencesExtractor { partitionId = RequestPartitionId.allPartitions(); } - //THIS IS THE NEW SPOT mySearchParamExtractorService.extractFromResource(partitionId, theRequest, theParams, theEntity, theResource, theTransactionDetails, theFailOnInvalidReference); Set> activeSearchParams = mySearchParamRegistry.getActiveSearchParams(theEntity.getResourceType()).entrySet(); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirDummyTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirDummyTest.java deleted file mode 100644 index 34424d84b12..00000000000 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirDummyTest.java +++ /dev/null @@ -1,206 +0,0 @@ -package ca.uhn.fhir.jpa.dao.r4; - -import ca.uhn.fhir.jpa.api.config.DaoConfig; -import ca.uhn.fhir.jpa.api.model.DaoMethodOutcome; -import ca.uhn.fhir.jpa.model.entity.NormalizedQuantitySearchLevel; -import ca.uhn.fhir.jpa.partition.SystemRequestDetails; -import org.hl7.fhir.r4.model.Bundle; -import org.hl7.fhir.r4.model.IdType; -import org.hl7.fhir.r4.model.Patient; -import org.hl7.fhir.r4.model.Task; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.startsWith; - -@SuppressWarnings({"unchecked", "deprecation", "Duplicates"}) -public class FhirDummyTest extends BaseJpaR4Test { - - private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirDummyTest.class); - - @AfterEach - public final void after() { - myDaoConfig.setAllowExternalReferences(new DaoConfig().isAllowExternalReferences()); - myDaoConfig.setTreatReferencesAsLogical(new DaoConfig().getTreatReferencesAsLogical()); - myDaoConfig.setEnforceReferentialIntegrityOnDelete(new DaoConfig().isEnforceReferentialIntegrityOnDelete()); - myDaoConfig.setEnforceReferenceTargetTypes(new DaoConfig().isEnforceReferenceTargetTypes()); - myDaoConfig.setIndexMissingFields(new DaoConfig().getIndexMissingFields()); - myDaoConfig.setInternalSynchronousSearchSize(new DaoConfig().getInternalSynchronousSearchSize()); - myModelConfig.setNormalizedQuantitySearchLevel(NormalizedQuantitySearchLevel.NORMALIZED_QUANTITY_SEARCH_NOT_SUPPORTED); - myDaoConfig.setHistoryCountMode(DaoConfig.DEFAULT_HISTORY_COUNT_MODE); - } - - @BeforeEach - public void before() { - myInterceptorRegistry.registerInterceptor(myInterceptor); - } - - - @BeforeEach - public void beforeDisableResultReuse() { - myDaoConfig.setReuseCachedSearchResultsForMillis(null); - } - - @Test - public void testConditionalCreateDoesntMakeContainedResource() { - String patientString = "{\n" + - "\"resourceType\": \"Patient\",\n" + - "\"identifier\": [\n" + - "{\n" + - "\"system\": \"https://example.org/fhir/memberidentifier\",\n" + - "\"value\": \"12345670\"\n" + - "},\n" + - "{\n" + - "\"system\": \"https://example.org/fhir/memberuniqueidentifier\",\n" + - "\"value\": \"12345670TT\"\n" + - "}\n" + - "]\n" + - "}"; - - Patient patient = myFhirCtx.newJsonParser().parseResource(Patient.class, patientString); - DaoMethodOutcome daoMethodOutcome = myPatientDao.create(patient); - String patientId = daoMethodOutcome.getResource().getIdElement().toVersionless().toString(); - - String bundleString = "{\n" + - " \"resourceType\": \"Bundle\",\n" + - " \"type\": \"transaction\",\n" + - " \"entry\": [\n" + - " {\n" + - " \"fullUrl\": \"urn:uuid:1f3b9e25-fd45-4342-a82b-7ca5755923bb\",\n" + - " \"resource\": {\n" + - " \"resourceType\": \"Task\",\n" + - " \"language\": \"en-US\",\n" + - " \"identifier\": [\n" + - " {\n" + - " \"system\": \"https://example.org/fhir/taskidentifier\",\n" + - " \"value\": \"101019\"\n" + - " }\n" + - " ],\n" + - " \"basedOn\": [\n" + - " {\n" + - " \"reference\": \"urn:uuid:47c6d106-3441-41c0-8a2c-054ad9897ced\"\n" + - " }\n" + - " ]\n" + - " },\n" + - " \"request\": {\n" + - " \"method\": \"PUT\",\n" + - " \"url\": \"/Task?identifier\\u003dhttps%3A%2F%2Fexample.org%2Ffhir%2Ftaskidentifier|101019\"\n" + - " }\n" + - " },\n" + - " {\n" + - " \"fullUrl\": \"urn:uuid:47c6d106-3441-41c0-8a2c-054ad9897ced\",\n" + - " \"resource\": {\n" + - " \"resourceType\": \"Patient\",\n" + - " \"identifier\": [\n" + - " {\n" + - " \"system\": \"https://example.org/fhir/memberidentifier\",\n" + - " \"value\": \"12345670\"\n" + - " },\n" + - " {\n" + - " \"system\": \"https://example.org/fhir/memberuniqueidentifier\",\n" + - " \"value\": \"12345670TT\"\n" + - " }\n" + - " ]\n" + - " },\n" + - " \"request\": {\n" + - " \"method\": \"POST\",\n" + - " \"url\": \"Patient\",\n" + - " \"ifNoneExist\": \"identifier\\u003dhttps%3A%2F%2Fexample.org%2Ffhir%2Fmemberuniqueidentifier|12345670TT\"\n" + - " }\n" + - " }\n" + - " ]\n" + - "}"; - Bundle bundle = myFhirCtx.newJsonParser().parseResource(Bundle.class, bundleString); - Bundle transaction2 = mySystemDao.transaction(new SystemRequestDetails(), bundle); - String taskId2 = transaction2.getEntry().stream() - .filter(entry -> entry.getResponse().getLocation().contains("Task")) - .map(entry -> entry.getResponse().getLocation()) - .findFirst().orElse(null); - - Task read2 = myTaskDao.read(new IdType(taskId2)); - assertThat(read2.getBasedOn().get(0).getReference(), is(equalTo(patientId))); - } - @Test - public void testConditionalUpdateDoesntMakeContainedResource() { - String patientString = "{\n" + - "\"resourceType\": \"Patient\",\n" + - "\"identifier\": [\n" + - "{\n" + - "\"system\": \"https://example.org/fhir/memberidentifier\",\n" + - "\"value\": \"12345670\"\n" + - "},\n" + - "{\n" + - "\"system\": \"https://example.org/fhir/memberuniqueidentifier\",\n" + - "\"value\": \"12345670TT\"\n" + - "}\n" + - "]\n" + - "}"; - - Patient patient = myFhirCtx.newJsonParser().parseResource(Patient.class, patientString); - DaoMethodOutcome daoMethodOutcome = myPatientDao.create(patient); - String patientId = daoMethodOutcome.getResource().getIdElement().toVersionless().toString(); - - String bundleString = "{\n" + - " \"resourceType\": \"Bundle\",\n" + - " \"type\": \"transaction\",\n" + - " \"entry\": [\n" + - " {\n" + -// " \"fullUrl\": \"urn:uuid:1f3b9e25-fd45-4342-a82b-7ca5755923bb\",\n" + - " \"resource\": {\n" + - " \"id\": \"abc123\",\n" + - " \"resourceType\": \"Task\",\n" + - " \"language\": \"en-US\",\n" + - " \"identifier\": [\n" + - " {\n" + - " \"system\": \"https://example.org/fhir/taskidentifier\",\n" + - " \"value\": \"101019\"\n" + - " }\n" + - " ],\n" + - " \"basedOn\": [\n" + - " {\n" + - " \"reference\": \"urn:uuid:47c6d106-3441-41c0-8a2c-054ad9897ced\"\n" + - " }\n" + - " ]\n" + - " },\n" + - " \"request\": {\n" + - " \"method\": \"PUT\",\n" + - " \"url\": \"/Task?identifier\\u003dhttps%3A%2F%2Fexample.org%2Ffhir%2Ftaskidentifier|101019\"\n" + - " }\n" + - " },\n" + - " {\n" + - " \"fullUrl\": \"urn:uuid:47c6d106-3441-41c0-8a2c-054ad9897ced\",\n" + - " \"resource\": {\n" + - " \"resourceType\": \"Patient\",\n" + - " \"identifier\": [\n" + - " {\n" + - " \"system\": \"https://example.org/fhir/memberidentifier\",\n" + - " \"value\": \"12345670\"\n" + - " },\n" + - " {\n" + - " \"system\": \"https://example.org/fhir/memberuniqueidentifier\",\n" + - " \"value\": \"12345670TT\"\n" + - " }\n" + - " ]\n" + - " },\n" + - " \"request\": {\n" + - " \"method\": \"PUT\",\n" + - " \"url\": \"/Patient?identifier\\u003dhttps%3A%2F%2Fexample.org%2Ffhir%2Fmemberuniqueidentifier|12345670TT\"\n" + - " }\n" + - " }\n" + - " ]\n" + - "}"; - Bundle bundle = myFhirCtx.newJsonParser().parseResource(Bundle.class, bundleString); - Bundle transaction2 = mySystemDao.transaction(new SystemRequestDetails(), bundle); - String taskId2 = transaction2.getEntry().stream() - .filter(entry -> entry.getResponse().getLocation().contains("Task")) - .map(entry -> entry.getResponse().getLocation()) - .findFirst().orElse(null); - - Task read2 = myTaskDao.read(new IdType(taskId2)); - assertThat(read2.getBasedOn().get(0).getReference(), is(equalTo(patientId))); - } -} diff --git a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/BaseSearchParamExtractor.java b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/BaseSearchParamExtractor.java index 886b8aaaeba..e109de415c7 100644 --- a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/BaseSearchParamExtractor.java +++ b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/BaseSearchParamExtractor.java @@ -991,7 +991,7 @@ public abstract class BaseSearchParamExtractor implements ISearchParamExtractor || anySearchParameterUsesResolve(searchParams, theSearchParamType); if (havePathWithResolveExpression) { - //FIXME GGG/JA: At this point, if the Task.basedOn.reference.resource does _not_ have an ID, we will attempt to contain it internally. + //TODO GGG/JA: At this point, if the Task.basedOn.reference.resource does _not_ have an ID, we will attempt to contain it internally. Wild myContext.newTerser().containResources(theResource, FhirTerser.OptionsEnum.MODIFY_RESOURCE, FhirTerser.OptionsEnum.STORE_AND_REUSE_RESULTS); } }