From 5a0bce915584881d0075cc3a71acf1549995e1b2 Mon Sep 17 00:00:00 2001 From: ianmarshall Date: Tue, 25 Aug 2020 12:45:53 -0400 Subject: [PATCH] Changes to enable request delete of specific Code System version. --- .../HapiFhirResourceDaoCodeSystemUtil.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/HapiFhirResourceDaoCodeSystemUtil.java diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/HapiFhirResourceDaoCodeSystemUtil.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/HapiFhirResourceDaoCodeSystemUtil.java new file mode 100644 index 00000000000..72cf8ac39ab --- /dev/null +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/HapiFhirResourceDaoCodeSystemUtil.java @@ -0,0 +1,28 @@ +package ca.uhn.fhir.jpa.dao; + +import ca.uhn.fhir.jpa.dao.data.ITermCodeSystemDao; +import ca.uhn.fhir.jpa.dao.data.ITermCodeSystemVersionDao; +import ca.uhn.fhir.jpa.entity.TermCodeSystem; +import ca.uhn.fhir.jpa.entity.TermCodeSystemVersion; +import ca.uhn.fhir.jpa.term.api.ITermDeferredStorageSvc; + +import static org.apache.commons.lang3.StringUtils.isNotBlank; + +public class HapiFhirResourceDaoCodeSystemUtil { + + static public void deleteCodeSystemEntities(ITermCodeSystemDao theCsDao, ITermCodeSystemVersionDao theCsvDao, + ITermDeferredStorageSvc theTermDeferredStorageSvc, String theCodeSystemUrl, + String theCodeSystemVersion) { + if (isNotBlank(theCodeSystemUrl)) { + TermCodeSystem persCs = theCsDao.findByCodeSystemUri(theCodeSystemUrl); + if (persCs != null) { + if (theCodeSystemVersion != null) { + TermCodeSystemVersion persCsVersion = theCsvDao.findByCodeSystemPidAndVersion(persCs.getPid(), theCodeSystemVersion); + theTermDeferredStorageSvc.deleteCodeSystemVersion(persCsVersion); + } else { + theTermDeferredStorageSvc.deleteCodeSystem(persCs); + } + } + } + } +}