Re-enable "Flush SP cache after SP change" (#4635)

* Revert "Revert "Flush SP cache after SP change (#4566)" (#4614)"

This reverts commit 9492999ed6.

* Additions for performance

* HAPI version bump

* Test logging improvement

* Test fixes

* Test fix

* Test fix

* Compile fix

* Fix

* License headers

* Test fix
This commit is contained in:
James Agnew 2023-03-29 19:57:57 -04:00 committed by GitHub
parent 05b3bff89f
commit e69fe05e96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
94 changed files with 534 additions and 120 deletions

View File

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

View File

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

View File

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

View File

@ -22,6 +22,7 @@ package ca.uhn.fhir.util;
import ca.uhn.fhir.context.BaseRuntimeChildDefinition;
import ca.uhn.fhir.context.BaseRuntimeElementDefinition;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.context.FhirVersionEnum;
import ca.uhn.fhir.context.RuntimeResourceDefinition;
import ca.uhn.fhir.model.primitive.IdDt;
import org.apache.commons.lang3.Validate;
@ -85,8 +86,13 @@ public class BundleBuilder {
mySearchChild = myEntryDef.getChildByName("search");
mySearchDef = mySearchChild.getChildByName("search");
myMetaChild = myBundleDef.getChildByName("meta");
myMetaDef = myMetaChild.getChildByName("meta");
if (myContext.getVersion().getVersion().isEqualOrNewerThan(FhirVersionEnum.DSTU3)) {
myMetaChild = myBundleDef.getChildByName("meta");
myMetaDef = myMetaChild.getChildByName("meta");
} else {
myMetaChild = null;
myMetaDef = null;
}
myEntryResourceChild = myEntryDef.getChildByName("resource");
myEntryFullUrlChild = myEntryDef.getChildByName("fullUrl");
@ -346,12 +352,16 @@ public class BundleBuilder {
}
/**
* Creates new search instance for the specified entry
* Creates new search instance for the specified entry.
* Note that this method does not work for DSTU2 model classes, it will only work
* on DSTU3+.
*
* @param entry Entry to create search instance for
* @return Returns the search instance
*/
public IBaseBackboneElement addSearch(IBase entry) {
Validate.isTrue(myContext.getVersion().getVersion().isEqualOrNewerThan(FhirVersionEnum.DSTU3), "This method may only be called for FHIR version DSTU3 and above");
IBase searchInstance = mySearchDef.newInstance();
mySearchChild.getMutator().setValue(entry, searchInstance);
return (IBaseBackboneElement) searchInstance;
@ -400,7 +410,13 @@ public class BundleBuilder {
return (T) myBundle;
}
/**
* Note that this method does not work for DSTU2 model classes, it will only work
* on DSTU3+.
*/
public BundleBuilder setMetaField(String theFieldName, IBase theFieldValue) {
Validate.isTrue(myContext.getVersion().getVersion().isEqualOrNewerThan(FhirVersionEnum.DSTU3), "This method may only be called for FHIR version DSTU3 and above");
BaseRuntimeChildDefinition.IMutator mutator = myMetaDef.getChildByName(theFieldName).getMutator();
mutator.setValue(myBundle.getMeta(), theFieldValue);
return this;

View File

@ -0,0 +1,53 @@
package ca.uhn.fhir.util;
/*-
* #%L
* HAPI FHIR - Core Library
* %%
* Copyright (C) 2014 - 2023 Smile CDR, Inc.
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.function.Consumer;
/**
* This utility takes an input collection, breaks it up into chunks of a
* given maximum chunk size, and then passes those chunks to a consumer for
* processing. Use this to break up large tasks into smaller tasks.
*
* @since 6.6.0
* @param <T> The type for the chunks
*/
public class TaskChunker<T> {
public void chunk(Collection<T> theInput, int theChunkSize, Consumer<List<T>> theBatchConsumer) {
List<T> input;
if (theInput instanceof List) {
input = (List<T>) theInput;
} else {
input = new ArrayList<>(theInput);
}
for (int i = 0; i < input.size(); i += theChunkSize) {
int to = i + theChunkSize;
to = Math.min(to, input.size());
List<T> batch = input.subList(i, to);
theBatchConsumer.accept(batch);
}
}
}

View File

@ -0,0 +1,53 @@
package ca.uhn.fhir.util;
import com.google.common.collect.Lists;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import javax.annotation.Nonnull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.times;
import java.util.Arrays;
import java.util.List;
import java.util.function.Consumer;
import java.util.stream.IntStream;
@ExtendWith(MockitoExtension.class)
public class TaskChunkerTest {
@Mock
private Consumer<List<Integer>> myConsumer;
@Captor
private ArgumentCaptor<List<Integer>> myConsumerCaptor;
@Test
public void testChunk() {
// Setup
List<Integer> input = newIntRangeList(0, 35);
// Execute
new TaskChunker<Integer>().chunk(input, 10, myConsumer);
// Verify
verify(myConsumer, times(4)).accept(myConsumerCaptor.capture());
assertEquals(newIntRangeList(0, 10), myConsumerCaptor.getAllValues().get(0));
assertEquals(newIntRangeList(10, 20), myConsumerCaptor.getAllValues().get(1));
assertEquals(newIntRangeList(20, 30), myConsumerCaptor.getAllValues().get(2));
assertEquals(newIntRangeList(30, 35), myConsumerCaptor.getAllValues().get(3));
}
@Nonnull
private static List<Integer> newIntRangeList(int startInclusive, int endExclusive) {
List<Integer> input = IntStream.range(startInclusive, endExclusive).boxed().toList();
return input;
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -180,6 +180,10 @@ public class VersionCanonicalizer {
return myStrategy.searchParameterToCanonical(theSearchParameter);
}
public IBaseResource searchParameterFromCanonical(SearchParameter theSearchParameter) {
return myStrategy.searchParameterFromCanonical(theSearchParameter);
}
public IBaseParameters parametersFromCanonical(Parameters theParameters) {
return myStrategy.parametersFromCanonical(theParameters);
}
@ -245,6 +249,8 @@ public class VersionCanonicalizer {
org.hl7.fhir.r5.model.ValueSet valueSetToValidatorCanonical(IBaseResource theResource);
org.hl7.fhir.r5.model.CodeSystem codeSystemToValidatorCanonical(IBaseResource theResource);
IBaseResource searchParameterFromCanonical(SearchParameter theResource);
}
private static class Dstu2Strategy implements IStrategy {
@ -374,7 +380,7 @@ public class VersionCanonicalizer {
@Override
public IBaseResource valueSetFromValidatorCanonical(org.hl7.fhir.r5.model.ValueSet theResource) {
Resource converted = VersionConvertorFactory_10_50.convertResource(theResource, ADVISOR_10_50);
return reencodeToHl7Org(converted);
return reencodeFromHl7Org(converted);
}
@Override
@ -395,6 +401,12 @@ public class VersionCanonicalizer {
return (org.hl7.fhir.r5.model.CodeSystem) VersionConvertorFactory_10_50.convertResource(reencoded, ADVISOR_10_50);
}
@Override
public IBaseResource searchParameterFromCanonical(SearchParameter theResource) {
Resource resource = VersionConvertorFactory_10_50.convertResource(theResource, ADVISOR_10_50);
return reencodeFromHl7Org(resource);
}
private Resource reencodeToHl7Org(IBaseResource theInput) {
if (myHl7OrgStructures) {
return (Resource) theInput;
@ -487,6 +499,11 @@ public class VersionCanonicalizer {
public org.hl7.fhir.r5.model.CodeSystem codeSystemToValidatorCanonical(IBaseResource theResource) {
return (org.hl7.fhir.r5.model.CodeSystem) VersionConvertorFactory_14_50.convertResource((org.hl7.fhir.dstu2016may.model.Resource) theResource, ADVISOR_14_50);
}
@Override
public IBaseResource searchParameterFromCanonical(SearchParameter theResource) {
return VersionConvertorFactory_14_50.convertResource(theResource, ADVISOR_14_50);
}
}
private static class Dstu3Strategy implements IStrategy {
@ -565,6 +582,11 @@ public class VersionCanonicalizer {
public org.hl7.fhir.r5.model.CodeSystem codeSystemToValidatorCanonical(IBaseResource theResource) {
return (org.hl7.fhir.r5.model.CodeSystem) VersionConvertorFactory_30_50.convertResource((org.hl7.fhir.dstu3.model.Resource) theResource, ADVISOR_30_50);
}
@Override
public IBaseResource searchParameterFromCanonical(SearchParameter theResource) {
return VersionConvertorFactory_30_50.convertResource(theResource, ADVISOR_30_50);
}
}
private static class R4Strategy implements IStrategy {
@ -643,6 +665,11 @@ public class VersionCanonicalizer {
return (org.hl7.fhir.r5.model.CodeSystem) VersionConvertorFactory_40_50.convertResource((org.hl7.fhir.r4.model.Resource) theResource, ADVISOR_40_50);
}
@Override
public IBaseResource searchParameterFromCanonical(SearchParameter theResource) {
return VersionConvertorFactory_40_50.convertResource(theResource, ADVISOR_40_50);
}
}
private static class R4BStrategy implements IStrategy {
@ -729,6 +756,11 @@ public class VersionCanonicalizer {
return (org.hl7.fhir.r5.model.CodeSystem) VersionConvertorFactory_43_50.convertResource((org.hl7.fhir.r4b.model.Resource) theResource, ADVISOR_43_50);
}
@Override
public IBaseResource searchParameterFromCanonical(SearchParameter theResource) {
return VersionConvertorFactory_43_50.convertResource(theResource, ADVISOR_43_50);
}
}
@ -809,6 +841,11 @@ public class VersionCanonicalizer {
return (org.hl7.fhir.r5.model.CodeSystem) theResource;
}
@Override
public IBaseResource searchParameterFromCanonical(SearchParameter theResource) {
return theResource;
}
}

View File

@ -3,7 +3,9 @@ package ca.uhn.hapi.converters.canonical;
import ca.uhn.fhir.context.FhirVersionEnum;
import ca.uhn.fhir.model.dstu2.composite.CodingDt;
import org.hl7.fhir.instance.model.api.IBaseCoding;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.r4.model.Coding;
import org.hl7.fhir.r5.model.SearchParameter;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
@ -19,4 +21,14 @@ class VersionCanonicalizerTest {
assertEquals("dstuSystem", convertedCoding.getSystem());
}
@Test
public void testFromCanonicalSearchParameter() {
VersionCanonicalizer canonicalizer = new VersionCanonicalizer(FhirVersionEnum.DSTU2);
SearchParameter inputR5 = new SearchParameter();
inputR5.setUrl("http://foo");
ca.uhn.fhir.model.dstu2.resource.SearchParameter outputDstu2 = (ca.uhn.fhir.model.dstu2.resource.SearchParameter) canonicalizer.searchParameterFromCanonical(inputR5);
assertEquals("http://foo", outputDstu2.getUrl());
}
}

View File

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

View File

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

View File

@ -0,0 +1,6 @@
---
type: add
issue: 4566
title: "When creating or modifying a SearchParameter in the JPA server, the local SearchParameter cache
is now immediately flushed. This should help with situations such as tests where a SearchParameter
is created and then used before the scheduled cache refresh typically occurs."

View File

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

View File

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

View File

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

View File

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

View File

@ -1025,7 +1025,7 @@ public abstract class BaseHapiFhirResourceDao<T extends IBaseResource> extends B
mySearchParamRegistry.requestRefresh();
}
private boolean shouldSkipReindex(RequestDetails theRequestDetails) {
protected final boolean shouldSkipReindex(RequestDetails theRequestDetails) {
if (theRequestDetails == null) {
return false;
}

View File

@ -28,12 +28,17 @@ import com.google.common.annotations.VisibleForTesting;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.r5.model.CodeType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.support.TransactionSynchronization;
import org.springframework.transaction.support.TransactionSynchronizationManager;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;
public class JpaResourceDaoSearchParameter<T extends IBaseResource> extends BaseHapiFhirResourceDao<T> implements IFhirResourceDaoSearchParameter<T> {
private final AtomicBoolean myCacheReloadTriggered = new AtomicBoolean(false);
@Autowired
private VersionCanonicalizer myVersionCanonicalizer;
@ -41,6 +46,26 @@ public class JpaResourceDaoSearchParameter<T extends IBaseResource> extends Base
private SearchParameterDaoValidator mySearchParameterDaoValidator;
protected void reindexAffectedResources(T theResource, RequestDetails theRequestDetails) {
/*
* After we commit, flush the search parameter cache. This only helps on the
* local server (ie in a cluster the other servers won't be flushed) but
* the cache is short anyhow, and flushing locally is better than nothing.
* Many use cases where you would create a search parameter and immediately
* try to use it tend to be on single-server setups anyhow, e.g. unit tests
*/
if (!shouldSkipReindex(theRequestDetails)) {
if (!myCacheReloadTriggered.getAndSet(true)) {
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
myCacheReloadTriggered.set(false);
mySearchParamRegistry.forceRefresh();
}
});
}
}
// N.B. Don't do this on the canonicalized version
Boolean reindex = theResource != null ? CURRENTLY_REINDEXING.get(theResource) : null;

View File

@ -40,6 +40,7 @@ import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId;
import ca.uhn.fhir.rest.api.server.storage.NotFoundPid;
import ca.uhn.fhir.rest.api.server.storage.TransactionDetails;
import ca.uhn.fhir.rest.server.exceptions.PreconditionFailedException;
import ca.uhn.fhir.rest.server.exceptions.ResourceVersionConflictException;
import ca.uhn.fhir.rest.server.util.ISearchParamRegistry;
import ca.uhn.fhir.rest.server.util.ResourceSearchParams;
import com.google.common.annotations.VisibleForTesting;
@ -185,7 +186,10 @@ public class SearchParamWithInlineReferencesExtractor extends BaseSearchParamWit
}
String msg = myFhirContext.getLocalizer().getMessage(BaseHapiFhirDao.class, "uniqueIndexConflictFailure", theEntity.getResourceType(), next.getIndexString(), existing.getResource().getIdDt().toUnqualifiedVersionless().getValue(), searchParameterId);
throw new PreconditionFailedException(Msg.code(1093) + msg);
// Use ResourceVersionConflictException here because the HapiTransactionService
// catches this and can retry it if needed
throw new ResourceVersionConflictException(Msg.code(1093) + msg);
}
}
ourLog.debug("Persisting unique index: {}", next);

View File

@ -20,6 +20,7 @@
package ca.uhn.fhir.jpa.util;
import ca.uhn.fhir.jpa.search.builder.SearchBuilder;
import ca.uhn.fhir.util.TaskChunker;
import java.util.ArrayList;
import java.util.Collection;
@ -32,24 +33,10 @@ import java.util.function.Consumer;
* if it's lots of IDs. I suppose maybe we should be doing this as a join anyhow
* but this should work too. Sigh.
*/
public class QueryChunker<T> {
public class QueryChunker<T> extends TaskChunker<T> {
public void chunk(Collection<T> theInput, Consumer<List<T>> theBatchConsumer) {
chunk(theInput, SearchBuilder.getMaximumPageSize(), theBatchConsumer);
}
public void chunk(Collection<T> theInput, int theChunkSize, Consumer<List<T>> theBatchConsumer) {
List<T> input;
if (theInput instanceof List) {
input = (List<T>) theInput;
} else {
input = new ArrayList<>(theInput);
}
for (int i = 0; i < input.size(); i += theChunkSize) {
int to = i + theChunkSize;
to = Math.min(to, input.size());
List<T> batch = input.subList(i, to);
theBatchConsumer.accept(batch);
}
}
}

View File

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

View File

@ -3,7 +3,7 @@
<parent>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-deployable-pom</artifactId>
<version>6.5.7-SNAPSHOT</version>
<version>6.5.8-SNAPSHOT</version>
<relativePath>../hapi-deployable-pom/pom.xml</relativePath>
</parent>

View File

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

View File

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

View File

@ -818,7 +818,9 @@ public class ResourceTable extends BaseHasResource implements Serializable, IBas
}
private void populateId(IIdType retVal) {
if (getTransientForcedId() != null) {
if (myFhirId != null) {
retVal.setValue(getResourceType() + '/' + myFhirId + '/' + Constants.PARAM_HISTORY + '/' + getVersion());
} else if (getTransientForcedId() != null) {
// Avoid a join query if possible
retVal.setValue(getResourceType() + '/' + getTransientForcedId() + '/' + Constants.PARAM_HISTORY + '/' + getVersion());
} else if (getForcedId() == null) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -474,7 +474,7 @@ public class FhirResourceDaoR4ConcurrentWriteTest extends BaseJpaR4Test {
assertThat(e.getMessage(), containsString("duplicate unique index matching query: Patient?gender=http%3A%2F%2Fhl7.org%2Ffhir%2Fadministrative-gender%7Cmale"));
} catch (ResourceVersionConflictException e) {
// expected - This is as a result of the unique SP
assertThat(e.getMessage(), containsString("would have resulted in a duplicate value for a unique index"));
assertThat(e.getMessage(), containsString("duplicate"));
}
};
Future<?> future = myExecutor.submit(task);

View File

@ -1744,6 +1744,7 @@ public class FhirResourceDaoR4SearchCustomSearchParamTest extends BaseJpaR4Test
@Test
public void testCompositeWithInvalidTarget() {
// Setup
SearchParameter sp = new SearchParameter();
sp.addBase("Patient");
sp.setCode("myDoctor");
@ -1752,14 +1753,15 @@ public class FhirResourceDaoR4SearchCustomSearchParamTest extends BaseJpaR4Test
sp.setStatus(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.ACTIVE);
sp.addComponent()
.setDefinition("http://foo");
mySearchParameterDao.create(sp);
IAnonymousInterceptor interceptor = mock(IAnonymousInterceptor.class);
myInterceptorRegistry.registerAnonymousInterceptor(Pointcut.JPA_PERFTRACE_WARNING, interceptor);
try {
mySearchParamRegistry.forceRefresh();
// Test
mySearchParameterDao.create(sp);
// Verify
ArgumentCaptor<HookParams> paramsCaptor = ArgumentCaptor.forClass(HookParams.class);
verify(interceptor, times(1)).invoke(any(), paramsCaptor.capture());

View File

@ -228,6 +228,7 @@ public class MultitenantBatchOperationR4Test extends BaseMultitenantResourceProv
IIdType obsCancelledB = doCreateResource(reindexTestHelper.buildObservationWithAlleleExtension(Observation.ObservationStatus.CANCELLED));
reindexTestHelper.createAlleleSearchParameter();
ourLog.info("Search params: {}", mySearchParamRegistry.getActiveSearchParams("Observation").getSearchParamNames());
// The searchparam value is on the observation, but it hasn't been indexed yet
myTenantClientInterceptor.setTenantId(TENANT_A);
@ -255,7 +256,6 @@ public class MultitenantBatchOperationR4Test extends BaseMultitenantResourceProv
myBatch2JobHelper.awaitJobCompletion(jobId.getValue());
// validate
ourLog.info("Search params: {}", mySearchParamRegistry.getActiveSearchParams("Observation").getSearchParamNames());
logAllTokenIndexes();
List<String> alleleObservationIds = reindexTestHelper.getAlleleObservationIds(myClient);

View File

@ -401,10 +401,6 @@ public class ResourceProviderCustomSearchParamR4Test extends BaseResourceProvide
fooSp.setStatus(org.hl7.fhir.r4.model.Enumerations.PublicationStatus.ACTIVE);
mySearchParameterDao.create(fooSp, mySrd);
myCaptureQueriesListener.clear();
mySearchParamRegistry.forceRefresh();
myCaptureQueriesListener.logAllQueriesForCurrentThread();
Patient pat = new Patient();
pat.setGender(AdministrativeGender.MALE);
IIdType patId = myPatientDao.create(pat, mySrd).getId().toUnqualifiedVersionless();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -7,7 +7,7 @@
<parent>
<artifactId>hapi-fhir-serviceloaders</artifactId>
<groupId>ca.uhn.hapi.fhir</groupId>
<version>6.5.7-SNAPSHOT</version>
<version>6.5.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -7,7 +7,7 @@
<parent>
<artifactId>hapi-fhir-serviceloaders</artifactId>
<groupId>ca.uhn.hapi.fhir</groupId>
<version>6.5.7-SNAPSHOT</version>
<version>6.5.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
@ -20,7 +20,7 @@
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-caching-api</artifactId>
<version>6.5.7-SNAPSHOT</version>
<version>6.5.8-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.github.ben-manes.caffeine</groupId>

View File

@ -7,7 +7,7 @@
<parent>
<artifactId>hapi-fhir-serviceloaders</artifactId>
<groupId>ca.uhn.hapi.fhir</groupId>
<version>6.5.7-SNAPSHOT</version>
<version>6.5.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

View File

@ -7,7 +7,7 @@
<parent>
<artifactId>hapi-fhir</artifactId>
<groupId>ca.uhn.hapi.fhir</groupId>
<version>6.5.7-SNAPSHOT</version>
<version>6.5.8-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -138,17 +138,26 @@ public abstract class BaseRequestPartitionHelperSvc implements IRequestPartition
public RequestPartitionId determineGenericPartitionForRequest(RequestDetails theRequestDetails) {
RequestPartitionId retVal = null;
if (hasHooks(Pointcut.STORAGE_PARTITION_IDENTIFY_ANY, myInterceptorBroadcaster, theRequestDetails)) {
// Interceptor call: STORAGE_PARTITION_IDENTIFY_ANY
HookParams params = new HookParams()
.add(RequestDetails.class, theRequestDetails)
.addIfMatchesType(ServletRequestDetails.class, theRequestDetails);
retVal = (RequestPartitionId) doCallHooksAndReturnObject(myInterceptorBroadcaster, theRequestDetails, Pointcut.STORAGE_PARTITION_IDENTIFY_ANY, params);
if (retVal != null) {
retVal = validateNormalizeAndNotifyHooksForRead(retVal, theRequestDetails, null);
if (myPartitionSettings.isPartitioningEnabled()) {
if (theRequestDetails instanceof SystemRequestDetails) {
SystemRequestDetails systemRequestDetails = (SystemRequestDetails) theRequestDetails;
retVal = systemRequestDetails.getRequestPartitionId();
}
}
if (retVal == null) {
if (hasHooks(Pointcut.STORAGE_PARTITION_IDENTIFY_ANY, myInterceptorBroadcaster, theRequestDetails)) {
// Interceptor call: STORAGE_PARTITION_IDENTIFY_ANY
HookParams params = new HookParams()
.add(RequestDetails.class, theRequestDetails)
.addIfMatchesType(ServletRequestDetails.class, theRequestDetails);
retVal = (RequestPartitionId) doCallHooksAndReturnObject(myInterceptorBroadcaster, theRequestDetails, Pointcut.STORAGE_PARTITION_IDENTIFY_ANY, params);
if (retVal != null) {
retVal = validateNormalizeAndNotifyHooksForRead(retVal, theRequestDetails, null);
}
}
}
return retVal;

View File

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

View File

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

View File

@ -0,0 +1,212 @@
package ca.uhn.fhir.util;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.dstu2.resource.Bundle;
import ca.uhn.fhir.model.dstu2.resource.Patient;
import ca.uhn.fhir.model.dstu2.valueset.BundleTypeEnum;
import ca.uhn.fhir.model.dstu2.valueset.HTTPVerbEnum;
import ca.uhn.fhir.model.dstu2.valueset.SearchEntryModeEnum;
import org.hl7.fhir.instance.model.api.IBase;
import org.hl7.fhir.instance.model.api.IPrimitiveType;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.math.BigDecimal;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.UUID;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.fail;
public class BundleBuilderDstu2Test {
private static final Logger ourLog = LoggerFactory.getLogger(BundleBuilderDstu2Test.class);
private FhirContext myFhirContext = FhirContext.forDstu2Cached();
private Date myCheckDate;
@BeforeEach
public void initDate() {
Calendar cal = GregorianCalendar.getInstance();
cal.set(2021, 0, 0);
myCheckDate = cal.getTime();
}
@Test
public void testAddEntryUpdate() {
BundleBuilder builder = new BundleBuilder(myFhirContext);
Patient patient = new Patient();
patient.setId("http://foo/Patient/123");
patient.setActive(true);
builder.addTransactionUpdateEntry(patient);
Bundle bundle = (Bundle) builder.getBundle();
ourLog.debug("Bundle:\n{}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle));
assertEquals(BundleTypeEnum.TRANSACTION, bundle.getTypeElement().getValueAsEnum());
assertEquals(1, bundle.getEntry().size());
assertSame(patient, bundle.getEntry().get(0).getResource());
assertEquals("http://foo/Patient/123", bundle.getEntry().get(0).getFullUrl());
assertEquals("Patient/123", bundle.getEntry().get(0).getRequest().getUrl());
assertEquals(HTTPVerbEnum.PUT, bundle.getEntry().get(0).getRequest().getMethodElement().getValueAsEnum());
}
@Test
public void testNewPrimitive() {
BundleBuilder builder = new BundleBuilder(myFhirContext);
IPrimitiveType<Date> datePrimitive = builder.newPrimitive("instant", myCheckDate);
assertNotNull(datePrimitive);
assertEquals(myCheckDate, datePrimitive.getValue());
}
@Test
public void testSettingBundleFields() {
String uuid = UUID.randomUUID().toString();
BundleBuilder builder = new BundleBuilder(myFhirContext);
try {
builder.setBundleField("id", uuid);
fail();
} catch (NullPointerException e) {
assertEquals("Unable to find field id", e.getMessage());
}
try {
builder.setMetaField("lastUpdated", builder.newPrimitive("instant", myCheckDate));
fail();
} catch (IllegalArgumentException e) {
assertEquals("This method may only be called for FHIR version DSTU3 and above", e.getMessage());
}
}
@Test
public void testAddEntryUpdateConditional() {
BundleBuilder builder = new BundleBuilder(myFhirContext);
Patient patient = new Patient();
patient.setId("http://foo/Patient/123");
patient.setActive(true);
builder.addTransactionUpdateEntry(patient).conditional("Patient?active=true");
Bundle bundle = (Bundle) builder.getBundle();
ourLog.debug("Bundle:\n{}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle));
assertEquals(BundleTypeEnum.TRANSACTION, bundle.getTypeElement().getValueAsEnum());
assertEquals(1, bundle.getEntry().size());
assertSame(patient, bundle.getEntry().get(0).getResource());
assertEquals("http://foo/Patient/123", bundle.getEntry().get(0).getFullUrl());
assertEquals("Patient?active=true", bundle.getEntry().get(0).getRequest().getUrl());
assertEquals(HTTPVerbEnum.PUT, bundle.getEntry().get(0).getRequest().getMethodElement().getValueAsEnum());
}
@Test
public void testSearchHandling() {
BundleBuilder builder = new BundleBuilder(myFhirContext);
IBase entry = builder.addEntry();
assertNotNull(entry);
try {
builder.addSearch(entry);
fail();
} catch (IllegalArgumentException e) {
assertEquals("This method may only be called for FHIR version DSTU3 and above", e.getMessage());
}
}
@Test
public void testAddToEntry() {
BundleBuilder builder = new BundleBuilder(myFhirContext);
IBase entry = builder.addEntry();
Patient patient = new Patient();
patient.setActive(true);
builder.addToEntry(entry, "resource", patient);
Bundle bundle = (Bundle) builder.getBundle();
ourLog.debug("Bundle:\n{}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle));
assertEquals(1, bundle.getEntry().size());
}
@Test
public void testAddEntryCreate() {
BundleBuilder builder = new BundleBuilder(myFhirContext);
Patient patient = new Patient();
patient.setActive(true);
builder.addTransactionCreateEntry(patient);
Bundle bundle = (Bundle) builder.getBundle();
ourLog.debug("Bundle:\n{}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle));
assertEquals(BundleTypeEnum.TRANSACTION, bundle.getTypeElement().getValueAsEnum());
assertEquals(1, bundle.getEntry().size());
assertSame(patient, bundle.getEntry().get(0).getResource());
assertEquals(null, bundle.getEntry().get(0).getFullUrl());
assertEquals("Patient", bundle.getEntry().get(0).getRequest().getUrl());
assertEquals(HTTPVerbEnum.POST, bundle.getEntry().get(0).getRequest().getMethodElement().getValueAsEnum());
}
@Test
public void testAddEntryDelete() {
BundleBuilder builder = new BundleBuilder(myFhirContext);
Patient patient = new Patient();
patient.setActive(true);
patient.setId("123");
builder.addTransactionDeleteEntry(patient);
builder.addTransactionDeleteEntry("Patient", "123");
Bundle bundle = (Bundle) builder.getBundle();
ourLog.debug("Bundle:\n{}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle));
assertEquals(BundleTypeEnum.TRANSACTION, bundle.getTypeElement().getValueAsEnum());
assertEquals(2, bundle.getEntry().size());
//Check the IBaseresource style entry
assertNull(bundle.getEntry().get(0).getResource());
assertEquals("Patient/123", bundle.getEntry().get(0).getRequest().getUrl());
assertEquals(HTTPVerbEnum.DELETE, bundle.getEntry().get(0).getRequest().getMethodElement().getValueAsEnum());
//Check the resourcetype + id style entry.
assertNull(bundle.getEntry().get(1).getResource());
assertEquals("Patient/123", bundle.getEntry().get(1).getRequest().getUrl());
assertEquals(HTTPVerbEnum.DELETE, bundle.getEntry().get(1).getRequest().getMethodElement().getValueAsEnum());
}
@Test
public void testAddEntryCreateConditional() {
BundleBuilder builder = new BundleBuilder(myFhirContext);
Patient patient = new Patient();
patient.setActive(true);
builder.addTransactionCreateEntry(patient).conditional("Patient?active=true");
Bundle bundle = (Bundle) builder.getBundle();
ourLog.debug("Bundle:\n{}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle));
assertEquals(BundleTypeEnum.TRANSACTION, bundle.getTypeElement().getValueAsEnum());
assertEquals(1, bundle.getEntry().size());
assertSame(patient, bundle.getEntry().get(0).getResource());
assertEquals(null, bundle.getEntry().get(0).getFullUrl());
assertEquals("Patient", bundle.getEntry().get(0).getRequest().getUrl());
assertEquals("Patient?active=true", bundle.getEntry().get(0).getRequest().getIfNoneExist());
assertEquals(HTTPVerbEnum.POST, bundle.getEntry().get(0).getRequest().getMethodElement().getValueAsEnum());
}
}

View File

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

View File

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

View File

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

View File

@ -24,10 +24,10 @@ import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class BundleBuilderTest {
public class BundleBuilderR4Test {
private static final Logger ourLog = LoggerFactory.getLogger(BundleBuilderTest.class);
private FhirContext myFhirContext = FhirContext.forR4();
private static final Logger ourLog = LoggerFactory.getLogger(BundleBuilderR4Test.class);
private FhirContext myFhirContext = FhirContext.forR4Cached();
private Date myCheckDate;
@BeforeEach

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -7,7 +7,7 @@
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir</artifactId>
<packaging>pom</packaging>
<version>6.5.7-SNAPSHOT</version>
<version>6.5.8-SNAPSHOT</version>
<name>HAPI-FHIR</name>
<description>An open-source implementation of the FHIR specification in Java.</description>
<url>https://hapifhir.io</url>

View File

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

View File

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

View File

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