From 1ba0ae396057cf5b6d42ab0f574db42580bfd52f Mon Sep 17 00:00:00 2001
From: James Agnew
Date: Tue, 23 Feb 2016 13:12:30 -0800
Subject: [PATCH 1/6] Support inline match URL references, per Simone's requast
for the next connectathon
---
.../ca/uhn/fhir/i18n/hapi-messages.properties | 3 +
.../ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java | 1071 +++++++++--------
.../java/ca/uhn/fhir/jpa/dao/DaoConfig.java | 26 +
.../uhn/fhir/jpa/dao/data/IForcedIdDao.java | 34 +
.../jpa/dao/dstu3/FhirSystemDaoDstu3.java | 2 +-
.../java/ca/uhn/fhir/jpa/entity/ForcedId.java | 3 +-
.../jpa/dao/dstu3/FhirSystemDaoDstu3Test.java | 104 +-
.../uhn/fhirtest/config/TestDstu2Config.java | 1 +
.../uhn/fhirtest/config/TestDstu3Config.java | 1 +
src/changes/changes.xml | 7 +
10 files changed, 733 insertions(+), 519 deletions(-)
create mode 100644 hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/data/IForcedIdDao.java
diff --git a/hapi-fhir-base/src/main/resources/ca/uhn/fhir/i18n/hapi-messages.properties b/hapi-fhir-base/src/main/resources/ca/uhn/fhir/i18n/hapi-messages.properties
index c8910c7f7b2..8e67b885236 100644
--- a/hapi-fhir-base/src/main/resources/ca/uhn/fhir/i18n/hapi-messages.properties
+++ b/hapi-fhir-base/src/main/resources/ca/uhn/fhir/i18n/hapi-messages.properties
@@ -43,6 +43,9 @@ ca.uhn.fhir.validation.ValidationResult.noIssuesDetected=No issues detected duri
# JPA Messages
ca.uhn.fhir.jpa.dao.BaseHapiFhirDao.incomingNoopInTransaction=Transaction contains resource with operation NOOP. This is only valid as a response operation, not in a request.
+ca.uhn.fhir.jpa.dao.BaseHapiFhirDao.invalidMatchUrlInvalidResourceType=Invalid match URL "{0}" - Unknown resource type: "{1}"
+ca.uhn.fhir.jpa.dao.BaseHapiFhirDao.invalidMatchUrlNoMatches=Invalid match URL "{0}" - No resources match this search
+ca.uhn.fhir.jpa.dao.BaseHapiFhirDao.invalidMatchUrlMultipleMatches=Invalid match URL "{0}" - Multiple resources match this search
ca.uhn.fhir.jpa.dao.BaseHapiFhirDao.transactionOperationWithMultipleMatchFailure=Failed to {0} resource with match URL "{1}" because this search matched {2} resources
ca.uhn.fhir.jpa.dao.BaseHapiFhirDao.transactionOperationFailedNoId=Failed to {0} resource in transaction because no ID was provided
ca.uhn.fhir.jpa.dao.BaseHapiFhirDao.transactionOperationFailedUnknownId=Failed to {0} resource in transaction because no resource could be found with ID {1}
diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java
index 5224012fed5..63dd5194e3f 100644
--- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java
+++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java
@@ -82,6 +82,7 @@ import ca.uhn.fhir.context.FhirVersionEnum;
import ca.uhn.fhir.context.RuntimeChildResourceDefinition;
import ca.uhn.fhir.context.RuntimeResourceDefinition;
import ca.uhn.fhir.context.RuntimeSearchParam;
+import ca.uhn.fhir.jpa.dao.data.IForcedIdDao;
import ca.uhn.fhir.jpa.dao.dstu3.SearchParamExtractorDstu3;
import ca.uhn.fhir.jpa.entity.BaseHasResource;
import ca.uhn.fhir.jpa.entity.BaseResourceIndexedSearchParam;
@@ -146,19 +147,27 @@ import ca.uhn.fhir.util.OperationOutcomeUtil;
public abstract class BaseHapiFhirDao implements IDao {
+ public static final long INDEX_STATUS_INDEXED = Long.valueOf(1L);
+ public static final long INDEX_STATUS_INDEXING_FAILED = Long.valueOf(2L);
+ public static final String NS_JPA_PROFILE = "https://github.com/jamesagnew/hapi-fhir/ns/jpa/profile";
+
public static final String OO_SEVERITY_ERROR = "error";
public static final String OO_SEVERITY_INFO = "information";
+
public static final String OO_SEVERITY_WARN = "warning";
- /**
- * These are parameters which are supported by {@link BaseHapiFhirResourceDao#searchForIds(Map)}
- */
- static final Map> RESOURCE_META_PARAMS;
+ private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BaseHapiFhirDao.class);
+ private static final Map ourRetrievalContexts = new HashMap();
/**
* These are parameters which are supported by {@link BaseHapiFhirResourceDao#searchForIds(Map)}
*/
static final Map>> RESOURCE_META_AND_PARAMS;
+ /**
+ * These are parameters which are supported by {@link BaseHapiFhirResourceDao#searchForIds(Map)}
+ */
+ static final Map> RESOURCE_META_PARAMS;
+ public static final String UCUM_NS = "http://unitsofmeasure.org";
static {
Map> resourceMetaParams = new HashMap>();
Map>> resourceMetaAndParams = new HashMap>>();
@@ -176,14 +185,6 @@ public abstract class BaseHapiFhirDao implements IDao {
RESOURCE_META_AND_PARAMS = Collections.unmodifiableMap(resourceMetaAndParams);
}
- public static final long INDEX_STATUS_INDEXED = Long.valueOf(1L);
- public static final long INDEX_STATUS_INDEXING_FAILED = Long.valueOf(2L);
- public static final String NS_JPA_PROFILE = "https://github.com/jamesagnew/hapi-fhir/ns/jpa/profile";
- private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BaseHapiFhirDao.class);
-
- private static final Map ourRetrievalContexts = new HashMap();
- public static final String UCUM_NS = "http://unitsofmeasure.org";
-
@Autowired(required = true)
private DaoConfig myConfig;
@@ -193,6 +194,9 @@ public abstract class BaseHapiFhirDao implements IDao {
@PersistenceContext(type = PersistenceContextType.TRANSACTION)
protected EntityManager myEntityManager;
+ @Autowired
+ private IForcedIdDao myForcedIdDao;
+
@Autowired
private PlatformTransactionManager myPlatformTransactionManager;
@@ -221,23 +225,6 @@ public abstract class BaseHapiFhirDao implements IDao {
return InstantDt.withCurrentTime();
}
- public void setConfig(DaoConfig theConfig) {
- myConfig = theConfig;
- }
-
- public void setEntityManager(EntityManager theEntityManager) {
- myEntityManager = theEntityManager;
- }
-
- public void setPlatformTransactionManager(PlatformTransactionManager thePlatformTransactionManager) {
- myPlatformTransactionManager = thePlatformTransactionManager;
- }
-
- // @Override
- // public void setResourceDaos(List> theResourceDaos) {
- // myResourceDaos = theResourceDaos;
- // }
-
protected Set extractResourceLinks(ResourceTable theEntity, IBaseResource theResource) {
Set retVal = new HashSet();
@@ -376,6 +363,15 @@ public abstract class BaseHapiFhirDao implements IDao {
return retVal;
}
+ protected Set extractSearchParamCoords(ResourceTable theEntity, IBaseResource theResource) {
+ return mySearchParamExtractor.extractSearchParamCoords(theEntity, theResource);
+ }
+
+ // @Override
+ // public void setResourceDaos(List> theResourceDaos) {
+ // myResourceDaos = theResourceDaos;
+ // }
+
protected Set extractSearchParamDates(ResourceTable theEntity, IBaseResource theResource) {
return mySearchParamExtractor.extractSearchParamDates(theEntity, theResource);
}
@@ -384,14 +380,6 @@ public abstract class BaseHapiFhirDao implements IDao {
return mySearchParamExtractor.extractSearchParamNumber(theEntity, theResource);
}
- protected Set extractSearchParamUri(ResourceTable theEntity, IBaseResource theResource) {
- return mySearchParamExtractor.extractSearchParamUri(theEntity, theResource);
- }
-
- protected Set extractSearchParamCoords(ResourceTable theEntity, IBaseResource theResource) {
- return mySearchParamExtractor.extractSearchParamCoords(theEntity, theResource);
- }
-
protected Set extractSearchParamQuantity(ResourceTable theEntity, IBaseResource theResource) {
return mySearchParamExtractor.extractSearchParamQuantity(theEntity, theResource);
}
@@ -404,6 +392,74 @@ public abstract class BaseHapiFhirDao implements IDao {
return mySearchParamExtractor.extractSearchParamTokens(theEntity, theResource);
}
+ protected Set extractSearchParamUri(ResourceTable theEntity, IBaseResource theResource) {
+ return mySearchParamExtractor.extractSearchParamUri(theEntity, theResource);
+ }
+
+ private void extractTagsHapi(IResource theResource, ResourceTable theEntity, Set allDefs) {
+ TagList tagList = ResourceMetadataKeyEnum.TAG_LIST.get(theResource);
+ if (tagList != null) {
+ for (Tag next : tagList) {
+ TagDefinition tag = getTag(TagTypeEnum.TAG, next.getScheme(), next.getTerm(), next.getLabel());
+ allDefs.add(tag);
+ theEntity.addTag(tag);
+ theEntity.setHasTags(true);
+ }
+ }
+
+ List securityLabels = ResourceMetadataKeyEnum.SECURITY_LABELS.get(theResource);
+ if (securityLabels != null) {
+ for (BaseCodingDt next : securityLabels) {
+ TagDefinition tag = getTag(TagTypeEnum.SECURITY_LABEL, next.getSystemElement().getValue(), next.getCodeElement().getValue(), next.getDisplayElement().getValue());
+ allDefs.add(tag);
+ theEntity.addTag(tag);
+ theEntity.setHasTags(true);
+ }
+ }
+
+ List profiles = ResourceMetadataKeyEnum.PROFILES.get(theResource);
+ if (profiles != null) {
+ for (IIdType next : profiles) {
+ TagDefinition tag = getTag(TagTypeEnum.PROFILE, NS_JPA_PROFILE, next.getValue(), null);
+ allDefs.add(tag);
+ theEntity.addTag(tag);
+ theEntity.setHasTags(true);
+ }
+ }
+ }
+
+ private void extractTagsRi(IAnyResource theResource, ResourceTable theEntity, Set allDefs) {
+ List extends IBaseCoding> tagList = theResource.getMeta().getTag();
+ if (tagList != null) {
+ for (IBaseCoding next : tagList) {
+ TagDefinition tag = getTag(TagTypeEnum.TAG, next.getSystem(), next.getCode(), next.getDisplay());
+ allDefs.add(tag);
+ theEntity.addTag(tag);
+ theEntity.setHasTags(true);
+ }
+ }
+
+ List extends IBaseCoding> securityLabels = theResource.getMeta().getSecurity();
+ if (securityLabels != null) {
+ for (IBaseCoding next : securityLabels) {
+ TagDefinition tag = getTag(TagTypeEnum.SECURITY_LABEL, next.getSystem(), next.getCode(), next.getDisplay());
+ allDefs.add(tag);
+ theEntity.addTag(tag);
+ theEntity.setHasTags(true);
+ }
+ }
+
+ List extends IPrimitiveType> profiles = theResource.getMeta().getProfile();
+ if (profiles != null) {
+ for (IPrimitiveType next : profiles) {
+ TagDefinition tag = getTag(TagTypeEnum.PROFILE, NS_JPA_PROFILE, next.getValue(), null);
+ allDefs.add(tag);
+ theEntity.addTag(tag);
+ theEntity.setHasTags(true);
+ }
+ }
+ }
+
private List
In addition, the method may optionally have a parameter annotated with the
@@ -316,8 +317,9 @@
Create methods must be annotated with the
@Create
annotation, and have a single parameter annotated with the
- @Resource
+ @ResourceParam
annotation. This parameter contains the resource instance to be created.
+ See the @ResourceParam for information on the types allowed for this parameter (resource types, String, byte[]).
Create methods must return an object of type
@@ -1104,7 +1106,7 @@
Validate methods must be annotated with the
@Validate
annotation, and have a parameter annotated with the
- @Resource
+ @ResourceParam
annotation. This parameter contains the resource instance to be created.
From 39f6420066f9ead73ea5c7e924398f1cc64af45c Mon Sep 17 00:00:00 2001
From: James Agnew
Date: Fri, 26 Feb 2016 18:16:35 -0500
Subject: [PATCH 5/6] Start working on compartment support
---
.../ca/uhn/fhir/context/ModelScanner.java | 163 +++++++-----------
.../uhn/fhir/context/RuntimeSearchParam.java | 31 +++-
.../model/api/annotation/Compartment.java | 19 ++
.../model/api/annotation/Compartments.java | 14 ++
.../java/ca/uhn/fhir/jpa/dao/DaoConfig.java | 70 +++++---
.../ResourceIndexedSearchParamCoords.java | 6 +-
.../ca/uhn/fhir/jpa/entity/ResourceTable.java | 26 ++-
.../fhir/jpa/dao/dstu3/BaseJpaDstu3Test.java | 5 +-
.../FhirResourceDaoDstu3ContainedTest.java | 58 +++++++
.../FhirResourceDaoDstu3SearchFtTest.java | 9 +-
.../FhirResourceDaoDstu3SearchNoFtTest.java | 64 ++++---
.../fhir/tinder/CompartmentGeneratorMojo.java | 35 ----
.../uhn/fhir/tinder/TinderStructuresMojo.java | 2 +-
.../ca/uhn/fhir/tinder/model/Resource.java | 19 ++
.../fhir/tinder/model/SearchParameter.java | 10 +-
.../BaseStructureSpreadsheetParser.java | 3 +-
.../fhir/tinder/parser/CompartmentParser.java | 74 +++++++-
.../DatatypeGeneratorUsingSpreadsheet.java | 2 +-
.../ResourceGeneratorUsingSpreadsheet.java | 11 +-
.../src/main/resources/vm/resource.vm | 7 +
20 files changed, 410 insertions(+), 218 deletions(-)
create mode 100644 hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/annotation/Compartment.java
create mode 100644 hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/annotation/Compartments.java
create mode 100644 hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3ContainedTest.java
delete mode 100644 hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/CompartmentGeneratorMojo.java
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/ModelScanner.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/ModelScanner.java
index af51741bc5d..0ee3f9ae573 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/ModelScanner.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/ModelScanner.java
@@ -70,6 +70,8 @@ import ca.uhn.fhir.model.api.IResourceBlock;
import ca.uhn.fhir.model.api.IValueSetEnumBinder;
import ca.uhn.fhir.model.api.annotation.Block;
import ca.uhn.fhir.model.api.annotation.Child;
+import ca.uhn.fhir.model.api.annotation.Compartment;
+import ca.uhn.fhir.model.api.annotation.Compartments;
import ca.uhn.fhir.model.api.annotation.DatatypeDef;
import ca.uhn.fhir.model.api.annotation.Description;
import ca.uhn.fhir.model.api.annotation.Extension;
@@ -87,7 +89,6 @@ import ca.uhn.fhir.util.ReflectionUtil;
class ModelScanner {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ModelScanner.class);
- private final Map, Class extends Annotation>> myAnnotationForwards = new HashMap, Class extends Annotation>>();
private Map, BaseRuntimeElementDefinition>> myClassToElementDefinitions = new HashMap, BaseRuntimeElementDefinition>>();
private FhirContext myContext;
private Map myIdToResourceDefinition = new HashMap();
@@ -101,7 +102,8 @@ class ModelScanner {
private Set> myVersionTypes;
- ModelScanner(FhirContext theContext, FhirVersionEnum theVersion, Map, BaseRuntimeElementDefinition>> theExistingDefinitions, Collection> theResourceTypes) throws ConfigurationException {
+ ModelScanner(FhirContext theContext, FhirVersionEnum theVersion, Map, BaseRuntimeElementDefinition>> theExistingDefinitions,
+ Collection> theResourceTypes) throws ConfigurationException {
myContext = theContext;
myVersion = theVersion;
Set> toScan;
@@ -189,7 +191,7 @@ class ModelScanner {
Map> resourceTypes = myNameToResourceType;
myVersionTypes = scanVersionPropertyFile(theDatatypes, resourceTypes, myVersion);
-
+
// toScan.add(DateDt.class);
// toScan.add(CodeDt.class);
// toScan.add(DecimalDt.class);
@@ -233,68 +235,13 @@ class ModelScanner {
}
/**
- * There are two implementations of all of the annotations (e.g. {@link Child} and
- * {@link org.hl7.fhir.instance.model.annotations.Child}) since the HL7.org ones will eventually replace the HAPI
- * ones. Annotations can't extend each other or implement interfaces or anything like that, so rather than duplicate
- * all of the annotation processing code this method just creates an interface Proxy to simulate the HAPI
- * annotations if the HL7.org ones are found instead.
+ * There are two implementations of all of the annotations (e.g. {@link Child} and {@link org.hl7.fhir.instance.model.annotations.Child}) since the HL7.org ones will eventually replace the HAPI
+ * ones. Annotations can't extend each other or implement interfaces or anything like that, so rather than duplicate all of the annotation processing code this method just creates an interface
+ * Proxy to simulate the HAPI annotations if the HL7.org ones are found instead.
*/
- @SuppressWarnings("unchecked")
- private T pullAnnotation(Class> theContainer, AnnotatedElement theTarget, Class theAnnotationType) {
-
+ private T pullAnnotation(AnnotatedElement theTarget, Class theAnnotationType) {
T retVal = theTarget.getAnnotation(theAnnotationType);
-// if (myContext.getVersion().getVersion() != FhirVersionEnum.DSTU2_HL7ORG) {
- return retVal;
-// }
-//
-// if (retVal == null) {
-// final Class extends Annotation> altAnnotationClass;
-// /*
-// * Use a cache to minimize Class.forName calls, since they are slow and expensive..
-// */
-// if (myAnnotationForwards.containsKey(theAnnotationType) == false) {
-// String sourceClassName = theAnnotationType.getName();
-// String candidateAltClassName = sourceClassName.replace("ca.uhn.fhir.model.api.annotation", "org.hl7.fhir.instance.model.annotations");
-// if (!sourceClassName.equals(candidateAltClassName)) {
-// Class> forName;
-// try {
-// forName = Class.forName(candidateAltClassName);
-// ourLog.debug("Forwarding annotation request for [{}] to class [{}]", theAnnotationType, forName);
-// } catch (ClassNotFoundException e) {
-// forName = null;
-// }
-// altAnnotationClass = (Class extends Annotation>) forName;
-// } else {
-// altAnnotationClass = null;
-// }
-// myAnnotationForwards.put(theAnnotationType, altAnnotationClass);
-// } else {
-// altAnnotationClass = myAnnotationForwards.get(theAnnotationType);
-// }
-//
-// if (altAnnotationClass == null) {
-// return null;
-// }
-//
-// final Annotation altAnnotation;
-// altAnnotation = theTarget.getAnnotation(altAnnotationClass);
-// if (altAnnotation == null) {
-// return null;
-// }
-//
-// InvocationHandler h = new InvocationHandler() {
-//
-// @Override
-// public Object invoke(Object theProxy, Method theMethod, Object[] theArgs) throws Throwable {
-// Method altMethod = altAnnotationClass.getMethod(theMethod.getName(), theMethod.getParameterTypes());
-// return altMethod.invoke(altAnnotation, theArgs);
-// }
-// };
-// retVal = (T) Proxy.newProxyInstance(theAnnotationType.getClassLoader(), new Class>[] { theAnnotationType }, h);
-//
-// }
-//
-// return retVal;
+ return retVal;
}
private void scan(Class extends IBase> theClass) throws ConfigurationException {
@@ -303,17 +250,18 @@ class ModelScanner {
return;
}
- ResourceDef resourceDefinition = pullAnnotation(theClass, theClass, ResourceDef.class);
+ ResourceDef resourceDefinition = pullAnnotation(theClass, ResourceDef.class);
if (resourceDefinition != null) {
if (!IBaseResource.class.isAssignableFrom(theClass)) {
- throw new ConfigurationException("Resource type contains a @" + ResourceDef.class.getSimpleName() + " annotation but does not implement " + IResource.class.getCanonicalName() + ": " + theClass.getCanonicalName());
+ throw new ConfigurationException(
+ "Resource type contains a @" + ResourceDef.class.getSimpleName() + " annotation but does not implement " + IResource.class.getCanonicalName() + ": " + theClass.getCanonicalName());
}
@SuppressWarnings("unchecked")
Class extends IBaseResource> resClass = (Class extends IBaseResource>) theClass;
scanResource(resClass, resourceDefinition);
}
- DatatypeDef datatypeDefinition = pullAnnotation(theClass, theClass, DatatypeDef.class);
+ DatatypeDef datatypeDefinition = pullAnnotation(theClass, DatatypeDef.class);
if (datatypeDefinition != null) {
if (ICompositeType.class.isAssignableFrom(theClass)) {
@SuppressWarnings("unchecked")
@@ -325,17 +273,19 @@ class ModelScanner {
scanPrimitiveDatatype(resClass, datatypeDefinition);
} else {
return;
-// throw new ConfigurationException("Resource type contains a @" + DatatypeDef.class.getSimpleName() + " annotation but does not implement " + IDatatype.class.getCanonicalName() + ": " + theClass.getCanonicalName());
+ // throw new ConfigurationException("Resource type contains a @" + DatatypeDef.class.getSimpleName() + " annotation but does not implement " + IDatatype.class.getCanonicalName() + ": " +
+ // theClass.getCanonicalName());
}
}
- Block blockDefinition = pullAnnotation(theClass, theClass, Block.class);
+ Block blockDefinition = pullAnnotation(theClass, Block.class);
if (blockDefinition != null) {
if (IResourceBlock.class.isAssignableFrom(theClass) || IBaseBackboneElement.class.isAssignableFrom(theClass) || IBaseDatatypeElement.class.isAssignableFrom(theClass)) {
scanBlock(theClass);
} else {
- throw new ConfigurationException("Type contains a @" + Block.class.getSimpleName() + " annotation but does not implement " + IResourceBlock.class.getCanonicalName() + ": " + theClass.getCanonicalName());
+ throw new ConfigurationException(
+ "Type contains a @" + Block.class.getSimpleName() + " annotation but does not implement " + IResourceBlock.class.getCanonicalName() + ": " + theClass.getCanonicalName());
}
}
@@ -364,8 +314,8 @@ class ModelScanner {
RuntimeCompositeDatatypeDefinition resourceDef;
if (theClass.equals(ExtensionDt.class)) {
resourceDef = new RuntimeExtensionDtDefinition(theDatatypeDefinition, theClass, true);
-// } else if (IBaseMetaType.class.isAssignableFrom(theClass)) {
-// resourceDef = new RuntimeMetaDefinition(theDatatypeDefinition, theClass, isStandardType(theClass));
+ // } else if (IBaseMetaType.class.isAssignableFrom(theClass)) {
+ // resourceDef = new RuntimeMetaDefinition(theDatatypeDefinition, theClass, isStandardType(theClass));
} else {
resourceDef = new RuntimeCompositeDatatypeDefinition(theDatatypeDefinition, theClass, isStandardType(theClass));
}
@@ -429,7 +379,8 @@ class ModelScanner {
}
@SuppressWarnings("unchecked")
- private void scanCompositeElementForChildren(Class extends IBase> theClass, Set elementNames, TreeMap theOrderToElementDef, TreeMap theOrderToExtensionDef) {
+ private void scanCompositeElementForChildren(Class extends IBase> theClass, Set elementNames, TreeMap theOrderToElementDef,
+ TreeMap theOrderToExtensionDef) {
int baseElementOrder = theOrderToElementDef.isEmpty() ? 0 : theOrderToElementDef.lastEntry().getKey() + 1;
for (Field next : theClass.getDeclaredFields()) {
@@ -439,16 +390,16 @@ class ModelScanner {
continue;
}
- Child childAnnotation = pullAnnotation(theClass, next, Child.class);
+ Child childAnnotation = pullAnnotation(next, Child.class);
if (childAnnotation == null) {
ourLog.trace("Ignoring non @Child field {} on target type {}", next.getName(), theClass);
continue;
}
- Description descriptionAnnotation = pullAnnotation(theClass, next, Description.class);
+ Description descriptionAnnotation = pullAnnotation(next, Description.class);
TreeMap orderMap = theOrderToElementDef;
- Extension extensionAttr = pullAnnotation(theClass, next, Extension.class);
+ Extension extensionAttr = pullAnnotation(next, Extension.class);
if (extensionAttr != null) {
orderMap = theOrderToExtensionDef;
}
@@ -471,8 +422,8 @@ class ModelScanner {
}
}
if (order == Child.REPLACE_PARENT) {
- throw new ConfigurationException("Field " + next.getName() + "' on target type " + theClass.getSimpleName() + " has order() of REPLACE_PARENT (" + Child.REPLACE_PARENT + ") but no parent element with extension URL " + extensionAttr.url() + " could be found on type "
- + next.getDeclaringClass().getSimpleName());
+ throw new ConfigurationException("Field " + next.getName() + "' on target type " + theClass.getSimpleName() + " has order() of REPLACE_PARENT (" + Child.REPLACE_PARENT
+ + ") but no parent element with extension URL " + extensionAttr.url() + " could be found on type " + next.getDeclaringClass().getSimpleName());
}
} else {
@@ -487,8 +438,8 @@ class ModelScanner {
}
}
if (order == Child.REPLACE_PARENT) {
- throw new ConfigurationException("Field " + next.getName() + "' on target type " + theClass.getSimpleName() + " has order() of REPLACE_PARENT (" + Child.REPLACE_PARENT + ") but no parent element with name " + elementName + " could be found on type "
- + next.getDeclaringClass().getSimpleName());
+ throw new ConfigurationException("Field " + next.getName() + "' on target type " + theClass.getSimpleName() + " has order() of REPLACE_PARENT (" + Child.REPLACE_PARENT
+ + ") but no parent element with name " + elementName + " could be found on type " + next.getDeclaringClass().getSimpleName());
}
}
@@ -504,8 +455,7 @@ class ModelScanner {
// int max = childAnnotation.max();
/*
- * Anything that's marked as unknown is given a new ID that is <0 so that it doesn't conflict with any given
- * IDs and can be figured out later
+ * Anything that's marked as unknown is given a new ID that is <0 so that it doesn't conflict with any given IDs and can be figured out later
*/
if (order == Child.ORDER_UNKNOWN) {
order = Integer.MIN_VALUE;
@@ -572,7 +522,8 @@ class ModelScanner {
binder = getBoundCodeBinder(next);
}
- RuntimeChildDeclaredExtensionDefinition def = new RuntimeChildDeclaredExtensionDefinition(next, childAnnotation, descriptionAnnotation, extensionAttr, elementName, extensionAttr.url(), et, binder);
+ RuntimeChildDeclaredExtensionDefinition def = new RuntimeChildDeclaredExtensionDefinition(next, childAnnotation, descriptionAnnotation, extensionAttr, elementName, extensionAttr.url(), et,
+ binder);
if (IBaseEnumeration.class.isAssignableFrom(nextElementType)) {
def.setEnumerationType(ReflectionUtil.getGenericCollectionTypeOfFieldWithSecondOrderForList(next));
@@ -589,7 +540,8 @@ class ModelScanner {
List> refTypesList = new ArrayList>();
for (Class extends IElement> nextType : childAnnotation.type()) {
if (IBaseResource.class.isAssignableFrom(nextType) == false) {
- throw new ConfigurationException("Field '" + next.getName() + "' in class '" + next.getDeclaringClass().getCanonicalName() + "' is of type " + BaseResourceReferenceDt.class + " but contains a non-resource type: " + nextType.getCanonicalName());
+ throw new ConfigurationException("Field '" + next.getName() + "' in class '" + next.getDeclaringClass().getCanonicalName() + "' is of type " + BaseResourceReferenceDt.class
+ + " but contains a non-resource type: " + nextType.getCanonicalName());
}
refTypesList.add((Class extends IBaseResource>) nextType);
addScanAlso(nextType);
@@ -597,10 +549,10 @@ class ModelScanner {
RuntimeChildResourceDefinition def = new RuntimeChildResourceDefinition(next, elementName, childAnnotation, descriptionAnnotation, refTypesList);
orderMap.put(order, def);
- } else if (IResourceBlock.class.isAssignableFrom(nextElementType) || IBaseBackboneElement.class.isAssignableFrom(nextElementType) || IBaseDatatypeElement.class.isAssignableFrom(nextElementType)) {
+ } else if (IResourceBlock.class.isAssignableFrom(nextElementType) || IBaseBackboneElement.class.isAssignableFrom(nextElementType)
+ || IBaseDatatypeElement.class.isAssignableFrom(nextElementType)) {
/*
- * Child is a resource block (i.e. a sub-tag within a resource) TODO: do these have a better name
- * according to HL7?
+ * Child is a resource block (i.e. a sub-tag within a resource) TODO: do these have a better name according to HL7?
*/
Class extends IBase> blockDef = (Class extends IBase>) nextElementType;
@@ -608,13 +560,14 @@ class ModelScanner {
RuntimeChildResourceBlockDefinition def = new RuntimeChildResourceBlockDefinition(next, childAnnotation, descriptionAnnotation, elementName, blockDef);
orderMap.put(order, def);
- } else if (IDatatype.class.equals(nextElementType) || IElement.class.equals(nextElementType) || "Type".equals(nextElementType.getSimpleName()) || IBaseDatatype.class.equals(nextElementType)) {
+ } else if (IDatatype.class.equals(nextElementType) || IElement.class.equals(nextElementType) || "Type".equals(nextElementType.getSimpleName())
+ || IBaseDatatype.class.equals(nextElementType)) {
RuntimeChildAny def = new RuntimeChildAny(next, elementName, childAnnotation, descriptionAnnotation);
orderMap.put(order, def);
- } else if (IDatatype.class.isAssignableFrom(nextElementType) || IPrimitiveType.class.isAssignableFrom(nextElementType) || ICompositeType.class.isAssignableFrom(nextElementType) || IBaseDatatype.class.isAssignableFrom(nextElementType)
- || IBaseExtension.class.isAssignableFrom(nextElementType)) {
+ } else if (IDatatype.class.isAssignableFrom(nextElementType) || IPrimitiveType.class.isAssignableFrom(nextElementType) || ICompositeType.class.isAssignableFrom(nextElementType)
+ || IBaseDatatype.class.isAssignableFrom(nextElementType) || IBaseExtension.class.isAssignableFrom(nextElementType)) {
Class extends IBase> nextDatatype = (Class extends IBase>) nextElementType;
addScanAlso(nextDatatype);
@@ -642,10 +595,11 @@ class ModelScanner {
}
}
- CodeableConceptElement concept = pullAnnotation(theClass, next, CodeableConceptElement.class);
+ CodeableConceptElement concept = pullAnnotation(next, CodeableConceptElement.class);
if (concept != null) {
if (!ICodedDatatype.class.isAssignableFrom(nextDatatype)) {
- throw new ConfigurationException("Field '" + elementName + "' in type '" + theClass.getCanonicalName() + "' is marked as @" + CodeableConceptElement.class.getCanonicalName() + " but type is not a subtype of " + ICodedDatatype.class.getName());
+ throw new ConfigurationException("Field '" + elementName + "' in type '" + theClass.getCanonicalName() + "' is marked as @" + CodeableConceptElement.class.getCanonicalName()
+ + " but type is not a subtype of " + ICodedDatatype.class.getName());
} else {
Class extends ICodeEnum> type = concept.type();
myScanAlsoCodeTable.add(type);
@@ -708,21 +662,23 @@ class ModelScanner {
Class> parent = theClass.getSuperclass();
primaryNameProvider = false;
while (parent.equals(Object.class) == false && isBlank(resourceName)) {
- ResourceDef nextDef = pullAnnotation(theClass, parent, ResourceDef.class);
+ ResourceDef nextDef = pullAnnotation(parent, ResourceDef.class);
if (nextDef != null) {
resourceName = nextDef.name();
}
parent = parent.getSuperclass();
}
if (isBlank(resourceName)) {
- throw new ConfigurationException("Resource type @" + ResourceDef.class.getSimpleName() + " annotation contains no resource name(): " + theClass.getCanonicalName() + " - This is only allowed for types that extend other resource types ");
+ throw new ConfigurationException("Resource type @" + ResourceDef.class.getSimpleName() + " annotation contains no resource name(): " + theClass.getCanonicalName()
+ + " - This is only allowed for types that extend other resource types ");
}
}
String resourceId = resourceDefinition.id();
if (!isBlank(resourceId)) {
if (myIdToResourceDefinition.containsKey(resourceId)) {
- throw new ConfigurationException("The following resource types have the same ID of '" + resourceId + "' - " + theClass.getCanonicalName() + " and " + myIdToResourceDefinition.get(resourceId).getImplementingClass().getCanonicalName());
+ throw new ConfigurationException("The following resource types have the same ID of '" + resourceId + "' - " + theClass.getCanonicalName() + " and "
+ + myIdToResourceDefinition.get(resourceId).getImplementingClass().getCanonicalName());
}
}
@@ -748,7 +704,7 @@ class ModelScanner {
Map compositeFields = new LinkedHashMap();
for (Field nextField : theClass.getFields()) {
- SearchParamDefinition searchParam = pullAnnotation(theClass, nextField, SearchParamDefinition.class);
+ SearchParamDefinition searchParam = pullAnnotation(nextField, SearchParamDefinition.class);
if (searchParam != null) {
RestSearchParameterTypeEnum paramType = RestSearchParameterTypeEnum.valueOf(searchParam.type().toUpperCase());
if (paramType == null) {
@@ -758,7 +714,17 @@ class ModelScanner {
compositeFields.put(nextField, searchParam);
continue;
}
- RuntimeSearchParam param = new RuntimeSearchParam(searchParam.name(), searchParam.description(), searchParam.path(), paramType);
+
+ Set providesMembershipInCompartments = null;
+ Compartments compartmentsAnnotation = pullAnnotation(nextField, Compartments.class);
+ if (compartmentsAnnotation != null) {
+ providesMembershipInCompartments = new HashSet();
+ for (Compartment next : compartmentsAnnotation.providesMembershipIn()) {
+ providesMembershipInCompartments.add(next.name());
+ }
+ }
+
+ RuntimeSearchParam param = new RuntimeSearchParam(searchParam.name(), searchParam.description(), searchParam.path(), paramType, providesMembershipInCompartments);
theResourceDef.addSearchParam(param);
nameToParam.put(param.getName(), param);
}
@@ -771,13 +737,14 @@ class ModelScanner {
for (String nextName : searchParam.compositeOf()) {
RuntimeSearchParam param = nameToParam.get(nextName);
if (param == null) {
- ourLog.warn("Search parameter {}.{} declares that it is a composite with compositeOf value '{}' but that is not a valid parametr name itself. Valid values are: {}", new Object[] { theResourceDef.getName(), searchParam.name(), nextName, nameToParam.keySet() });
+ ourLog.warn("Search parameter {}.{} declares that it is a composite with compositeOf value '{}' but that is not a valid parametr name itself. Valid values are: {}",
+ new Object[] { theResourceDef.getName(), searchParam.name(), nextName, nameToParam.keySet() });
continue;
}
compositeOf.add(param);
}
- RuntimeSearchParam param = new RuntimeSearchParam(searchParam.name(), searchParam.description(), searchParam.path(), RestSearchParameterTypeEnum.COMPOSITE, compositeOf);
+ RuntimeSearchParam param = new RuntimeSearchParam(searchParam.name(), searchParam.description(), searchParam.path(), RestSearchParameterTypeEnum.COMPOSITE, compositeOf, null);
theResourceDef.addSearchParam(param);
}
}
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeSearchParam.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeSearchParam.java
index e7eb498daa8..c8ccc62ae68 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeSearchParam.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeSearchParam.java
@@ -3,6 +3,7 @@ package ca.uhn.fhir.context;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import java.util.Set;
import java.util.StringTokenizer;
import ca.uhn.fhir.rest.method.RestSearchParameterTypeEnum;
@@ -29,23 +30,30 @@ import ca.uhn.fhir.rest.method.RestSearchParameterTypeEnum;
public class RuntimeSearchParam {
+ private List myCompositeOf;
private String myDescription;
private String myName;
private RestSearchParameterTypeEnum myParamType;
private String myPath;
- private List myCompositeOf;
+ private Set myProvidesMembershipInCompartments;
- public RuntimeSearchParam(String theName, String theDescription, String thePath, RestSearchParameterTypeEnum theParamType) {
- this(theName, theDescription, thePath, theParamType, null);
- }
-
- public RuntimeSearchParam(String theName, String theDescription, String thePath, RestSearchParameterTypeEnum theParamType, List theCompositeOf) {
+ public RuntimeSearchParam(String theName, String theDescription, String thePath, RestSearchParameterTypeEnum theParamType, List theCompositeOf,
+ Set theProvidesMembershipInCompartments) {
super();
myName = theName;
myDescription = theDescription;
myPath = thePath;
myParamType = theParamType;
myCompositeOf = theCompositeOf;
+ if (theProvidesMembershipInCompartments != null && !theProvidesMembershipInCompartments.isEmpty()) {
+ myProvidesMembershipInCompartments = Collections.unmodifiableSet(theProvidesMembershipInCompartments);
+ } else {
+ myProvidesMembershipInCompartments = null;
+ }
+ }
+
+ public RuntimeSearchParam(String theName, String theDescription, String thePath, RestSearchParameterTypeEnum theParamType, Set theProvidesMembershipInCompartments) {
+ this(theName, theDescription, thePath, theParamType, null, theProvidesMembershipInCompartments);
}
public List getCompositeOf() {
@@ -70,10 +78,10 @@ public class RuntimeSearchParam {
public List getPathsSplit() {
String path = getPath();
- if (path.indexOf('|')==-1) {
+ if (path.indexOf('|') == -1) {
return Collections.singletonList(path);
}
-
+
List retVal = new ArrayList();
StringTokenizer tok = new StringTokenizer(path, "|");
while (tok.hasMoreElements()) {
@@ -83,4 +91,11 @@ public class RuntimeSearchParam {
return retVal;
}
+ /**
+ * Can return null
+ */
+ public Set getProvidesMembershipInCompartments() {
+ return myProvidesMembershipInCompartments;
+ }
+
}
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/annotation/Compartment.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/annotation/Compartment.java
new file mode 100644
index 00000000000..3a8df120949
--- /dev/null
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/annotation/Compartment.java
@@ -0,0 +1,19 @@
+package ca.uhn.fhir.model.api.annotation;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(value= {})
+public @interface Compartment {
+
+ /**
+ * This may only be populated on a reference field. On such a field, places the containing
+ * resource in a compartment with the name(s) specified by the given strings, where the compartment
+ * belongs to the target resource. For example, this field could be populated with Patient on
+ * the Observation.subject field.
+ */
+ String name();
+
+}
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/annotation/Compartments.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/annotation/Compartments.java
new file mode 100644
index 00000000000..826b6f95321
--- /dev/null
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/annotation/Compartments.java
@@ -0,0 +1,14 @@
+package ca.uhn.fhir.model.api.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(value= {ElementType.FIELD})
+public @interface Compartments {
+
+ Compartment[] providesMembershipIn();
+
+}
diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/DaoConfig.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/DaoConfig.java
index bc55967eb8d..126fc47f0fb 100644
--- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/DaoConfig.java
+++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/DaoConfig.java
@@ -38,54 +38,35 @@ public class DaoConfig {
// update setter javadoc if default changes
// ***
private boolean myAllowInlineMatchUrlReferences = false;
-
- /**
- * @see #setAllowInlineMatchUrlReferences(boolean)
- */
- public boolean isAllowInlineMatchUrlReferences() {
- return myAllowInlineMatchUrlReferences;
- }
- /**
- * Should references containing match URLs be resolved and replaced in create and update operations. For
- * example, if this property is set to true and a resource is created containing a reference
- * to "Patient?identifier=12345", this is reference match URL will be resolved and replaced according
- * to the usual match URL rules.
- *
- * Default is false for now, as this is an experimental feature.
- *
- * @since 1.5
- */
- public void setAllowInlineMatchUrlReferences(boolean theAllowInlineMatchUrlReferences) {
- myAllowInlineMatchUrlReferences = theAllowInlineMatchUrlReferences;
- }
-
- private boolean myAllowMultipleDelete;
+ private boolean myAllowMultipleDelete;
private int myHardSearchLimit = 1000;
private int myHardTagListLimit = 1000;
private int myIncludeLimit = 2000;
+
+ // ***
+ // update setter javadoc if default changes
+ // ***
+ private boolean myIndexContainedResources = true;
+
private List myInterceptors;
private ResourceEncodingEnum myResourceEncoding = ResourceEncodingEnum.JSONC;
private boolean mySchedulingDisabled;
private boolean mySubscriptionEnabled;
private long mySubscriptionPollDelay = 1000;
private Long mySubscriptionPurgeInactiveAfterMillis;
-
/**
* See {@link #setIncludeLimit(int)}
*/
public int getHardSearchLimit() {
return myHardSearchLimit;
}
-
public int getHardTagListLimit() {
return myHardTagListLimit;
}
-
public int getIncludeLimit() {
return myIncludeLimit;
}
-
/**
* Returns the interceptors which will be notified of operations.
*
@@ -110,10 +91,25 @@ public class DaoConfig {
return mySubscriptionPurgeInactiveAfterMillis;
}
+ /**
+ * @see #setAllowInlineMatchUrlReferences(boolean)
+ */
+ public boolean isAllowInlineMatchUrlReferences() {
+ return myAllowInlineMatchUrlReferences;
+ }
+
public boolean isAllowMultipleDelete() {
return myAllowMultipleDelete;
}
+ /**
+ * Should contained IDs be indexed the same way that non-contained IDs are (default is
+ * true)
+ */
+ public boolean isIndexContainedResources() {
+ return myIndexContainedResources;
+ }
+
public boolean isSchedulingDisabled() {
return mySchedulingDisabled;
}
@@ -125,6 +121,20 @@ public class DaoConfig {
return mySubscriptionEnabled;
}
+ /**
+ * Should references containing match URLs be resolved and replaced in create and update operations. For
+ * example, if this property is set to true and a resource is created containing a reference
+ * to "Patient?identifier=12345", this is reference match URL will be resolved and replaced according
+ * to the usual match URL rules.
+ *
+ * Default is false for now, as this is an experimental feature.
+ *
+ * @since 1.5
+ */
+ public void setAllowInlineMatchUrlReferences(boolean theAllowInlineMatchUrlReferences) {
+ myAllowInlineMatchUrlReferences = theAllowInlineMatchUrlReferences;
+ }
+
public void setAllowMultipleDelete(boolean theAllowMultipleDelete) {
myAllowMultipleDelete = theAllowMultipleDelete;
}
@@ -146,6 +156,14 @@ public class DaoConfig {
myIncludeLimit = theIncludeLimit;
}
+ /**
+ * Should contained IDs be indexed the same way that non-contained IDs are (default is
+ * true)
+ */
+ public void setIndexContainedResources(boolean theIndexContainedResources) {
+ myIndexContainedResources = theIndexContainedResources;
+ }
+
/**
* This may be used to optionally register server interceptors directly against the DAOs.
*
diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/ResourceIndexedSearchParamCoords.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/ResourceIndexedSearchParamCoords.java
index 52666ec75c6..1fd44201d30 100644
--- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/ResourceIndexedSearchParamCoords.java
+++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/ResourceIndexedSearchParamCoords.java
@@ -23,6 +23,7 @@ package ca.uhn.fhir.jpa.entity;
import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.Entity;
+import javax.persistence.Index;
import javax.persistence.Table;
import org.apache.commons.lang3.builder.EqualsBuilder;
@@ -34,9 +35,8 @@ import org.hibernate.search.annotations.Field;
//@formatter:off
@Embeddable
@Entity
-@Table(name = "HFJ_SPIDX_COORDS" /* , indexes = { @Index(name = "IDX_SP_TOKEN", columnList = "SP_SYSTEM,SP_VALUE") } */)
-@org.hibernate.annotations.Table(appliesTo = "HFJ_SPIDX_COORDS", indexes = {
- @org.hibernate.annotations.Index(name = "IDX_SP_COORDS", columnNames = { "RES_TYPE", "SP_NAME", "SP_LATITUDE" })
+@Table(name = "HFJ_SPIDX_COORDS", indexes = {
+ @Index(name = "IDX_SP_COORDS", columnList = "RES_TYPE,SP_NAME,SP_LATITUDE,SP_LONGITUDE")
})
//@formatter:on
public class ResourceIndexedSearchParamCoords extends BaseResourceIndexedSearchParam {
diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/ResourceTable.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/ResourceTable.java
index 8c04aa591ba..73604ef8c37 100644
--- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/ResourceTable.java
+++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/ResourceTable.java
@@ -144,6 +144,9 @@ public class ResourceTable extends BaseHasResource implements Serializable {
//@formatter:on
private String myContentText;
+ @Column(name = "HAS_CONTAINED", nullable = true)
+ private boolean myHasContainedResource;
+
@Column(name = "SP_HAS_LINKS")
private boolean myHasLinks;
@@ -158,6 +161,9 @@ public class ResourceTable extends BaseHasResource implements Serializable {
@Column(name = "SP_INDEX_STATUS", nullable = true)
private Long myIndexStatus;
+ @Column(name = "IS_CONTAINED", nullable = true)
+ private boolean myIsContainedResource;
+
@Column(name = "RES_LANGUAGE", length = MAX_LANGUAGE_LENGTH, nullable = true)
private String myLanguage;
@@ -173,13 +179,13 @@ public class ResourceTable extends BaseHasResource implements Serializable {
@Column(name = "SP_COORDS_PRESENT")
private boolean myParamsCoordsPopulated;
-
+
@OneToMany(mappedBy = "myResource", cascade = {}, fetch = FetchType.LAZY, orphanRemoval = false)
private Collection myParamsDate;
@Column(name = "SP_DATE_PRESENT")
private boolean myParamsDatePopulated;
-
+
@OneToMany(mappedBy = "myResource", cascade = {}, fetch = FetchType.LAZY, orphanRemoval = false)
private Collection myParamsNumber;
@@ -340,10 +346,18 @@ public class ResourceTable extends BaseHasResource implements Serializable {
return false;
}
+ public boolean isHasContainedResource() {
+ return myHasContainedResource;
+ }
+
public boolean isHasLinks() {
return myHasLinks;
}
+ public boolean isIsContainedResource() {
+ return myIsContainedResource;
+ }
+
public boolean isParamsCoordsPopulated() {
return myParamsCoordsPopulated;
}
@@ -376,6 +390,10 @@ public class ResourceTable extends BaseHasResource implements Serializable {
myContentText = theContentText;
}
+ public void setHasContainedResource(boolean theHasContainedResource) {
+ myHasContainedResource = theHasContainedResource;
+ }
+
public void setHasLinks(boolean theHasLinks) {
myHasLinks = theHasLinks;
}
@@ -388,6 +406,10 @@ public class ResourceTable extends BaseHasResource implements Serializable {
myIndexStatus = theIndexStatus;
}
+ public void setIsContainedResource(boolean theIsContainedResource) {
+ myIsContainedResource = theIsContainedResource;
+ }
+
public void setLanguage(String theLanguage) {
if (defaultString(theLanguage).length() > MAX_LANGUAGE_LENGTH) {
throw new UnprocessableEntityException("Language exceeds maximum length of " + MAX_LANGUAGE_LENGTH + " chars: " + theLanguage);
diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/BaseJpaDstu3Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/BaseJpaDstu3Test.java
index 398d137f2c8..6b448f2a4a8 100644
--- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/BaseJpaDstu3Test.java
+++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/BaseJpaDstu3Test.java
@@ -46,6 +46,7 @@ import org.springframework.context.ApplicationContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.transaction.PlatformTransactionManager;
+import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionCallback;
@@ -225,14 +226,14 @@ public abstract class BaseJpaDstu3Test extends BaseJpaTest {
public TransactionTemplate newTxTemplate() {
TransactionTemplate retVal = new TransactionTemplate(myTxManager);
- retVal.setPropagationBehavior(TransactionTemplate.PROPAGATION_REQUIRES_NEW);
+ retVal.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
retVal.afterPropertiesSet();
return retVal;
}
public static void purgeDatabase(final EntityManager entityManager, PlatformTransactionManager theTxManager) {
TransactionTemplate txTemplate = new TransactionTemplate(theTxManager);
- txTemplate.setPropagationBehavior(TransactionTemplate.PROPAGATION_REQUIRED);
+ txTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
txTemplate.execute(new TransactionCallback() {
@Override
public Void doInTransaction(TransactionStatus theStatus) {
diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3ContainedTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3ContainedTest.java
new file mode 100644
index 00000000000..9fceb615e08
--- /dev/null
+++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3ContainedTest.java
@@ -0,0 +1,58 @@
+package ca.uhn.fhir.jpa.dao.dstu3;
+
+import static org.hamcrest.Matchers.containsInAnyOrder;
+import static org.junit.Assert.assertThat;
+
+import org.hl7.fhir.dstu3.model.Observation;
+import org.hl7.fhir.dstu3.model.Patient;
+import org.hl7.fhir.dstu3.model.Reference;
+import org.hl7.fhir.instance.model.api.IIdType;
+import org.junit.Test;
+
+import ca.uhn.fhir.jpa.dao.SearchParameterMap;
+import ca.uhn.fhir.rest.param.TokenParam;
+import ca.uhn.fhir.rest.param.TokenParamModifier;
+
+public class FhirResourceDaoDstu3ContainedTest extends BaseJpaDstu3Test {
+ private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirResourceDaoDstu3ContainedTest.class);
+
+ @Test
+ public void before() {
+ myDaoConfig.setIndexContainedResources(true);
+ }
+
+ @Test
+ public void testIndexContained() {
+ Patient p = new Patient();
+ p.setId("#some_patient");
+ p.addName().addFamily("MYFAMILY").addGiven("MYGIVEN");
+
+ Observation o1 = new Observation();
+ o1.getCode().setText("Some Observation");
+ o1.setSubject(new Reference(p));
+ IIdType oid1 = myObservationDao.create(o1).getId().toUnqualifiedVersionless();
+
+ Observation o2 = new Observation();
+ o2.getCode().setText("Some Observation");
+ o2.setSubject(new Reference(p));
+ IIdType oid2 = myObservationDao.create(o2).getId().toUnqualifiedVersionless();
+
+ Patient p2 = new Patient();
+ p2.addName().addFamily("MYFAMILY").addGiven("MYGIVEN");
+ IIdType pid2 = myPatientDao.create(p2).getId().toUnqualifiedVersionless();
+
+ ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(o2));
+
+
+ SearchParameterMap map;
+
+// map = new SearchParameterMap();
+// map.add(Observation.SP_CODE, new TokenParam(null, "some observation").setModifier(TokenParamModifier.TEXT));
+// assertThat(toUnqualifiedVersionlessIdValues(myObservationDao.search(map)), containsInAnyOrder(toValues(id1, id2)));
+
+ }
+
+
+ // TODO: make sure match URLs don't delete
+
+}
diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchFtTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchFtTest.java
index 8df9c19757d..d29d178c334 100644
--- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchFtTest.java
+++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchFtTest.java
@@ -31,6 +31,7 @@ import ca.uhn.fhir.rest.param.StringAndListParam;
import ca.uhn.fhir.rest.param.StringOrListParam;
import ca.uhn.fhir.rest.param.StringParam;
import ca.uhn.fhir.rest.param.TokenParam;
+import ca.uhn.fhir.rest.param.TokenParamModifier;
import ca.uhn.fhir.rest.server.Constants;
public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test {
@@ -56,15 +57,15 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test {
SearchParameterMap map;
map = new SearchParameterMap();
- map.add(Observation.SP_CODE, new TokenParam(null, "blood").setText(true));
+ map.add(Observation.SP_CODE, new TokenParam(null, "blood").setModifier(TokenParamModifier.TEXT));
assertThat(toUnqualifiedVersionlessIdValues(myObservationDao.search(map)), containsInAnyOrder(toValues(id1, id2)));
map = new SearchParameterMap();
- map.add(Observation.SP_CODE, new TokenParam(null, "blood").setText(true));
+ map.add(Observation.SP_CODE, new TokenParam(null, "blood").setModifier(TokenParamModifier.TEXT));
assertThat(toUnqualifiedVersionlessIdValues(myPatientDao.search(map)), empty());
map = new SearchParameterMap();
- map.add(Observation.SP_CODE, new TokenParam(null, "blood").setText(true));
+ map.add(Observation.SP_CODE, new TokenParam(null, "blood").setModifier(TokenParamModifier.TEXT));
map.add(Constants.PARAM_CONTENT, new StringParam("obs1"));
assertThat(toUnqualifiedVersionlessIdValues(myObservationDao.search(map)), containsInAnyOrder(toValues(id1)));
@@ -358,7 +359,7 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test {
Device dev2 = new Device();
dev2.setManufacturer("Some Manufacturer 2");
- IIdType devId2 = myDeviceDao.create(dev2).getId().toUnqualifiedVersionless();
+ myDeviceDao.create(dev2).getId().toUnqualifiedVersionless();
Observation obs1 = new Observation();
obs1.getSubject().setReferenceElement(ptId1);
diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchNoFtTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchNoFtTest.java
index 2669598952f..c182581def3 100644
--- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchNoFtTest.java
+++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchNoFtTest.java
@@ -23,9 +23,9 @@ import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
-import org.hl7.fhir.dstu3.model.BaseResource;
import org.hl7.fhir.dstu3.model.CodeType;
import org.hl7.fhir.dstu3.model.ConceptMap;
+import org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem;
import org.hl7.fhir.dstu3.model.DateTimeType;
import org.hl7.fhir.dstu3.model.DateType;
import org.hl7.fhir.dstu3.model.Device;
@@ -46,12 +46,12 @@ import org.hl7.fhir.dstu3.model.Quantity;
import org.hl7.fhir.dstu3.model.Reference;
import org.hl7.fhir.dstu3.model.StringType;
import org.hl7.fhir.dstu3.model.Subscription;
+import org.hl7.fhir.dstu3.model.Subscription.SubscriptionChannelType;
+import org.hl7.fhir.dstu3.model.Subscription.SubscriptionStatus;
import org.hl7.fhir.dstu3.model.Substance;
import org.hl7.fhir.dstu3.model.TemporalPrecisionEnum;
import org.hl7.fhir.dstu3.model.ValueSet;
-import org.hl7.fhir.dstu3.model.ContactPoint.ContactPointSystem;
-import org.hl7.fhir.dstu3.model.Subscription.SubscriptionChannelType;
-import org.hl7.fhir.dstu3.model.Subscription.SubscriptionStatus;
+import org.hl7.fhir.instance.model.api.IAnyResource;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.instance.model.api.IIdType;
import org.junit.Ignore;
@@ -68,7 +68,6 @@ import ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamUri;
import ca.uhn.fhir.jpa.entity.ResourceLink;
import ca.uhn.fhir.model.api.IQueryParameterType;
import ca.uhn.fhir.model.api.Include;
-import ca.uhn.fhir.model.dstu.valueset.QuantityCompararatorEnum;
import ca.uhn.fhir.rest.api.SortOrderEnum;
import ca.uhn.fhir.rest.api.SortSpec;
import ca.uhn.fhir.rest.param.CompositeParam;
@@ -585,21 +584,21 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
}
{
Map params = new HashMap();
- params.put(BaseResource.SP_RES_LANGUAGE, new StringParam("en_CA"));
+ params.put(IAnyResource.SP_RES_LANGUAGE, new StringParam("en_CA"));
List patients = toList(myPatientDao.search(params));
assertEquals(1, patients.size());
assertEquals(id1.toUnqualifiedVersionless(), patients.get(0).getIdElement().toUnqualifiedVersionless());
}
{
Map params = new HashMap();
- params.put(BaseResource.SP_RES_LANGUAGE, new StringParam("en_US"));
+ params.put(IAnyResource.SP_RES_LANGUAGE, new StringParam("en_US"));
List patients = toList(myPatientDao.search(params));
assertEquals(1, patients.size());
assertEquals(id2.toUnqualifiedVersionless(), patients.get(0).getIdElement().toUnqualifiedVersionless());
}
{
Map params = new HashMap();
- params.put(BaseResource.SP_RES_LANGUAGE, new StringParam("en_GB"));
+ params.put(IAnyResource.SP_RES_LANGUAGE, new StringParam("en_GB"));
List patients = toList(myPatientDao.search(params));
assertEquals(0, patients.size());
}
@@ -628,18 +627,18 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
}
{
SearchParameterMap params = new SearchParameterMap();
- params.add(BaseResource.SP_RES_LANGUAGE, new StringOrListParam().addOr(new StringParam("en_CA")).addOr(new StringParam("en_US")));
+ params.add(IAnyResource.SP_RES_LANGUAGE, new StringOrListParam().addOr(new StringParam("en_CA")).addOr(new StringParam("en_US")));
assertThat(toUnqualifiedVersionlessIds(myPatientDao.search(params)), containsInAnyOrder(id1, id2));
}
{
SearchParameterMap params = new SearchParameterMap();
- params.add(BaseResource.SP_RES_LANGUAGE, new StringOrListParam().addOr(new StringParam("en_CA")).addOr(new StringParam("en_US")));
+ params.add(IAnyResource.SP_RES_LANGUAGE, new StringOrListParam().addOr(new StringParam("en_CA")).addOr(new StringParam("en_US")));
params.setLastUpdated(new DateRangeParam(betweenTime, null));
assertThat(toUnqualifiedVersionlessIds(myPatientDao.search(params)), containsInAnyOrder(id2));
}
{
SearchParameterMap params = new SearchParameterMap();
- params.add(BaseResource.SP_RES_LANGUAGE, new StringOrListParam().addOr(new StringParam("en_CA")).addOr(new StringParam("ZZZZ")));
+ params.add(IAnyResource.SP_RES_LANGUAGE, new StringOrListParam().addOr(new StringParam("en_CA")).addOr(new StringParam("ZZZZ")));
assertThat(toUnqualifiedVersionlessIds(myPatientDao.search(params)), containsInAnyOrder(id1));
}
{
@@ -647,7 +646,7 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
StringAndListParam and = new StringAndListParam();
and.addAnd(new StringOrListParam().addOr(new StringParam("en_CA")).addOr(new StringParam("ZZZZ")));
and.addAnd(new StringOrListParam().addOr(new StringParam("en_CA")));
- params.add(BaseResource.SP_RES_LANGUAGE, and);
+ params.add(IAnyResource.SP_RES_LANGUAGE, and);
assertThat(toUnqualifiedVersionlessIds(myPatientDao.search(params)), containsInAnyOrder(id1));
}
{
@@ -655,7 +654,7 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
StringAndListParam and = new StringAndListParam();
and.addAnd(new StringOrListParam().addOr(new StringParam("en_CA")).addOr(new StringParam("ZZZZ")));
and.addAnd(new StringOrListParam().addOr(new StringParam("ZZZZZ")));
- params.add(BaseResource.SP_RES_LANGUAGE, and);
+ params.add(IAnyResource.SP_RES_LANGUAGE, and);
assertThat(toUnqualifiedVersionlessIds(myPatientDao.search(params)), empty());
}
{
@@ -663,7 +662,7 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
StringAndListParam and = new StringAndListParam();
and.addAnd(new StringOrListParam().addOr(new StringParam("ZZZZZ")));
and.addAnd(new StringOrListParam().addOr(new StringParam("en_CA")).addOr(new StringParam("ZZZZ")));
- params.add(BaseResource.SP_RES_LANGUAGE, and);
+ params.add(IAnyResource.SP_RES_LANGUAGE, and);
assertThat(toUnqualifiedVersionlessIds(myPatientDao.search(params)), empty());
}
{
@@ -671,7 +670,7 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
StringAndListParam and = new StringAndListParam();
and.addAnd(new StringOrListParam().addOr(new StringParam("en_CA")).addOr(new StringParam("ZZZZ")));
and.addAnd(new StringOrListParam().addOr(new StringParam("")).addOr(new StringParam(null)));
- params.add(BaseResource.SP_RES_LANGUAGE, and);
+ params.add(IAnyResource.SP_RES_LANGUAGE, and);
assertThat(toUnqualifiedVersionlessIds(myPatientDao.search(params)), containsInAnyOrder(id1));
}
{
@@ -680,7 +679,7 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
StringAndListParam and = new StringAndListParam();
and.addAnd(new StringOrListParam().addOr(new StringParam("en_CA")).addOr(new StringParam("ZZZZ")));
and.addAnd(new StringOrListParam().addOr(new StringParam("")).addOr(new StringParam(null)));
- params.add(BaseResource.SP_RES_LANGUAGE, and);
+ params.add(IAnyResource.SP_RES_LANGUAGE, and);
assertThat(toUnqualifiedVersionlessIds(myPatientDao.search(params)), containsInAnyOrder(id1));
}
{
@@ -688,7 +687,7 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
StringAndListParam and = new StringAndListParam();
and.addAnd(new StringOrListParam().addOr(new StringParam("en_CA")).addOr(new StringParam("ZZZZ")));
and.addAnd(new StringOrListParam().addOr(new StringParam("")).addOr(new StringParam(null)));
- params.add(BaseResource.SP_RES_LANGUAGE, and);
+ params.add(IAnyResource.SP_RES_LANGUAGE, and);
params.add("_id", new StringParam(id1.getIdPart()));
assertThat(toUnqualifiedVersionlessIds(myPatientDao.search(params)), containsInAnyOrder(id1));
}
@@ -766,8 +765,6 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
@Test
public void testSearchLastUpdatedParamWithComparator() throws InterruptedException {
- String methodName = "testSearchLastUpdatedParamWithComparator";
-
IIdType id0;
{
Patient patient = new Patient();
@@ -780,7 +777,6 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
long start = System.currentTimeMillis();
Thread.sleep(sleep);
- DateTimeType beforeAny = new DateTimeType(new Date(), TemporalPrecisionEnum.MILLI);
IIdType id1a;
{
Patient patient = new Patient();
@@ -814,17 +810,17 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
assertThat(toUnqualifiedVersionlessIds(myPatientDao.search(map)), containsInAnyOrder(id1a, id1b));
map = new SearchParameterMap();
- map.setLastUpdated(new DateRangeParam(new DateParam(QuantityCompararatorEnum.GREATERTHAN_OR_EQUALS, startDateTime), new DateParam(QuantityCompararatorEnum.LESSTHAN_OR_EQUALS, endDateTime)));
+ map.setLastUpdated(new DateRangeParam(new DateParam(ParamPrefixEnum.GREATERTHAN_OR_EQUALS, startDateTime), new DateParam(ParamPrefixEnum.LESSTHAN_OR_EQUALS, endDateTime)));
ourLog.info("Searching: {}", map.getLastUpdated());
assertThat(toUnqualifiedVersionlessIds(myPatientDao.search(map)), containsInAnyOrder(id1a, id1b));
map = new SearchParameterMap();
- map.setLastUpdated(new DateRangeParam(new DateParam(QuantityCompararatorEnum.GREATERTHAN, startDateTime), new DateParam(QuantityCompararatorEnum.LESSTHAN, endDateTime)));
+ map.setLastUpdated(new DateRangeParam(new DateParam(ParamPrefixEnum.GREATERTHAN, startDateTime), new DateParam(ParamPrefixEnum.LESSTHAN, endDateTime)));
ourLog.info("Searching: {}", map.getLastUpdated());
assertThat(toUnqualifiedVersionlessIds(myPatientDao.search(map)), containsInAnyOrder(id1a, id1b));
map = new SearchParameterMap();
- map.setLastUpdated(new DateRangeParam(new DateParam(QuantityCompararatorEnum.GREATERTHAN, startDateTime.getValue()), new DateParam(QuantityCompararatorEnum.LESSTHAN, myPatientDao.read(id1b).getMeta().getLastUpdatedElement().getValue())));
+ map.setLastUpdated(new DateRangeParam(new DateParam(ParamPrefixEnum.GREATERTHAN, startDateTime.getValue()), new DateParam(ParamPrefixEnum.LESSTHAN, myPatientDao.read(id1b).getMeta().getLastUpdatedElement().getValue())));
ourLog.info("Searching: {}", map.getLastUpdated());
assertThat(toUnqualifiedVersionlessIds(myPatientDao.search(map)), containsInAnyOrder(id1a));
}
@@ -1372,7 +1368,7 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
QuantityParam param;
Set found;
- param = new QuantityParam(QuantityCompararatorEnum.GREATERTHAN_OR_EQUALS, new BigDecimal("10"), null, null);
+ param = new QuantityParam(ParamPrefixEnum.GREATERTHAN_OR_EQUALS, new BigDecimal("10"), null, null);
found = myObservationDao.searchForIds("value-quantity", param);
int initialSize = found.size();
@@ -1383,19 +1379,19 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
myObservationDao.create(o);
- param = new QuantityParam(QuantityCompararatorEnum.GREATERTHAN_OR_EQUALS, new BigDecimal("10"), null, null);
+ param = new QuantityParam(ParamPrefixEnum.GREATERTHAN_OR_EQUALS, new BigDecimal("10"), null, null);
found = myObservationDao.searchForIds("value-quantity", param);
assertEquals(1 + initialSize, found.size());
- param = new QuantityParam(QuantityCompararatorEnum.GREATERTHAN_OR_EQUALS, new BigDecimal("10"), null, methodName + "units");
+ param = new QuantityParam(ParamPrefixEnum.GREATERTHAN_OR_EQUALS, new BigDecimal("10"), null, methodName + "units");
found = myObservationDao.searchForIds("value-quantity", param);
assertEquals(1, found.size());
- param = new QuantityParam(QuantityCompararatorEnum.GREATERTHAN_OR_EQUALS, new BigDecimal("10"), "urn:bar:" + methodName, null);
+ param = new QuantityParam(ParamPrefixEnum.GREATERTHAN_OR_EQUALS, new BigDecimal("10"), "urn:bar:" + methodName, null);
found = myObservationDao.searchForIds("value-quantity", param);
assertEquals(1, found.size());
- param = new QuantityParam(QuantityCompararatorEnum.GREATERTHAN_OR_EQUALS, new BigDecimal("10"), "urn:bar:" + methodName, methodName + "units");
+ param = new QuantityParam(ParamPrefixEnum.GREATERTHAN_OR_EQUALS, new BigDecimal("10"), "urn:bar:" + methodName, methodName + "units");
found = myObservationDao.searchForIds("value-quantity", param);
assertEquals(1, found.size());
@@ -1405,8 +1401,8 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
public void testSearchWithEmptySort() {
SearchParameterMap criteriaUrl = new SearchParameterMap();
DateRangeParam range = new DateRangeParam();
- range.setLowerBound(new DateParam(QuantityCompararatorEnum.GREATERTHAN, 1000000));
- range.setUpperBound(new DateParam(QuantityCompararatorEnum.LESSTHAN, 2000000));
+ range.setLowerBound(new DateParam(ParamPrefixEnum.GREATERTHAN, 1000000));
+ range.setUpperBound(new DateParam(ParamPrefixEnum.LESSTHAN, 2000000));
criteriaUrl.setLastUpdated(range);
criteriaUrl.setSort(new SortSpec(Constants.PARAM_LASTUPDATED, SortOrderEnum.ASC));
IBundleProvider results = myObservationDao.search(criteriaUrl);
@@ -1554,7 +1550,7 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
{
SearchParameterMap params = new SearchParameterMap();
- params.add(BaseResource.SP_RES_ID, new StringParam(orgId.getIdPart()));
+ params.add(IAnyResource.SP_RES_ID, new StringParam(orgId.getIdPart()));
params.addInclude(Organization.INCLUDE_PARTOF.asNonRecursive());
List resources = toUnqualifiedVersionlessIds(myOrganizationDao.search(params));
assertThat(resources, contains(orgId, parentOrgId));
@@ -1596,7 +1592,7 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
{
SearchParameterMap params = new SearchParameterMap();
- params.add(Organization.SP_RES_ID, new StringParam(orgId.getIdPart()));
+ params.add(IAnyResource.SP_RES_ID, new StringParam(orgId.getIdPart()));
params.addInclude(Organization.INCLUDE_PARTOF.asRecursive());
List resources = toUnqualifiedVersionlessIds(myOrganizationDao.search(params));
ourLog.info(resources.toString());
@@ -1891,7 +1887,7 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
ourLog.info("Initial size: " + value.size());
for (IBaseResource next : value.getResources(0, value.size())) {
ourLog.info("Deleting: {}", next.getIdElement());
- myDeviceDao.delete((IIdType) next.getIdElement());
+ myDeviceDao.delete(next.getIdElement());
}
value = myDeviceDao.search(new SearchParameterMap());
@@ -2098,7 +2094,7 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
ValueSet vs2 = new ValueSet();
vs2.setUrl("http://hl7.org/foo/bar");
- IIdType id2 = myValueSetDao.create(vs2).getId().toUnqualifiedVersionless();
+ myValueSetDao.create(vs2).getId().toUnqualifiedVersionless();
IBundleProvider result;
result = myValueSetDao.search(ValueSet.SP_URL, new UriParam("http://hl7.org/fhir/ValueSet/basic-resource-type"));
diff --git a/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/CompartmentGeneratorMojo.java b/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/CompartmentGeneratorMojo.java
deleted file mode 100644
index 843189ae17a..00000000000
--- a/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/CompartmentGeneratorMojo.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package ca.uhn.fhir.tinder;
-
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugins.annotations.Parameter;
-
-import ca.uhn.fhir.tinder.parser.CompartmentParser;
-
-public class CompartmentGeneratorMojo extends AbstractMojo {
-
- @Parameter(required = true)
- private String fhirVersion;
-
- @Override
- public void execute() throws MojoExecutionException, MojoFailureException {
- CompartmentParser p = new CompartmentParser(fhirVersion);
- try {
- p.parse();
- } catch (MojoExecutionException e) {
- throw e;
- } catch (MojoFailureException e) {
- throw e;
- } catch (Exception e) {
- throw new MojoFailureException("Failure during parse", e);
- }
- }
-
- public static void main(String[] args) throws MojoExecutionException, MojoFailureException {
- CompartmentGeneratorMojo mojo = new CompartmentGeneratorMojo();
- mojo.fhirVersion = "dstu2";
- mojo.execute();
- }
-
-}
diff --git a/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/TinderStructuresMojo.java b/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/TinderStructuresMojo.java
index f4d9a368819..890d35745ce 100644
--- a/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/TinderStructuresMojo.java
+++ b/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/TinderStructuresMojo.java
@@ -228,7 +228,7 @@ public class TinderStructuresMojo extends AbstractMojo {
String dtOutputDir = "target/generated-sources/tinder/ca/uhn/fhir/model/dev/composite";
ResourceGeneratorUsingSpreadsheet rp = new ResourceGeneratorUsingSpreadsheet("dstu2", ".");
- rp.setBaseResourceNames(Arrays.asList( "supplyrequest"
+ rp.setBaseResourceNames(Arrays.asList( "patient", "auditevent" , "observation"
// //, "contract"
// "valueset", "organization", "location"
// , "observation", "conformance"
diff --git a/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/model/Resource.java b/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/model/Resource.java
index 1b53906c08c..3b9e60a3f80 100644
--- a/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/model/Resource.java
+++ b/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/model/Resource.java
@@ -1,5 +1,8 @@
package ca.uhn.fhir.tinder.model;
+import java.util.ArrayList;
+import java.util.List;
+
public class Resource extends BaseRootType {
@Override
@@ -20,4 +23,20 @@ public class Resource extends BaseRootType {
return name;
}
+ public SearchParameter getSearchParameterByName(String theName) {
+ for (SearchParameter next : getSearchParameters()) {
+ if (next.getName().equalsIgnoreCase(theName)) {
+ return next;
+ }
+ }
+ return null;
+ }
+ public List getSearchParameterNames() {
+ ArrayList retVal = new ArrayList();
+ for (SearchParameter next : getSearchParameters()) {
+ retVal.add(next.getName());
+ }
+ return retVal;
+ }
+
}
diff --git a/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/model/SearchParameter.java b/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/model/SearchParameter.java
index b91e2aa668a..201d88dc92b 100644
--- a/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/model/SearchParameter.java
+++ b/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/model/SearchParameter.java
@@ -10,6 +10,7 @@ import org.apache.commons.lang3.StringUtils;
public class SearchParameter {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(SearchParameter.class);
+ private List myCompartments = new ArrayList();
private List myCompositeOf;
private List myCompositeTypes;
private String myDescription;
@@ -18,7 +19,6 @@ public class SearchParameter {
private String myResourceName;
private List myTargetTypes;
private String myType;
-
private String myVersion;
public SearchParameter(String theVersion, String theResourceName) {
@@ -26,6 +26,14 @@ public class SearchParameter {
this.myResourceName = theResourceName;
}
+ public void addCompartment(String theCompartment) {
+ myCompartments.add(theCompartment);
+ }
+
+ public List getCompartments() {
+ return myCompartments;
+ }
+
public List getCompositeOf() {
if (myCompositeOf == null) {
myCompositeOf = new ArrayList();
diff --git a/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/parser/BaseStructureSpreadsheetParser.java b/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/parser/BaseStructureSpreadsheetParser.java
index c13a6afa0ce..14ef3483899 100644
--- a/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/parser/BaseStructureSpreadsheetParser.java
+++ b/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/parser/BaseStructureSpreadsheetParser.java
@@ -16,6 +16,7 @@ import java.util.Set;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.text.WordUtils;
import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
@@ -404,7 +405,7 @@ public abstract class BaseStructureSpreadsheetParser extends BaseStructureParser
/**
* Subclasses may override
*/
- protected void postProcess(BaseElement theTarget) {
+ protected void postProcess(BaseElement theTarget) throws MojoFailureException {
// nothing
}
diff --git a/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/parser/CompartmentParser.java b/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/parser/CompartmentParser.java
index 56ee4fe4485..29ce20ae055 100644
--- a/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/parser/CompartmentParser.java
+++ b/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/parser/CompartmentParser.java
@@ -1,20 +1,31 @@
package ca.uhn.fhir.tinder.parser;
+import static org.apache.commons.lang3.StringUtils.isBlank;
+
import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
import org.apache.maven.plugin.MojoFailureException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import ca.uhn.fhir.tinder.model.BaseElement;
+import ca.uhn.fhir.tinder.model.Resource;
+import ca.uhn.fhir.tinder.model.SearchParameter;
import ca.uhn.fhir.tinder.util.XMLUtils;
public class CompartmentParser {
private String myVersion;
+ private Resource myResourceDef;
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(CompartmentParser.class);
- public CompartmentParser(String theVersion) {
+ public CompartmentParser(String theVersion, Resource theResourceDef) {
myVersion = theVersion;
+ myResourceDef = theResourceDef;
}
public void parse() throws Exception {
@@ -45,6 +56,67 @@ public class CompartmentParser {
throw new Exception("Failed to find worksheet with name 'Data Elements' in spreadsheet: " + resName);
}
+ Element table = (Element) resourcesSheet.getElementsByTagName("Table").item(0);
+ NodeList rows = table.getElementsByTagName("Row");
+
+ Map col2compartment = new HashMap();
+ Element headerRow = (Element) rows.item(0);
+ for (int i = 1; i < headerRow.getElementsByTagName("Cell").getLength(); i++) {
+ Element cellElement = (Element) headerRow.getElementsByTagName("Cell").item(i);
+ Element dataElement = (Element) cellElement.getElementsByTagName("Data").item(0);
+ col2compartment.put(i, dataElement.getTextContent());
+ }
+
+ Element row = null;
+ for (int i = 1; i < rows.getLength(); i++) {
+ Element nextRow = (Element) rows.item(i);
+
+ NodeList cells = nextRow.getElementsByTagName("Cell");
+ Element cellElement = (Element) cells.item(0);
+ Element dataElement = (Element) cellElement.getElementsByTagName("Data").item(0);
+ if (dataElement.getTextContent().equals(myResourceDef.getName())) {
+ row = nextRow;
+ break;
+ }
+ }
+
+ if (row == null) {
+ ourLog.debug("No compartments for resource {}", myResourceDef.getName());
+ return;
+ }
+
+ NodeList cells = row.getElementsByTagName("Cell");
+ for (int i = 1; i < cells.getLength(); i++) {
+ Element cellElement = (Element) cells.item(i);
+ int index = i;
+ if (cellElement.hasAttribute("Index")) {
+ index = Integer.parseInt(cellElement.getAttribute("Index"));
+ }
+
+ String compartment = col2compartment.get(index);
+
+ Element dataElement = (Element) cellElement.getElementsByTagName("Data").item(0);
+ String namesUnsplit = dataElement.getTextContent();
+ String[] namesSplit = namesUnsplit.split("\\|");
+ for (String nextName : namesSplit) {
+ nextName = nextName.trim();
+ if (isBlank(nextName)) {
+ continue;
+ }
+
+ String[] parts = nextName.split("\\.");
+ if (parts[0].equals("{def}")) {
+ continue;
+ }
+ Resource element = myResourceDef;
+ SearchParameter sp = element.getSearchParameterByName(parts[0]);
+ if (sp == null) {
+ throw new MojoFailureException("Can't find child named " + parts[0] + " - Valid names: " + element.getSearchParameterNames());
+ }
+
+ sp.addCompartment(compartment);
+ }
+ }
}
}
diff --git a/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/parser/DatatypeGeneratorUsingSpreadsheet.java b/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/parser/DatatypeGeneratorUsingSpreadsheet.java
index b219761afa9..8045985edd5 100644
--- a/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/parser/DatatypeGeneratorUsingSpreadsheet.java
+++ b/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/parser/DatatypeGeneratorUsingSpreadsheet.java
@@ -22,7 +22,7 @@ import com.google.common.reflect.ClassPath.ClassInfo;
public class DatatypeGeneratorUsingSpreadsheet extends BaseStructureSpreadsheetParser {
@Override
- protected void postProcess(BaseElement theTarget) {
+ protected void postProcess(BaseElement theTarget) throws MojoFailureException {
super.postProcess(theTarget);
/*
diff --git a/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/parser/ResourceGeneratorUsingSpreadsheet.java b/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/parser/ResourceGeneratorUsingSpreadsheet.java
index 44cf091d25b..9ed90614419 100644
--- a/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/parser/ResourceGeneratorUsingSpreadsheet.java
+++ b/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/parser/ResourceGeneratorUsingSpreadsheet.java
@@ -26,12 +26,21 @@ public class ResourceGeneratorUsingSpreadsheet extends BaseStructureSpreadsheetP
}
@Override
- protected void postProcess(BaseElement theTarget) {
+ protected void postProcess(BaseElement theTarget) throws MojoFailureException {
super.postProcess(theTarget);
if ("Bundle".equals(theTarget.getName())) {
addEverythingToSummary(theTarget);
}
+
+ if (getVersion().equals("dstu2") && theTarget instanceof Resource) {
+ try {
+ new CompartmentParser(getVersion(), (Resource) theTarget).parse();
+ } catch (Exception e) {
+ throw new MojoFailureException(e.toString(), e);
+ }
+ }
+
}
private void addEverythingToSummary(BaseElement theTarget) {
diff --git a/hapi-tinder-plugin/src/main/resources/vm/resource.vm b/hapi-tinder-plugin/src/main/resources/vm/resource.vm
index 9ac7c4e85d1..b83f5519c4d 100644
--- a/hapi-tinder-plugin/src/main/resources/vm/resource.vm
+++ b/hapi-tinder-plugin/src/main/resources/vm/resource.vm
@@ -56,6 +56,13 @@ public class ${className} extends ca.uhn.fhir.model.${version}.resource.BaseReso
*
*/
@SearchParamDefinition(name="${param.name}", path="${param.path}", description="${param.description}", type="${param.type}" #{if}($param.compositeOf.empty == false) , compositeOf={ #{foreach}($compositeOf in $param.compositeOf) "${compositeOf}"#{if}($foreach.hasNext), #{end}#{end} } #{end} )
+#if ($param.compartments.size() > 0)
+ @Compartments(providesMembershipIn={
+#foreach ($compartment in $param.compartments)
+ @Compartment(name="$compartment") #{if}($foreach.hasNext), #{end}
+#end
+ })
+#end
public static final String $param.constantName = "${param.name}";
/**
From 3f363eff9f63cae9daae67fcd986ee14fc6d41e2 Mon Sep 17 00:00:00 2001
From: jamesagnew
Date: Sat, 27 Feb 2016 09:42:15 -0500
Subject: [PATCH 6/6] Fix compile issues from merge
---
.../ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java | 10 +-
.../java/ca/uhn/fhir/jpa/dao/BaseJpaTest.java | 11 ++-
.../FhirResourceDaoDstu3ContainedTest.java | 7 +-
.../FhirResourceDaoDstu3SearchFtTest.java | 98 ++++++++++---------
.../FhirResourceDaoDstu3SearchNoFtTest.java | 2 +
.../jpa/dao/dstu3/FhirSystemDaoDstu3Test.java | 12 +--
.../fhir/rest/server/DynamicSearchTest.java | 4 +-
7 files changed, 80 insertions(+), 64 deletions(-)
diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java
index 6c40ea27aa8..9285b207d59 100644
--- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java
+++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java
@@ -796,6 +796,7 @@ public abstract class BaseHapiFhirDao implements IDao {
}
+ @SuppressWarnings("unchecked")
private R populateResourceMetadataHapi(Class theResourceType, BaseHasResource theEntity, boolean theForHistoryOperation, IResource res) {
R retVal = (R) res;
if (theEntity.getDeleted() != null) {
@@ -866,6 +867,7 @@ public abstract class BaseHapiFhirDao implements IDao {
return retVal;
}
+ @SuppressWarnings("unchecked")
private R populateResourceMetadataRi(Class theResourceType, BaseHasResource theEntity, boolean theForHistoryOperation, IAnyResource res) {
R retVal = (R) res;
if (theEntity.getDeleted() != null) {
@@ -936,6 +938,7 @@ public abstract class BaseHapiFhirDao implements IDao {
* @return Returns true if the tag should be removed
* @see Updates to Tags, Profiles, and Security Labels for a description of the logic that the default behaviour folows.
*/
+ @SuppressWarnings("unused")
protected void postPersist(ResourceTable theEntity, T theResource) {
// nothing
}
@@ -968,6 +971,8 @@ public abstract class BaseHapiFhirDao implements IDao {
return ids;
}
+ @SuppressWarnings("unused")
+ @CoverageIgnore
public BaseHasResource readEntity(IIdType theValueId) {
throw new NotImplementedException("");
}
@@ -1194,7 +1199,6 @@ public abstract class BaseHapiFhirDao implements IDao {
}
@Override
- @SuppressWarnings("unchecked")
public R toResource(Class theResourceType, BaseHasResource theEntity, boolean theForHistoryOperation) {
String resourceText = null;
switch (theEntity.getEncoding()) {
@@ -1563,10 +1567,6 @@ public abstract class BaseHapiFhirDao implements IDao {
return theEntity;
}
- protected ResourceTable updateEntity(final IResource theResource, ResourceTable entity, boolean theUpdateHistory, Date theDeletedTimestampOrNull, Date theUpdateTime) {
- return updateEntity(theResource, entity, theUpdateHistory, theDeletedTimestampOrNull, true, true, theUpdateTime);
- }
-
protected void validateDeleteConflictsEmptyOrThrowException(List theDeleteConflicts) {
if (theDeleteConflicts.isEmpty()) {
return;
diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/BaseJpaTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/BaseJpaTest.java
index 14261c933a2..c4e36e56d99 100644
--- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/BaseJpaTest.java
+++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/BaseJpaTest.java
@@ -1,8 +1,9 @@
package ca.uhn.fhir.jpa.dao;
+import static org.mockito.Mockito.mock;
+
import java.io.IOException;
import java.io.InputStream;
-import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
@@ -12,21 +13,29 @@ import org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.instance.model.api.IIdType;
import org.junit.AfterClass;
+import org.junit.Before;
import ca.uhn.fhir.jpa.provider.SystemProviderDstu2Test;
import ca.uhn.fhir.model.dstu2.resource.Bundle;
import ca.uhn.fhir.model.dstu2.resource.Bundle.Entry;
import ca.uhn.fhir.rest.server.IBundleProvider;
+import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
public class BaseJpaTest {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BaseJpaTest.class);
+ protected ServletRequestDetails mySrd;
@SuppressWarnings({ "rawtypes" })
protected List toList(IBundleProvider theSearch) {
return theSearch.getResources(0, theSearch.size());
}
+ @Before
+ public void beforeCreateSrd() {
+ mySrd = mock(ServletRequestDetails.class);
+ }
+
protected List toUnqualifiedVersionlessIds(Bundle theFound) {
List retVal = new ArrayList();
for (Entry next : theFound.getEntry()) {
diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3ContainedTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3ContainedTest.java
index 9fceb615e08..bc8cd77dd02 100644
--- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3ContainedTest.java
+++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3ContainedTest.java
@@ -12,6 +12,7 @@ import org.junit.Test;
import ca.uhn.fhir.jpa.dao.SearchParameterMap;
import ca.uhn.fhir.rest.param.TokenParam;
import ca.uhn.fhir.rest.param.TokenParamModifier;
+import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
public class FhirResourceDaoDstu3ContainedTest extends BaseJpaDstu3Test {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirResourceDaoDstu3ContainedTest.class);
@@ -30,16 +31,16 @@ public class FhirResourceDaoDstu3ContainedTest extends BaseJpaDstu3Test {
Observation o1 = new Observation();
o1.getCode().setText("Some Observation");
o1.setSubject(new Reference(p));
- IIdType oid1 = myObservationDao.create(o1).getId().toUnqualifiedVersionless();
+ IIdType oid1 = myObservationDao.create(o1, new ServletRequestDetails()).getId().toUnqualifiedVersionless();
Observation o2 = new Observation();
o2.getCode().setText("Some Observation");
o2.setSubject(new Reference(p));
- IIdType oid2 = myObservationDao.create(o2).getId().toUnqualifiedVersionless();
+ IIdType oid2 = myObservationDao.create(o2, new ServletRequestDetails()).getId().toUnqualifiedVersionless();
Patient p2 = new Patient();
p2.addName().addFamily("MYFAMILY").addGiven("MYGIVEN");
- IIdType pid2 = myPatientDao.create(p2).getId().toUnqualifiedVersionless();
+ IIdType pid2 = myPatientDao.create(p2, new ServletRequestDetails()).getId().toUnqualifiedVersionless();
ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(o2));
diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchFtTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchFtTest.java
index c6cc058627d..33eff79c03c 100644
--- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchFtTest.java
+++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchFtTest.java
@@ -47,13 +47,13 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test {
obs1.setStatus(ObservationStatus.FINAL);
obs1.setValue(new Quantity(123));
obs1.setComments("obs1");
- IIdType id1 = myObservationDao.create(obs1, new ServletRequestDetails()).getId().toUnqualifiedVersionless();
+ IIdType id1 = myObservationDao.create(obs1, mySrd).getId().toUnqualifiedVersionless();
Observation obs2 = new Observation();
obs2.getCode().setText("Diastolic Blood Pressure");
obs2.setStatus(ObservationStatus.FINAL);
obs2.setValue(new Quantity(81));
- IIdType id2 = myObservationDao.create(obs2, new ServletRequestDetails()).getId().toUnqualifiedVersionless();
+ IIdType id2 = myObservationDao.create(obs2, mySrd).getId().toUnqualifiedVersionless();
SearchParameterMap map;
@@ -72,6 +72,10 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test {
}
+ private ServletRequestDetails mockSrd() {
+ return new ServletRequestDetails();
+ }
+
@Test
@Ignore
public void testStringTextSearch() {
@@ -79,13 +83,13 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test {
obs1.getCode().setText("AAAAA");
obs1.setValue(new StringType("Systolic Blood Pressure"));
obs1.setStatus(ObservationStatus.FINAL);
- IIdType id1 = myObservationDao.create(obs1, new ServletRequestDetails()).getId().toUnqualifiedVersionless();
+ IIdType id1 = myObservationDao.create(obs1, mockSrd()).getId().toUnqualifiedVersionless();
Observation obs2 = new Observation();
obs1.getCode().setText("AAAAA");
obs1.setValue(new StringType("Diastolic Blood Pressure"));
obs2.setStatus(ObservationStatus.FINAL);
- IIdType id2 = myObservationDao.create(obs2, new ServletRequestDetails()).getId().toUnqualifiedVersionless();
+ IIdType id2 = myObservationDao.create(obs2, mockSrd()).getId().toUnqualifiedVersionless();
SearchParameterMap map;
@@ -100,7 +104,7 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test {
public void testSuggestIgnoresBase64Content() {
Patient patient = new Patient();
patient.addName().addFamily("testSuggest");
- IIdType ptId = myPatientDao.create(patient, new ServletRequestDetails()).getId().toUnqualifiedVersionless();
+ IIdType ptId = myPatientDao.create(patient, mockSrd()).getId().toUnqualifiedVersionless();
Media med = new Media();
med.getSubject().setReferenceElement(ptId);
@@ -108,7 +112,7 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test {
med.getContent().setContentType("LCws");
med.getContent().setDataElement(new Base64BinaryType(new byte[] {44,44,44,44,44,44,44,44}));
med.getContent().setTitle("bbbb syst");
- myMediaDao.create(med, new ServletRequestDetails());
+ myMediaDao.create(med, mockSrd());
ourLog.info(myFhirCtx.newJsonParser().encodeResourceToString(med));
List output = mySearchDao.suggestKeywords("Patient/" + ptId.getIdPart() + "/$everything", "_content", "press");
@@ -140,35 +144,35 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test {
public void testSuggest() {
Patient patient = new Patient();
patient.addName().addFamily("testSuggest");
- IIdType ptId = myPatientDao.create(patient, new ServletRequestDetails()).getId().toUnqualifiedVersionless();
+ IIdType ptId = myPatientDao.create(patient, mockSrd()).getId().toUnqualifiedVersionless();
Observation obs = new Observation();
obs.getSubject().setReferenceElement(ptId);
obs.getCode().setText("ZXCVBNM ASDFGHJKL QWERTYUIOPASDFGHJKL");
- myObservationDao.create(obs, new ServletRequestDetails());
+ myObservationDao.create(obs, mockSrd());
obs = new Observation();
obs.getSubject().setReferenceElement(ptId);
obs.getCode().setText("MNBVCXZ");
- myObservationDao.create(obs, new ServletRequestDetails());
+ myObservationDao.create(obs, mockSrd());
obs = new Observation();
obs.getSubject().setReferenceElement(ptId);
obs.getCode().setText("ZXC HELLO");
obs.addComponent().getCode().setText("HHHHHHHHHH");
- myObservationDao.create(obs, new ServletRequestDetails());
+ myObservationDao.create(obs, mockSrd());
/*
* These shouldn't match since they're for another patient
*/
patient = new Patient();
patient.addName().addFamily("testSuggest2");
- IIdType ptId2 = myPatientDao.create(patient, new ServletRequestDetails()).getId().toUnqualifiedVersionless();
+ IIdType ptId2 = myPatientDao.create(patient, mockSrd()).getId().toUnqualifiedVersionless();
Observation obs2 = new Observation();
obs2.getSubject().setReferenceElement(ptId2);
obs2.getCode().setText("ZXCVBNMZZ");
- myObservationDao.create(obs2, new ServletRequestDetails());
+ myObservationDao.create(obs2, mockSrd());
List output = mySearchDao.suggestKeywords("Patient/" + ptId.getIdPart() + "/$everything", "_content", "ZXCVBNM");
ourLog.info("Found: " + output);
@@ -213,7 +217,7 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test {
patient = new Patient();
patient.getText().setDivAsString("
DIVAAA
");
patient.addName().addGiven("NAMEAAA");
- IIdType pId1 = myPatientDao.create(patient, new ServletRequestDetails()).getId().toUnqualifiedVersionless();
+ IIdType pId1 = myPatientDao.create(patient, mockSrd()).getId().toUnqualifiedVersionless();
map = new SearchParameterMap();
map.add(Constants.PARAM_CONTENT, new StringParam("NAMEAAA"));
@@ -231,7 +235,7 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test {
patient.setId(pId1);
patient.getText().setDivAsString("
DIVBBB
");
patient.addName().addGiven("NAMEBBB");
- myPatientDao.update(patient, new ServletRequestDetails());
+ myPatientDao.update(patient, mockSrd());
map = new SearchParameterMap();
map.add(Constants.PARAM_CONTENT, new StringParam("NAMEAAA"));
@@ -255,19 +259,19 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test {
public void testEverythingInstanceWithContentFilter() {
Patient pt1 = new Patient();
pt1.addName().addFamily("Everything").addGiven("Arthur");
- IIdType ptId1 = myPatientDao.create(pt1, new ServletRequestDetails()).getId().toUnqualifiedVersionless();
+ IIdType ptId1 = myPatientDao.create(pt1, mockSrd()).getId().toUnqualifiedVersionless();
Patient pt2 = new Patient();
pt2.addName().addFamily("Everything").addGiven("Arthur");
- IIdType ptId2 = myPatientDao.create(pt2, new ServletRequestDetails()).getId().toUnqualifiedVersionless();
+ IIdType ptId2 = myPatientDao.create(pt2, mockSrd()).getId().toUnqualifiedVersionless();
Device dev1 = new Device();
dev1.setManufacturer("Some Manufacturer");
- IIdType devId1 = myDeviceDao.create(dev1, new ServletRequestDetails()).getId().toUnqualifiedVersionless();
+ IIdType devId1 = myDeviceDao.create(dev1, mockSrd()).getId().toUnqualifiedVersionless();
Device dev2 = new Device();
dev2.setManufacturer("Some Manufacturer 2");
- myDeviceDao.create(dev2, new ServletRequestDetails()).getId().toUnqualifiedVersionless();
+ myDeviceDao.create(dev2, mockSrd()).getId().toUnqualifiedVersionless();
Observation obs1 = new Observation();
obs1.getText().setDivAsString("
OBSTEXT1
");
@@ -275,19 +279,19 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test {
obs1.getCode().addCoding().setCode("CODE1");
obs1.setValue(new StringType("obsvalue1"));
obs1.getDevice().setReferenceElement(devId1);
- IIdType obsId1 = myObservationDao.create(obs1, new ServletRequestDetails()).getId().toUnqualifiedVersionless();
+ IIdType obsId1 = myObservationDao.create(obs1, mockSrd()).getId().toUnqualifiedVersionless();
Observation obs2 = new Observation();
obs2.getSubject().setReferenceElement(ptId1);
obs2.getCode().addCoding().setCode("CODE2");
obs2.setValue(new StringType("obsvalue2"));
- IIdType obsId2 = myObservationDao.create(obs2, new ServletRequestDetails()).getId().toUnqualifiedVersionless();
+ IIdType obsId2 = myObservationDao.create(obs2, mockSrd()).getId().toUnqualifiedVersionless();
Observation obs3 = new Observation();
obs3.getSubject().setReferenceElement(ptId2);
obs3.getCode().addCoding().setCode("CODE3");
obs3.setValue(new StringType("obsvalue3"));
- IIdType obsId3 = myObservationDao.create(obs3, new ServletRequestDetails()).getId().toUnqualifiedVersionless();
+ IIdType obsId3 = myObservationDao.create(obs3, mockSrd()).getId().toUnqualifiedVersionless();
HttpServletRequest request;
List actual;
@@ -298,16 +302,16 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test {
param = new StringAndListParam();
param.addAnd(new StringOrListParam().addOr(new StringParam("obsvalue1")));
- actual = toUnqualifiedVersionlessIdValues(myPatientDao.patientInstanceEverything(request, ptId1, null, null, null, param, null, new ServletRequestDetails()));
+ actual = toUnqualifiedVersionlessIdValues(myPatientDao.patientInstanceEverything(request, ptId1, null, null, null, param, null, mockSrd()));
assertThat(actual, containsInAnyOrder(toValues(ptId1, obsId1, devId1)));
param = new StringAndListParam();
param.addAnd(new StringOrListParam().addOr(new StringParam("obstext1")));
- actual = toUnqualifiedVersionlessIdValues(myPatientDao.patientInstanceEverything(request, ptId1, null, null, null, null, param, new ServletRequestDetails()));
+ actual = toUnqualifiedVersionlessIdValues(myPatientDao.patientInstanceEverything(request, ptId1, null, null, null, null, param, mockSrd()));
assertThat(actual, containsInAnyOrder(toValues(ptId1, obsId1, devId1)));
request = mock(HttpServletRequest.class);
- actual = toUnqualifiedVersionlessIdValues(myPatientDao.patientInstanceEverything(request, ptId1, null, null, null, null, null, new ServletRequestDetails()));
+ actual = toUnqualifiedVersionlessIdValues(myPatientDao.patientInstanceEverything(request, ptId1, null, null, null, null, null, mockSrd()));
assertThat(actual, containsInAnyOrder(toValues(ptId1, obsId1, obsId2, devId1)));
/*
@@ -318,12 +322,12 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test {
obs4.getSubject().setReferenceElement(ptId1);
obs4.getCode().addCoding().setCode("CODE1");
obs4.setValue(new StringType("obsvalue1"));
- IIdType obsId4 = myObservationDao.create(obs4, new ServletRequestDetails()).getId().toUnqualifiedVersionless();
+ IIdType obsId4 = myObservationDao.create(obs4, mockSrd()).getId().toUnqualifiedVersionless();
assertNotEquals(obsId1.getIdPart(), obsId4.getIdPart(), devId1);
param = new StringAndListParam();
param.addAnd(new StringOrListParam().addOr(new StringParam("obsvalue1")));
- actual = toUnqualifiedVersionlessIdValues(myPatientDao.patientInstanceEverything(request, ptId1, null, null, null, param, null, new ServletRequestDetails()));
+ actual = toUnqualifiedVersionlessIdValues(myPatientDao.patientInstanceEverything(request, ptId1, null, null, null, param, null, mockSrd()));
assertThat(actual, containsInAnyOrder(toValues(ptId1, obsId1, obsId4, devId1)));
/*
@@ -335,11 +339,11 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test {
obs1.getSubject().setReferenceElement(ptId1);
obs1.getCode().addCoding().setCode("CODE2");
obs1.setValue(new StringType("obsvalue2"));
- myObservationDao.update(obs1, new ServletRequestDetails());
+ myObservationDao.update(obs1, mockSrd());
param = new StringAndListParam();
param.addAnd(new StringOrListParam().addOr(new StringParam("obsvalue1")));
- actual = toUnqualifiedVersionlessIdValues(myPatientDao.patientInstanceEverything(request, ptId1, null, null, null, param, null, new ServletRequestDetails()));
+ actual = toUnqualifiedVersionlessIdValues(myPatientDao.patientInstanceEverything(request, ptId1, null, null, null, param, null, mockSrd()));
assertThat(actual, containsInAnyOrder(toValues(ptId1, obsId4)));
}
@@ -348,38 +352,38 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test {
public void testEverythingTypeWithContentFilter() {
Patient pt1 = new Patient();
pt1.addName().addFamily("Everything").addGiven("Arthur");
- IIdType ptId1 = myPatientDao.create(pt1, new ServletRequestDetails()).getId().toUnqualifiedVersionless();
+ IIdType ptId1 = myPatientDao.create(pt1, mockSrd()).getId().toUnqualifiedVersionless();
Patient pt2 = new Patient();
pt2.addName().addFamily("Everything").addGiven("Arthur");
- IIdType ptId2 = myPatientDao.create(pt2, new ServletRequestDetails()).getId().toUnqualifiedVersionless();
+ IIdType ptId2 = myPatientDao.create(pt2, mockSrd()).getId().toUnqualifiedVersionless();
Device dev1 = new Device();
dev1.setManufacturer("Some Manufacturer");
- IIdType devId1 = myDeviceDao.create(dev1, new ServletRequestDetails()).getId().toUnqualifiedVersionless();
+ IIdType devId1 = myDeviceDao.create(dev1, mockSrd()).getId().toUnqualifiedVersionless();
Device dev2 = new Device();
dev2.setManufacturer("Some Manufacturer 2");
- IIdType devId2 = myDeviceDao.create(dev2, new ServletRequestDetails()).getId().toUnqualifiedVersionless();
+ myDeviceDao.create(dev2, mockSrd()).getId().toUnqualifiedVersionless();
Observation obs1 = new Observation();
obs1.getSubject().setReferenceElement(ptId1);
obs1.getCode().addCoding().setCode("CODE1");
obs1.setValue(new StringType("obsvalue1"));
obs1.getDevice().setReferenceElement(devId1);
- IIdType obsId1 = myObservationDao.create(obs1, new ServletRequestDetails()).getId().toUnqualifiedVersionless();
+ IIdType obsId1 = myObservationDao.create(obs1, mockSrd()).getId().toUnqualifiedVersionless();
Observation obs2 = new Observation();
obs2.getSubject().setReferenceElement(ptId1);
obs2.getCode().addCoding().setCode("CODE2");
obs2.setValue(new StringType("obsvalue2"));
- IIdType obsId2 = myObservationDao.create(obs2, new ServletRequestDetails()).getId().toUnqualifiedVersionless();
+ IIdType obsId2 = myObservationDao.create(obs2, mockSrd()).getId().toUnqualifiedVersionless();
Observation obs3 = new Observation();
obs3.getSubject().setReferenceElement(ptId2);
obs3.getCode().addCoding().setCode("CODE3");
obs3.setValue(new StringType("obsvalue3"));
- IIdType obsId3 = myObservationDao.create(obs3, new ServletRequestDetails()).getId().toUnqualifiedVersionless();
+ IIdType obsId3 = myObservationDao.create(obs3, mockSrd()).getId().toUnqualifiedVersionless();
HttpServletRequest request;
List actual;
@@ -390,11 +394,11 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test {
param = new StringAndListParam();
param.addAnd(new StringOrListParam().addOr(new StringParam("obsvalue1")));
- actual = toUnqualifiedVersionlessIdValues(myPatientDao.patientTypeEverything(request, null, null, null, param, null, new ServletRequestDetails()));
+ actual = toUnqualifiedVersionlessIdValues(myPatientDao.patientTypeEverything(request, null, null, null, param, null, mockSrd()));
assertThat(actual, containsInAnyOrder(toValues(ptId1, obsId1, devId1)));
request = mock(HttpServletRequest.class);
- actual = toUnqualifiedVersionlessIdValues(myPatientDao.patientTypeEverything(request, null, null, null, null, null, new ServletRequestDetails()));
+ actual = toUnqualifiedVersionlessIdValues(myPatientDao.patientTypeEverything(request, null, null, null, null, null, mockSrd()));
assertThat(actual, containsInAnyOrder(toValues(ptId1, obsId1, obsId2, devId1, ptId2, obsId3)));
/*
@@ -405,12 +409,12 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test {
obs4.getSubject().setReferenceElement(ptId1);
obs4.getCode().addCoding().setCode("CODE1");
obs4.setValue(new StringType("obsvalue1"));
- IIdType obsId4 = myObservationDao.create(obs4, new ServletRequestDetails()).getId().toUnqualifiedVersionless();
+ IIdType obsId4 = myObservationDao.create(obs4, mockSrd()).getId().toUnqualifiedVersionless();
assertNotEquals(obsId1.getIdPart(), obsId4.getIdPart(), devId1);
param = new StringAndListParam();
param.addAnd(new StringOrListParam().addOr(new StringParam("obsvalue1")));
- actual = toUnqualifiedVersionlessIdValues(myPatientDao.patientTypeEverything(request, null, null, null, param, null, new ServletRequestDetails()));
+ actual = toUnqualifiedVersionlessIdValues(myPatientDao.patientTypeEverything(request, null, null, null, param, null, mockSrd()));
assertThat(actual, containsInAnyOrder(toValues(ptId1, obsId1, obsId4, devId1)));
/*
@@ -422,11 +426,11 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test {
obs1.getSubject().setReferenceElement(ptId1);
obs1.getCode().addCoding().setCode("CODE2");
obs1.setValue(new StringType("obsvalue2"));
- myObservationDao.update(obs1, new ServletRequestDetails());
+ myObservationDao.update(obs1, mockSrd());
param = new StringAndListParam();
param.addAnd(new StringOrListParam().addOr(new StringParam("obsvalue1")));
- actual = toUnqualifiedVersionlessIdValues(myPatientDao.patientTypeEverything(request, null, null, null, param, null, new ServletRequestDetails()));
+ actual = toUnqualifiedVersionlessIdValues(myPatientDao.patientTypeEverything(request, null, null, null, param, null, mockSrd()));
assertThat(actual, containsInAnyOrder(toValues(ptId1, obsId4)));
}
@@ -444,7 +448,7 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test {
patient = new Patient();
patient.getText().setDivAsString("
DIVAAA
");
patient.addName().addGiven("NAMEAAA");
- IIdType pId1 = myPatientDao.create(patient, new ServletRequestDetails()).getId().toUnqualifiedVersionless();
+ IIdType pId1 = myPatientDao.create(patient, mockSrd()).getId().toUnqualifiedVersionless();
map = new SearchParameterMap();
map.add(Constants.PARAM_CONTENT, new StringParam("NAMEAAA"));
@@ -462,7 +466,7 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test {
patient.setId(pId1);
patient.getText().setDivAsString("
DIVBBB
");
patient.addName().addGiven("NAMEBBB");
- myPatientDao.update(patient, null, false, new ServletRequestDetails());
+ myPatientDao.update(patient, null, false, mockSrd());
map = new SearchParameterMap();
map.add(Constants.PARAM_CONTENT, new StringParam("NAMEAAA"));
@@ -471,7 +475,7 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test {
map.add(Constants.PARAM_CONTENT, new StringParam("NAMEBBB"));
assertThat(toUnqualifiedVersionlessIdValues(myPatientDao.search(map)), not(contains(toValues(pId1))));
- myPatientDao.update(patient, null, true, new ServletRequestDetails());
+ myPatientDao.update(patient, null, true, mockSrd());
map = new SearchParameterMap();
map.add(Constants.PARAM_CONTENT, new StringParam("NAMEAAA"));
@@ -499,18 +503,18 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test {
Patient patient = new Patient();
patient.addName().addGiven(methodName);
patient.addAddress().addLine("My fulltext address");
- pId1 = myPatientDao.create(patient, new ServletRequestDetails()).getId().toUnqualifiedVersionless();
+ pId1 = myPatientDao.create(patient, mockSrd()).getId().toUnqualifiedVersionless();
}
Observation obs = new Observation();
obs.getSubject().setReferenceElement(pId1);
obs.setValue(new StringType("This is the FULLtext of the observation"));
- IIdType oId1 = myObservationDao.create(obs, new ServletRequestDetails()).getId().toUnqualifiedVersionless();
+ IIdType oId1 = myObservationDao.create(obs, mockSrd()).getId().toUnqualifiedVersionless();
obs = new Observation();
obs.getSubject().setReferenceElement(pId1);
obs.setValue(new StringType("Another fullText"));
- IIdType oId2 = myObservationDao.create(obs, new ServletRequestDetails()).getId().toUnqualifiedVersionless();
+ IIdType oId2 = myObservationDao.create(obs, mockSrd()).getId().toUnqualifiedVersionless();
List patients;
SearchParameterMap params;
diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchNoFtTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchNoFtTest.java
index cfad4424cb2..1c3df054e74 100644
--- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchNoFtTest.java
+++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchNoFtTest.java
@@ -51,6 +51,7 @@ import org.hl7.fhir.dstu3.model.Subscription.SubscriptionStatus;
import org.hl7.fhir.dstu3.model.Substance;
import org.hl7.fhir.dstu3.model.TemporalPrecisionEnum;
import org.hl7.fhir.dstu3.model.ValueSet;
+import org.hl7.fhir.instance.model.api.IAnyResource;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.instance.model.api.IIdType;
import org.junit.Ignore;
@@ -67,6 +68,7 @@ import ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamUri;
import ca.uhn.fhir.jpa.entity.ResourceLink;
import ca.uhn.fhir.model.api.IQueryParameterType;
import ca.uhn.fhir.model.api.Include;
+import ca.uhn.fhir.model.dstu.valueset.QuantityCompararatorEnum;
import ca.uhn.fhir.rest.api.SortOrderEnum;
import ca.uhn.fhir.rest.api.SortSpec;
import ca.uhn.fhir.rest.param.CompositeParam;
diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirSystemDaoDstu3Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirSystemDaoDstu3Test.java
index eb39585b3f3..f79375cd079 100644
--- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirSystemDaoDstu3Test.java
+++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirSystemDaoDstu3Test.java
@@ -322,7 +322,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest {
Patient p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName);
p.setId("Patient/" + methodName);
- IIdType id = myPatientDao.update(p).getId();
+ IIdType id = myPatientDao.update(p, mySrd).getId();
ourLog.info("Created patient, got it: {}", id);
Observation o = new Observation();
@@ -339,7 +339,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest {
assertThat(respEntry.getResponse().getLocation(), endsWith("/_history/1"));
assertEquals("1", respEntry.getResponse().getEtag());
- o = myObservationDao.read(new IdType(respEntry.getResponse().getLocationElement()));
+ o = myObservationDao.read(new IdType(respEntry.getResponse().getLocationElement()), mySrd);
assertEquals(id.toVersionless().getValue(), o.getSubject().getReference());
assertEquals("1", o.getIdElement().getVersionIdPart());
@@ -354,11 +354,11 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest {
Patient p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName);
- myPatientDao.create(p).getId();
+ myPatientDao.create(p, mySrd).getId();
p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName);
- myPatientDao.create(p).getId();
+ myPatientDao.create(p, mySrd).getId();
Observation o = new Observation();
o.getCode().setText("Some Observation");
@@ -382,11 +382,11 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest {
Patient p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName);
- myPatientDao.create(p).getId();
+ myPatientDao.create(p, mySrd).getId();
p = new Patient();
p.addIdentifier().setSystem("urn:system").setValue(methodName);
- myPatientDao.create(p).getId();
+ myPatientDao.create(p, mySrd).getId();
Observation o = new Observation();
o.getCode().setText("Some Observation");
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/DynamicSearchTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/DynamicSearchTest.java
index 63d06a264b1..a72e55159d0 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/DynamicSearchTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/DynamicSearchTest.java
@@ -173,8 +173,8 @@ public class DynamicSearchTest {
@Override
public List getSearchParameters() {
ArrayList retVal = new ArrayList();
- retVal.add(new RuntimeSearchParam("param1", "This is the first parameter", "Patient.param1", RestSearchParameterTypeEnum.STRING));
- retVal.add(new RuntimeSearchParam("param2", "This is the second parameter", "Patient.param2", RestSearchParameterTypeEnum.DATE));
+ retVal.add(new RuntimeSearchParam("param1", "This is the first parameter", "Patient.param1", RestSearchParameterTypeEnum.STRING, null));
+ retVal.add(new RuntimeSearchParam("param2", "This is the second parameter", "Patient.param2", RestSearchParameterTypeEnum.DATE, null));
return retVal;
}