Search in sources :

Example 6 with RelativePropertyContext

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);
}
Also used : RelativePropertyContext(org.hisp.dhis.schema.RelativePropertyContext)

Aggregations

RelativePropertyContext (org.hisp.dhis.schema.RelativePropertyContext)6 Schema (org.hisp.dhis.schema.Schema)2 JsonProperty (com.fasterxml.jackson.annotation.JsonProperty)1 URI (java.net.URI)1 LinkedHashMap (java.util.LinkedHashMap)1 IdentifiableObject (org.hisp.dhis.common.IdentifiableObject)1 GistLogic.isAccessProperty (org.hisp.dhis.gist.GistLogic.isAccessProperty)1 GistLogic.isHrefProperty (org.hisp.dhis.gist.GistLogic.isHrefProperty)1 Period (org.hisp.dhis.period.Period)1 Property (org.hisp.dhis.schema.Property)1