use of org.pmiops.workbench.cohortbuilder.querybuilder.QueryParameters in project workbench by all-of-us.
the class ParticipantCounter method buildQuery.
private StringJoiner buildQuery(List<SearchGroup> groups, String mainTable, Map<String, QueryParameterValue> params, Boolean excludeSQL) {
StringJoiner joiner = new StringJoiner("and ");
List<String> queryParts = new ArrayList<>();
for (SearchGroup includeGroup : groups) {
for (SearchGroupItem includeItem : includeGroup.getItems()) {
QueryJobConfiguration queryRequest = QueryBuilderFactory.getQueryBuilder(FactoryKey.getType(includeItem.getType())).buildQueryJobConfig(new QueryParameters().type(includeItem.getType()).parameters(includeItem.getSearchParameters()));
params.putAll(queryRequest.getNamedParameters());
queryParts.add(queryRequest.getQuery());
}
if (excludeSQL) {
joiner.add(EXCLUDE_SQL_TEMPLATE.replace("${mainTable}", mainTable).replace("${excludeSql}", String.join(UNION_TEMPLATE, queryParts)));
} else {
joiner.add(INCLUDE_SQL_TEMPLATE.replace("${mainTable}", mainTable).replace("${includeSql}", String.join(UNION_TEMPLATE, queryParts)));
}
queryParts = new ArrayList<>();
}
return joiner;
}
Aggregations