Merge branch 'master' of github.com:jamesagnew/hapi-fhir

This commit is contained in:
James 2017-08-24 13:07:39 -04:00
commit be532ba127
10 changed files with 60 additions and 46 deletions

View File

@ -35,7 +35,7 @@ public interface ITermConceptParentChildLinkDao extends JpaRepository<TermConcep
@Modifying
void deleteByCodeSystemVersion(@Param("cs_pid") Long thePid);
@Query("SELECT t FROM TermConceptParentChildLink t WHERE t.myChildPid = :child_pid")
Collection<TermConceptParentChildLink> findAllWithChild(@Param("child_pid") Long theConceptPid);
@Query("SELECT t.myParentPid FROM TermConceptParentChildLink t WHERE t.myChildPid = :child_pid")
Collection<Long> findAllWithChild(@Param("child_pid") Long theConceptPid);
}

View File

@ -357,13 +357,14 @@ public abstract class BaseHapiTerminologySvc implements IHapiTerminologySvc {
if (parents.contains(-1L)) {
return;
} else if (parents.isEmpty()) {
Collection<TermConceptParentChildLink> parentLinks = myConceptParentChildLinkDao.findAllWithChild(theConceptPid);
ourLog.info("Loading parent concepts of concept {}", theConceptPid);
Collection<Long> parentLinks = myConceptParentChildLinkDao.findAllWithChild(theConceptPid);
if (parentLinks.isEmpty()) {
myChildToParentPidCache.put(theConceptPid, -1L);
return;
} else {
for (TermConceptParentChildLink next : parentLinks) {
myChildToParentPidCache.put(theConceptPid, next.getParentPid());
for (Long next : parentLinks) {
myChildToParentPidCache.put(theConceptPid, next);
}
}
}
@ -382,6 +383,7 @@ public abstract class BaseHapiTerminologySvc implements IHapiTerminologySvc {
int maxResult = 1000;
Page<TermConcept> concepts = myConceptDao.findResourcesRequiringReindexing(new PageRequest(0, maxResult));
if (concepts.hasContent() == false) {
ourLog.info("Clearing parent concept cache");
myNextReindexPass = System.currentTimeMillis() + DateUtils.MILLIS_PER_MINUTE;
myChildToParentPidCache = null;
return;

View File

@ -79,6 +79,7 @@ public class ResourceProviderInterceptorDstu3Test extends BaseResourceProviderDs
private void resetServerInterceptor() throws ServletException, IOException {
reset(myServerInterceptor);
reset(myDaoInterceptor);
when(myServerInterceptor.handleException(any(RequestDetails.class), any(BaseServerResponseException.class), any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true);
when(myServerInterceptor.incomingRequestPostProcessed(any(RequestDetails.class), any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true);
when(myServerInterceptor.incomingRequestPreProcessed(any(HttpServletRequest.class), any(HttpServletResponse.class))).thenReturn(true);
@ -95,6 +96,7 @@ public class ResourceProviderInterceptorDstu3Test extends BaseResourceProviderDs
String resource = myFhirCtx.newXmlParser().encodeResourceToString(pt);
verify(myServerInterceptor, never()).incomingRequestPreHandled(any(RestOperationTypeEnum.class), any(ActionRequestDetails.class));
verify(myDaoInterceptor, never()).incomingRequestPreHandled(any(RestOperationTypeEnum.class), any(ActionRequestDetails.class));
HttpPost post = new HttpPost(ourServerBase + "/Patient");
post.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));

View File

@ -3,6 +3,8 @@ package ca.uhn.fhir.jpa.demo;
import java.util.Collection;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.ServletException;

View File

@ -11,6 +11,7 @@ curl -H "Authorization: Bearer " "http://fhirtest.uhn.ca/baseDstu3/\$mark-all-re
# Delete all errored resources
update hfj_res_ver set forced_id_pid = null where res_id in (select res_id from hfj_resource where sp_index_status = 2);
update hfj_resource set forced_id_pid = null where res_id in (select res_id from hfj_resource where sp_index_status = 2);
delete from hfj_history_tag where res_id in (select res_id from hfj_resource where sp_index_status = 2);
delete from hfj_res_ver where res_id in (select res_id from hfj_resource where sp_index_status = 2);
delete from hfj_forced_id where resource_pid in (select res_id from hfj_resource where sp_index_status = 2);
delete from hfj_res_link where src_resource_id in (select res_id from hfj_resource where sp_index_status = 2);

View File

@ -351,6 +351,7 @@ public class ResponseHighlighterInterceptor extends InterceptorAdapter {
*
* @return Returns a reference to this for easy method chaining
*/
@SuppressWarnings("UnusedReturnValue")
public ResponseHighlighterInterceptor setShowRequestHeaders(boolean theShowRequestHeaders) {
myShowRequestHeaders = theShowRequestHeaders;
return this;
@ -362,6 +363,7 @@ public class ResponseHighlighterInterceptor extends InterceptorAdapter {
*
* @return Returns a reference to this for easy method chaining
*/
@SuppressWarnings("UnusedReturnValue")
public ResponseHighlighterInterceptor setShowResponseHeaders(boolean theShowResponseHeaders) {
myShowResponseHeaders = theShowResponseHeaders;
return this;
@ -415,7 +417,7 @@ public class ResponseHighlighterInterceptor extends InterceptorAdapter {
}
}
if (prettyPrintResponse) {
p.setPrettyPrint(prettyPrintResponse);
p.setPrettyPrint(true);
}
EncodingEnum encoding = p.getEncoding();
@ -558,18 +560,16 @@ public class ResponseHighlighterInterceptor extends InterceptorAdapter {
b.append("\n");
b.append("\n");
if (true) {
try {
if (isShowRequestHeaders()) {
streamRequestHeaders(theServletRequest, b);
}
if (isShowResponseHeaders()) {
streamResponseHeaders(theRequestDetails, theServletResponse, b);
}
} catch (Throwable t) {
// ignore (this will hit if we're running in a servlet 2.5 environment)
}
}
try {
if (isShowRequestHeaders()) {
streamRequestHeaders(theServletRequest, b);
}
if (isShowResponseHeaders()) {
streamResponseHeaders(theRequestDetails, theServletResponse, b);
}
} catch (Throwable t) {
// ignore (this will hit if we're running in a servlet 2.5 environment)
}
StringBuilder target = new StringBuilder();
int linesCount = format(encoded, target, encoding);

View File

@ -761,6 +761,7 @@ public class ResponseHighlightingInterceptorTest {
@BeforeClass
public static void beforeClass() throws Exception {
ourPort = PortUtil.findFreePort();
ourLog.info("Using port: {}", ourPort);
ourServer = new Server(ourPort);
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();

View File

@ -1,33 +1,5 @@
package ca.uhn.fhir.rest.server.interceptor;
import static org.junit.Assert.assertEquals;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.io.IOUtils;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.junit.*;
import org.mockito.ArgumentCaptor;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.context.api.BundleInclusionRule;
import ca.uhn.fhir.model.dstu2.resource.Observation;
@ -44,6 +16,32 @@ import ca.uhn.fhir.rest.server.RestfulServer;
import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor.ActionRequestDetails;
import ca.uhn.fhir.util.PortUtil;
import ca.uhn.fhir.util.TestUtil;
import org.apache.commons.io.IOUtils;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
import static org.junit.Assert.*;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.*;
public class ServerActionInterceptorTest {

View File

@ -358,6 +358,10 @@
<id>InfiniteLoop90</id>
<name>Clayton Bodendein</name>
</developer>
<developer>
<id>rhausam</id>
<name>Rob Hausam</name>
</developer>
</developers>
<licenses>

View File

@ -328,6 +328,10 @@
specified, regardless of whether the source event was a create or an
update
</action>
<action type="add" issue="712">
Add appropriate import statements for logging to JPA demo code. Thanks to
Rob Hausam for the pull request!
</action>
</release>
<release version="2.5" date="2017-06-08">
<action type="fix">