Fix all tests
This commit is contained in:
parent
309b67c010
commit
c7d191dc38
|
@ -1,7 +1,6 @@
|
||||||
package ca.uhn.fhir.rest.method;
|
package ca.uhn.fhir.rest.method;
|
||||||
|
|
||||||
import static org.apache.commons.lang3.StringUtils.defaultIfBlank;
|
import static org.apache.commons.lang3.StringUtils.defaultIfBlank;
|
||||||
import static org.apache.commons.lang3.StringUtils.isBlank;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* #%L
|
* #%L
|
||||||
|
@ -38,7 +37,6 @@ import ca.uhn.fhir.rest.client.BaseHttpClientInvocation;
|
||||||
import ca.uhn.fhir.rest.param.ResourceParameter;
|
import ca.uhn.fhir.rest.param.ResourceParameter;
|
||||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
|
||||||
import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor.ActionRequestDetails;
|
import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor.ActionRequestDetails;
|
||||||
|
|
||||||
abstract class BaseOutcomeReturningMethodBindingWithResourceParam extends BaseOutcomeReturningMethodBinding {
|
abstract class BaseOutcomeReturningMethodBindingWithResourceParam extends BaseOutcomeReturningMethodBinding {
|
||||||
|
@ -111,7 +109,7 @@ abstract class BaseOutcomeReturningMethodBindingWithResourceParam extends BaseOu
|
||||||
matchUrl = (String) theParams[myConditionalUrlIndex];
|
matchUrl = (String) theParams[myConditionalUrlIndex];
|
||||||
matchUrl = defaultIfBlank(matchUrl, null);
|
matchUrl = defaultIfBlank(matchUrl, null);
|
||||||
}
|
}
|
||||||
validateResourceIdAndUrlIdForNonConditionalOperation(resourceId, urlId, matchUrl);
|
validateResourceIdAndUrlIdForNonConditionalOperation(resource, resourceId, urlId, matchUrl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -151,7 +149,7 @@ abstract class BaseOutcomeReturningMethodBindingWithResourceParam extends BaseOu
|
||||||
* Subclasses may override
|
* Subclasses may override
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
protected void validateResourceIdAndUrlIdForNonConditionalOperation(String theResourceId, String theUrlId, String theMatchUrl) {
|
protected void validateResourceIdAndUrlIdForNonConditionalOperation(IBaseResource theResource, String theResourceId, String theUrlId, String theMatchUrl) {
|
||||||
// nothing by default
|
// nothing by default
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,8 +32,8 @@ import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.TreeSet;
|
||||||
|
|
||||||
import org.hl7.fhir.instance.model.api.IBaseBundle;
|
import org.hl7.fhir.instance.model.api.IBaseBundle;
|
||||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||||
|
@ -318,15 +318,15 @@ public abstract class BaseResourceReturningMethodBinding extends BaseMethodBindi
|
||||||
if (theRequest.getRequestType() == RequestTypeEnum.GET) {
|
if (theRequest.getRequestType() == RequestTypeEnum.GET) {
|
||||||
boolean first = true;
|
boolean first = true;
|
||||||
Map<String, String[]> parameters = theRequest.getParameters();
|
Map<String, String[]> parameters = theRequest.getParameters();
|
||||||
for (Entry<String, String[]> nextParams : parameters.entrySet()) {
|
for (String nextParamName : new TreeSet<String>(parameters.keySet())) {
|
||||||
for (String nextParamValue : nextParams.getValue()) {
|
for (String nextParamValue : parameters.get(nextParamName)) {
|
||||||
if (first) {
|
if (first) {
|
||||||
b.append('?');
|
b.append('?');
|
||||||
first = false;
|
first = false;
|
||||||
} else {
|
} else {
|
||||||
b.append('&');
|
b.append('&');
|
||||||
}
|
}
|
||||||
b.append(UrlUtil.escape(nextParams.getKey()));
|
b.append(UrlUtil.escape(nextParamName));
|
||||||
b.append('=');
|
b.append('=');
|
||||||
b.append(UrlUtil.escape(nextParamValue));
|
b.append(UrlUtil.escape(nextParamValue));
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,8 @@ import java.lang.reflect.Method;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||||
|
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
import ca.uhn.fhir.model.api.IResource;
|
import ca.uhn.fhir.model.api.IResource;
|
||||||
import ca.uhn.fhir.rest.annotation.Create;
|
import ca.uhn.fhir.rest.annotation.Create;
|
||||||
|
@ -72,7 +74,7 @@ public class CreateMethodBinding extends BaseOutcomeReturningMethodBindingWithRe
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void validateResourceIdAndUrlIdForNonConditionalOperation(String theResourceId, String theUrlId, String theMatchUrl) {
|
protected void validateResourceIdAndUrlIdForNonConditionalOperation(IBaseResource theResource, String theResourceId, String theUrlId, String theMatchUrl) {
|
||||||
if (isNotBlank(theUrlId)) {
|
if (isNotBlank(theUrlId)) {
|
||||||
String msg = getContext().getLocalizer().getMessage(BaseOutcomeReturningMethodBindingWithResourceParam.class, "idInUrlForCreate", theUrlId);
|
String msg = getContext().getLocalizer().getMessage(BaseOutcomeReturningMethodBindingWithResourceParam.class, "idInUrlForCreate", theUrlId);
|
||||||
throw new InvalidRequestException(msg);
|
throw new InvalidRequestException(msg);
|
||||||
|
|
|
@ -26,6 +26,7 @@ import java.lang.reflect.Method;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||||
import org.hl7.fhir.instance.model.api.IIdType;
|
import org.hl7.fhir.instance.model.api.IIdType;
|
||||||
|
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
|
@ -133,21 +134,22 @@ public class UpdateMethodBinding extends BaseOutcomeReturningMethodBindingWithRe
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void validateResourceIdAndUrlIdForNonConditionalOperation(String theResourceId, String theUrlId, String theMatchUrl) {
|
protected void validateResourceIdAndUrlIdForNonConditionalOperation(IBaseResource theResource, String theResourceId, String theUrlId, String theMatchUrl) {
|
||||||
if (isBlank(theMatchUrl)) {
|
if (isBlank(theMatchUrl)) {
|
||||||
|
if (isBlank(theUrlId)) {
|
||||||
|
String msg = getContext().getLocalizer().getMessage(BaseOutcomeReturningMethodBindingWithResourceParam.class, "noIdInUrlForUpdate");
|
||||||
|
throw new InvalidRequestException(msg);
|
||||||
|
}
|
||||||
if (isBlank(theResourceId)) {
|
if (isBlank(theResourceId)) {
|
||||||
// String msg = getContext().getLocalizer().getMessage(BaseOutcomeReturningMethodBindingWithResourceParam.class, "noIdInBodyForUpdate");
|
// String msg = getContext().getLocalizer().getMessage(BaseOutcomeReturningMethodBindingWithResourceParam.class, "noIdInBodyForUpdate");
|
||||||
ourLog.warn("No resource ID found in resource body for update");
|
ourLog.warn("No resource ID found in resource body for update");
|
||||||
|
theResource.setId(theUrlId);
|
||||||
} else {
|
} else {
|
||||||
if (!theResourceId.equals(theUrlId)) {
|
if (!theResourceId.equals(theUrlId)) {
|
||||||
String msg = getContext().getLocalizer().getMessage(BaseOutcomeReturningMethodBindingWithResourceParam.class, "incorrectIdForUpdate", theResourceId, theUrlId);
|
String msg = getContext().getLocalizer().getMessage(BaseOutcomeReturningMethodBindingWithResourceParam.class, "incorrectIdForUpdate", theResourceId, theUrlId);
|
||||||
throw new InvalidRequestException(msg);
|
throw new InvalidRequestException(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isBlank(theUrlId)) {
|
|
||||||
String msg = getContext().getLocalizer().getMessage(BaseOutcomeReturningMethodBindingWithResourceParam.class, "noIdInUrlForUpdate");
|
|
||||||
throw new InvalidRequestException(msg);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,4 +76,4 @@ ca.uhn.fhir.jpa.dao.BaseHapiFhirResourceDao.successfulUpdate=Successfully update
|
||||||
ca.uhn.fhir.jpa.dao.SearchBuilder.invalidQuantityPrefix=Unable to handle quantity prefix "{0}" for value: {1}
|
ca.uhn.fhir.jpa.dao.SearchBuilder.invalidQuantityPrefix=Unable to handle quantity prefix "{0}" for value: {1}
|
||||||
ca.uhn.fhir.jpa.dao.SearchBuilder.invalidNumberPrefix=Unable to handle number prefix "{0}" for value: {1}
|
ca.uhn.fhir.jpa.dao.SearchBuilder.invalidNumberPrefix=Unable to handle number prefix "{0}" for value: {1}
|
||||||
|
|
||||||
ca.uhn.fhir.jpa.term.TerminologySvcImpl.cannotCreateDuplicateCodeSystemUri=Can not create multiple code systems with URI "{0}", already have one with resource ID: {1}
|
ca.uhn.fhir.jpa.term.HapiTerminologySvcImpl.cannotCreateDuplicateCodeSystemUri=Can not create multiple code systems with URI "{0}", already have one with resource ID: {1}
|
|
@ -1,9 +1,5 @@
|
||||||
package ca.uhn.fhir.jpa.config;
|
package ca.uhn.fhir.jpa.config;
|
||||||
|
|
||||||
import java.util.concurrent.RejectedExecutionHandler;
|
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
|
||||||
import java.util.concurrent.ThreadFactory;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* #%L
|
* #%L
|
||||||
* HAPI FHIR JPA Server
|
* HAPI FHIR JPA Server
|
||||||
|
@ -40,14 +36,13 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
import org.springframework.scheduling.annotation.SchedulingConfigurer;
|
import org.springframework.scheduling.annotation.SchedulingConfigurer;
|
||||||
import org.springframework.scheduling.concurrent.ConcurrentTaskScheduler;
|
import org.springframework.scheduling.concurrent.ConcurrentTaskScheduler;
|
||||||
import org.springframework.scheduling.concurrent.ScheduledExecutorFactoryBean;
|
import org.springframework.scheduling.concurrent.ScheduledExecutorFactoryBean;
|
||||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
|
||||||
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
|
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
|
||||||
|
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider;
|
import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider;
|
||||||
import ca.uhn.fhir.jpa.search.StaleSearchDeletingSvc;
|
import ca.uhn.fhir.jpa.search.StaleSearchDeletingSvc;
|
||||||
import ca.uhn.fhir.jpa.term.ITerminologySvc;
|
import ca.uhn.fhir.jpa.term.HapiTerminologySvcImpl;
|
||||||
import ca.uhn.fhir.jpa.term.TerminologySvcImpl;
|
import ca.uhn.fhir.jpa.term.IHapiTerminologySvc;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableScheduling
|
@EnableScheduling
|
||||||
|
@ -135,8 +130,8 @@ public class BaseConfig implements SchedulingConfigurer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean(autowire = Autowire.BY_TYPE)
|
@Bean(autowire = Autowire.BY_TYPE)
|
||||||
public ITerminologySvc terminologyService() {
|
public IHapiTerminologySvc terminologyService() {
|
||||||
return new TerminologySvcImpl();
|
return new HapiTerminologySvcImpl();
|
||||||
}
|
}
|
||||||
|
|
||||||
// @PostConstruct
|
// @PostConstruct
|
||||||
|
|
|
@ -65,7 +65,7 @@ import ca.uhn.fhir.jpa.entity.ResourceTable;
|
||||||
import ca.uhn.fhir.jpa.entity.TagDefinition;
|
import ca.uhn.fhir.jpa.entity.TagDefinition;
|
||||||
import ca.uhn.fhir.jpa.entity.TagTypeEnum;
|
import ca.uhn.fhir.jpa.entity.TagTypeEnum;
|
||||||
import ca.uhn.fhir.jpa.interceptor.IJpaServerInterceptor;
|
import ca.uhn.fhir.jpa.interceptor.IJpaServerInterceptor;
|
||||||
import ca.uhn.fhir.jpa.term.ITerminologySvc;
|
import ca.uhn.fhir.jpa.term.IHapiTerminologySvc;
|
||||||
import ca.uhn.fhir.jpa.util.DeleteConflict;
|
import ca.uhn.fhir.jpa.util.DeleteConflict;
|
||||||
import ca.uhn.fhir.jpa.util.StopWatch;
|
import ca.uhn.fhir.jpa.util.StopWatch;
|
||||||
import ca.uhn.fhir.model.api.IQueryParameterType;
|
import ca.uhn.fhir.model.api.IQueryParameterType;
|
||||||
|
@ -77,7 +77,6 @@ import ca.uhn.fhir.model.primitive.IdDt;
|
||||||
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
|
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
|
||||||
import ca.uhn.fhir.rest.method.RequestDetails;
|
import ca.uhn.fhir.rest.method.RequestDetails;
|
||||||
import ca.uhn.fhir.rest.method.RestSearchParameterTypeEnum;
|
import ca.uhn.fhir.rest.method.RestSearchParameterTypeEnum;
|
||||||
import ca.uhn.fhir.rest.param.DateRangeParam;
|
|
||||||
import ca.uhn.fhir.rest.server.IBundleProvider;
|
import ca.uhn.fhir.rest.server.IBundleProvider;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||||
|
@ -111,7 +110,7 @@ public abstract class BaseHapiFhirResourceDao<T extends IBaseResource> extends B
|
||||||
@Autowired()
|
@Autowired()
|
||||||
protected IResourceIndexedSearchParamUriDao myResourceIndexedSearchParamUriDao;
|
protected IResourceIndexedSearchParamUriDao myResourceIndexedSearchParamUriDao;
|
||||||
@Autowired()
|
@Autowired()
|
||||||
protected ITerminologySvc myTerminologySvc;
|
protected IHapiTerminologySvc myTerminologySvc;
|
||||||
|
|
||||||
private String mySecondaryPrimaryKeyParamName;
|
private String mySecondaryPrimaryKeyParamName;
|
||||||
|
|
||||||
|
@ -986,7 +985,6 @@ public abstract class BaseHapiFhirResourceDao<T extends IBaseResource> extends B
|
||||||
/* Note: resourcdeId will not be null or empty here, because
|
/* Note: resourcdeId will not be null or empty here, because
|
||||||
* we check it and reject requests in BaseOutcomeReturningMethodBindingWithResourceParam
|
* we check it and reject requests in BaseOutcomeReturningMethodBindingWithResourceParam
|
||||||
*/
|
*/
|
||||||
//
|
|
||||||
resourceId = theResource.getIdElement();
|
resourceId = theResource.getIdElement();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -28,7 +28,6 @@ import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.MathContext;
|
import java.math.MathContext;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
@ -63,7 +62,6 @@ import org.apache.commons.lang3.tuple.Pair;
|
||||||
import org.hl7.fhir.instance.model.api.IAnyResource;
|
import org.hl7.fhir.instance.model.api.IAnyResource;
|
||||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||||
import org.hl7.fhir.instance.model.api.IIdType;
|
import org.hl7.fhir.instance.model.api.IIdType;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.transaction.PlatformTransactionManager;
|
import org.springframework.transaction.PlatformTransactionManager;
|
||||||
import org.springframework.transaction.TransactionStatus;
|
import org.springframework.transaction.TransactionStatus;
|
||||||
import org.springframework.transaction.support.TransactionCallback;
|
import org.springframework.transaction.support.TransactionCallback;
|
||||||
|
@ -101,7 +99,7 @@ import ca.uhn.fhir.jpa.entity.TagDefinition;
|
||||||
import ca.uhn.fhir.jpa.entity.TagTypeEnum;
|
import ca.uhn.fhir.jpa.entity.TagTypeEnum;
|
||||||
import ca.uhn.fhir.jpa.entity.TermConcept;
|
import ca.uhn.fhir.jpa.entity.TermConcept;
|
||||||
import ca.uhn.fhir.jpa.search.PersistedJpaBundleProvider;
|
import ca.uhn.fhir.jpa.search.PersistedJpaBundleProvider;
|
||||||
import ca.uhn.fhir.jpa.term.ITerminologySvc;
|
import ca.uhn.fhir.jpa.term.IHapiTerminologySvc;
|
||||||
import ca.uhn.fhir.jpa.util.StopWatch;
|
import ca.uhn.fhir.jpa.util.StopWatch;
|
||||||
import ca.uhn.fhir.model.api.IPrimitiveDatatype;
|
import ca.uhn.fhir.model.api.IPrimitiveDatatype;
|
||||||
import ca.uhn.fhir.model.api.IQueryParameterType;
|
import ca.uhn.fhir.model.api.IQueryParameterType;
|
||||||
|
@ -122,8 +120,6 @@ import ca.uhn.fhir.rest.method.RestSearchParameterTypeEnum;
|
||||||
import ca.uhn.fhir.rest.param.CompositeParam;
|
import ca.uhn.fhir.rest.param.CompositeParam;
|
||||||
import ca.uhn.fhir.rest.param.DateParam;
|
import ca.uhn.fhir.rest.param.DateParam;
|
||||||
import ca.uhn.fhir.rest.param.DateRangeParam;
|
import ca.uhn.fhir.rest.param.DateRangeParam;
|
||||||
import ca.uhn.fhir.rest.param.HasAndListParam;
|
|
||||||
import ca.uhn.fhir.rest.param.HasOrListParam;
|
|
||||||
import ca.uhn.fhir.rest.param.HasParam;
|
import ca.uhn.fhir.rest.param.HasParam;
|
||||||
import ca.uhn.fhir.rest.param.NumberParam;
|
import ca.uhn.fhir.rest.param.NumberParam;
|
||||||
import ca.uhn.fhir.rest.param.ParamPrefixEnum;
|
import ca.uhn.fhir.rest.param.ParamPrefixEnum;
|
||||||
|
@ -158,10 +154,10 @@ public class SearchBuilder {
|
||||||
private IFulltextSearchSvc mySearchDao;
|
private IFulltextSearchSvc mySearchDao;
|
||||||
private Search mySearchEntity;
|
private Search mySearchEntity;
|
||||||
private ISearchResultDao mySearchResultDao;
|
private ISearchResultDao mySearchResultDao;
|
||||||
private ITerminologySvc myTerminologySvc;
|
private IHapiTerminologySvc myTerminologySvc;
|
||||||
|
|
||||||
public SearchBuilder(FhirContext theFhirContext, EntityManager theEntityManager, PlatformTransactionManager thePlatformTransactionManager, IFulltextSearchSvc theSearchDao,
|
public SearchBuilder(FhirContext theFhirContext, EntityManager theEntityManager, PlatformTransactionManager thePlatformTransactionManager, IFulltextSearchSvc theSearchDao,
|
||||||
ISearchResultDao theSearchResultDao, BaseHapiFhirDao<?> theDao, IResourceIndexedSearchParamUriDao theResourceIndexedSearchParamUriDao, IForcedIdDao theForcedIdDao, ITerminologySvc theTerminologySvc) {
|
ISearchResultDao theSearchResultDao, BaseHapiFhirDao<?> theDao, IResourceIndexedSearchParamUriDao theResourceIndexedSearchParamUriDao, IForcedIdDao theForcedIdDao, IHapiTerminologySvc theTerminologySvc) {
|
||||||
myContext = theFhirContext;
|
myContext = theFhirContext;
|
||||||
myEntityManager = theEntityManager;
|
myEntityManager = theEntityManager;
|
||||||
myPlatformTransactionManager = thePlatformTransactionManager;
|
myPlatformTransactionManager = thePlatformTransactionManager;
|
||||||
|
|
|
@ -48,7 +48,7 @@ import ca.uhn.fhir.jpa.dao.IFhirResourceDaoCodeSystem;
|
||||||
import ca.uhn.fhir.jpa.entity.ResourceTable;
|
import ca.uhn.fhir.jpa.entity.ResourceTable;
|
||||||
import ca.uhn.fhir.jpa.entity.TermCodeSystemVersion;
|
import ca.uhn.fhir.jpa.entity.TermCodeSystemVersion;
|
||||||
import ca.uhn.fhir.jpa.entity.TermConcept;
|
import ca.uhn.fhir.jpa.entity.TermConcept;
|
||||||
import ca.uhn.fhir.jpa.term.ITerminologySvc;
|
import ca.uhn.fhir.jpa.term.IHapiTerminologySvc;
|
||||||
import ca.uhn.fhir.jpa.util.LogicUtil;
|
import ca.uhn.fhir.jpa.util.LogicUtil;
|
||||||
import ca.uhn.fhir.rest.method.RequestDetails;
|
import ca.uhn.fhir.rest.method.RequestDetails;
|
||||||
import ca.uhn.fhir.rest.param.TokenParam;
|
import ca.uhn.fhir.rest.param.TokenParam;
|
||||||
|
@ -60,7 +60,7 @@ public class FhirResourceDaoCodeSystemDstu3 extends FhirResourceDaoDstu3<CodeSys
|
||||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirResourceDaoCodeSystemDstu3.class);
|
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirResourceDaoCodeSystemDstu3.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ITerminologySvc myTerminologySvc;
|
private IHapiTerminologySvc myTerminologySvc;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ValidationSupportChain myValidationSupport;
|
private ValidationSupportChain myValidationSupport;
|
||||||
|
|
|
@ -26,8 +26,8 @@ import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
|
||||||
import ca.uhn.fhir.util.ObjectUtil;
|
import ca.uhn.fhir.util.ObjectUtil;
|
||||||
import ca.uhn.fhir.util.ValidateUtil;
|
import ca.uhn.fhir.util.ValidateUtil;
|
||||||
|
|
||||||
public class TerminologySvcImpl implements ITerminologySvc {
|
public class HapiTerminologySvcImpl implements IHapiTerminologySvc {
|
||||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(TerminologySvcImpl.class);
|
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(HapiTerminologySvcImpl.class);
|
||||||
private static final Object PLACEHOLDER_OBJECT = new Object();
|
private static final Object PLACEHOLDER_OBJECT = new Object();
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@ -142,7 +142,7 @@ public class TerminologySvcImpl implements ITerminologySvc {
|
||||||
myCodeSystemDao.save(codeSystem);
|
myCodeSystemDao.save(codeSystem);
|
||||||
} else {
|
} else {
|
||||||
if (!ObjectUtil.equals(codeSystem.getResource().getId(), theCodeSystem.getResource().getId())) {
|
if (!ObjectUtil.equals(codeSystem.getResource().getId(), theCodeSystem.getResource().getId())) {
|
||||||
String msg = myContext.getLocalizer().getMessage(TerminologySvcImpl.class, "cannotCreateDuplicateCodeSystemUri", theSystemUri, codeSystem.getResource().getIdDt().toUnqualifiedVersionless().getValue());
|
String msg = myContext.getLocalizer().getMessage(HapiTerminologySvcImpl.class, "cannotCreateDuplicateCodeSystemUri", theSystemUri, codeSystem.getResource().getIdDt().toUnqualifiedVersionless().getValue());
|
||||||
throw new UnprocessableEntityException(msg);
|
throw new UnprocessableEntityException(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -25,7 +25,7 @@ import java.util.Set;
|
||||||
import ca.uhn.fhir.jpa.entity.TermCodeSystemVersion;
|
import ca.uhn.fhir.jpa.entity.TermCodeSystemVersion;
|
||||||
import ca.uhn.fhir.jpa.entity.TermConcept;
|
import ca.uhn.fhir.jpa.entity.TermConcept;
|
||||||
|
|
||||||
public interface ITerminologySvc {
|
public interface IHapiTerminologySvc {
|
||||||
|
|
||||||
Set<TermConcept> findCodesAbove(Long theCodeSystemResourcePid, Long theCodeSystemResourceVersionPid, String theCode);
|
Set<TermConcept> findCodesAbove(Long theCodeSystemResourcePid, Long theCodeSystemResourceVersionPid, String theCode);
|
||||||
|
|
|
@ -73,7 +73,7 @@ import ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamString;
|
||||||
import ca.uhn.fhir.jpa.entity.ResourceTable;
|
import ca.uhn.fhir.jpa.entity.ResourceTable;
|
||||||
import ca.uhn.fhir.jpa.provider.dstu3.JpaSystemProviderDstu3;
|
import ca.uhn.fhir.jpa.provider.dstu3.JpaSystemProviderDstu3;
|
||||||
import ca.uhn.fhir.jpa.search.StaleSearchDeletingSvc;
|
import ca.uhn.fhir.jpa.search.StaleSearchDeletingSvc;
|
||||||
import ca.uhn.fhir.jpa.term.ITerminologySvc;
|
import ca.uhn.fhir.jpa.term.IHapiTerminologySvc;
|
||||||
import ca.uhn.fhir.jpa.validation.JpaValidationSupportChainDstu3;
|
import ca.uhn.fhir.jpa.validation.JpaValidationSupportChainDstu3;
|
||||||
import ca.uhn.fhir.parser.IParser;
|
import ca.uhn.fhir.parser.IParser;
|
||||||
import ca.uhn.fhir.rest.method.MethodUtil;
|
import ca.uhn.fhir.rest.method.MethodUtil;
|
||||||
|
@ -198,7 +198,7 @@ public abstract class BaseJpaDstu3Test extends BaseJpaTest {
|
||||||
@Qualifier("mySystemProviderDstu3")
|
@Qualifier("mySystemProviderDstu3")
|
||||||
protected JpaSystemProviderDstu3 mySystemProvider;
|
protected JpaSystemProviderDstu3 mySystemProvider;
|
||||||
@Autowired
|
@Autowired
|
||||||
protected ITerminologySvc myTermSvc;
|
protected IHapiTerminologySvc myTermSvc;
|
||||||
@Autowired
|
@Autowired
|
||||||
protected PlatformTransactionManager myTxManager;
|
protected PlatformTransactionManager myTxManager;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|
|
@ -617,7 +617,7 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
|
||||||
|
|
||||||
Observation o2 = new Observation();
|
Observation o2 = new Observation();
|
||||||
o2.getCode().addCoding().setSystem("foo").setCode("testSearchCompositeParamDateN01");
|
o2.getCode().addCoding().setSystem("foo").setCode("testSearchCompositeParamDateN01");
|
||||||
o1.setValue(new Period().setStartElement(new DateTimeType("2001-01-02T11:11:11")).setEndElement(new DateTimeType("2001-01-02T12:11:11")));
|
o2.setValue(new Period().setStartElement(new DateTimeType("2001-01-02T11:11:11")).setEndElement(new DateTimeType("2001-01-02T12:11:11")));
|
||||||
IIdType id2 = myObservationDao.create(o2, mySrd).getId().toUnqualifiedVersionless();
|
IIdType id2 = myObservationDao.create(o2, mySrd).getId().toUnqualifiedVersionless();
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -625,18 +625,29 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
|
||||||
DateParam v1 = new DateParam("2001-01-01");
|
DateParam v1 = new DateParam("2001-01-01");
|
||||||
CompositeParam<TokenParam, DateParam> val = new CompositeParam<TokenParam, DateParam>(v0, v1);
|
CompositeParam<TokenParam, DateParam> val = new CompositeParam<TokenParam, DateParam>(v0, v1);
|
||||||
IBundleProvider result = myObservationDao.search(Observation.SP_CODE_VALUE_DATE, val);
|
IBundleProvider result = myObservationDao.search(Observation.SP_CODE_VALUE_DATE, val);
|
||||||
assertEquals(1, result.size());
|
assertThat(toUnqualifiedVersionlessIds(result), containsInAnyOrder(id1));
|
||||||
assertEquals(id1.toUnqualifiedVersionless(), result.getResources(0, 1).get(0).getIdElement().toUnqualifiedVersionless());
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
TokenParam v0 = new TokenParam("foo", "testSearchCompositeParamDateN01");
|
TokenParam v0 = new TokenParam("foo", "testSearchCompositeParamDateN01");
|
||||||
// TODO: this should also work with ">2001-01-01T15:12:12" since the two times only have a lower bound
|
|
||||||
DateParam v1 = new DateParam(">2001-01-01T10:12:12");
|
DateParam v1 = new DateParam(">2001-01-01T10:12:12");
|
||||||
CompositeParam<TokenParam, DateParam> val = new CompositeParam<TokenParam, DateParam>(v0, v1);
|
CompositeParam<TokenParam, DateParam> val = new CompositeParam<TokenParam, DateParam>(v0, v1);
|
||||||
IBundleProvider result = myObservationDao.search(Observation.SP_CODE_VALUE_DATE, val);
|
IBundleProvider result = myObservationDao.search(Observation.SP_CODE_VALUE_DATE, val);
|
||||||
assertEquals(2, result.size());
|
|
||||||
assertThat(toUnqualifiedVersionlessIds(result), containsInAnyOrder(id1, id2));
|
assertThat(toUnqualifiedVersionlessIds(result), containsInAnyOrder(id1, id2));
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
TokenParam v0 = new TokenParam("foo", "testSearchCompositeParamDateN01");
|
||||||
|
DateParam v1 = new DateParam("gt2001-01-01T11:12:12");
|
||||||
|
CompositeParam<TokenParam, DateParam> val = new CompositeParam<TokenParam, DateParam>(v0, v1);
|
||||||
|
IBundleProvider result = myObservationDao.search(Observation.SP_CODE_VALUE_DATE, val);
|
||||||
|
assertThat(toUnqualifiedVersionlessIds(result), containsInAnyOrder(id1, id2));
|
||||||
|
}
|
||||||
|
{
|
||||||
|
TokenParam v0 = new TokenParam("foo", "testSearchCompositeParamDateN01");
|
||||||
|
DateParam v1 = new DateParam("gt2001-01-01T15:12:12");
|
||||||
|
CompositeParam<TokenParam, DateParam> val = new CompositeParam<TokenParam, DateParam>(v0, v1);
|
||||||
|
IBundleProvider result = myObservationDao.search(Observation.SP_CODE_VALUE_DATE, val);
|
||||||
|
assertThat(toUnqualifiedVersionlessIds(result), containsInAnyOrder(id2));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ import static org.hamcrest.Matchers.containsString;
|
||||||
import static org.hamcrest.Matchers.emptyString;
|
import static org.hamcrest.Matchers.emptyString;
|
||||||
import static org.hamcrest.Matchers.endsWith;
|
import static org.hamcrest.Matchers.endsWith;
|
||||||
import static org.hamcrest.Matchers.greaterThan;
|
import static org.hamcrest.Matchers.greaterThan;
|
||||||
|
import static org.hamcrest.Matchers.matchesPattern;
|
||||||
import static org.hamcrest.Matchers.not;
|
import static org.hamcrest.Matchers.not;
|
||||||
import static org.hamcrest.Matchers.startsWith;
|
import static org.hamcrest.Matchers.startsWith;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
@ -17,7 +18,6 @@ import static org.mockito.Matchers.eq;
|
||||||
import static org.mockito.Mockito.times;
|
import static org.mockito.Mockito.times;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -88,7 +88,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest {
|
||||||
|
|
||||||
ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(response));
|
ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(response));
|
||||||
assertEquals("201 Created", response.getEntryFirstRep().getResponse().getStatus());
|
assertEquals("201 Created", response.getEntryFirstRep().getResponse().getStatus());
|
||||||
assertEquals("Practitioner/1/_history/1", response.getEntryFirstRep().getResponse().getLocation());
|
assertThat(response.getEntryFirstRep().getResponse().getLocation(), matchesPattern("Practitioner/[0-9]+/_history/1"));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Now a second time
|
* Now a second time
|
||||||
|
@ -99,7 +99,7 @@ public class FhirSystemDaoDstu3Test extends BaseJpaDstu3SystemTest {
|
||||||
|
|
||||||
ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(response));
|
ourLog.info(myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(response));
|
||||||
assertEquals("200 OK", response.getEntryFirstRep().getResponse().getStatus());
|
assertEquals("200 OK", response.getEntryFirstRep().getResponse().getStatus());
|
||||||
assertEquals("Practitioner/1/_history/1", response.getEntryFirstRep().getResponse().getLocation());
|
assertThat(response.getEntryFirstRep().getResponse().getLocation(), matchesPattern("Practitioner/[0-9]+/_history/1"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -241,8 +241,13 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
|
||||||
String output = IOUtils.toString(resp.getEntity().getContent());
|
String output = IOUtils.toString(resp.getEntity().getContent());
|
||||||
ourLog.info(output);
|
ourLog.info(output);
|
||||||
|
|
||||||
assertThat(output, containsString("<url value=\"http://localhost:" + ourPort + "/fhir/context/Patient?_pretty=true&name=Jernel%C3%B6v\"/>"));
|
Bundle b = myFhirCtx.newXmlParser().parseResource(Bundle.class, output);
|
||||||
assertThat(output, containsString("<family value=\"Jernelöv\"/>"));
|
|
||||||
|
assertEquals("http://localhost:" + ourPort + "/fhir/context/Patient?_count=5&_pretty=true&name=Jernel%C3%B6v", b.getLink("self").getUrl());
|
||||||
|
|
||||||
|
Patient p = (Patient) b.getEntryFirstRep().getResource();
|
||||||
|
assertEquals("Jernelöv", p.getNameFirstRep().getFamilyFirstRep().getValue());
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
IOUtils.closeQuietly(resp.getEntity().getContent());
|
IOUtils.closeQuietly(resp.getEntity().getContent());
|
||||||
}
|
}
|
||||||
|
@ -2316,7 +2321,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
|
||||||
ourLog.info(responseString);
|
ourLog.info(responseString);
|
||||||
assertEquals(400, response.getStatusLine().getStatusCode());
|
assertEquals(400, response.getStatusLine().getStatusCode());
|
||||||
OperationOutcome oo = myFhirCtx.newXmlParser().parseResource(OperationOutcome.class, responseString);
|
OperationOutcome oo = myFhirCtx.newXmlParser().parseResource(OperationOutcome.class, responseString);
|
||||||
assertThat(oo.getIssue().get(0).getDiagnostics(), containsString("Can not update resource, resource body must contain an ID element for update (PUT) operation"));
|
assertThat(oo.getIssue().get(0).getDiagnostics(), containsString("Can not update resource, request URL must contain an ID element for update (PUT) operation (it must be of the form [base]/[resource type]/[id])"));
|
||||||
} finally {
|
} finally {
|
||||||
response.close();
|
response.close();
|
||||||
}
|
}
|
||||||
|
@ -2345,7 +2350,11 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This does not currently cause an error, so this test is disabled
|
||||||
|
*/
|
||||||
@Test
|
@Test
|
||||||
|
@Ignore
|
||||||
public void testUpdateNoIdInBody() throws IOException, Exception {
|
public void testUpdateNoIdInBody() throws IOException, Exception {
|
||||||
String methodName = "testUpdateNoIdInBody";
|
String methodName = "testUpdateNoIdInBody";
|
||||||
|
|
||||||
|
@ -2353,13 +2362,13 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
|
||||||
pt.addName().addFamily(methodName);
|
pt.addName().addFamily(methodName);
|
||||||
String resource = myFhirCtx.newXmlParser().encodeResourceToString(pt);
|
String resource = myFhirCtx.newXmlParser().encodeResourceToString(pt);
|
||||||
|
|
||||||
HttpPut post = new HttpPut(ourServerBase + "/Patient/2");
|
HttpPut post = new HttpPut(ourServerBase + "/Patient/FOO");
|
||||||
post.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
post.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||||
CloseableHttpResponse response = ourHttpClient.execute(post);
|
CloseableHttpResponse response = ourHttpClient.execute(post);
|
||||||
try {
|
try {
|
||||||
String responseString = IOUtils.toString(response.getEntity().getContent());
|
String responseString = IOUtils.toString(response.getEntity().getContent());
|
||||||
ourLog.info(responseString);
|
ourLog.info(responseString);
|
||||||
assertThat(responseString, containsString("Can not update resource, resource body must contain an ID element for update (PUT) operation"));
|
assertThat(responseString, containsString("Can not update resource, request URL must contain an ID element for update (PUT) operation (it must be of the form [base]/[resource type]/[id])"));
|
||||||
assertThat(responseString, containsString("<OperationOutcome"));
|
assertThat(responseString, containsString("<OperationOutcome"));
|
||||||
assertEquals(400, response.getStatusLine().getStatusCode());
|
assertEquals(400, response.getStatusLine().getStatusCode());
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -2403,9 +2412,10 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
|
||||||
put.addHeader("Accept", Constants.CT_FHIR_JSON);
|
put.addHeader("Accept", Constants.CT_FHIR_JSON);
|
||||||
response = ourHttpClient.execute(put);
|
response = ourHttpClient.execute(put);
|
||||||
try {
|
try {
|
||||||
assertEquals(400, response.getStatusLine().getStatusCode());
|
// As of HAPI 1.6 this is accepted
|
||||||
OperationOutcome oo = myFhirCtx.newJsonParser().parseResource(OperationOutcome.class, new InputStreamReader(response.getEntity().getContent()));
|
assertEquals(200, response.getStatusLine().getStatusCode());
|
||||||
assertEquals("Can not update resource, resource body must contain an ID element for update (PUT) operation", oo.getIssue().get(0).getDiagnostics());
|
// OperationOutcome oo = myFhirCtx.newJsonParser().parseResource(OperationOutcome.class, new InputStreamReader(response.getEntity().getContent()));
|
||||||
|
// assertEquals("Can not update resource, resource body must contain an ID element for update (PUT) operation", oo.getIssue().get(0).getDiagnostics());
|
||||||
} finally {
|
} finally {
|
||||||
response.close();
|
response.close();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue