use of com.infiniteautomation.mango.rest.latest.model.StreamedVORqlQueryWithTotal in project ma-modules-public by infiniteautomation.
the class PublishedPointsRestController method query.
@ApiOperation(value = "Query Published Points", notes = "RQL Formatted Query", responseContainer = "List")
@RequestMapping(method = RequestMethod.GET)
public StreamedArrayWithTotal query(HttpServletRequest request, @ApiParam(value = "User", required = true) @AuthenticationPrincipal PermissionHolder user, UriComponentsBuilder builder) {
ASTNode rql = RQLUtils.parseRQLtoAST(request.getQueryString());
permissionService.ensureAdminRole(user);
return new StreamedVORqlQueryWithTotal<>(service, rql, null, fieldMap, null, vo -> map.apply(vo, user));
}
use of com.infiniteautomation.mango.rest.latest.model.StreamedVORqlQueryWithTotal in project ma-modules-public by infiniteautomation.
the class DataPointTagsRestController method queryTagsForDataPointCSV.
@ApiOperation(value = "Query for data point tags using RQL", notes = "User must have read permission for the data points")
@RequestMapping(method = RequestMethod.GET, value = "/points", produces = MediaTypes.CSV_VALUE)
public StreamedArrayWithTotal queryTagsForDataPointCSV(HttpServletRequest request, @AuthenticationPrincipal PermissionHolder user) {
ASTNode rql = RQLUtils.parseRQLtoAST(request.getQueryString());
ConditionSortLimitWithTagKeys conditions = (ConditionSortLimitWithTagKeys) dataPointDao.rqlToCondition(rql, null, null, null);
return new StreamedVORqlQueryWithTotal<>(dataPointService, conditions, dataPoint -> {
Map<String, String> tags = dataPointTagsDao.getTagsForDataPointId(dataPoint.getId());
// we set the tags on the data point then retrieve them so that the device and name tags are removed
dataPoint.setTags(tags);
ActionAndTags individualRequest = new ActionAndTags();
individualRequest.setAction(BulkTagAction.MERGE);
individualRequest.setXid(dataPoint.getXid());
individualRequest.setTags(dataPoint.getTags());
return individualRequest;
});
}
use of com.infiniteautomation.mango.rest.latest.model.StreamedVORqlQueryWithTotal in project ma-modules-public by infiniteautomation.
the class DataPointTagsRestController method queryTagsForDataPoint.
@ApiOperation(value = "Query for data point tags using RQL", notes = "User must have read permission for the data points")
@RequestMapping(method = RequestMethod.GET, value = "/points")
public StreamedArrayWithTotal queryTagsForDataPoint(HttpServletRequest request, @AuthenticationPrincipal PermissionHolder user) {
ASTNode rql = RQLUtils.parseRQLtoAST(request.getQueryString());
ConditionSortLimitWithTagKeys conditions = (ConditionSortLimitWithTagKeys) dataPointDao.rqlToCondition(rql, null, null, null);
return new StreamedVORqlQueryWithTotal<>(dataPointService, conditions, dataPoint -> {
Map<String, String> tags = dataPointTagsDao.getTagsForDataPointId(dataPoint.getId());
// we set the tags on the data point then retrieve them so that the device and name tags are removed
dataPoint.setTags(tags);
TagIndividualRequest individualRequest = new TagIndividualRequest();
individualRequest.setAction(BulkTagAction.MERGE);
individualRequest.setXid(dataPoint.getXid());
individualRequest.setBody(dataPoint.getTags());
return individualRequest;
});
}
use of com.infiniteautomation.mango.rest.latest.model.StreamedVORqlQueryWithTotal 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);
}
}
Aggregations