From a56060a09695e149801ae4a71568ca1f0d2f2806 Mon Sep 17 00:00:00 2001 From: Tadgh Date: Wed, 24 Feb 2021 17:16:54 -0500 Subject: [PATCH] Tidy things from preliminary review --- .../uhn/fhir/jpa/bulk/job/BulkItemReader.java | 2 +- .../GroupBulkExportJobParametersBuilder.java | 2 +- .../jpa/bulk/job/ResourceToFileWriter.java | 3 --- .../jpa/bulk/job/ResourceTypePartitioner.java | 5 +--- .../uhn/fhir/jpa/term/TermLoaderSvcImpl.java | 2 +- .../java/ca/uhn/fhir/jpa/util/Counter.java | 2 +- ...rResourceDaoR4LegacySearchBuilderTest.java | 26 ------------------- .../jpa/dao/r4/SearchParameterMapTest.java | 10 ------- 8 files changed, 5 insertions(+), 47 deletions(-) diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/bulk/job/BulkItemReader.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/bulk/job/BulkItemReader.java index c6f2405f93b..c2e475edf1f 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/bulk/job/BulkItemReader.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/bulk/job/BulkItemReader.java @@ -93,7 +93,7 @@ public class BulkItemReader implements ItemReader> { ISearchBuilder sb = mySearchBuilderFactory.newSearchBuilder(dao, myResourceType, nextTypeClass); SearchParameterMap map = createSearchParameterMapFromTypeFilter(jobEntity, def); - + if (jobEntity.getSince() != null) { map.setLastUpdated(new DateRangeParam(jobEntity.getSince(), null)); } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/bulk/job/GroupBulkExportJobParametersBuilder.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/bulk/job/GroupBulkExportJobParametersBuilder.java index 47da5d2f119..9b6a3a90002 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/bulk/job/GroupBulkExportJobParametersBuilder.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/bulk/job/GroupBulkExportJobParametersBuilder.java @@ -2,7 +2,7 @@ package ca.uhn.fhir.jpa.bulk.job; public class GroupBulkExportJobParametersBuilder extends BulkExportJobParametersBuilder { public GroupBulkExportJobParametersBuilder setGroupId(String theGroupId) { - this.addString("groupId", theGroupId); + this.addString(BulkExportJobConfig.GROUP_ID_PARAMETER, theGroupId); return this; } } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/bulk/job/ResourceToFileWriter.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/bulk/job/ResourceToFileWriter.java index 066954f9133..82501c274c8 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/bulk/job/ResourceToFileWriter.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/bulk/job/ResourceToFileWriter.java @@ -100,7 +100,6 @@ public class ResourceToFileWriter implements ItemWriter> { IBaseBinary binary = BinaryUtil.newBinary(myFhirContext); binary.setContentType(Constants.CT_FHIR_NDJSON); binary.setContent(myOutputStream.toByteArray()); - DaoMethodOutcome outcome = myBinaryDao.create(binary); return outcome.getResource().getIdElement(); } @@ -116,8 +115,6 @@ public class ResourceToFileWriter implements ItemWriter> { int count = 0; for (List resourceList : theList) { for (IBaseResource nextFileResource : resourceList) { - System.out.println("ZOOP"); - System.out.println(myParser.setPrettyPrint(true).encodeResourceToString(nextFileResource)); myParser.encodeResourceToWriter(nextFileResource, myWriter); myWriter.append("\n"); count++; diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/bulk/job/ResourceTypePartitioner.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/bulk/job/ResourceTypePartitioner.java index bbfc590c919..4cde1ab954b 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/bulk/job/ResourceTypePartitioner.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/bulk/job/ResourceTypePartitioner.java @@ -39,9 +39,6 @@ public class ResourceTypePartitioner implements Partitioner { @Value("#{jobExecutionContext['jobUUID']}") private String myJobUUID; - @Value("#{jobExecutionContext['groupId']}") - private String myGroupId; - @Autowired private BulkExportDaoSvc myBulkExportDaoSvc; @@ -63,7 +60,7 @@ public class ResourceTypePartitioner implements Partitioner { // The worker step needs to know which parent job it is processing for, and which collection entity it will be // attaching its results to. - context.putString("jobUUID", myJobUUID); + context.putString(BulkExportJobConfig.JOB_UUID_PARAMETER, myJobUUID); context.putLong("bulkExportCollectionEntityId", collectionEntityId); // Name the partition based on the resource type diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TermLoaderSvcImpl.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TermLoaderSvcImpl.java index dbde4943c9e..788d1c10a87 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TermLoaderSvcImpl.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TermLoaderSvcImpl.java @@ -663,7 +663,7 @@ public class TermLoaderSvcImpl implements ITermLoaderSvc { Counter circularCounter = new Counter(); for (TermConcept next : rootConcepts.values()) { - long count = circularCounter.getnAdd(); + long count = circularCounter.getThenAdd(); float pct = ((float) count / rootConcepts.size()) * 100.0f; ourLog.info(" * Scanning for circular refs - have scanned {} / {} codes ({}%)", count, rootConcepts.size(), pct); dropCircularRefs(next, new ArrayList<>(), code2concept); diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/util/Counter.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/util/Counter.java index ca10f7ad5b6..f42188d840e 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/util/Counter.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/util/Counter.java @@ -24,7 +24,7 @@ public class Counter { private long myCount; - public long getnAdd() { + public long getThenAdd() { return myCount++; } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4LegacySearchBuilderTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4LegacySearchBuilderTest.java index 21d96542b35..ef7cbf272af 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4LegacySearchBuilderTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4LegacySearchBuilderTest.java @@ -270,32 +270,6 @@ public class FhirResourceDaoR4LegacySearchBuilderTest extends BaseJpaR4Test { assertThat(ids, hasItems(patientId)); } - @Test - public void testPatientHasGroupImmunization(){ - - Patient patient = new Patient(); - String patientId = myPatientDao.create(patient).getId().toUnqualifiedVersionless().getValue(); - - Group group = new Group(); - group.addMember().setEntity(new Reference(patientId)); - myGroupDao.create(group).getId().getIdPartAsLong(); - - Immunization immunization = new Immunization(); - immunization.setPatient(new Reference(patientId)); - String immunizationId = myImmunizationDao.create(immunization).getId().toUnqualifiedVersionless().getValue(); - -// String criteria = "?_has:Group:member:_id="+ daoMethodOutcome + "&_revinclude=Immunization:patient"; - String criteria = "?_revinclude=Immunization:patient"; - //TODO GGG the matchUrlService _doesnt translate rev includes! - SearchParameterMap searchParameterMap = myMatchUrlService.translateMatchUrl(criteria, myFhirCtx.getResourceDefinition(Patient.class)); - searchParameterMap.addRevInclude(new Include("Immunization:patient").toLocked()); - searchParameterMap.setLoadSynchronous(true); - IBundleProvider search = myPatientDao.search(searchParameterMap); - List strings = toUnqualifiedVersionlessIdValues(search); - assertThat(strings, hasItems(patientId, immunizationId)); - - } - @Test public void testHasConditionOr() { Patient patient = new Patient(); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/SearchParameterMapTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/SearchParameterMapTest.java index 2bdcc6f4a4d..af4c2e9bfd6 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/SearchParameterMapTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/SearchParameterMapTest.java @@ -21,14 +21,4 @@ public class SearchParameterMapTest extends BaseTest { String criteria = params.toNormalizedQueryString(myContext); assertEquals(criteria, "?_has:Observation:identifier:urn:system|FOO=urn%3Asystem%7CFOO"); } - - @Test - public void testGroupToImmunizationHas() { - SearchParameterMap params = new SearchParameterMap(); - params.add("_has", new HasParam("Group", "member", "_id", "1000")); - params.addRevInclude(new Include("Immunization:patient")); - String criteria = params.toNormalizedQueryString(myContext); - assertEquals("?_has:Group:member:_id=1000&_revinclude=Immunization:patient", criteria); - } - }