use of org.hisp.dhis.schema.RelativePropertyContext in project dhis2-core by dhis2.
the class GistBuilder method createSizeTransformerHQL.
private String createSizeTransformerHQL(int index, Field field, Property property, String compare) {
String tableName = "t_" + index;
RelativePropertyContext fieldContext = context.switchedTo(property.getItemKlass());
String memberPath = getMemberPath(field.getPropertyPath());
if (!isFilterBySharing(fieldContext)) {
// generates better SQL in case no access control is needed
return String.format("size(e.%s) %s", memberPath, compare);
}
String accessFilter = createAccessFilterHQL(fieldContext, tableName);
return String.format("(select count(*) %5$s from %2$s %1$s where %1$s in elements(e.%3$s) and %4$s)", tableName, property.getItemKlass().getSimpleName(), memberPath, accessFilter, compare);
}
Aggregations