diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/ResourceMetadataKeyEnum.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/ResourceMetadataKeyEnum.java
index 12e8f3091ab..a4dd53ff6ce 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/ResourceMetadataKeyEnum.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/ResourceMetadataKeyEnum.java
@@ -27,19 +27,13 @@ import ca.uhn.fhir.model.primitive.InstantDt;
import ca.uhn.fhir.model.valueset.BundleEntrySearchModeEnum;
import ca.uhn.fhir.model.valueset.BundleEntryTransactionMethodEnum;
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
-import org.apache.commons.lang3.StringUtils;
import org.hl7.fhir.instance.model.api.IAnyResource;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.instance.model.api.IPrimitiveType;
import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collections;
import java.util.Date;
import java.util.List;
-import java.util.Map;
-
-import static org.apache.commons.lang3.StringUtils.isNotBlank;
/**
* Keys in this map refer to resource metadata keys, which are keys used to access information about specific resource instances that live outside of the resource body. Typically, these are
@@ -65,23 +59,6 @@ import static org.apache.commons.lang3.StringUtils.isNotBlank;
*/
public abstract class ResourceMetadataKeyEnum implements Serializable {
- // TODO: JA - Replace all of the various other get/put methods in subclasses with just using the two that are here
- public T get(IBaseResource theResource) {
- if (theResource instanceof IAnyResource) {
- return (T) theResource.getUserData(name());
- } else {
- return (T) ((IResource)theResource).getResourceMetadata().get(this);
- }
- }
-
- public void put(IBaseResource theResource, T theValue) {
- if (theResource instanceof IAnyResource) {
- theResource.setUserData(name(), theValue);
- } else {
- ((IResource)theResource).getResourceMetadata().put(this, theValue);
- }
- }
-
/**
* If present and populated with a date/time (as an instance of {@link InstantDt}), this value is an indication that the resource is in the deleted state. This key is only used in a limited number
* of scenarios, such as POSTing transaction bundles to a server, or returning resource history.
@@ -89,21 +66,8 @@ public abstract class ResourceMetadataKeyEnum implements Serializable {
* Values for this key are of type {@link InstantDt}
*
*/
- public static final ResourceMetadataKeyEnum> DELETED_AT = new ResourceMetadataKeyEnum<>("DELETED_AT") {
- private static final long serialVersionUID = 1L;
-
- @Override
- public IPrimitiveType get(IResource theResource) {
- return (IPrimitiveType) theResource.getResourceMetadata().get(this);
- }
-
- @Override
- public void put(IResource theResource, IPrimitiveType theObject) {
- theResource.getResourceMetadata().put(this, theObject);
- }
-
+ public static final ResourceMetadataKeyEnum> DELETED_AT = new ResourceMetadataKeyEnum<>("DELETED_AT", IPrimitiveType.class) {
};
-
/**
* If present and populated with a {@link BundleEntrySearchModeEnum}, contains the "bundle entry search mode", which is the value of the status field in the Bundle entry containing this resource.
* The value for this key corresponds to field Bundle.entry.search.mode. This value can be set to provide a status value of "include" for included resources being returned by a
@@ -115,28 +79,7 @@ public abstract class ResourceMetadataKeyEnum implements Serializable {
* Values for this key are of type {@link BundleEntrySearchModeEnum}
*
*/
- public static final ResourceMetadataKeySupportingAnyResource ENTRY_SEARCH_MODE = new ResourceMetadataKeySupportingAnyResource("ENTRY_SEARCH_MODE") {
- private static final long serialVersionUID = 1L;
-
- @Override
- public BundleEntrySearchModeEnum get(IResource theResource) {
- return getEnumFromMetadataOrNullIfNone(theResource.getResourceMetadata(), ENTRY_SEARCH_MODE, BundleEntrySearchModeEnum.class, BundleEntrySearchModeEnum.VALUESET_BINDER);
- }
-
- @Override
- public String get(IAnyResource theResource) {
- return (String) theResource.getUserData(ENTRY_SEARCH_MODE.name());
- }
-
- @Override
- public void put(IResource theResource, BundleEntrySearchModeEnum theObject) {
- theResource.getResourceMetadata().put(ENTRY_SEARCH_MODE, theObject);
- }
-
- @Override
- public void put(IAnyResource theResource, String theObject) {
- theResource.setUserData(ENTRY_SEARCH_MODE.name(), theObject);
- }
+ public static final ResourceMetadataKeyEnum ENTRY_SEARCH_MODE = new ResourceMetadataKeyEnum<>("ENTRY_SEARCH_MODE", BundleEntrySearchModeEnum.class) {
};
/**
* If present and populated with a {@link BundleEntryTransactionMethodEnum}, contains the "bundle entry transaction operation", which is the value of the status field in the Bundle entry
@@ -150,33 +93,8 @@ public abstract class ResourceMetadataKeyEnum implements Serializable {
* Values for this key are of type {@link BundleEntryTransactionMethodEnum}
*
*/
- public static final ResourceMetadataKeySupportingAnyResource ENTRY_TRANSACTION_METHOD = new ResourceMetadataKeySupportingAnyResource(
- "ENTRY_TRANSACTION_OPERATION") {
- private static final long serialVersionUID = 1L;
-
- @Override
- public BundleEntryTransactionMethodEnum get(IResource theResource) {
- return getEnumFromMetadataOrNullIfNone(theResource.getResourceMetadata(), ENTRY_TRANSACTION_METHOD, BundleEntryTransactionMethodEnum.class,
- BundleEntryTransactionMethodEnum.VALUESET_BINDER);
- }
-
- @Override
- public String get(IAnyResource theResource) {
- return (String) theResource.getUserData(ENTRY_TRANSACTION_METHOD.name());
- }
-
- @Override
- public void put(IResource theResource, BundleEntryTransactionMethodEnum theObject) {
- theResource.getResourceMetadata().put(ENTRY_TRANSACTION_METHOD, theObject);
- }
-
- @Override
- public void put(IAnyResource theResource, String theObject) {
- theResource.setUserData(ENTRY_TRANSACTION_METHOD.name(), theObject);
- }
-
+ public static final ResourceMetadataKeyEnum ENTRY_TRANSACTION_METHOD = new ResourceMetadataKeyEnum<>("ENTRY_TRANSACTION_OPERATION", BundleEntryTransactionMethodEnum.class) {
};
-
/**
* The value for this key represents a {@link List} of profile IDs that this resource claims to conform to.
*
@@ -184,18 +102,7 @@ public abstract class ResourceMetadataKeyEnum implements Serializable {
* Values for this key are of type List<IdDt>. Note that the returned list is unmodifiable, so you need to create a new list and call put to change its value.
*
*/
- public static final ResourceMetadataKeyEnum> PROFILES = new ResourceMetadataKeyEnum>("PROFILES") {
- private static final long serialVersionUID = 1L;
-
- @Override
- public List get(IResource theResource) {
- return getIdListFromMetadataOrNullIfNone(theResource.getResourceMetadata(), PROFILES);
- }
-
- @Override
- public void put(IResource theResource, List theObject) {
- theResource.getResourceMetadata().put(PROFILES, theObject);
- }
+ public static final ResourceMetadataKeyEnum> PROFILES = new ResourceMetadataKeyEnum<>("PROFILES", List.class) {
};
/**
* The value for this key is the bundle entry Published time. This is defined by FHIR as "Time resource copied into the feed", which is generally best left to the current time.
@@ -208,37 +115,9 @@ public abstract class ResourceMetadataKeyEnum implements Serializable {
*
* @see InstantDt
*/
- public static final ResourceMetadataKeyEnum PUBLISHED = new ResourceMetadataKeyEnum("PUBLISHED") {
- private static final long serialVersionUID = 1L;
-
- @Override
- public InstantDt get(IResource theResource) {
- return getInstantFromMetadataOrNullIfNone(theResource.getResourceMetadata(), PUBLISHED);
- }
-
- @Override
- public void put(IResource theResource, InstantDt theObject) {
- theResource.getResourceMetadata().put(PUBLISHED, theObject);
- }
+ public static final ResourceMetadataKeyEnum PUBLISHED = new ResourceMetadataKeyEnum<>("PUBLISHED", InstantDt.class) {
};
- public static final ResourceMetadataKeyEnum> SECURITY_LABELS = new ResourceMetadataKeyEnum>("SECURITY_LABELS") {
- private static final long serialVersionUID = 1L;
-
- @Override
- public List get(IResource resource) {
- Object obj = resource.getResourceMetadata().get(SECURITY_LABELS);
- if (obj == null) {
- return null;
- }
- //noinspection unchecked
- return (List) obj;
- }
-
- @Override
- public void put(IResource iResource, List labels) {
- iResource.getResourceMetadata().put(SECURITY_LABELS, labels);
- }
-
+ public static final ResourceMetadataKeyEnum> SECURITY_LABELS = new ResourceMetadataKeyEnum<>("SECURITY_LABELS", List.class) {
};
/**
* The value for this key is the list of tags associated with this resource
@@ -248,23 +127,7 @@ public abstract class ResourceMetadataKeyEnum implements Serializable {
*
* @see TagList
*/
- public static final ResourceMetadataKeyEnum TAG_LIST = new ResourceMetadataKeyEnum("TAG_LIST") {
- private static final long serialVersionUID = 1L;
-
- @Override
- public TagList get(IResource theResource) {
- Object retValObj = theResource.getResourceMetadata().get(TAG_LIST);
- if (retValObj == null) {
- return null;
- } else {
- return (TagList) retValObj;
- }
- }
-
- @Override
- public void put(IResource theResource, TagList theObject) {
- theResource.getResourceMetadata().put(TAG_LIST, theObject);
- }
+ public static final ResourceMetadataKeyEnum TAG_LIST = new ResourceMetadataKeyEnum<>("TAG_LIST", TagList.class) {
};
/**
* The value for this key is the bundle entry Updated time. This is defined by FHIR as "Last Updated for resource". This value is also used for populating the "Last-Modified" header in the
@@ -275,18 +138,7 @@ public abstract class ResourceMetadataKeyEnum implements Serializable {
*
* @see InstantDt
*/
- public static final ResourceMetadataKeyEnum UPDATED = new ResourceMetadataKeyEnum("UPDATED") {
- private static final long serialVersionUID = 1L;
-
- @Override
- public InstantDt get(IResource theResource) {
- return getInstantFromMetadataOrNullIfNone(theResource.getResourceMetadata(), UPDATED);
- }
-
- @Override
- public void put(IResource theResource, InstantDt theObject) {
- theResource.getResourceMetadata().put(UPDATED, theObject);
- }
+ public static final ResourceMetadataKeyEnum UPDATED = new ResourceMetadataKeyEnum<>("UPDATED", InstantDt.class) {
};
/**
* The value for this key is the version ID of the resource object.
@@ -297,18 +149,7 @@ public abstract class ResourceMetadataKeyEnum implements Serializable {
* @deprecated The {@link IResource#getId()} resource ID will now be populated with the version ID via the {@link IdDt#getVersionIdPart()} method
*/
@Deprecated
- public static final ResourceMetadataKeyEnum VERSION = new ResourceMetadataKeyEnum("VERSION") {
- private static final long serialVersionUID = 1L;
-
- @Override
- public String get(IResource theResource) {
- return getStringFromMetadataOrNullIfNone(theResource.getResourceMetadata(), VERSION);
- }
-
- @Override
- public void put(IResource theResource, String theObject) {
- theResource.getResourceMetadata().put(VERSION, theObject);
- }
+ public static final ResourceMetadataKeyEnum VERSION = new ResourceMetadataKeyEnum<>("VERSION", String.class) {
};
/**
* The value for this key is the version ID of the resource object.
@@ -319,24 +160,48 @@ public abstract class ResourceMetadataKeyEnum implements Serializable {
* @deprecated The {@link IResource#getId()} resource ID will now be populated with the version ID via the {@link IdDt#getVersionIdPart()} method
*/
@Deprecated
- public static final ResourceMetadataKeyEnum VERSION_ID = new ResourceMetadataKeyEnum("VERSION_ID") {
- private static final long serialVersionUID = 1L;
-
- @Override
- public IdDt get(IResource theResource) {
- return getIdFromMetadataOrNullIfNone(theResource.getResourceMetadata());
- }
-
- @Override
- public void put(IResource theResource, IdDt theObject) {
- theResource.getResourceMetadata().put(VERSION_ID, theObject);
- }
+ public static final ResourceMetadataKeyEnum VERSION_ID = new ResourceMetadataKeyEnum<>("VERSION_ID", IdDt.class) {
};
private static final long serialVersionUID = 1L;
private final String myValue;
+ private final Class> myType;
- public ResourceMetadataKeyEnum(String theValue) {
+ public ResourceMetadataKeyEnum(String theValue, Class> theType) {
myValue = theValue;
+ myType = theType;
+ }
+
+ // TODO: JA - Replace all of the various other get/put methods in subclasses with just using the two that are here
+ public T get(IBaseResource theResource) {
+ Object retVal;
+ if (theResource instanceof IAnyResource) {
+ retVal = theResource.getUserData(name());
+ } else {
+ retVal = ((IResource) theResource).getResourceMetadata().get(this);
+ }
+
+ if (retVal != null && !myType.isAssignableFrom(retVal.getClass())) {
+ throw new InternalErrorException(Msg.code(1890) + "Found an object of type '" + retVal.getClass().getCanonicalName()
+ + "' in resource metadata for key " + this.name() + " - Expected "
+ + myType.getCanonicalName());
+ }
+
+ //noinspection unchecked
+ return (T) retVal;
+ }
+
+ public void put(IBaseResource theResource, T theValue) {
+ if (theValue != null && !myType.isAssignableFrom(theValue.getClass())) {
+ throw new InternalErrorException(Msg.code(1891) + "Can not put object of type '" + theValue.getClass().getCanonicalName()
+ + "' in resource metadata for key " + this.name() + " - Expected "
+ + myType.getCanonicalName());
+ }
+
+ if (theResource instanceof IAnyResource) {
+ theResource.setUserData(name(), theValue);
+ } else {
+ ((IResource) theResource).getResourceMetadata().put(this, theValue);
+ }
}
@Override
@@ -349,15 +214,10 @@ public abstract class ResourceMetadataKeyEnum implements Serializable {
return false;
ResourceMetadataKeyEnum> other = (ResourceMetadataKeyEnum>) obj;
if (myValue == null) {
- if (other.myValue != null)
- return false;
- } else if (!myValue.equals(other.myValue))
- return false;
- return true;
+ return other.myValue == null;
+ } else return myValue.equals(other.myValue);
}
- public abstract T get(IResource theResource);
-
@Override
public int hashCode() {
final int prime = 31;
@@ -370,138 +230,9 @@ public abstract class ResourceMetadataKeyEnum implements Serializable {
return myValue;
}
- public abstract void put(IResource theResource, T theObject);
-
- public static abstract class ResourceMetadataKeySupportingAnyResource extends ResourceMetadataKeyEnum {
-
- private static final long serialVersionUID = 1L;
-
- public ResourceMetadataKeySupportingAnyResource(String theValue) {
- super(theValue);
- }
-
- public abstract T2 get(IAnyResource theResource);
-
- public abstract void put(IAnyResource theResource, T2 theObject);
-
- }
-
public static final class ExtensionResourceMetadataKey extends ResourceMetadataKeyEnum {
public ExtensionResourceMetadataKey(String theUrl) {
- super(theUrl);
- }
-
- @Override
- public ExtensionDt get(IResource theResource) {
- Object retValObj = theResource.getResourceMetadata().get(this);
- if (retValObj == null) {
- return null;
- } else if (retValObj instanceof ExtensionDt) {
- return (ExtensionDt) retValObj;
- }
- throw new InternalErrorException(Msg.code(1890) + "Found an object of type '" + retValObj.getClass().getCanonicalName()
- + "' in resource metadata for key " + this.name() + " - Expected "
- + ExtensionDt.class.getCanonicalName());
- }
-
- @Override
- public void put(IResource theResource, ExtensionDt theObject) {
- theResource.getResourceMetadata().put(this, theObject);
+ super(theUrl, ExtensionDt.class);
}
}
-
-
- @SuppressWarnings("unchecked")
- private static > T getEnumFromMetadataOrNullIfNone(Map, Object> theResourceMetadata, ResourceMetadataKeyEnum theKey, Class theEnumType,
- IValueSetEnumBinder theBinder) {
- Object retValObj = theResourceMetadata.get(theKey);
- if (retValObj == null) {
- return null;
- } else if (theEnumType.equals(retValObj.getClass())) {
- return (T) retValObj;
- } else if (retValObj instanceof String) {
- return theBinder.fromCodeString((String) retValObj);
- }
- throw new InternalErrorException(Msg.code(1891) + "Found an object of type '" + retValObj.getClass().getCanonicalName() + "' in resource metadata for key " + theKey.name() + " - Expected "
- + InstantDt.class.getCanonicalName());
- }
-
- private static IdDt getIdFromMetadataOrNullIfNone(Map, Object> theResourceMetadata) {
- return toId(ResourceMetadataKeyEnum.VERSION_ID, theResourceMetadata.get(ResourceMetadataKeyEnum.VERSION_ID));
- }
-
- private static List getIdListFromMetadataOrNullIfNone(Map, Object> theResourceMetadata, ResourceMetadataKeyEnum> theKey) {
- Object retValObj = theResourceMetadata.get(theKey);
- if (retValObj == null) {
- return null;
- } else if (retValObj instanceof List) {
- List> retValList = (List>) retValObj;
- for (Object next : retValList) {
- if (!(next instanceof IdDt)) {
- List retVal = new ArrayList();
- for (Object nextVal : retValList) {
- retVal.add(toId(theKey, nextVal));
- }
- return Collections.unmodifiableList(retVal);
- }
- }
- @SuppressWarnings("unchecked")
- List retVal = (List) retValList;
- return Collections.unmodifiableList(retVal);
- } else {
- return Collections.singletonList(toId(theKey, retValObj));
- }
- }
-
- private static InstantDt getInstantFromMetadataOrNullIfNone(Map, Object> theResourceMetadata, ResourceMetadataKeyEnum theKey) {
- Object retValObj = theResourceMetadata.get(theKey);
- if (retValObj == null) {
- return null;
- } else if (retValObj instanceof Date) {
- return new InstantDt((Date) retValObj);
- } else if (retValObj instanceof InstantDt) {
- if (((InstantDt) retValObj).isEmpty()) {
- return null;
- }
- return (InstantDt) retValObj;
- }
- throw new InternalErrorException(Msg.code(1892) + "Found an object of type '" + retValObj.getClass().getCanonicalName() + "' in resource metadata for key " + theKey.name() + " - Expected "
- + InstantDt.class.getCanonicalName());
- }
-
- private static String getStringFromMetadataOrNullIfNone(Map, Object> theResourceMetadata, ResourceMetadataKeyEnum theKey) {
- Object retValObj = theResourceMetadata.get(theKey);
- if (retValObj == null) {
- return null;
- } else if (retValObj instanceof String) {
- if (StringUtils.isBlank(((String) retValObj))) {
- return null;
- }
- return (String) retValObj;
- }
- throw new InternalErrorException(Msg.code(1893) + "Found an object of type '" + retValObj.getClass().getCanonicalName() + "' in resource metadata for key " + theKey.name() + " - Expected "
- + String.class.getCanonicalName());
- }
-
- private static IdDt toId(ResourceMetadataKeyEnum> theKey, Object retValObj) {
- if (retValObj == null) {
- return null;
- } else if (retValObj instanceof String) {
- if (isNotBlank((String) retValObj)) {
- return new IdDt((String) retValObj);
- }
- return null;
- } else if (retValObj instanceof IdDt) {
- if (((IdDt) retValObj).isEmpty()) {
- return null;
- }
- return (IdDt) retValObj;
- } else if (retValObj instanceof Number) {
- return new IdDt(retValObj.toString());
- }
- throw new InternalErrorException(Msg.code(1894) + "Found an object of type '" + retValObj.getClass().getCanonicalName() + "' in resource metadata for key " + theKey.name() + " - Expected "
- + IdDt.class.getCanonicalName());
- }
-
-
}
diff --git a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/impl/GenericClient.java b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/impl/GenericClient.java
index caec3d04e7a..6e33997f9d7 100644
--- a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/impl/GenericClient.java
+++ b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/impl/GenericClient.java
@@ -2206,28 +2206,15 @@ public class GenericClient extends BaseClient implements IGenericClient {
Validate.notNull(theResources, "theResources must not be null");
for (IBaseResource next : theResources) {
- String entryMethod = null;
- if (next instanceof IResource) {
- BundleEntryTransactionMethodEnum entryMethodEnum = ResourceMetadataKeyEnum.ENTRY_TRANSACTION_METHOD.get((IResource) next);
- if (entryMethodEnum != null) {
- entryMethod = entryMethodEnum.getCode();
- }
- } else {
- entryMethod = ResourceMetadataKeyEnum.ENTRY_TRANSACTION_METHOD.get((IAnyResource) next);
- }
+ BundleEntryTransactionMethodEnum entryMethod = ResourceMetadataKeyEnum.ENTRY_TRANSACTION_METHOD.get(next);
- if (isBlank(entryMethod)) {
+ if (entryMethod == null) {
if (isBlank(next.getIdElement().getValue())) {
- entryMethod = "POST";
+ entryMethod = BundleEntryTransactionMethodEnum.POST;
} else {
- entryMethod = "PUT";
+ entryMethod = BundleEntryTransactionMethodEnum.PUT;
}
- if (next instanceof IResource) {
- ResourceMetadataKeyEnum.ENTRY_TRANSACTION_METHOD.put((IResource) next, BundleEntryTransactionMethodEnum.valueOf(entryMethod));
- } else {
- ResourceMetadataKeyEnum.ENTRY_TRANSACTION_METHOD.put((IAnyResource) next, entryMethod);
- }
-
+ ResourceMetadataKeyEnum.ENTRY_TRANSACTION_METHOD.put(next, entryMethod);
}
}
@@ -2305,7 +2292,7 @@ public class GenericClient extends BaseClient implements IGenericClient {
OutcomeResponseHandler binding = new OutcomeResponseHandler(myPrefer);
- Map> params = new HashMap>();
+ Map> params = new HashMap<>();
return invoke(params, binding, invocation);
}
@@ -2362,7 +2349,7 @@ public class GenericClient extends BaseClient implements IGenericClient {
@Override
public MethodOutcome execute() {
BaseHttpClientInvocation invocation = ValidateMethodBindingDstu2Plus.createValidateInvocation(myContext, myResource);
- ResourceResponseHandler handler = new ResourceResponseHandler(null, null);
+ ResourceResponseHandler handler = new ResourceResponseHandler<>(null, null);
IBaseOperationOutcome outcome = invoke(null, handler, invocation);
MethodOutcome retVal = new MethodOutcome();
retVal.setOperationOutcome(outcome);
@@ -2486,7 +2473,7 @@ public class GenericClient extends BaseClient implements IGenericClient {
private static void addParam(Map> params, String parameterName, String parameterValue) {
if (!params.containsKey(parameterName)) {
- params.put(parameterName, new ArrayList());
+ params.put(parameterName, new ArrayList<>());
}
params.get(parameterName).add(parameterValue);
}
diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/JpaStorageResourceParser.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/JpaStorageResourceParser.java
index 438a6097290..45e53ec091a 100644
--- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/JpaStorageResourceParser.java
+++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/JpaStorageResourceParser.java
@@ -387,7 +387,7 @@ public class JpaStorageResourceParser implements IJpaStorageResourceParser {
retVal = (R) res;
ResourceMetadataKeyEnum.DELETED_AT.put(res, new InstantDt(theEntity.getDeleted()));
if (theForHistoryOperation) {
- ResourceMetadataKeyEnum.ENTRY_TRANSACTION_METHOD.put(res, Bundle.HTTPVerb.DELETE.toCode());
+ ResourceMetadataKeyEnum.ENTRY_TRANSACTION_METHOD.put(res, BundleEntryTransactionMethodEnum.DELETE);
}
} else if (theForHistoryOperation) {
/*
@@ -396,9 +396,9 @@ public class JpaStorageResourceParser implements IJpaStorageResourceParser {
Date published = theEntity.getPublished().getValue();
Date updated = theEntity.getUpdated().getValue();
if (published.equals(updated)) {
- ResourceMetadataKeyEnum.ENTRY_TRANSACTION_METHOD.put(res, Bundle.HTTPVerb.POST.toCode());
+ ResourceMetadataKeyEnum.ENTRY_TRANSACTION_METHOD.put(res, BundleEntryTransactionMethodEnum.POST);
} else {
- ResourceMetadataKeyEnum.ENTRY_TRANSACTION_METHOD.put(res, Bundle.HTTPVerb.PUT.toCode());
+ ResourceMetadataKeyEnum.ENTRY_TRANSACTION_METHOD.put(res, BundleEntryTransactionMethodEnum.PUT);
}
}
diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/PersistedJpaSearchFirstPageBundleProvider.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/PersistedJpaSearchFirstPageBundleProvider.java
index 64e83a343c9..f1d9be88b5c 100644
--- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/PersistedJpaSearchFirstPageBundleProvider.java
+++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/PersistedJpaSearchFirstPageBundleProvider.java
@@ -42,9 +42,9 @@ import java.util.stream.Collectors;
public class PersistedJpaSearchFirstPageBundleProvider extends PersistedJpaBundleProvider {
private static final Logger ourLog = LoggerFactory.getLogger(PersistedJpaSearchFirstPageBundleProvider.class);
- private SearchTask mySearchTask;
- private ISearchBuilder mySearchBuilder;
- private Search mySearch;
+ private final SearchTask mySearchTask;
+ private final ISearchBuilder mySearchBuilder;
+ private final Search mySearch;
/**
* Constructor
@@ -105,10 +105,7 @@ public class PersistedJpaSearchFirstPageBundleProvider extends PersistedJpaBundl
}
private boolean isInclude(IBaseResource theResource) {
- if (theResource instanceof IAnyResource) {
- return "include".equals(ResourceMetadataKeyEnum.ENTRY_SEARCH_MODE.get(((IAnyResource) theResource)));
- }
- BundleEntrySearchModeEnum searchMode = ResourceMetadataKeyEnum.ENTRY_SEARCH_MODE.get(((IResource) theResource));
+ BundleEntrySearchModeEnum searchMode = ResourceMetadataKeyEnum.ENTRY_SEARCH_MODE.get(theResource);
return BundleEntrySearchModeEnum.INCLUDE.equals(searchMode);
}
diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/SearchCoordinatorSvcImpl.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/SearchCoordinatorSvcImpl.java
index 64ef4870975..a828159b31e 100644
--- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/SearchCoordinatorSvcImpl.java
+++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/SearchCoordinatorSvcImpl.java
@@ -63,7 +63,6 @@ import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
import ca.uhn.fhir.rest.server.util.CompositeInterceptorBroadcaster;
import ca.uhn.fhir.rest.server.util.ISearchParamRegistry;
import ca.uhn.fhir.util.AsyncUtil;
-import ca.uhn.fhir.util.ICallable;
import ca.uhn.fhir.util.StopWatch;
import ca.uhn.fhir.util.UrlUtil;
import com.google.common.annotations.VisibleForTesting;
@@ -293,7 +292,9 @@ public class SearchCoordinatorSvcImpl implements ISearchCoordinatorSvc {
}
}
- AsyncUtil.sleep(500);
+ if (!search.getStatus().isDone()) {
+ AsyncUtil.sleep(500);
+ }
}
ourLog.trace("Finished looping");
@@ -444,7 +445,7 @@ public class SearchCoordinatorSvcImpl implements ISearchCoordinatorSvc {
* In case there is no running search, if the total is listed as accurate we know one is coming
* so let's wait a bit for it to show up
*/
- Optional search = myTxService.withRequest(theRequestDetails).execute(()->mySearchCacheSvc.fetchByUuid(theUuid));
+ Optional search = myTxService.withRequest(theRequestDetails).execute(() -> mySearchCacheSvc.fetchByUuid(theUuid));
if (search.isPresent()) {
Optional searchParameterMap = search.get().getSearchParameterMap();
if (searchParameterMap.isPresent() && searchParameterMap.get().getSearchTotalMode() == SearchTotalModeEnum.ACCURATE) {
diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/builder/SearchBuilder.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/builder/SearchBuilder.java
index eb2df93afc2..99bdfb5221e 100644
--- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/builder/SearchBuilder.java
+++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/builder/SearchBuilder.java
@@ -903,18 +903,10 @@ public class SearchBuilder implements ISearchBuilder {
continue;
}
- if (resource instanceof IResource) {
- if (theIncludedPids.contains(resourceId)) {
- ResourceMetadataKeyEnum.ENTRY_SEARCH_MODE.put((IResource) resource, BundleEntrySearchModeEnum.INCLUDE);
- } else {
- ResourceMetadataKeyEnum.ENTRY_SEARCH_MODE.put((IResource) resource, BundleEntrySearchModeEnum.MATCH);
- }
+ if (theIncludedPids.contains(resourceId)) {
+ ResourceMetadataKeyEnum.ENTRY_SEARCH_MODE.put(resource, BundleEntrySearchModeEnum.INCLUDE);
} else {
- if (theIncludedPids.contains(resourceId)) {
- ResourceMetadataKeyEnum.ENTRY_SEARCH_MODE.put((IAnyResource) resource, BundleEntrySearchModeEnum.INCLUDE.getCode());
- } else {
- ResourceMetadataKeyEnum.ENTRY_SEARCH_MODE.put((IAnyResource) resource, BundleEntrySearchModeEnum.MATCH.getCode());
- }
+ ResourceMetadataKeyEnum.ENTRY_SEARCH_MODE.put(resource, BundleEntrySearchModeEnum.MATCH);
}
theResourceListToPopulate.set(index, resource);
diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/util/AllowStatusChangeMetadata.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/util/AllowStatusChangeMetadata.java
deleted file mode 100644
index 17d3059cb97..00000000000
--- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/util/AllowStatusChangeMetadata.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package ca.uhn.fhir.jpa.util;
-
-/*-
- * #%L
- * HAPI FHIR JPA Server
- * %%
- * 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 ca.uhn.fhir.i18n.Msg;
-import ca.uhn.fhir.model.api.IResource;
-import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum;
-import ca.uhn.fhir.util.CoverageIgnore;
-
-final class AllowStatusChangeMetadata extends ResourceMetadataKeyEnum