use of com.infiniteautomation.mango.rest.v2.model.StreamedArrayWithTotal in project ma-modules-public by infiniteautomation.
the class DataPointRestController method doQuery.
private static StreamedArrayWithTotal doQuery(ASTNode rql, User user) {
if (user.isAdmin()) {
return new StreamedVOQueryWithTotal<>(DataPointDao.instance, rql, item -> {
DataPointDao.instance.loadPartialRelationalData(item);
return new DataPointModel(item);
});
} else {
// Add some conditions to restrict based on user permissions
ConditionSortLimitWithTagKeys conditions = DataPointDao.instance.rqlToCondition(rql);
conditions.addCondition(DataPointDao.instance.userHasPermission(user));
DataPointFilter dataPointFilter = new DataPointFilter(user);
return new StreamedVOQueryWithTotal<>(DataPointDao.instance, conditions, item -> {
boolean oldFilterMatches = dataPointFilter.hasDataPointReadPermission(item);
// this is just a double check, permissions should be accounted for via SQL restrictions added by DataPointDao.userHasPermission()
if (!oldFilterMatches) {
throw new RuntimeException("Data point does not match old permission filter");
}
return true;
}, item -> {
DataPointDao.instance.loadPartialRelationalData(item);
return new DataPointModel(item);
});
}
}
Aggregations