From db0a2089278ef9ce5ffb0ff88c47877d71ca5429 Mon Sep 17 00:00:00 2001
From: James Agnew
Date: Fri, 24 Jun 2016 18:40:44 -0400
Subject: [PATCH] Work on terminology importing
---
.../fhir/rest/client/IClientInterceptor.java | 8 ++++
.../fhir/jpa/dao/BaseHapiFhirSystemDao.java | 41 +++++++++++++++++++
.../FhirResourceDaoSearchParameterDstu2.java | 2 +-
.../FhirResourceDaoSearchParameterDstu3.java | 2 +-
.../dstu3/JpaConformanceProviderDstu3.java | 4 ++
.../fhir/jpa/term/BaseHapiTerminologySvc.java | 29 ++++++++-----
.../ca/uhn/fhirtest/TestRestfulServer.java | 25 ++++-------
src/site/xdoc/hacking_hapi_fhir.xml | 23 +++++++++++
8 files changed, 104 insertions(+), 30 deletions(-)
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/IClientInterceptor.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/IClientInterceptor.java
index b1d1ec73e7c..583133c5997 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/IClientInterceptor.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/IClientInterceptor.java
@@ -25,6 +25,14 @@ import java.io.IOException;
import ca.uhn.fhir.rest.client.api.IHttpRequest;
import ca.uhn.fhir.rest.client.api.IHttpResponse;
+/**
+ * This interface represents an interceptor which can be used to access (and optionally change or take actions upon)
+ * requests that are being sent by the HTTP client, and responses received by it.
+ *
+ */
public interface IClientInterceptor {
/**
diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirSystemDao.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirSystemDao.java
index a068a68b921..eecc2d43ba6 100644
--- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirSystemDao.java
+++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirSystemDao.java
@@ -253,6 +253,47 @@ public abstract class BaseHapiFhirSystemDao extends BaseHapiFhirDao 0; i++) {
+ for (int i = 0; i < 50 && count != 0; i++) {
count = mySystemDao.performReindexingPass(100, requestDetails);
try {
Thread.sleep(DateUtils.MILLIS_PER_SECOND);
diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoSearchParameterDstu3.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoSearchParameterDstu3.java
index b6490c883c4..b7665883a88 100644
--- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoSearchParameterDstu3.java
+++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoSearchParameterDstu3.java
@@ -52,7 +52,7 @@ public class FhirResourceDaoSearchParameterDstu3 extends FhirResourceDaoDstu3 0; i++) {
+ for (int i = 0; i < 50 && count != 0; i++) {
count = mySystemDao.performReindexingPass(100, requestDetails);
try {
Thread.sleep(DateUtils.MILLIS_PER_SECOND);
diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/dstu3/JpaConformanceProviderDstu3.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/dstu3/JpaConformanceProviderDstu3.java
index 96919a3d945..7f3dd0e163e 100644
--- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/dstu3/JpaConformanceProviderDstu3.java
+++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/provider/dstu3/JpaConformanceProviderDstu3.java
@@ -35,6 +35,7 @@ import org.hl7.fhir.dstu3.model.Conformance.ConditionalDeleteStatus;
import org.hl7.fhir.dstu3.model.Conformance.ConformanceRestComponent;
import org.hl7.fhir.dstu3.model.Conformance.ConformanceRestResourceComponent;
import org.hl7.fhir.dstu3.model.Conformance.ConformanceRestResourceSearchParamComponent;
+import org.hl7.fhir.dstu3.model.Conformance.ResourceVersionPolicy;
import org.hl7.fhir.dstu3.model.Enumerations.SearchParamType;
import ca.uhn.fhir.context.FhirContext;
@@ -42,6 +43,7 @@ import ca.uhn.fhir.context.RuntimeResourceDefinition;
import ca.uhn.fhir.context.RuntimeSearchParam;
import ca.uhn.fhir.jpa.dao.DaoConfig;
import ca.uhn.fhir.jpa.dao.IFhirSystemDao;
+import ca.uhn.fhir.jpa.entity.ResourceEncodingEnum;
import ca.uhn.fhir.rest.server.RestfulServer;
import ca.uhn.fhir.util.CoverageIgnore;
import ca.uhn.fhir.util.ExtensionConstants;
@@ -87,6 +89,8 @@ public class JpaConformanceProviderDstu3 extends org.hl7.fhir.dstu3.hapi.rest.se
for (ConformanceRestResourceComponent nextResource : nextRest.getResource()) {
+ nextResource.setVersioning(ResourceVersionPolicy.VERSIONEDUPDATE);
+
ConditionalDeleteStatus conditionalDelete = nextResource.getConditionalDelete();
if (conditionalDelete == ConditionalDeleteStatus.MULTIPLE && myDaoConfig.isAllowMultipleDelete() == false) {
nextResource.setConditionalDelete(ConditionalDeleteStatus.SINGLE);
diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/BaseHapiTerminologySvc.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/BaseHapiTerminologySvc.java
index 6953964590e..0f7391e8561 100644
--- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/BaseHapiTerminologySvc.java
+++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/BaseHapiTerminologySvc.java
@@ -312,6 +312,24 @@ public abstract class BaseHapiTerminologySvc implements IHapiTerminologySvc {
// Grab the existing versions so we can delete them later
List existing = myCodeSystemVersionDao.findByCodeSystemResource(theCodeSystemResourcePid);
+ /*
+ * For now we always delete old versions.. At some point it would be nice to allow configuration to keep old versions
+ */
+
+ ourLog.info("Deleting old code system versions");
+ for (TermCodeSystemVersion next : existing) {
+ ourLog.info(" * Deleting code system version {}", next.getPid());
+ myConceptParentChildLinkDao.deleteByCodeSystemVersion(next.getPid());
+ myConceptDao.deleteByCodeSystemVersion(next.getPid());
+ }
+
+ ourLog.info("Flushing...");
+
+ myConceptParentChildLinkDao.flush();
+ myConceptDao.flush();
+
+ ourLog.info("Done flushing");
+
/*
* Do the upload
*/
@@ -370,17 +388,6 @@ public abstract class BaseHapiTerminologySvc implements IHapiTerminologySvc {
myConceptDao.flush();
myConceptParentChildLinkDao.flush();
- /*
- * For now we always delete old versions.. At some point it would be nice to allow configuration to keep old versions
- */
-
- ourLog.info("Deleting old code system versions");
- for (TermCodeSystemVersion next : existing) {
- ourLog.info(" * Deleting code system version {}", next.getPid());
- myConceptParentChildLinkDao.deleteByCodeSystemVersion(next.getPid());
- myConceptDao.deleteByCodeSystemVersion(next.getPid());
- }
-
ourLog.info("Done deleting old code system versions");
if (myConceptsToSaveLater.size() > 0 || myConceptLinksToSaveLater.size() > 0) {
diff --git a/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/TestRestfulServer.java b/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/TestRestfulServer.java
index e4f8fffce0b..8c78c67677b 100644
--- a/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/TestRestfulServer.java
+++ b/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/TestRestfulServer.java
@@ -24,6 +24,7 @@ import ca.uhn.fhir.jpa.provider.JpaSystemProviderDstu1;
import ca.uhn.fhir.jpa.provider.JpaSystemProviderDstu2;
import ca.uhn.fhir.jpa.provider.dstu3.JpaConformanceProviderDstu3;
import ca.uhn.fhir.jpa.provider.dstu3.JpaSystemProviderDstu3;
+import ca.uhn.fhir.jpa.provider.dstu3.TerminologyUploaderProviderDstu3;
import ca.uhn.fhir.narrative.DefaultThymeleafNarrativeGenerator;
import ca.uhn.fhir.rest.server.ETagSupportEnum;
import ca.uhn.fhir.rest.server.EncodingEnum;
@@ -71,13 +72,12 @@ public class TestRestfulServer extends RestfulServer {
// retrieve all the appropriate resource providers and the
// conformance provider
List beans;
- JpaSystemProviderDstu1 systemProviderDstu1 = null;
- JpaSystemProviderDstu2 systemProviderDstu2 = null;
- JpaSystemProviderDstu3 systemProviderDstu3 = null;
@SuppressWarnings("rawtypes")
IFhirSystemDao systemDao;
ETagSupportEnum etagSupport;
String baseUrlProperty;
+ List
+
+
+
+
+ When importing the HAPI projects into Eclipse, sometimes Eclipse
+ will fail to correctly import libraries. If you import a module
+ into Eclipse and it fails to compile with many errors relating to
+ packages other than HAPI's, the following steps will fix this:
+
+
+
Delete the project from your Eclipse workspace
+
+ On the local filesystem, delete the files .project
+ and .classpath, and the directory .settings
+ from each module you want to open.
+
+
+ Import each module again using the instructions above
+