use of org.hisp.dhis.common.QueryFilter in project dhis2-core by dhis2.
the class TrackedEntityCriteriaMapper method getQueryItem.
/**
* Creates a QueryItem from the given item string. Item is on format
* {attribute-id}:{operator}:{filter-value}[:{operator}:{filter-value}].
* Only the attribute-id is mandatory.
*/
private QueryItem getQueryItem(String item, Map<String, TrackedEntityAttribute> attributes) {
String[] split = item.split(DimensionalObject.DIMENSION_NAME_SEP);
if (split.length % 2 != 1) {
throw new IllegalQueryException("Query item or filter is invalid: " + item);
}
QueryItem queryItem = getItem(split[0], attributes);
if (// Filters specified
split.length > 1) {
for (int i = 1; i < split.length; i += 2) {
QueryOperator operator = QueryOperator.fromString(split[i]);
queryItem.getFilters().add(new QueryFilter(operator, split[i + 1]));
}
}
return queryItem;
}
use of org.hisp.dhis.common.QueryFilter in project dhis2-core by dhis2.
the class TrackedEntityCriteriaMapper method getQueryFilter.
/**
* Creates a QueryFilter from the given query string. Query is on format
* {operator}:{filter-value}. Only the filter-value is mandatory. The EQ
* QueryOperator is used as operator if not specified.
*/
private QueryFilter getQueryFilter(String query) {
if (query == null || query.isEmpty()) {
return null;
}
if (!query.contains(DimensionalObject.DIMENSION_NAME_SEP)) {
return new QueryFilter(QueryOperator.EQ, query);
} else {
String[] split = query.split(DimensionalObject.DIMENSION_NAME_SEP);
if (split.length != 2) {
throw new IllegalQueryException("Query has invalid format: " + query);
}
QueryOperator op = QueryOperator.fromString(split[0]);
return new QueryFilter(op, split[1]);
}
}
Aggregations