Work on terminology importing

This commit is contained in:
James Agnew 2016-06-24 18:40:44 -04:00
parent b84150ff5e
commit db0a208927
8 changed files with 104 additions and 30 deletions

View File

@ -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.
* <p>
* See the <a href="http://jamesagnew.github.io/hapi-fhir/doc_rest_client_interceptor.html">HAPI Documentation Client Interceptor</a>
* page for more information on how to use this feature.
* </p>
*/
public interface IClientInterceptor {
/**

View File

@ -253,6 +253,47 @@ public abstract class BaseHapiFhirSystemDao<T, MT> extends BaseHapiFhirDao<IBase
q.setParameter("status", INDEX_STATUS_INDEXING_FAILED);
q.setParameter("id", theId);
q.executeUpdate();
q = myEntityManager.createQuery("DELETE FROM ResourceTag t WHERE t.myResourceId = :id");
q.setParameter("id", theId);
q.executeUpdate();
q = myEntityManager.createQuery("DELETE FROM ResourceIndexedSearchParamCoords t WHERE t.myResourcePid = :id");
q.setParameter("id", theId);
q.executeUpdate();
q = myEntityManager.createQuery("DELETE FROM ResourceIndexedSearchParamDate t WHERE t.myResourcePid = :id");
q.setParameter("id", theId);
q.executeUpdate();
q = myEntityManager.createQuery("DELETE FROM ResourceIndexedSearchParamNumber t WHERE t.myResourcePid = :id");
q.setParameter("id", theId);
q.executeUpdate();
q = myEntityManager.createQuery("DELETE FROM ResourceIndexedSearchParamQuantity t WHERE t.myResourcePid = :id");
q.setParameter("id", theId);
q.executeUpdate();
q = myEntityManager.createQuery("DELETE FROM ResourceIndexedSearchParamString t WHERE t.myResourcePid = :id");
q.setParameter("id", theId);
q.executeUpdate();
q = myEntityManager.createQuery("DELETE FROM ResourceIndexedSearchParamToken t WHERE t.myResourcePid = :id");
q.setParameter("id", theId);
q.executeUpdate();
q = myEntityManager.createQuery("DELETE FROM ResourceIndexedSearchParamUri t WHERE t.myResourcePid = :id");
q.setParameter("id", theId);
q.executeUpdate();
q = myEntityManager.createQuery("DELETE FROM ResourceLink t WHERE t.mySourceResourcePid = :id");
q.setParameter("id", theId);
q.executeUpdate();
q = myEntityManager.createQuery("DELETE FROM ResourceLink t WHERE t.myTargetResourcePid = :id");
q.setParameter("id", theId);
q.executeUpdate();
return null;
}
});

View File

@ -50,7 +50,7 @@ public class FhirResourceDaoSearchParameterDstu2 extends FhirResourceDaoDstu2<Se
RequestDetails requestDetails = new ServletRequestDetails();
int count = mySystemDao.performReindexingPass(100, requestDetails);
for (int i = 0; i < 50 && count > 0; i++) {
for (int i = 0; i < 50 && count != 0; i++) {
count = mySystemDao.performReindexingPass(100, requestDetails);
try {
Thread.sleep(DateUtils.MILLIS_PER_SECOND);

View File

@ -52,7 +52,7 @@ public class FhirResourceDaoSearchParameterDstu3 extends FhirResourceDaoDstu3<Se
RequestDetails requestDetails = new ServletRequestDetails();
int count = mySystemDao.performReindexingPass(100, requestDetails);
for (int i = 0; i < 50 && count > 0; i++) {
for (int i = 0; i < 50 && count != 0; i++) {
count = mySystemDao.performReindexingPass(100, requestDetails);
try {
Thread.sleep(DateUtils.MILLIS_PER_SECOND);

View File

@ -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);

View File

@ -312,6 +312,24 @@ public abstract class BaseHapiTerminologySvc implements IHapiTerminologySvc {
// Grab the existing versions so we can delete them later
List<TermCodeSystemVersion> 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) {

View File

@ -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<IResourceProvider> beans;
JpaSystemProviderDstu1 systemProviderDstu1 = null;
JpaSystemProviderDstu2 systemProviderDstu2 = null;
JpaSystemProviderDstu3 systemProviderDstu3 = null;
@SuppressWarnings("rawtypes")
IFhirSystemDao systemDao;
ETagSupportEnum etagSupport;
String baseUrlProperty;
List<Object> plainProviders = new ArrayList<Object>();
switch (fhirVersionParam.trim().toUpperCase()) {
case "DSTU1": {
myAppCtx = new AnnotationConfigWebApplicationContext();
@ -87,7 +87,7 @@ public class TestRestfulServer extends RestfulServer {
myAppCtx.refresh();
setFhirContext(FhirContext.forDstu1());
beans = myAppCtx.getBean("myResourceProvidersDstu1", List.class);
systemProviderDstu1 = myAppCtx.getBean("mySystemProviderDstu1", JpaSystemProviderDstu1.class);
plainProviders.add(myAppCtx.getBean("mySystemProviderDstu1", JpaSystemProviderDstu1.class));
systemDao = myAppCtx.getBean("mySystemDaoDstu1", IFhirSystemDao.class);
etagSupport = ETagSupportEnum.DISABLED;
JpaConformanceProviderDstu1 confProvider = new JpaConformanceProviderDstu1(this, systemDao);
@ -111,7 +111,7 @@ public class TestRestfulServer extends RestfulServer {
myAppCtx.refresh();
setFhirContext(FhirContext.forDstu2());
beans = myAppCtx.getBean("myResourceProvidersDstu2", List.class);
systemProviderDstu2 = myAppCtx.getBean("mySystemProviderDstu2", JpaSystemProviderDstu2.class);
plainProviders.add(myAppCtx.getBean("mySystemProviderDstu2", JpaSystemProviderDstu2.class));
systemDao = myAppCtx.getBean("mySystemDaoDstu2", IFhirSystemDao.class);
etagSupport = ETagSupportEnum.ENABLED;
JpaConformanceProviderDstu2 confProvider = new JpaConformanceProviderDstu2(this, systemDao, myAppCtx.getBean(DaoConfig.class));
@ -134,12 +134,13 @@ public class TestRestfulServer extends RestfulServer {
myAppCtx.refresh();
setFhirContext(FhirContext.forDstu3());
beans = myAppCtx.getBean("myResourceProvidersDstu3", List.class);
systemProviderDstu3 = myAppCtx.getBean("mySystemProviderDstu3", JpaSystemProviderDstu3.class);
plainProviders.add(myAppCtx.getBean("mySystemProviderDstu3", JpaSystemProviderDstu3.class));
systemDao = myAppCtx.getBean("mySystemDaoDstu3", IFhirSystemDao.class);
etagSupport = ETagSupportEnum.ENABLED;
JpaConformanceProviderDstu3 confProvider = new JpaConformanceProviderDstu3(this, systemDao, myAppCtx.getBean(DaoConfig.class));
confProvider.setImplementationDescription(implDesc);
setServerConformanceProvider(confProvider);
plainProviders.add(myAppCtx.getBean(TerminologyUploaderProviderDstu3.class));
break;
}
default:
@ -167,17 +168,7 @@ public class TestRestfulServer extends RestfulServer {
}
setResourceProviders(beans);
List<Object> provList = new ArrayList<Object>();
if (systemProviderDstu1 != null) {
provList.add(systemProviderDstu1);
}
if (systemProviderDstu2 != null) {
provList.add(systemProviderDstu2);
}
if (systemProviderDstu3 != null) {
provList.add(systemProviderDstu3);
}
setPlainProviders(provList);
setPlainProviders(plainProviders);
/*
* We want to format the response using nice HTML if it's a browser, since this

View File

@ -120,6 +120,29 @@
import more later.
</p>
<img src="./images/hacking_import_step2.png"/>
<subsection name="Troubleshooting">
<p>
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:
</p>
<ul>
<li>Delete the project from your Eclipse workspace</li>
<li>
On the local filesystem, delete the files <code>.project</code>
and <code>.classpath</code>, and the directory <code>.settings</code>
from each module you want to open.
</li>
<li>
Import each module again using the instructions above
</li>
</ul>
</subsection>
</section>
</body>