From b4a362b8eeca42fc96fd68c5b6f48ea98d1403db Mon Sep 17 00:00:00 2001
From: James
Date: Wed, 1 Feb 2017 05:55:35 -0500
Subject: [PATCH] Work in progress
---
.../.settings/org.eclipse.jdt.core.prefs | 5 +
.../.settings/org.eclipse.jdt.core.prefs | 5 +
.../java/ca/uhn/fhir/context/FhirContext.java | 172 ++++++------
.../ca/uhn/fhir/context/ModelScanner.java | 5 +-
.../uhn/fhir/context/RuntimeSearchParam.java | 18 +-
.../fhir/rest/annotation/OptionalParam.java | 126 ++++-----
.../ca/uhn/fhir/rest/annotation/RawParam.java | 20 ++
.../fhir/rest/annotation/RequiredParam.java | 63 +++--
.../ca/uhn/fhir/rest/method/MethodUtil.java | 2 +
.../fhir/rest/method/RawParamsParmeter.java | 74 +++++
.../fhir/rest/method/SearchMethodBinding.java | 19 +-
.../.settings/org.eclipse.jdt.core.prefs | 5 +
.../.settings/org.eclipse.jdt.core.prefs | 5 +
.../.settings/org.eclipse.jdt.core.prefs | 5 +
.../.settings/org.eclipse.jdt.core.prefs | 5 +
.../uhn/fhir/jpa/config/BaseDstu1Config.java | 36 ++-
.../uhn/fhir/jpa/config/BaseDstu2Config.java | 7 +
.../jpa/config/dstu3/BaseDstu3Config.java | 58 ++--
.../fhir/jpa/dao/BaseHapiFhirResourceDao.java | 7 +-
.../jpa/dao/BaseSearchParamExtractor.java | 51 ++--
.../fhir/jpa/dao/BaseSearchParamRegistry.java | 65 +++++
.../java/ca/uhn/fhir/jpa/dao/DaoConfig.java | 120 +++++---
.../jpa/dao/FhirResourceDaoPatientDstu2.java | 6 +-
.../fhir/jpa/dao/ISearchParamRegistry.java | 13 +
.../ca/uhn/fhir/jpa/dao/SearchBuilder.java | 91 +++---
.../jpa/dao/SearchParamExtractorDstu1.java | 24 +-
.../jpa/dao/SearchParamExtractorDstu2.java | 44 +--
.../jpa/dao/SearchParamRegistryDstu1.java | 6 +
.../jpa/dao/SearchParamRegistryDstu2.java | 6 +
.../dstu3/FhirResourceDaoPatientDstu3.java | 7 +-
.../dao/dstu3/SearchParamExtractorDstu3.java | 68 ++---
.../dao/dstu3/SearchParamRegistryDstu3.java | 194 +++++++++++++
.../fhir/jpa/dao/dstu3/BaseJpaDstu3Test.java | 6 +
...ResourceDaoDstu3SearchCustomParamTest.java | 203 ++++++++++++++
.../dstu3/SearchParamExtractorDstu3Test.java | 26 +-
.../fhir/rest/server/DynamicSearchTest.java | 5 +-
.../server/SearchDefaultMethodDstu3Test.java | 261 ++++++++++++++++++
.../.settings/org.eclipse.jdt.core.prefs | 5 +
38 files changed, 1448 insertions(+), 390 deletions(-)
create mode 100644 example-projects/hapi-fhir-base-example-embedded-ws/.settings/org.eclipse.jdt.core.prefs
create mode 100644 example-projects/hapi-fhir-standalone-overlay-example/.settings/org.eclipse.jdt.core.prefs
create mode 100644 hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/annotation/RawParam.java
create mode 100644 hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/RawParamsParmeter.java
create mode 100644 hapi-fhir-client-okhttp/.settings/org.eclipse.jdt.core.prefs
create mode 100644 hapi-fhir-jacoco/.settings/org.eclipse.jdt.core.prefs
create mode 100644 hapi-fhir-jaxrsserver-base/.settings/org.eclipse.jdt.core.prefs
create mode 100644 hapi-fhir-jaxrsserver-example/.settings/org.eclipse.jdt.core.prefs
create mode 100644 hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseSearchParamRegistry.java
create mode 100644 hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/ISearchParamRegistry.java
create mode 100644 hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchParamRegistryDstu1.java
create mode 100644 hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchParamRegistryDstu2.java
create mode 100644 hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/dstu3/SearchParamRegistryDstu3.java
create mode 100644 hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3SearchCustomParamTest.java
create mode 100644 hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/rest/server/SearchDefaultMethodDstu3Test.java
create mode 100644 hapi-fhir-validation-resources-dstu2.1/.settings/org.eclipse.jdt.core.prefs
diff --git a/example-projects/hapi-fhir-base-example-embedded-ws/.settings/org.eclipse.jdt.core.prefs b/example-projects/hapi-fhir-base-example-embedded-ws/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..60105c1b951
--- /dev/null
+++ b/example-projects/hapi-fhir-base-example-embedded-ws/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,5 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/example-projects/hapi-fhir-standalone-overlay-example/.settings/org.eclipse.jdt.core.prefs b/example-projects/hapi-fhir-standalone-overlay-example/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..714351aec19
--- /dev/null
+++ b/example-projects/hapi-fhir-standalone-overlay-example/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,5 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/FhirContext.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/FhirContext.java
index edcbecb4ea6..8e60f760bb5 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/FhirContext.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/FhirContext.java
@@ -82,87 +82,22 @@ public class FhirContext {
private Map> myDefaultTypeForProfile = new HashMap>();
private volatile Map myIdToResourceDefinition = Collections.emptyMap();
private boolean myInitialized;
+ private boolean myInitializing;
private HapiLocalizer myLocalizer = new HapiLocalizer();
private volatile Map> myNameToElementDefinition = Collections.emptyMap();
private volatile Map myNameToResourceDefinition = Collections.emptyMap();
private volatile Map> myNameToResourceType;
private volatile INarrativeGenerator myNarrativeGenerator;
private volatile IParserErrorHandler myParserErrorHandler = new LenientErrorHandler();
+ private ParserOptions myParserOptions = new ParserOptions();
private Set myPerformanceOptions = new HashSet();
private Collection> myResourceTypesToScan;
private volatile IRestfulClientFactory myRestfulClientFactory;
private volatile RuntimeChildUndeclaredExtensionDefinition myRuntimeChildUndeclaredExtensionDefinition;
- private final IFhirVersion myVersion;
- private Map>> myVersionToNameToResourceType = Collections.emptyMap();
- private boolean myInitializing;
private IContextValidationSupport, ?, ?, ?, ?, ?> myValidationSupport;
+ private final IFhirVersion myVersion;
- /**
- * Returns the validation support module configured for this context, creating a default
- * implementation if no module has been passed in via the {@link #setValidationSupport(IContextValidationSupport)}
- * method
- * @see #setValidationSupport(IContextValidationSupport)
- */
- public IContextValidationSupport, ?, ?, ?, ?, ?> getValidationSupport() {
- if (myValidationSupport == null) {
- myValidationSupport = myVersion.createValidationSupport();
- }
- return myValidationSupport;
- }
-
- /**
- * Creates a new FluentPath engine which can be used to exvaluate
- * path expressions over FHIR resources. Note that this engine will use the
- * {@link IContextValidationSupport context validation support} module which is
- * configured on the context at the time this method is called.
- *
- * In other words, call {@link #setValidationSupport(IContextValidationSupport)} before
- * calling {@link #newFluentPath()}
- *
- *
- * Note that this feature was added for FHIR DSTU3 and is not available
- * for contexts configured to use an older version of FHIR. Calling this method
- * on a context for a previous version of fhir will result in an
- * {@link UnsupportedOperationException}
- *
- *
- * @since 2.2
- */
- public IFluentPath newFluentPath() {
- return myVersion.createFluentPathExecutor(this);
- }
-
- /**
- * Sets the validation support module to use for this context. The validation support module
- * is used to supply underlying infrastructure such as conformance resources (StructureDefinition, ValueSet, etc)
- * as well as to provide terminology services to modules such as the validator and FluentPath executor
- */
- public void setValidationSupport(IContextValidationSupport, ?, ?, ?, ?, ?> theValidationSupport) {
- myValidationSupport = theValidationSupport;
- }
-
- private ParserOptions myParserOptions = new ParserOptions();
-
- /**
- * Returns the parser options object which will be used to supply default
- * options to newly created parsers
- *
- * @return The parser options - Will not return null
- */
- public ParserOptions getParserOptions() {
- return myParserOptions;
- }
-
- /**
- * Sets the parser options object which will be used to supply default
- * options to newly created parsers
- *
- * @param theParserOptions The parser options object - Must not be null
- */
- public void setParserOptions(ParserOptions theParserOptions) {
- Validate.notNull(theParserOptions, "theParserOptions must not be null");
- myParserOptions = theParserOptions;
- }
+ private Map>> myVersionToNameToResourceType = Collections.emptyMap();
/**
* @deprecated It is recommended that you use one of the static initializer methods instead
@@ -172,7 +107,7 @@ public class FhirContext {
public FhirContext() {
this(EMPTY_LIST);
}
-
+
/**
* @deprecated It is recommended that you use one of the static initializer methods instead
* of this method, e.g. {@link #forDstu2()} or {@link #forDstu3()}
@@ -282,7 +217,7 @@ public class FhirContext {
validateInitialized();
return myNameToResourceDefinition.values();
}
-
+
/**
* Returns the default resource type for the given profile
*
@@ -332,7 +267,7 @@ public class FhirContext {
validateInitialized();
return Collections.unmodifiableCollection(myClassToElementDefinition.values());
}
-
+
/**
* This feature is not yet in its final state and should be considered an internal part of HAPI for now - use with
* caution
@@ -348,6 +283,16 @@ public class FhirContext {
return myNarrativeGenerator;
}
+ /**
+ * Returns the parser options object which will be used to supply default
+ * options to newly created parsers
+ *
+ * @return The parser options - Will not return null
+ */
+ public ParserOptions getParserOptions() {
+ return myParserOptions;
+ }
+
/**
* Get the configured performance options
*/
@@ -449,6 +394,20 @@ public class FhirContext {
return myIdToResourceDefinition.get(theId);
}
+// /**
+// * Return an unmodifiable collection containing all known resource definitions
+// */
+// public Collection getResourceDefinitions() {
+//
+// Set> datatypes = Collections.emptySet();
+// Map, BaseRuntimeElementDefinition>> existing = Collections.emptyMap();
+// HashMap> types = new HashMap>();
+// ModelScanner.scanVersionPropertyFile(datatypes, types, myVersion.getVersion(), existing);
+// for (int next : types.)
+//
+// return Collections.unmodifiableCollection(myIdToResourceDefinition.values());
+// }
+
/**
* Returns the scanned runtime models. This is an advanced feature which is generally only needed for extending the
* core library.
@@ -476,6 +435,19 @@ public class FhirContext {
return myRuntimeChildUndeclaredExtensionDefinition;
}
+ /**
+ * Returns the validation support module configured for this context, creating a default
+ * implementation if no module has been passed in via the {@link #setValidationSupport(IContextValidationSupport)}
+ * method
+ * @see #setValidationSupport(IContextValidationSupport)
+ */
+ public IContextValidationSupport, ?, ?, ?, ?, ?> getValidationSupport() {
+ if (myValidationSupport == null) {
+ myValidationSupport = myVersion.createValidationSupport();
+ }
+ return myValidationSupport;
+ }
+
public IFhirVersion getVersion() {
return myVersion;
}
@@ -500,6 +472,28 @@ public class FhirContext {
return myVersion.newBundleFactory(this);
}
+ /**
+ * Creates a new FluentPath engine which can be used to exvaluate
+ * path expressions over FHIR resources. Note that this engine will use the
+ * {@link IContextValidationSupport context validation support} module which is
+ * configured on the context at the time this method is called.
+ *
+ * In other words, call {@link #setValidationSupport(IContextValidationSupport)} before
+ * calling {@link #newFluentPath()}
+ *
+ *
+ * Note that this feature was added for FHIR DSTU3 and is not available
+ * for contexts configured to use an older version of FHIR. Calling this method
+ * on a context for a previous version of fhir will result in an
+ * {@link UnsupportedOperationException}
+ *
+ *
+ * @since 2.2
+ */
+ public IFluentPath newFluentPath() {
+ return myVersion.createFluentPathExecutor(this);
+ }
+
/**
* Create and return a new JSON parser.
*
@@ -783,6 +777,17 @@ public class FhirContext {
myParserErrorHandler = theParserErrorHandler;
}
+ /**
+ * Sets the parser options object which will be used to supply default
+ * options to newly created parsers
+ *
+ * @param theParserOptions The parser options object - Must not be null
+ */
+ public void setParserOptions(ParserOptions theParserOptions) {
+ Validate.notNull(theParserOptions, "theParserOptions must not be null");
+ myParserOptions = theParserOptions;
+ }
+
/**
* Sets the configured performance options
*
@@ -818,6 +823,15 @@ public class FhirContext {
this.myRestfulClientFactory = theRestfulClientFactory;
}
+ /**
+ * Sets the validation support module to use for this context. The validation support module
+ * is used to supply underlying infrastructure such as conformance resources (StructureDefinition, ValueSet, etc)
+ * as well as to provide terminology services to modules such as the validator and FluentPath executor
+ */
+ public void setValidationSupport(IContextValidationSupport, ?, ?, ?, ?, ?> theValidationSupport) {
+ myValidationSupport = theValidationSupport;
+ }
+
@SuppressWarnings({ "cast" })
private List> toElementList(Collection> theResourceTypes) {
if (theResourceTypes == null) {
@@ -850,6 +864,13 @@ public class FhirContext {
return new FhirContext(FhirVersionEnum.DSTU2);
}
+ /**
+ * Creates and returns a new FhirContext with version {@link FhirVersionEnum#DSTU2 DSTU2} (2016 May DSTU3 Snapshot)
+ */
+ public static FhirContext forDstu2_1() {
+ return new FhirContext(FhirVersionEnum.DSTU2_1);
+ }
+
/**
* Creates and returns a new FhirContext with version {@link FhirVersionEnum#DSTU2_HL7ORG DSTU2} (using the Reference
* Implementation Structures)
@@ -885,11 +906,4 @@ public class FhirContext {
return retVal;
}
- /**
- * Creates and returns a new FhirContext with version {@link FhirVersionEnum#DSTU2 DSTU2} (2016 May DSTU3 Snapshot)
- */
- public static FhirContext forDstu2_1() {
- return new FhirContext(FhirVersionEnum.DSTU2_1);
- }
-
}
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 42776441e9a..96a418a7c95 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
@@ -34,6 +34,7 @@ import java.util.Map.Entry;
import org.apache.commons.io.IOUtils;
import org.hl7.fhir.instance.model.api.*;
+import ca.uhn.fhir.context.RuntimeSearchParam.RuntimeSearchParamStatusEnum;
import ca.uhn.fhir.model.api.ExtensionDt;
import ca.uhn.fhir.model.api.IDatatype;
import ca.uhn.fhir.model.api.IElement;
@@ -437,7 +438,7 @@ class ModelScanner {
}
- RuntimeSearchParam param = new RuntimeSearchParam(searchParam.name(), searchParam.description(), searchParam.path(), paramType, providesMembershipInCompartments, toTargetList(searchParam.target()));
+ RuntimeSearchParam param = new RuntimeSearchParam(searchParam.name(), searchParam.description(), searchParam.path(), paramType, providesMembershipInCompartments, toTargetList(searchParam.target()), RuntimeSearchParamStatusEnum.ACTIVE);
theResourceDef.addSearchParam(param);
nameToParam.put(param.getName(), param);
}
@@ -457,7 +458,7 @@ class ModelScanner {
compositeOf.add(param);
}
- RuntimeSearchParam param = new RuntimeSearchParam(searchParam.name(), searchParam.description(), searchParam.path(), RestSearchParameterTypeEnum.COMPOSITE, compositeOf, null, toTargetList(searchParam.target()));
+ RuntimeSearchParam param = new RuntimeSearchParam(searchParam.name(), searchParam.description(), searchParam.path(), RestSearchParameterTypeEnum.COMPOSITE, compositeOf, null, toTargetList(searchParam.target()), RuntimeSearchParamStatusEnum.ACTIVE);
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 22da3f10e0f..7851ef55d6b 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
@@ -37,15 +37,17 @@ public class RuntimeSearchParam {
private final String myPath;
private final Set myTargets;
private final Set myProvidesMembershipInCompartments;
+ private final RuntimeSearchParamStatusEnum myStatus;
public RuntimeSearchParam(String theName, String theDescription, String thePath, RestSearchParameterTypeEnum theParamType, List theCompositeOf,
- Set theProvidesMembershipInCompartments, Set theTargets) {
+ Set theProvidesMembershipInCompartments, Set theTargets, RuntimeSearchParamStatusEnum theStatus) {
super();
myName = theName;
myDescription = theDescription;
myPath = thePath;
myParamType = theParamType;
myCompositeOf = theCompositeOf;
+ myStatus = theStatus;
if (theProvidesMembershipInCompartments != null && !theProvidesMembershipInCompartments.isEmpty()) {
myProvidesMembershipInCompartments = Collections.unmodifiableSet(theProvidesMembershipInCompartments);
} else {
@@ -62,8 +64,12 @@ public class RuntimeSearchParam {
return myTargets;
}
- public RuntimeSearchParam(String theName, String theDescription, String thePath, RestSearchParameterTypeEnum theParamType, Set theProvidesMembershipInCompartments, Set theTargets) {
- this(theName, theDescription, thePath, theParamType, null, theProvidesMembershipInCompartments, theTargets);
+ public RuntimeSearchParamStatusEnum getStatus() {
+ return myStatus;
+ }
+
+ public RuntimeSearchParam(String theName, String theDescription, String thePath, RestSearchParameterTypeEnum theParamType, Set theProvidesMembershipInCompartments, Set theTargets, RuntimeSearchParamStatusEnum theStatus) {
+ this(theName, theDescription, thePath, theParamType, null, theProvidesMembershipInCompartments, theTargets, theStatus);
}
public List getCompositeOf() {
@@ -108,4 +114,10 @@ public class RuntimeSearchParam {
return myProvidesMembershipInCompartments;
}
+ public enum RuntimeSearchParamStatusEnum {
+ ACTIVE,
+ DRAFT,
+ RETIRED
+ }
+
}
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/annotation/OptionalParam.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/annotation/OptionalParam.java
index 5a1b573b030..6b7bf8a3df6 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/annotation/OptionalParam.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/annotation/OptionalParam.java
@@ -1,5 +1,7 @@
package ca.uhn.fhir.rest.annotation;
+import java.lang.annotation.ElementType;
+
/*
* #%L
* HAPI FHIR - Core Library
@@ -10,7 +12,7 @@ package ca.uhn.fhir.rest.annotation;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -22,19 +24,19 @@ package ca.uhn.fhir.rest.annotation;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
import org.hl7.fhir.instance.model.api.IBaseResource;
import ca.uhn.fhir.model.api.IQueryParameterType;
import ca.uhn.fhir.rest.param.CompositeParam;
import ca.uhn.fhir.rest.param.ReferenceParam;
-//import ca.uhn.fhir.testmodel.Patient; // TODO: qualify this correctly
-
/**
- * Parameter annotation which specifies a search parameter for a {@link Search} method.
+ * Parameter annotation which specifies a search parameter for a {@link Search} method.
*/
@Retention(RetentionPolicy.RUNTIME)
+@Target(value=ElementType.PARAMETER)
public @interface OptionalParam {
public static final String ALLOW_CHAIN_ANY = "*";
@@ -42,63 +44,63 @@ public @interface OptionalParam {
public static final String ALLOW_CHAIN_NOTCHAINED = "";
/**
- * For reference parameters ({@link ReferenceParam}) this value may be
- * used to indicate which chain values (if any) are not valid
- * for the given parameter. Values here will supercede any values specified
- * in {@link #chainWhitelist()}
- *
- * If the parameter annotated with this annotation is not a {@link ReferenceParam},
- * this value must not be populated.
- *
- */
+ * For reference parameters ({@link ReferenceParam}) this value may be
+ * used to indicate which chain values (if any) are not valid
+ * for the given parameter. Values here will supercede any values specified
+ * in {@link #chainWhitelist()}
+ *
+ * If the parameter annotated with this annotation is not a {@link ReferenceParam},
+ * this value must not be populated.
+ *
+ */
String[] chainBlacklist() default {};
-
- /**
- * For reference parameters ({@link ReferenceParam}) this value may be
- * used to indicate which chain values (if any) are valid for the given
- * parameter. If the list contains the value {@link #ALLOW_CHAIN_ANY}, all values are valid. (this is the default)
- * If the list contains the value {@link #ALLOW_CHAIN_NOTCHAINED}
- * then the reference param only supports the empty chain (i.e. the resource
- * ID).
- *
- * Valid values for this parameter include:
- *
- *
- *
chainWhitelist={ OptionalParam.ALLOW_CHAIN_NOTCHAINED } - Only allow resource reference (no chaining allowed for this parameter)
- *
chainWhitelist={ OptionalParam.ALLOW_CHAIN_ANY } - Allow any chaining at all (including a non chained value, this is the default)
- *
chainWhitelist={ "foo", "bar" } - Allow property.foo and property.bar
- *
- *
- * Any values specified in
- * {@link #chainBlacklist()} will supercede (have priority over) values
- * here.
- *
- *
- * If the parameter annotated with this annotation is not a {@link ReferenceParam},
- * this value must not be populated.
- *
- */
- String[] chainWhitelist() default {ALLOW_CHAIN_ANY};
-
- /**
- * For composite parameters ({@link CompositeParam}) this value may be
- * used to indicate the parameter type(s) which may be referenced by this param.
- *
- * If the parameter annotated with this annotation is not a {@link CompositeParam},
- * this value must not be populated.
- *
- */
- Class extends IQueryParameterType>[] compositeTypes() default {};
- /**
- * This is the name for the parameter. Generally this should be a
+ /**
+ * For reference parameters ({@link ReferenceParam}) this value may be
+ * used to indicate which chain values (if any) are valid for the given
+ * parameter. If the list contains the value {@link #ALLOW_CHAIN_ANY}, all values are valid. (this is the default)
+ * If the list contains the value {@link #ALLOW_CHAIN_NOTCHAINED}
+ * then the reference param only supports the empty chain (i.e. the resource
+ * ID).
+ *
+ * Valid values for this parameter include:
+ *
+ *
+ *
chainWhitelist={ OptionalParam.ALLOW_CHAIN_NOTCHAINED } - Only allow resource reference (no chaining allowed for this parameter)
+ *
chainWhitelist={ OptionalParam.ALLOW_CHAIN_ANY } - Allow any chaining at all (including a non chained value, this is the default)
+ *
chainWhitelist={ "foo", "bar" } - Allow property.foo and property.bar
+ *
+ *
+ * Any values specified in
+ * {@link #chainBlacklist()} will supercede (have priority over) values
+ * here.
+ *
+ *
+ * If the parameter annotated with this annotation is not a {@link ReferenceParam},
+ * this value must not be populated.
+ *
+ */
+ String[] chainWhitelist() default { ALLOW_CHAIN_ANY };
+
+ /**
+ * For composite parameters ({@link CompositeParam}) this value may be
+ * used to indicate the parameter type(s) which may be referenced by this param.
+ *
+ * If the parameter annotated with this annotation is not a {@link CompositeParam},
+ * this value must not be populated.
+ *
+ */
+ Class extends IQueryParameterType>[] compositeTypes() default {};
+
+ /**
+ * This is the name for the parameter. Generally this should be a
* simple string (e.g. "name", or "identifier") which will be the name
* of the URL parameter used to populate this method parameter.
*
* Most resource model classes have constants which may be used to
* supply values for this field, e.g. Patient.SP_NAME or
* Observation.SP_DATE
- *
+ *
*
* If you wish to specify a parameter for a resource reference which
* only accepts a specific chained value, it is also valid to supply
@@ -109,13 +111,13 @@ public @interface OptionalParam {
*/
String name();
- /**
- * For resource reference parameters ({@link ReferenceParam}) this value may be
- * used to indicate the resource type(s) which may be referenced by this param.
- *
- * If the parameter annotated with this annotation is not a {@link ReferenceParam},
- * this value must not be populated.
- *
- */
- Class extends IBaseResource>[] targetTypes() default {};
+ /**
+ * For resource reference parameters ({@link ReferenceParam}) this value may be
+ * used to indicate the resource type(s) which may be referenced by this param.
+ *
+ * If the parameter annotated with this annotation is not a {@link ReferenceParam},
+ * this value must not be populated.
+ *
+ */
+ Class extends IBaseResource>[] targetTypes() default {};
}
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/annotation/RawParam.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/annotation/RawParam.java
new file mode 100644
index 00000000000..db68c28b50b
--- /dev/null
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/annotation/RawParam.java
@@ -0,0 +1,20 @@
+package ca.uhn.fhir.rest.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * On a {@link Search} method, a parameter marked with this annotation
+ * will receive search parameters not captured by other parameters.
+ *
+ * Parameters with this annotation must be of type
+ * {@code Map>}
+ *
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(value=ElementType.PARAMETER)
+public @interface RawParam {
+ // nothing
+}
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/annotation/RequiredParam.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/annotation/RequiredParam.java
index af12e9e14ac..9efda9da757 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/annotation/RequiredParam.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/annotation/RequiredParam.java
@@ -1,5 +1,7 @@
package ca.uhn.fhir.rest.annotation;
+import java.lang.annotation.ElementType;
+
/*
* #%L
* HAPI FHIR - Core Library
@@ -10,7 +12,7 @@ package ca.uhn.fhir.rest.annotation;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -22,18 +24,19 @@ package ca.uhn.fhir.rest.annotation;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
import org.hl7.fhir.instance.model.api.IBaseResource;
import ca.uhn.fhir.model.api.IQueryParameterType;
import ca.uhn.fhir.rest.param.CompositeParam;
import ca.uhn.fhir.rest.param.ReferenceParam;
-//import ca.uhn.fhir.testmodel.Patient; // TODO: qualify this correctly
-@Retention(RetentionPolicy.RUNTIME)
/**
- * Parameter annotation which specifies a search parameter for a {@link Search} method.
+ * Parameter annotation which specifies a search parameter for a {@link Search} method.
*/
+@Retention(RetentionPolicy.RUNTIME)
+@Target(value=ElementType.PARAMETER)
public @interface RequiredParam {
/**
@@ -45,32 +48,32 @@ public @interface RequiredParam {
*/
String[] chainBlacklist() default {};
- /**
- * For reference parameters ({@link ReferenceParam}) this value may be
- * used to indicate which chain values (if any) are valid for the given
- * parameter. If the list contains the value {@link OptionalParam#ALLOW_CHAIN_ANY}, all values are valid. (this is the default)
- * If the list contains the value {@link OptionalParam#ALLOW_CHAIN_NOTCHAINED}
- * then the reference param only supports the empty chain (i.e. the resource
- * ID).
- *
- * Valid values for this parameter include:
- *
- *
- *
chainWhitelist={ OptionalParam.ALLOW_CHAIN_NOTCHAINED } - Only allow resource reference (no chaining allowed for this parameter)
- *
chainWhitelist={ OptionalParam.ALLOW_CHAIN_ANY } - Allow any chaining at all (including a non chained value, this is the default)
- *
chainWhitelist={ "foo", "bar" } - Allow property.foo and property.bar
- *
- *
- * Any values specified in
- * {@link #chainBlacklist()} will supercede (have priority over) values
- * here.
- *
- *
- * If the parameter annotated with this annotation is not a {@link ReferenceParam},
- * this value must not be populated.
- *
- */
- String[] chainWhitelist() default {OptionalParam.ALLOW_CHAIN_ANY};
+ /**
+ * For reference parameters ({@link ReferenceParam}) this value may be
+ * used to indicate which chain values (if any) are valid for the given
+ * parameter. If the list contains the value {@link OptionalParam#ALLOW_CHAIN_ANY}, all values are valid. (this is the default)
+ * If the list contains the value {@link OptionalParam#ALLOW_CHAIN_NOTCHAINED}
+ * then the reference param only supports the empty chain (i.e. the resource
+ * ID).
+ *
+ * Valid values for this parameter include:
+ *
+ *
+ *
chainWhitelist={ OptionalParam.ALLOW_CHAIN_NOTCHAINED } - Only allow resource reference (no chaining allowed for this parameter)
+ *
chainWhitelist={ OptionalParam.ALLOW_CHAIN_ANY } - Allow any chaining at all (including a non chained value, this is the default)
+ *
chainWhitelist={ "foo", "bar" } - Allow property.foo and property.bar
+ *
+ *
+ * Any values specified in
+ * {@link #chainBlacklist()} will supercede (have priority over) values
+ * here.
+ *
+ *
+ * If the parameter annotated with this annotation is not a {@link ReferenceParam},
+ * this value must not be populated.
+ *
+ */
+ String[] chainWhitelist() default { OptionalParam.ALLOW_CHAIN_ANY };
/**
* For composite parameters ({@link CompositeParam}) this parameter may be used to indicate the parameter type(s) which may be referenced by this param.
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/MethodUtil.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/MethodUtil.java
index acf66dc7a1e..0a1ec69dbfd 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/MethodUtil.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/MethodUtil.java
@@ -407,6 +407,8 @@ public class MethodUtil {
parameter.setType(theContext, parameterType, innerCollectionType, outerCollectionType);
MethodUtil.extractDescription(parameter, annotations);
param = parameter;
+ } else if (nextAnnotation instanceof RawParam) {
+ param = new RawParamsParmeter(parameters);
} else if (nextAnnotation instanceof IncludeParam) {
Class extends Collection> instantiableCollectionType;
Class> specType;
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/RawParamsParmeter.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/RawParamsParmeter.java
new file mode 100644
index 00000000000..91afa3afe88
--- /dev/null
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/RawParamsParmeter.java
@@ -0,0 +1,74 @@
+package ca.uhn.fhir.rest.method;
+
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.lang3.Validate;
+import org.hl7.fhir.instance.model.api.IBaseResource;
+
+import ca.uhn.fhir.context.FhirContext;
+import ca.uhn.fhir.rest.annotation.RawParam;
+import ca.uhn.fhir.rest.method.SearchMethodBinding.QualifierDetails;
+import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
+import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
+
+public class RawParamsParmeter implements IParameter {
+
+ private final List myAllMethodParameters;
+
+ public RawParamsParmeter(List theParameters) {
+ myAllMethodParameters = theParameters;
+ }
+
+ @Override
+ public void translateClientArgumentIntoQueryArgument(FhirContext theContext, Object theSourceClientArgument, Map> theTargetQueryArguments, IBaseResource theTargetResource)
+ throws InternalErrorException {
+ // not supported on client for now
+ }
+
+ @Override
+ public Object translateQueryParametersIntoServerArgument(RequestDetails theRequest, BaseMethodBinding> theMethodBinding) throws InternalErrorException, InvalidRequestException {
+ HashMap> retVal = null;
+
+ for (String nextName : theRequest.getParameters().keySet()) {
+ if (nextName.startsWith("_")) {
+ continue;
+ }
+
+ QualifierDetails qualifiers = SearchMethodBinding.extractQualifiersFromParameterName(nextName);
+
+ boolean alreadyCaptured = false;
+ for (IParameter nextParameter : myAllMethodParameters) {
+ if (nextParameter instanceof SearchParameter) {
+ SearchParameter nextSearchParam = (SearchParameter)nextParameter;
+ if (nextSearchParam.getName().equals(qualifiers.getParamName())) {
+ if (qualifiers.passes(nextSearchParam.getQualifierWhitelist(), nextSearchParam.getQualifierBlacklist())) {
+ alreadyCaptured = true;
+ break;
+ }
+ }
+ }
+ }
+
+ if (!alreadyCaptured) {
+ if (retVal == null) {
+ retVal = new HashMap>();
+ }
+ retVal.put(nextName, Arrays.asList(theRequest.getParameters().get(nextName)));
+ }
+
+ }
+
+ return retVal;
+ }
+
+ @Override
+ public void initializeTypes(Method theMethod, Class extends Collection>> theOuterCollectionType, Class extends Collection>> theInnerCollectionType, Class> theParameterType) {
+ Validate.isTrue(theParameterType.equals(Map.class), "Parameter with @" + RawParam.class + " must be of type Map>");
+ }
+
+}
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/SearchMethodBinding.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/SearchMethodBinding.java
index 9e364c4cbb3..456b24cf304 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/SearchMethodBinding.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/SearchMethodBinding.java
@@ -130,11 +130,7 @@ public class SearchMethodBinding extends BaseResourceReturningMethodBinding {
@Override
public ReturnTypeEnum getReturnType() {
-// if (getContext().getVersion().getVersion() == FhirVersionEnum.DSTU1) {
return ReturnTypeEnum.BUNDLE;
-// } else {
-// return ReturnTypeEnum.RESOURCE;
-// }
}
@Override
@@ -406,14 +402,20 @@ public class SearchMethodBinding extends BaseResourceReturningMethodBinding {
if (dotIdx < colonIdx) {
retVal.setDotQualifier(theParamName.substring(dotIdx, colonIdx));
retVal.setColonQualifier(theParamName.substring(colonIdx));
+ retVal.setParamName(theParamName.substring(0, dotIdx));
} else {
retVal.setColonQualifier(theParamName.substring(colonIdx, dotIdx));
retVal.setDotQualifier(theParamName.substring(dotIdx));
+ retVal.setParamName(theParamName.substring(0, colonIdx));
}
} else if (dotIdx != -1) {
retVal.setDotQualifier(theParamName.substring(dotIdx));
+ retVal.setParamName(theParamName.substring(0, dotIdx));
} else if (colonIdx != -1) {
retVal.setColonQualifier(theParamName.substring(colonIdx));
+ retVal.setParamName(theParamName.substring(0, colonIdx));
+ } else {
+ retVal.setParamName(theParamName);
}
return retVal;
@@ -423,6 +425,7 @@ public class SearchMethodBinding extends BaseResourceReturningMethodBinding {
private String myColonQualifier;
private String myDotQualifier;
+ private String myParamName;
public boolean passes(Set theQualifierWhitelist, Set theQualifierBlacklist) {
if (theQualifierWhitelist != null) {
@@ -468,6 +471,14 @@ public class SearchMethodBinding extends BaseResourceReturningMethodBinding {
return true;
}
+ public void setParamName(String theParamName) {
+ myParamName = theParamName;
+ }
+
+ public String getParamName() {
+ return myParamName;
+ }
+
public void setColonQualifier(String theColonQualifier) {
myColonQualifier = theColonQualifier;
}
diff --git a/hapi-fhir-client-okhttp/.settings/org.eclipse.jdt.core.prefs b/hapi-fhir-client-okhttp/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..60105c1b951
--- /dev/null
+++ b/hapi-fhir-client-okhttp/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,5 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/hapi-fhir-jacoco/.settings/org.eclipse.jdt.core.prefs b/hapi-fhir-jacoco/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..60105c1b951
--- /dev/null
+++ b/hapi-fhir-jacoco/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,5 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/hapi-fhir-jaxrsserver-base/.settings/org.eclipse.jdt.core.prefs b/hapi-fhir-jaxrsserver-base/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..60105c1b951
--- /dev/null
+++ b/hapi-fhir-jaxrsserver-base/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,5 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/hapi-fhir-jaxrsserver-example/.settings/org.eclipse.jdt.core.prefs b/hapi-fhir-jaxrsserver-example/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..60105c1b951
--- /dev/null
+++ b/hapi-fhir-jaxrsserver-example/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,5 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/BaseDstu1Config.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/BaseDstu1Config.java
index 695cf2ea97c..08682c4463a 100644
--- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/BaseDstu1Config.java
+++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/BaseDstu1Config.java
@@ -10,7 +10,7 @@ package ca.uhn.fhir.jpa.config;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -29,7 +29,9 @@ import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Primary;
import ca.uhn.fhir.context.FhirContext;
+import ca.uhn.fhir.jpa.dao.ISearchParamRegistry;
import ca.uhn.fhir.jpa.dao.SearchParamExtractorDstu1;
+import ca.uhn.fhir.jpa.dao.SearchParamRegistryDstu1;
import ca.uhn.fhir.jpa.term.HapiTerminologySvcDstu1;
import ca.uhn.fhir.jpa.term.IHapiTerminologySvc;
import ca.uhn.fhir.model.api.IResource;
@@ -39,9 +41,10 @@ import ca.uhn.fhir.model.dstu2.composite.MetaDt;
public class BaseDstu1Config extends BaseConfig {
private static FhirContext ourFhirContextDstu1;
- @Bean(autowire = Autowire.BY_TYPE)
- public IHapiTerminologySvc terminologyService() {
- return new HapiTerminologySvcDstu1();
+ @Bean
+ @Primary
+ public FhirContext defaultFhirContext() {
+ return fhirContextDstu1();
}
@Bean(name = "myFhirContextDstu1")
@@ -53,19 +56,22 @@ public class BaseDstu1Config extends BaseConfig {
return ourFhirContextDstu1;
}
-
- @Bean
- @Primary
- public FhirContext defaultFhirContext() {
- return fhirContextDstu1();
- }
-
@Bean(name = "mySystemDaoDstu1", autowire = Autowire.BY_NAME)
public ca.uhn.fhir.jpa.dao.IFhirSystemDao, MetaDt> fhirSystemDaoDstu1() {
ca.uhn.fhir.jpa.dao.FhirSystemDaoDstu1 retVal = new ca.uhn.fhir.jpa.dao.FhirSystemDaoDstu1();
return retVal;
}
+ @Bean(autowire = Autowire.BY_TYPE)
+ public SearchParamExtractorDstu1 searchParamExtractor() {
+ return new SearchParamExtractorDstu1();
+ }
+
+ @Bean
+ public ISearchParamRegistry searchParamRegistry() {
+ return new SearchParamRegistryDstu1();
+ }
+
@Bean(name = "mySystemProviderDstu1")
public ca.uhn.fhir.jpa.provider.JpaSystemProviderDstu1 systemDaoDstu1() {
ca.uhn.fhir.jpa.provider.JpaSystemProviderDstu1 retVal = new ca.uhn.fhir.jpa.provider.JpaSystemProviderDstu1();
@@ -73,9 +79,9 @@ public class BaseDstu1Config extends BaseConfig {
return retVal;
}
- @Bean(autowire=Autowire.BY_TYPE)
- public SearchParamExtractorDstu1 searchParamExtractor() {
- return new SearchParamExtractorDstu1();
+ @Bean(autowire = Autowire.BY_TYPE)
+ public IHapiTerminologySvc terminologyService() {
+ return new HapiTerminologySvcDstu1();
}
-
+
}
diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/BaseDstu2Config.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/BaseDstu2Config.java
index e0b74a75a68..32a5021cd45 100644
--- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/BaseDstu2Config.java
+++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/BaseDstu2Config.java
@@ -31,7 +31,9 @@ import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.jpa.dao.FulltextSearchSvcImpl;
import ca.uhn.fhir.jpa.dao.IFhirSystemDao;
import ca.uhn.fhir.jpa.dao.IFulltextSearchSvc;
+import ca.uhn.fhir.jpa.dao.ISearchParamRegistry;
import ca.uhn.fhir.jpa.dao.SearchParamExtractorDstu2;
+import ca.uhn.fhir.jpa.dao.SearchParamRegistryDstu2;
import ca.uhn.fhir.jpa.term.HapiTerminologySvcDstu2;
import ca.uhn.fhir.jpa.term.IHapiTerminologySvc;
import ca.uhn.fhir.model.dstu2.composite.MetaDt;
@@ -84,6 +86,11 @@ public class BaseDstu2Config extends BaseConfig {
return new SearchParamExtractorDstu2();
}
+ @Bean
+ public ISearchParamRegistry searchParamRegistry() {
+ return new SearchParamRegistryDstu2();
+ }
+
@Bean(name = "mySystemDaoDstu2", autowire = Autowire.BY_NAME)
public IFhirSystemDao systemDaoDstu2() {
ca.uhn.fhir.jpa.dao.FhirSystemDaoDstu2 retVal = new ca.uhn.fhir.jpa.dao.FhirSystemDaoDstu2();
diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/dstu3/BaseDstu3Config.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/dstu3/BaseDstu3Config.java
index f99f83495d2..802d69e3717 100644
--- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/dstu3/BaseDstu3Config.java
+++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/config/dstu3/BaseDstu3Config.java
@@ -14,7 +14,7 @@ import org.hl7.fhir.dstu3.validation.IResourceValidator.BestPracticeWarningLevel
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -37,7 +37,9 @@ import ca.uhn.fhir.jpa.config.BaseConfig;
import ca.uhn.fhir.jpa.dao.FulltextSearchSvcImpl;
import ca.uhn.fhir.jpa.dao.IFhirSystemDao;
import ca.uhn.fhir.jpa.dao.IFulltextSearchSvc;
+import ca.uhn.fhir.jpa.dao.ISearchParamRegistry;
import ca.uhn.fhir.jpa.dao.dstu3.SearchParamExtractorDstu3;
+import ca.uhn.fhir.jpa.dao.dstu3.SearchParamRegistryDstu3;
import ca.uhn.fhir.jpa.provider.dstu3.TerminologyUploaderProviderDstu3;
import ca.uhn.fhir.jpa.term.HapiTerminologySvcDstu3;
import ca.uhn.fhir.jpa.term.IHapiTerminologyLoaderSvc;
@@ -50,25 +52,15 @@ import ca.uhn.fhir.validation.IValidatorModule;
@EnableTransactionManagement
public class BaseDstu3Config extends BaseConfig {
- @Bean(autowire = Autowire.BY_TYPE)
- public IHapiTerminologySvcDstu3 terminologyService() {
- return new HapiTerminologySvcDstu3();
- }
-
- @Bean(autowire = Autowire.BY_TYPE)
- public IHapiTerminologyLoaderSvc terminologyLoaderService() {
- return new TerminologyLoaderSvc();
- }
-
@Bean
@Primary
public FhirContext fhirContextDstu3() {
FhirContext retVal = FhirContext.forDstu3();
-
+
// Don't strip versions in some places
ParserOptions parserOptions = retVal.getParserOptions();
parserOptions.setDontStripVersionsFromReferencesAtPaths("AuditEvent.entity.reference");
-
+
return retVal;
}
@@ -93,6 +85,16 @@ public class BaseDstu3Config extends BaseConfig {
return searchDao;
}
+ @Bean(autowire = Autowire.BY_TYPE)
+ public SearchParamExtractorDstu3 searchParamExtractor() {
+ return new SearchParamExtractorDstu3();
+ }
+
+ @Bean
+ public ISearchParamRegistry searchParamRegistry() {
+ return new SearchParamRegistryDstu3();
+ }
+
@Bean(name = "mySystemDaoDstu3", autowire = Autowire.BY_NAME)
public IFhirSystemDao systemDaoDstu3() {
ca.uhn.fhir.jpa.dao.dstu3.FhirSystemDaoDstu3 retVal = new ca.uhn.fhir.jpa.dao.dstu3.FhirSystemDaoDstu3();
@@ -107,23 +109,27 @@ public class BaseDstu3Config extends BaseConfig {
return retVal;
}
+ @Bean(autowire = Autowire.BY_TYPE)
+ public IHapiTerminologyLoaderSvc terminologyLoaderService() {
+ return new TerminologyLoaderSvc();
+ }
+
+ @Bean(autowire = Autowire.BY_TYPE)
+ public IHapiTerminologySvcDstu3 terminologyService() {
+ return new HapiTerminologySvcDstu3();
+ }
+
+ @Bean(autowire = Autowire.BY_TYPE)
+ public TerminologyUploaderProviderDstu3 terminologyUploaderProvider() {
+ TerminologyUploaderProviderDstu3 retVal = new TerminologyUploaderProviderDstu3();
+ retVal.setContext(fhirContextDstu3());
+ return retVal;
+ }
+
@Primary
@Bean(autowire = Autowire.BY_NAME, name = "myJpaValidationSupportChainDstu3")
public IValidationSupport validationSupportChainDstu3() {
return new JpaValidationSupportChainDstu3();
}
- @Bean(autowire = Autowire.BY_TYPE)
- public SearchParamExtractorDstu3 searchParamExtractor() {
- return new SearchParamExtractorDstu3();
- }
-
- @Bean(autowire=Autowire.BY_TYPE)
- public TerminologyUploaderProviderDstu3 terminologyUploaderProvider() {
- TerminologyUploaderProviderDstu3 retVal = new TerminologyUploaderProviderDstu3();
- retVal.setContext(fhirContextDstu3());
- return retVal;
- }
-
-
}
diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDao.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDao.java
index 8d13f894354..5057c12612f 100644
--- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDao.java
+++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDao.java
@@ -863,6 +863,9 @@ public abstract class BaseHapiFhirResourceDao extends B
return search(map);
}
+ @Autowired
+ private ISearchParamRegistry mySerarchParamRegistry;
+
@Override
public IBundleProvider search(final SearchParameterMap theParams) {
// Notify interceptors
@@ -870,7 +873,7 @@ public abstract class BaseHapiFhirResourceDao extends B
notifyInterceptors(RestOperationTypeEnum.SEARCH_TYPE, requestDetails);
SearchBuilder builder = new SearchBuilder(getContext(), myEntityManager, myPlatformTransactionManager, mySearchDao, mySearchResultDao, this, myResourceIndexedSearchParamUriDao, myForcedIdDao,
- myTerminologySvc);
+ myTerminologySvc, mySerarchParamRegistry);
builder.setType(getResourceType(), getResourceName());
return builder.search(theParams);
}
@@ -899,7 +902,7 @@ public abstract class BaseHapiFhirResourceDao extends B
theParams.setPersistResults(false);
SearchBuilder builder = new SearchBuilder(getContext(), myEntityManager, myPlatformTransactionManager, mySearchDao, mySearchResultDao, this, myResourceIndexedSearchParamUriDao, myForcedIdDao,
- myTerminologySvc);
+ myTerminologySvc, mySerarchParamRegistry);
builder.setType(getResourceType(), getResourceName());
builder.search(theParams);
return builder.doGetPids();
diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseSearchParamExtractor.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseSearchParamExtractor.java
index 8014a78be84..61e825139e8 100644
--- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseSearchParamExtractor.java
+++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseSearchParamExtractor.java
@@ -21,9 +21,12 @@ package ca.uhn.fhir.jpa.dao;
*/
import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
import java.util.List;
import java.util.regex.Pattern;
+import org.apache.commons.lang3.ObjectUtils;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.springframework.beans.factory.annotation.Autowired;
@@ -42,12 +45,32 @@ public abstract class BaseSearchParamExtractor implements ISearchParamExtractor
@Autowired
private FhirContext myContext;
+ @Autowired
+ private ISearchParamRegistry mySearchParamRegistry;
+
public BaseSearchParamExtractor() {
super();
}
-
- public BaseSearchParamExtractor(FhirContext theCtx) {
+
+ public BaseSearchParamExtractor(FhirContext theCtx, ISearchParamRegistry theSearchParamRegistry) {
myContext = theCtx;
+ mySearchParamRegistry = theSearchParamRegistry;
+ }
+
+ @Override
+ public List extractResourceLinks(IBaseResource theResource, RuntimeSearchParam theNextSpDef) {
+ List refs = new ArrayList();
+ String[] nextPathsSplit = theNextSpDef.getPath().split("\\|");
+ for (String nextPath : nextPathsSplit) {
+ nextPath = nextPath.trim();
+ for (Object nextObject : extractValues(nextPath, theResource)) {
+ if (nextObject == null) {
+ continue;
+ }
+ refs.add(new PathAndRef(nextPath, nextObject));
+ }
+ }
+ return refs;
}
protected List