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;
}
Aggregations