Skip to content

Commit

Permalink
issue #3232 - add resourceType IN where clause to whole-system search…
Browse files Browse the repository at this point in the history
… subquery

Signed-off-by: Lee Surprenant <[email protected]>
  • Loading branch information
lmsurpre committed Jan 21, 2022
1 parent e07b804 commit 44e5492
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2021
* (C) Copyright IBM Corp. 2021, 2022
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -71,13 +71,18 @@ public void add(SearchExtension ext) {
*/
public <T> T visit(SearchQueryVisitor<T> visitor) throws FHIRPersistenceException {
logger.entering(CLASSNAME, "visit");
T query = getRoot(visitor);

// Pre-process any extensions before we process the parameters
// Get the root query and process extensions for it
T query = getRoot(visitor);
visitExtensions(query, visitor);

// Add the parameters subquery and add the extensions there too
T parameterBase = visitor.getParameterBaseQuery(query);
for (SearchExtension ext: this.extensions) {
ext.visit(parameterBase, visitor);
}
visitSearchParams(parameterBase, visitor);

logger.exiting(CLASSNAME, "visit");
return query;
}
Expand Down Expand Up @@ -115,4 +120,4 @@ protected <T> void visitSearchParams(T query, SearchQueryVisitor<T> visitor) thr
sp.visit(query, visitor);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2016, 2021
* (C) Copyright IBM Corp. 2016, 2022
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -469,8 +469,14 @@ public void testSearchAllUsingTagNot_NoResults() throws Exception {
public void testSearchAllUsingType() throws Exception {
List<Resource> resources = runQueryTest(Resource.class, "_type", "Basic,EvidenceVariable,ServiceRequest");
assertNotNull(resources);
assertEquals(resources.size(), 1, "Number of resources returned");
assertTrue(isResourceInResponse(savedResource, resources), "Expected resource not found in the response");
assertTrue(resources.size() > 0, "At least one resource returned");
assertTrue(resources.size() == resources.stream().distinct().count(), "No repeats");
assertTrue(isResourceInResponse(savedResource, resources), "Expected resource is in the response");
for (Resource resource : resources) {
if (!(resource instanceof Basic) && !(resource instanceof Basic) && !(resource instanceof Basic)) {
fail("query retrieved unexpected resource of type " + resource.getClass());
}
}
}

@Test
Expand Down Expand Up @@ -573,4 +579,4 @@ public void testSearchAllUsingTypeNoResults() throws Exception {
assertEquals(resources.size(), 0, "Number of resources returned");
}

}
}

0 comments on commit 44e5492

Please sign in to comment.