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 d3e56b9bed0..fc8132cd5ef 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 @@ -769,7 +769,7 @@ class ModelScanner { } - RuntimeSearchParam param = new RuntimeSearchParam(searchParam.name(), searchParam.description(), searchParam.path(), paramType, providesMembershipInCompartments); + RuntimeSearchParam param = new RuntimeSearchParam(searchParam.name(), searchParam.description(), searchParam.path(), paramType, providesMembershipInCompartments, toTargetList(searchParam.target())); theResourceDef.addSearchParam(param); nameToParam.put(param.getName(), param); } @@ -789,11 +789,24 @@ class ModelScanner { compositeOf.add(param); } - RuntimeSearchParam param = new RuntimeSearchParam(searchParam.name(), searchParam.description(), searchParam.path(), RestSearchParameterTypeEnum.COMPOSITE, compositeOf, null); + RuntimeSearchParam param = new RuntimeSearchParam(searchParam.name(), searchParam.description(), searchParam.path(), RestSearchParameterTypeEnum.COMPOSITE, compositeOf, null, toTargetList(searchParam.target())); theResourceDef.addSearchParam(param); } } + private Set toTargetList(Class[] theTarget) { + HashSet retVal = new HashSet(); + + for (Class nextType : theTarget) { + ResourceDef resourceDef = nextType.getAnnotation(ResourceDef.class); + if (resourceDef != null) { + retVal.add(resourceDef.name()); + } + } + + return retVal; + } + private static Class getGenericCollectionTypeOfCodedField(Field next) { Class type; ParameterizedType collectionType = (ParameterizedType) next.getGenericType(); 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 c8ccc62ae68..f573add1935 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 @@ -30,15 +30,16 @@ 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 Set myProvidesMembershipInCompartments; + private final List myCompositeOf; + private final String myDescription; + private final String myName; + private final RestSearchParameterTypeEnum myParamType; + private final String myPath; + private final Set myTargets; + private final Set myProvidesMembershipInCompartments; public RuntimeSearchParam(String theName, String theDescription, String thePath, RestSearchParameterTypeEnum theParamType, List theCompositeOf, - Set theProvidesMembershipInCompartments) { + Set theProvidesMembershipInCompartments, Set theTargets) { super(); myName = theName; myDescription = theDescription; @@ -50,10 +51,19 @@ public class RuntimeSearchParam { } else { myProvidesMembershipInCompartments = null; } + if (theTargets != null && theTargets.isEmpty() == false) { + myTargets = Collections.unmodifiableSet(theTargets); + } else { + myTargets = null; + } } - public RuntimeSearchParam(String theName, String theDescription, String thePath, RestSearchParameterTypeEnum theParamType, Set theProvidesMembershipInCompartments) { - this(theName, theDescription, thePath, theParamType, null, theProvidesMembershipInCompartments); + public Set getTargets() { + 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 List getCompositeOf() { diff --git a/hapi-fhir-cli/hapi-fhir-cli-app/src/main/java/ca/uhn/fhir/cli/LoadingValidationSupportDstu3.java b/hapi-fhir-cli/hapi-fhir-cli-app/src/main/java/ca/uhn/fhir/cli/LoadingValidationSupportDstu3.java index b8682333737..c7fadf0b938 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-app/src/main/java/ca/uhn/fhir/cli/LoadingValidationSupportDstu3.java +++ b/hapi-fhir-cli/hapi-fhir-cli-app/src/main/java/ca/uhn/fhir/cli/LoadingValidationSupportDstu3.java @@ -1,5 +1,8 @@ package ca.uhn.fhir.cli; +import java.util.Collections; +import java.util.List; + import org.hl7.fhir.dstu3.hapi.validation.IValidationSupport; import org.hl7.fhir.dstu3.model.CodeSystem; import org.hl7.fhir.dstu3.model.StructureDefinition; @@ -61,4 +64,9 @@ public class LoadingValidationSupportDstu3 implements IValidationSupport { return null; } + @Override + public List fetchAllStructureDefinitions(FhirContext theContext) { + return Collections.emptyList(); + } + } 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 6351524d25b..041137f4273 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 @@ -45,7 +45,6 @@ import javax.persistence.Tuple; import javax.persistence.TypedQuery; import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Expression; import javax.persistence.criteria.Predicate; import javax.persistence.criteria.Root; import javax.xml.stream.events.Characters; @@ -60,6 +59,7 @@ import org.hl7.fhir.dstu3.model.Bundle.HTTPVerb; import org.hl7.fhir.dstu3.model.IdType; import org.hl7.fhir.dstu3.model.StringType; import org.hl7.fhir.instance.model.api.IAnyResource; +import org.hl7.fhir.instance.model.api.IBase; import org.hl7.fhir.instance.model.api.IBaseCoding; import org.hl7.fhir.instance.model.api.IBaseOperationOutcome; import org.hl7.fhir.instance.model.api.IBaseReference; @@ -74,6 +74,8 @@ import com.google.common.base.Charsets; import com.google.common.collect.ArrayListMultimap; import ca.uhn.fhir.context.BaseRuntimeChildDefinition; +import ca.uhn.fhir.context.BaseRuntimeElementCompositeDefinition; +import ca.uhn.fhir.context.BaseRuntimeElementDefinition; import ca.uhn.fhir.context.ConfigurationException; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirVersionEnum; @@ -84,7 +86,6 @@ import ca.uhn.fhir.jpa.dao.data.IForcedIdDao; import ca.uhn.fhir.jpa.dao.data.IResourceHistoryTableDao; import ca.uhn.fhir.jpa.dao.data.ISearchDao; import ca.uhn.fhir.jpa.dao.data.ISearchResultDao; -import ca.uhn.fhir.jpa.dao.dstu3.SearchParamExtractorDstu3; import ca.uhn.fhir.jpa.entity.BaseHasResource; import ca.uhn.fhir.jpa.entity.BaseResourceIndexedSearchParam; import ca.uhn.fhir.jpa.entity.BaseTag; @@ -224,7 +225,7 @@ public abstract class BaseHapiFhirDao implements IDao { if (isValidPid(theId)) { return; } - + ForcedId fid = new ForcedId(); fid.setResourceType(theEntity.getResourceType()); fid.setForcedId(theId.getIdPart()); @@ -259,121 +260,121 @@ public abstract class BaseHapiFhirDao implements IDao { multiType = true; } - String[] nextPathsSplit = nextPathsUnsplit.split("\\|"); - for (String nextPath : nextPathsSplit) { - nextPath = nextPath.trim(); + List refs = mySearchParamExtractor.extractResourceLinks(theResource, nextSpDef); + List> allowedTypesInField = null; + for (PathAndRef nextPathAndRef : refs) { + Object nextObject = nextPathAndRef.getRef(); - List> allowedTypesInField = null; - for (Object nextObject : extractValues(nextPath, theResource)) { - if (nextObject == null) { + ResourceLink nextEntity; + if (nextObject instanceof IBaseReference) { + IBaseReference nextValue = (IBaseReference) nextObject; + if (nextValue.isEmpty()) { + continue; + } + if (nextValue.getReferenceElement().isEmpty() || nextValue.getReferenceElement().getValue().startsWith("#")) { + // This is a blank or contained resource reference continue; } - ResourceLink nextEntity; - if (nextObject instanceof IBaseReference) { - IBaseReference nextValue = (IBaseReference) nextObject; - if (nextValue.isEmpty()) { - continue; - } - if (nextValue.getReferenceElement().isEmpty() || nextValue.getReferenceElement().getValue().startsWith("#")) { - // This is a blank or contained resource reference - continue; - } - - String typeString = nextValue.getReferenceElement().getResourceType(); - if (isBlank(typeString)) { - throw new InvalidRequestException( - "Invalid resource reference found at path[" + nextPathsUnsplit + "] - Does not contain resource type - " + nextValue.getReferenceElement().getValue()); - } - RuntimeResourceDefinition resourceDefinition; - try { - resourceDefinition = getContext().getResourceDefinition(typeString); - } catch (DataFormatException e) { - throw new InvalidRequestException("Invalid resource reference found at path[" + nextPathsUnsplit + "] - Resource type is unknown or not supported on this server - " - + nextValue.getReferenceElement().getValue()); - } - - Class type = resourceDefinition.getImplementingClass(); - String id = nextValue.getReferenceElement().getIdPart(); - if (StringUtils.isBlank(id)) { - throw new InvalidRequestException( - "Invalid resource reference found at path[" + nextPathsUnsplit + "] - Does not contain resource ID - " + nextValue.getReferenceElement().getValue()); - } - - IFhirResourceDao dao = getDao(type); - if (dao == null) { - StringBuilder b = new StringBuilder(); - b.append("This server (version "); - b.append(myContext.getVersion().getVersion()); - b.append(") is not able to handle resources of type["); - b.append(nextValue.getReferenceElement().getResourceType()); - b.append("] - Valid resource types for this server: "); - b.append(myResourceTypeToDao.keySet().toString()); - - throw new InvalidRequestException(b.toString()); - } - Long valueOf; - try { - valueOf = translateForcedIdToPid(typeString, id); - } catch (ResourceNotFoundException e) { - String resName = getContext().getResourceDefinition(type).getName(); - throw new InvalidRequestException("Resource " + resName + "/" + id + " not found, specified in path: " + nextPathsUnsplit); - } - ResourceTable target = myEntityManager.find(ResourceTable.class, valueOf); - RuntimeResourceDefinition targetResourceDef = getContext().getResourceDefinition(type); - if (target == null) { - String resName = targetResourceDef.getName(); - throw new InvalidRequestException("Resource " + resName + "/" + id + " not found, specified in path: " + nextPathsUnsplit); - } - - if (!typeString.equals(target.getResourceType())) { - throw new UnprocessableEntityException("Resource contains reference to " + nextValue.getReferenceElement().getValue() + " but resource with ID " - + nextValue.getReferenceElement().getIdPart() + " is actually of type " + target.getResourceType()); - } - - /* - * Is the target type an allowable type of resource for the path where it is referenced? - */ - - if (allowedTypesInField == null) { - BaseRuntimeChildDefinition childDef = getContext().newTerser().getDefinition(theResource.getClass(), nextPath); - if (childDef instanceof RuntimeChildResourceDefinition) { - RuntimeChildResourceDefinition resRefDef = (RuntimeChildResourceDefinition) childDef; - allowedTypesInField = resRefDef.getResourceTypes(); - } else { - allowedTypesInField = new ArrayList>(); - allowedTypesInField.add(IBaseResource.class); - } - } - - boolean acceptableLink = false; - for (Class next : allowedTypesInField) { - if (next.isAssignableFrom(targetResourceDef.getImplementingClass())) { - acceptableLink = true; - break; - } - } - - if (!acceptableLink) { - throw new UnprocessableEntityException("Invalid reference found at path '" + nextPath + "'. Resource type '" + targetResourceDef.getName() + "' is not valid for this path"); - } - - nextEntity = new ResourceLink(nextPath, theEntity, target); - } else { - if (!multiType) { - if (nextSpDef.getName().equals("sourceuri")) { - continue; // TODO: disable this eventually - ConceptMap:sourceuri is of type reference but points to a URI - } - throw new ConfigurationException("Search param " + nextSpDef.getName() + " is of unexpected datatype: " + nextObject.getClass()); - } else { - continue; - } + String typeString = nextValue.getReferenceElement().getResourceType(); + if (isBlank(typeString)) { + throw new InvalidRequestException( + "Invalid resource reference found at path[" + nextPathsUnsplit + "] - Does not contain resource type - " + nextValue.getReferenceElement().getValue()); } - if (nextEntity != null) { - retVal.add(nextEntity); + RuntimeResourceDefinition resourceDefinition; + try { + resourceDefinition = getContext().getResourceDefinition(typeString); + } catch (DataFormatException e) { + throw new InvalidRequestException("Invalid resource reference found at path[" + nextPathsUnsplit + "] - Resource type is unknown or not supported on this server - " + + nextValue.getReferenceElement().getValue()); + } + + Class type = resourceDefinition.getImplementingClass(); + String id = nextValue.getReferenceElement().getIdPart(); + if (StringUtils.isBlank(id)) { + throw new InvalidRequestException( + "Invalid resource reference found at path[" + nextPathsUnsplit + "] - Does not contain resource ID - " + nextValue.getReferenceElement().getValue()); + } + + IFhirResourceDao dao = getDao(type); + if (dao == null) { + StringBuilder b = new StringBuilder(); + b.append("This server (version "); + b.append(myContext.getVersion().getVersion()); + b.append(") is not able to handle resources of type["); + b.append(nextValue.getReferenceElement().getResourceType()); + b.append("] - Valid resource types for this server: "); + b.append(myResourceTypeToDao.keySet().toString()); + + throw new InvalidRequestException(b.toString()); + } + Long valueOf; + try { + valueOf = translateForcedIdToPid(typeString, id); + } catch (ResourceNotFoundException e) { + String resName = getContext().getResourceDefinition(type).getName(); + throw new InvalidRequestException("Resource " + resName + "/" + id + " not found, specified in path: " + nextPathsUnsplit); + } + ResourceTable target = myEntityManager.find(ResourceTable.class, valueOf); + RuntimeResourceDefinition targetResourceDef = getContext().getResourceDefinition(type); + if (target == null) { + String resName = targetResourceDef.getName(); + throw new InvalidRequestException("Resource " + resName + "/" + id + " not found, specified in path: " + nextPathsUnsplit); + } + + if (!typeString.equals(target.getResourceType())) { + throw new UnprocessableEntityException("Resource contains reference to " + nextValue.getReferenceElement().getValue() + " but resource with ID " + + nextValue.getReferenceElement().getIdPart() + " is actually of type " + target.getResourceType()); + } + + if (nextSpDef.getTargets() != null && !nextSpDef.getTargets().contains(typeString)) { + continue; + } + +// /* +// * Is the target type an allowable type of resource for the path where it is referenced? +// */ +// +// if (allowedTypesInField == null) { +// BaseRuntimeChildDefinition childDef = getContext().newTerser().getDefinition(theResource.getClass(), nextPathAndRef.getPath()); +// if (childDef instanceof RuntimeChildResourceDefinition) { +// RuntimeChildResourceDefinition resRefDef = (RuntimeChildResourceDefinition) childDef; +// allowedTypesInField = resRefDef.getResourceTypes(); +// } else { +// allowedTypesInField = new ArrayList>(); +// allowedTypesInField.add(IBaseResource.class); +// } +// } +// +// boolean acceptableLink = false; +// for (Class next : allowedTypesInField) { +// if (next.isAssignableFrom(targetResourceDef.getImplementingClass())) { +// acceptableLink = true; +// break; +// } +// } +// +// if (!acceptableLink) { +// throw new UnprocessableEntityException( +// "Invalid reference found at path '" + nextPathAndRef.getPath() + "'. Resource type '" + targetResourceDef.getName() + "' is not valid for this path"); +// } + + nextEntity = new ResourceLink(nextPathAndRef.getPath(), theEntity, target); + } else { + if (!multiType) { + if (nextSpDef.getName().equals("sourceuri")) { + continue; // TODO: disable this eventually - ConceptMap:sourceuri is of type reference but points to a URI + } + throw new ConfigurationException("Search param " + nextSpDef.getName() + " is of unexpected datatype: " + nextObject.getClass()); + } else { + continue; } } + if (nextEntity != null) { + retVal.add(nextEntity); + } } + } theEntity.setHasLinks(retVal.size() > 0); @@ -518,7 +519,6 @@ public abstract class BaseHapiFhirDao implements IDao { return myConfig; } - @Override public FhirContext getContext() { return myContext; @@ -655,7 +655,7 @@ public abstract class BaseHapiFhirDao implements IDao { search.setTotalCount(myResourceHistoryTableDao.countForResourceInstance(theId)); } } - + search = mySearchDao.save(search); return new PersistedJpaBundleProvider(search.getUuid(), this); @@ -679,7 +679,7 @@ public abstract class BaseHapiFhirDao implements IDao { } requestDetails.notifyIncomingRequestPreHandled(theOperationType); - + List interceptors = getConfig().getInterceptors(); if (interceptors == null) { return; @@ -877,7 +877,7 @@ public abstract class BaseHapiFhirDao implements IDao { IDao.RESOURCE_PID.put(res, theEntity.getId()); Collection tags = theEntity.getTags(); - + if (theEntity.isHasTags()) { for (BaseTag next : tags) { switch (next.getTag().getTagType()) { @@ -977,7 +977,6 @@ public abstract class BaseHapiFhirDao implements IDao { myContext = theContext; } - public void setEntityManager(EntityManager theEntityManager) { myEntityManager = theEntityManager; } @@ -1458,6 +1457,63 @@ public abstract class BaseHapiFhirDao implements IDao { if (tag != null) { throw new UnprocessableEntityException("Resource contains the 'subsetted' tag, and must not be stored as it may contain a subset of available data"); } + + String resName = getContext().getResourceDefinition(theResource).getName(); + validateChildReferences(theResource, resName); + + } + + private void validateChildReferences(IBase theElement, String thePath) { + if (theElement == null) { + return; + } + BaseRuntimeElementDefinition def = myContext.getElementDefinition(theElement.getClass()); + if (!(def instanceof BaseRuntimeElementCompositeDefinition)) { + return; + } + + BaseRuntimeElementCompositeDefinition cdef = (BaseRuntimeElementCompositeDefinition)def; + for (BaseRuntimeChildDefinition nextChildDef : cdef.getChildren()) { + + List values = nextChildDef.getAccessor().getValues(theElement); + if (values == null || values.isEmpty()) { + continue; + } + + String newPath = thePath + "." + nextChildDef.getElementName(); + + for (IBase nextChild : values) { + validateChildReferences(nextChild, newPath); + } + + if (nextChildDef instanceof RuntimeChildResourceDefinition) { + RuntimeChildResourceDefinition nextChildDefRes = (RuntimeChildResourceDefinition)nextChildDef; + Set validTypes = new HashSet(); + boolean allowAny = false; + for (Class nextValidType : nextChildDefRes.getResourceTypes()) { + if (nextValidType.isInterface()) { + allowAny = true; + break; + } + validTypes.add(getContext().getResourceDefinition(nextValidType).getName()); + } + + if (allowAny) { + continue; + } + + for (IBase nextChild : values) { + IBaseReference nextRef = (IBaseReference)nextChild; + if (!isBlank(nextRef.getReferenceElement().getResourceType())) { + if (!validTypes.contains(nextRef.getReferenceElement().getResourceType())) { + throw new UnprocessableEntityException( + "Invalid reference found at path '" + newPath + "'. Resource type '" + nextRef.getReferenceElement().getResourceType() + "' is not valid for this path"); + } + } + } + + } + } } protected static boolean isValidPid(IIdType theId) { @@ -1561,7 +1617,7 @@ public abstract class BaseHapiFhirDao implements IDao { static List translateForcedIdToPids(IIdType theId, IForcedIdDao theForcedIdDao) { Validate.isTrue(theId.hasIdPart()); - + if (isValidPid(theId)) { return Collections.singletonList(theId.getIdPartAsLong()); } else { @@ -1571,7 +1627,7 @@ public abstract class BaseHapiFhirDao implements IDao { } else { forcedId = theForcedIdDao.findByForcedId(theId.getIdPart()); } - + if (forcedId.isEmpty() == false) { List retVal = new ArrayList(forcedId.size()); for (ForcedId next : forcedId) { 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 ec0d6b0ed7b..c01a677ce4e 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 @@ -31,12 +31,13 @@ import com.google.common.annotations.VisibleForTesting; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.RuntimeResourceDefinition; +import ca.uhn.fhir.context.RuntimeSearchParam; import ca.uhn.fhir.util.FhirTerser; -public class BaseSearchParamExtractor { +public abstract class BaseSearchParamExtractor implements ISearchParamExtractor { private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BaseSearchParamExtractor.class); - private static final Pattern SPLIT = Pattern.compile("\\||( or )"); + protected static final Pattern SPLIT = Pattern.compile("\\||( or )"); @Autowired private FhirContext myContext; @@ -74,5 +75,21 @@ public class BaseSearchParamExtractor { myContext = theContext; } - + @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; + } + + } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/ISearchParamExtractor.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/ISearchParamExtractor.java index 72c1108eaec..89d24b795f7 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/ISearchParamExtractor.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/ISearchParamExtractor.java @@ -1,5 +1,7 @@ package ca.uhn.fhir.jpa.dao; +import java.util.List; + /* * #%L * HAPI FHIR JPA Server @@ -24,6 +26,7 @@ import java.util.Set; import org.hl7.fhir.instance.model.api.IBaseResource; +import ca.uhn.fhir.context.RuntimeSearchParam; import ca.uhn.fhir.jpa.entity.BaseResourceIndexedSearchParam; import ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamCoords; import ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamDate; @@ -49,4 +52,6 @@ public interface ISearchParamExtractor { public abstract Set extractSearchParamUri(ResourceTable theEntity, IBaseResource theResource); + public abstract List extractResourceLinks(IBaseResource theResource, RuntimeSearchParam theNextSpDef); + } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/PathAndRef.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/PathAndRef.java new file mode 100644 index 00000000000..79bbe93e473 --- /dev/null +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/PathAndRef.java @@ -0,0 +1,19 @@ +package ca.uhn.fhir.jpa.dao; + +public class PathAndRef { + + private final String myPath; + public String getPath() { + return myPath; + } + public PathAndRef(String thePath, Object theRef) { + super(); + myPath = thePath; + myRef = theRef; + } + public Object getRef() { + return myRef; + } + private final Object myRef; + +} diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/dstu3/SearchParamExtractorDstu3.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/dstu3/SearchParamExtractorDstu3.java index 52f0ee329f9..a24645e7098 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/dstu3/SearchParamExtractorDstu3.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/dstu3/SearchParamExtractorDstu3.java @@ -73,6 +73,7 @@ import ca.uhn.fhir.context.RuntimeSearchParam; import ca.uhn.fhir.jpa.dao.BaseHapiFhirDao; import ca.uhn.fhir.jpa.dao.BaseSearchParamExtractor; import ca.uhn.fhir.jpa.dao.ISearchParamExtractor; +import ca.uhn.fhir.jpa.dao.PathAndRef; import ca.uhn.fhir.jpa.entity.BaseResourceIndexedSearchParam; import ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamCoords; import ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamDate; @@ -88,17 +89,17 @@ import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; public class SearchParamExtractorDstu3 extends BaseSearchParamExtractor implements ISearchParamExtractor { private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(SearchParamExtractorDstu3.class); - + @Autowired private org.hl7.fhir.dstu3.hapi.validation.IValidationSupport myValidationSupport; - + /** * Constructor */ public SearchParamExtractorDstu3() { super(); } - + public SearchParamExtractorDstu3(FhirContext theCtx, IValidationSupport theValidationSupport) { super(theCtx); myValidationSupport = theValidationSupport; @@ -135,8 +136,7 @@ public class SearchParamExtractorDstu3 extends BaseSearchParamExtractor implemen /* * (non-Javadoc) * - * @see ca.uhn.fhir.jpa.dao.ISearchParamExtractor#extractSearchParamDates(ca.uhn.fhir.jpa.entity.ResourceTable, - * ca.uhn.fhir.model.api.IBaseResource) + * @see ca.uhn.fhir.jpa.dao.ISearchParamExtractor#extractSearchParamDates(ca.uhn.fhir.jpa.entity.ResourceTable, ca.uhn.fhir.model.api.IBaseResource) */ @Override public Set extractSearchParamDates(ResourceTable theEntity, IBaseResource theResource) { @@ -196,8 +196,7 @@ public class SearchParamExtractorDstu3 extends BaseSearchParamExtractor implemen /* * (non-Javadoc) * - * @see ca.uhn.fhir.jpa.dao.ISearchParamExtractor#extractSearchParamNumber(ca.uhn.fhir.jpa.entity.ResourceTable, - * ca.uhn.fhir.model.api.IBaseResource) + * @see ca.uhn.fhir.jpa.dao.ISearchParamExtractor#extractSearchParamNumber(ca.uhn.fhir.jpa.entity.ResourceTable, ca.uhn.fhir.model.api.IBaseResource) */ @Override public HashSet extractSearchParamNumber(ResourceTable theEntity, IBaseResource theResource) { @@ -244,17 +243,12 @@ public class SearchParamExtractorDstu3 extends BaseSearchParamExtractor implemen nextValue = newValue; /* - * @SuppressWarnings("unchecked") PhysicsUnit> unit = (PhysicsUnit>) - * UCUMFormat.getCaseInsensitiveInstance().parse(nextValue.getCode().getValue(), null); if - * (unit.isCompatible(UCUM.DAY)) { + * @SuppressWarnings("unchecked") PhysicsUnit> unit = (PhysicsUnit>) + * UCUMFormat.getCaseInsensitiveInstance().parse(nextValue.getCode().getValue(), null); if (unit.isCompatible(UCUM.DAY)) { * - * @SuppressWarnings("unchecked") PhysicsUnit timeUnit = - * (PhysicsUnit