Search in sources :

Example 1 with EventDetectorStreamCallback

use of com.serotonin.m2m2.web.mvc.rest.v1.model.eventDetector.EventDetectorStreamCallback in project ma-modules-public by infiniteautomation.

the class EventDetectorRestV2Controller method queryRQL.

@ApiOperation(value = "Query Event Detectors", notes = "Use RQL formatted query, filtered by data point permissions", response = AbstractEventDetectorModel.class, responseContainer = "List")
@RequestMapping(method = RequestMethod.GET)
public ResponseEntity<QueryDataPageStream<AbstractEventDetectorVO<?>>> queryRQL(@AuthenticationPrincipal User user, HttpServletRequest request) {
    ASTNode node = parseRQLtoAST(request.getQueryString());
    if (user.isAdmin()) {
        // admin users don't need to filter the results
        return new ResponseEntity<>(getPageStream(node), HttpStatus.OK);
    } else {
        EventDetectorStreamCallback callback = new EventDetectorStreamCallback(this, user);
        FilteredPageQueryStream<AbstractEventDetectorVO<?>, AbstractEventDetectorModel<?>, EventDetectorDao> stream = new FilteredPageQueryStream<AbstractEventDetectorVO<?>, AbstractEventDetectorModel<?>, EventDetectorDao>(EventDetectorDao.instance, this, node, callback);
        stream.setupQuery();
        return new ResponseEntity<>(stream, HttpStatus.OK);
    }
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) EventDetectorStreamCallback(com.serotonin.m2m2.web.mvc.rest.v1.model.eventDetector.EventDetectorStreamCallback) AbstractEventDetectorVO(com.serotonin.m2m2.vo.event.detector.AbstractEventDetectorVO) ASTNode(net.jazdw.rql.parser.ASTNode) AbstractEventDetectorModel(com.serotonin.m2m2.web.mvc.rest.v1.model.events.detectors.AbstractEventDetectorModel) EventDetectorDao(com.serotonin.m2m2.db.dao.EventDetectorDao) FilteredPageQueryStream(com.serotonin.m2m2.web.mvc.rest.v1.model.FilteredPageQueryStream) ApiOperation(com.wordnik.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

EventDetectorDao (com.serotonin.m2m2.db.dao.EventDetectorDao)1 AbstractEventDetectorVO (com.serotonin.m2m2.vo.event.detector.AbstractEventDetectorVO)1 FilteredPageQueryStream (com.serotonin.m2m2.web.mvc.rest.v1.model.FilteredPageQueryStream)1 EventDetectorStreamCallback (com.serotonin.m2m2.web.mvc.rest.v1.model.eventDetector.EventDetectorStreamCallback)1 AbstractEventDetectorModel (com.serotonin.m2m2.web.mvc.rest.v1.model.events.detectors.AbstractEventDetectorModel)1 ApiOperation (com.wordnik.swagger.annotations.ApiOperation)1 ASTNode (net.jazdw.rql.parser.ASTNode)1 ResponseEntity (org.springframework.http.ResponseEntity)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1