Search in sources :

Example 1 with EventHandlerStreamCallback

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

the class EventHandlerRestController method queryRQL.

@ApiOperation(value = "Query Event Handlers", notes = "Use RQL formatted query", response = AbstractEventHandlerModel.class, responseContainer = "List")
@RequestMapping(method = RequestMethod.GET, produces = { "application/json" })
public ResponseEntity<QueryDataPageStream<AbstractEventHandlerVO<?>>> queryRQL(HttpServletRequest request) {
    RestProcessResult<QueryDataPageStream<AbstractEventHandlerVO<?>>> result = new RestProcessResult<QueryDataPageStream<AbstractEventHandlerVO<?>>>(HttpStatus.OK);
    User user = this.checkUser(request, result);
    if (result.isOk()) {
        try {
            ASTNode node = parseRQLtoAST(request.getQueryString());
            EventHandlerStreamCallback callback = new EventHandlerStreamCallback(this, user);
            FilteredPageQueryStream<AbstractEventHandlerVO<?>, AbstractEventHandlerModel<?>, EventHandlerDao> stream = new FilteredPageQueryStream<AbstractEventHandlerVO<?>, AbstractEventHandlerModel<?>, EventHandlerDao>(EventHandlerDao.instance, this, node, callback);
            stream.setupQuery();
            return result.createResponseEntity(stream);
        } catch (InvalidRQLRestException e) {
            LOG.error(e.getMessage(), e);
            result.addRestMessage(getInternalServerErrorMessage(e.getMessage()));
            return result.createResponseEntity();
        }
    }
    return result.createResponseEntity();
}
Also used : RestProcessResult(com.serotonin.m2m2.web.mvc.rest.v1.message.RestProcessResult) QueryDataPageStream(com.serotonin.m2m2.web.mvc.rest.v1.model.QueryDataPageStream) User(com.serotonin.m2m2.vo.User) InvalidRQLRestException(com.infiniteautomation.mango.rest.v2.exception.InvalidRQLRestException) AbstractEventHandlerModel(com.serotonin.m2m2.web.mvc.rest.v1.model.events.handlers.AbstractEventHandlerModel) ASTNode(net.jazdw.rql.parser.ASTNode) EventHandlerStreamCallback(com.serotonin.m2m2.web.mvc.rest.v1.model.eventHandler.EventHandlerStreamCallback) AbstractEventHandlerVO(com.serotonin.m2m2.vo.event.AbstractEventHandlerVO) EventHandlerDao(com.serotonin.m2m2.db.dao.EventHandlerDao) FilteredPageQueryStream(com.serotonin.m2m2.web.mvc.rest.v1.model.FilteredPageQueryStream) ApiOperation(com.wordnik.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

InvalidRQLRestException (com.infiniteautomation.mango.rest.v2.exception.InvalidRQLRestException)1 EventHandlerDao (com.serotonin.m2m2.db.dao.EventHandlerDao)1 User (com.serotonin.m2m2.vo.User)1 AbstractEventHandlerVO (com.serotonin.m2m2.vo.event.AbstractEventHandlerVO)1 RestProcessResult (com.serotonin.m2m2.web.mvc.rest.v1.message.RestProcessResult)1 FilteredPageQueryStream (com.serotonin.m2m2.web.mvc.rest.v1.model.FilteredPageQueryStream)1 QueryDataPageStream (com.serotonin.m2m2.web.mvc.rest.v1.model.QueryDataPageStream)1 EventHandlerStreamCallback (com.serotonin.m2m2.web.mvc.rest.v1.model.eventHandler.EventHandlerStreamCallback)1 AbstractEventHandlerModel (com.serotonin.m2m2.web.mvc.rest.v1.model.events.handlers.AbstractEventHandlerModel)1 ApiOperation (com.wordnik.swagger.annotations.ApiOperation)1 ASTNode (net.jazdw.rql.parser.ASTNode)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1