Search in sources :

Example 1 with DataSourceStreamCallback

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

the class DataSourceRestController method queryRQL.

@ApiOperation(value = "Query Data Sources", notes = "Use RQL formatted query", response = AbstractDataSourceModel.class, responseContainer = "List")
@RequestMapping(method = RequestMethod.GET, produces = { "application/json" })
public ResponseEntity<QueryDataPageStream<DataSourceVO<?>>> queryRQL(HttpServletRequest request) {
    RestProcessResult<QueryDataPageStream<DataSourceVO<?>>> result = new RestProcessResult<QueryDataPageStream<DataSourceVO<?>>>(HttpStatus.OK);
    User user = this.checkUser(request, result);
    if (result.isOk()) {
        try {
            ASTNode node = parseRQLtoAST(request.getQueryString());
            DataSourceStreamCallback callback = new DataSourceStreamCallback(this, user);
            return result.createResponseEntity(getPageStream(node, callback));
        } catch (InvalidRQLRestException e) {
            LOG.error(e.getMessage(), e);
            result.addRestMessage(getInternalServerErrorMessage(e.getMessage()));
            return result.createResponseEntity();
        }
    }
    return result.createResponseEntity();
}
Also used : DataSourceVO(com.serotonin.m2m2.vo.dataSource.DataSourceVO) 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) ASTNode(net.jazdw.rql.parser.ASTNode) DataSourceStreamCallback(com.serotonin.m2m2.web.mvc.rest.v1.model.dataSource.DataSourceStreamCallback) ApiOperation(com.wordnik.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

InvalidRQLRestException (com.infiniteautomation.mango.rest.v2.exception.InvalidRQLRestException)1 User (com.serotonin.m2m2.vo.User)1 DataSourceVO (com.serotonin.m2m2.vo.dataSource.DataSourceVO)1 RestProcessResult (com.serotonin.m2m2.web.mvc.rest.v1.message.RestProcessResult)1 QueryDataPageStream (com.serotonin.m2m2.web.mvc.rest.v1.model.QueryDataPageStream)1 DataSourceStreamCallback (com.serotonin.m2m2.web.mvc.rest.v1.model.dataSource.DataSourceStreamCallback)1 ApiOperation (com.wordnik.swagger.annotations.ApiOperation)1 ASTNode (net.jazdw.rql.parser.ASTNode)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1