Search in sources :

Example 6 with Field

use of org.hisp.dhis.gist.GistQuery.Field in project dhis2-core by dhis2.

the class GistPlanner method withInnerAsSeparateFields.

/**
 * Transforms {@code field[a,b]} syntax to {@code field.a,field.b}
 */
private List<Field> withInnerAsSeparateFields(List<Field> fields) {
    List<Field> expanded = new ArrayList<>();
    for (Field f : fields) {
        String path = f.getPropertyPath();
        if (path.indexOf('[') >= 0) {
            String outerPath = path.substring(0, path.indexOf('['));
            String innerList = path.substring(path.indexOf('[') + 1, path.lastIndexOf(']'));
            for (String innerFieldName : innerList.split(",")) {
                Field child = Field.parse(innerFieldName);
                expanded.add(child.withPropertyPath(outerPath + "." + child.getPropertyPath()).withAlias((f.getAlias().isEmpty() ? outerPath : f.getAlias()) + "." + child.getName()));
            }
        } else {
            expanded.add(f);
        }
    }
    return expanded;
}
Also used : GistLogic.isPersistentCollectionField(org.hisp.dhis.gist.GistLogic.isPersistentCollectionField) Field(org.hisp.dhis.gist.GistQuery.Field) GistLogic.isPersistentReferenceField(org.hisp.dhis.gist.GistLogic.isPersistentReferenceField) GistLogic.isIncludedField(org.hisp.dhis.gist.GistLogic.isIncludedField) ArrayList(java.util.ArrayList)

Aggregations

Field (org.hisp.dhis.gist.GistQuery.Field)6 ArrayList (java.util.ArrayList)5 GistLogic.isPersistentCollectionField (org.hisp.dhis.gist.GistLogic.isPersistentCollectionField)5 GistLogic.isPersistentReferenceField (org.hisp.dhis.gist.GistLogic.isPersistentReferenceField)5 GistLogic.isIncludedField (org.hisp.dhis.gist.GistLogic.isIncludedField)4 Property (org.hisp.dhis.schema.Property)4 IdentifiableObject (org.hisp.dhis.common.IdentifiableObject)3 Filter (org.hisp.dhis.gist.GistQuery.Filter)3 Arrays.stream (java.util.Arrays.stream)2 List (java.util.List)2 Set (java.util.Set)2 Collectors.toList (java.util.stream.Collectors.toList)2 AllArgsConstructor (lombok.AllArgsConstructor)2 Slf4j (lombok.extern.slf4j.Slf4j)2 GistLogic.isCollectionSizeFilter (org.hisp.dhis.gist.GistLogic.isCollectionSizeFilter)2 GistLogic.isNonNestedPath (org.hisp.dhis.gist.GistLogic.isNonNestedPath)2 GistLogic.parentPath (org.hisp.dhis.gist.GistLogic.parentPath)2 GistLogic.pathOnSameParent (org.hisp.dhis.gist.GistLogic.pathOnSameParent)2 Comparison (org.hisp.dhis.gist.GistQuery.Comparison)2 RelativePropertyContext (org.hisp.dhis.schema.RelativePropertyContext)2