use of com.infiniteautomation.mango.spring.service.maintenanceEvents.MaintenanceEventsService.DataSourcePermissionsCheckCallback in project ma-modules-public by infiniteautomation.
the class MaintenanceEventsRestController method doQuery.
public StreamedArrayWithTotal doQuery(ASTNode rql, PermissionHolder user, Function<MaintenanceEventVO, Object> transformVO) {
// If we are admin or have overall data source permission we can view all
if (permissionService.hasPermission(user, dataSourcePermissionDefinition.getPermission())) {
return new StreamedVORqlQueryWithTotal<>(service, rql, null, null, null, transformVO);
} else {
return new StreamedVORqlQueryWithTotal<>(service, rql, null, null, null, item -> {
if (item.getDataPoints().size() > 0) {
DataPointPermissionsCheckCallback callback = new DataPointPermissionsCheckCallback(user, true, permissionService, dataPointService);
dao.getPoints(item.getId(), callback);
if (!callback.hasPermission())
return false;
}
if (item.getDataSources().size() > 0) {
DataSourcePermissionsCheckCallback callback = new DataSourcePermissionsCheckCallback(user, true, permissionService);
dao.getDataSources(item.getId(), callback);
if (!callback.hasPermission())
return false;
}
return true;
}, transformVO);
}
}
use of com.infiniteautomation.mango.spring.service.maintenanceEvents.MaintenanceEventsService.DataSourcePermissionsCheckCallback in project ma-modules-public by infiniteautomation.
the class MaintenanceEventsRestController method exportQuery.
@ApiOperation(value = "Export formatted for Configuration Import by supplying an RQL query", notes = "User must have read permission")
@RequestMapping(method = RequestMethod.GET, value = "/export", produces = MediaTypes.SEROTONIN_JSON_VALUE)
public Map<String, JsonStreamedArray> exportQuery(HttpServletRequest request, @AuthenticationPrincipal PermissionHolder user) {
ASTNode rql = RQLUtils.parseRQLtoAST(request.getQueryString());
Map<String, JsonStreamedArray> export = new HashMap<>();
if (permissionService.hasPermission(user, dataSourcePermissionDefinition.getPermission())) {
export.put("maintenanceEvents", new StreamedSeroJsonVORqlQuery<>(service, rql, null, null, null));
} else {
export.put("maintenanceEvents", new StreamedSeroJsonVORqlQuery<>(service, rql, null, null, null, item -> {
if (item.getDataPoints().size() > 0) {
DataPointPermissionsCheckCallback callback = new DataPointPermissionsCheckCallback(user, true, permissionService, dataPointService);
dao.getPoints(item.getId(), callback);
if (!callback.hasPermission())
return false;
}
if (item.getDataSources().size() > 0) {
DataSourcePermissionsCheckCallback callback = new DataSourcePermissionsCheckCallback(user, true, permissionService);
dao.getDataSources(item.getId(), callback);
if (!callback.hasPermission())
return false;
}
return true;
}));
}
return export;
}
Aggregations