Search in sources :

Example 11 with InvalidRQLRestException

use of com.infiniteautomation.mango.rest.v2.exception.InvalidRQLRestException 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)

Example 12 with InvalidRQLRestException

use of com.infiniteautomation.mango.rest.v2.exception.InvalidRQLRestException 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)

Example 13 with InvalidRQLRestException

use of com.infiniteautomation.mango.rest.v2.exception.InvalidRQLRestException in project ma-modules-public by infiniteautomation.

the class UserCommentRestController method queryRQL.

@ApiOperation(value = "Query User Comments", notes = "", response = UserCommentModel.class, responseContainer = "Array")
@RequestMapping(method = RequestMethod.GET, produces = { "application/json" })
public ResponseEntity<QueryDataPageStream<UserCommentVO>> queryRQL(HttpServletRequest request) {
    RestProcessResult<QueryDataPageStream<UserCommentVO>> result = new RestProcessResult<QueryDataPageStream<UserCommentVO>>(HttpStatus.OK);
    this.checkUser(request, result);
    if (result.isOk()) {
        try {
            ASTNode query = parseRQLtoAST(request.getQueryString());
            return result.createResponseEntity(getPageStream(query));
        } 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) InvalidRQLRestException(com.infiniteautomation.mango.rest.v2.exception.InvalidRQLRestException) ASTNode(net.jazdw.rql.parser.ASTNode) UserCommentVO(com.serotonin.m2m2.vo.comment.UserCommentVO) ApiOperation(com.wordnik.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 14 with InvalidRQLRestException

use of com.infiniteautomation.mango.rest.v2.exception.InvalidRQLRestException in project ma-modules-public by infiniteautomation.

the class DataPointSummaryRestController method queryRQL.

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

Example 15 with InvalidRQLRestException

use of com.infiniteautomation.mango.rest.v2.exception.InvalidRQLRestException in project ma-modules-public by infiniteautomation.

the class EventsRestController method queryRQL.

@ApiOperation(value = "Query Events", notes = "Query via rql in url", response = EventInstanceModel.class, responseContainer = "Array")
@RequestMapping(method = RequestMethod.GET, produces = { "application/json" })
public ResponseEntity<QueryDataPageStream<EventInstanceVO>> queryRQL(HttpServletRequest request) {
    RestProcessResult<QueryDataPageStream<EventInstanceVO>> result = new RestProcessResult<QueryDataPageStream<EventInstanceVO>>(HttpStatus.OK);
    User user = this.checkUser(request, result);
    if (result.isOk()) {
        try {
            // Parse the RQL Query
            ASTNode query = parseRQLtoAST(request.getQueryString());
            query = addAndRestriction(query, new ASTNode("eq", "userId", user.getId()));
            return result.createResponseEntity(getPageStream(query));
        } 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) EventInstanceVO(com.serotonin.m2m2.vo.event.EventInstanceVO) User(com.serotonin.m2m2.vo.User) InvalidRQLRestException(com.infiniteautomation.mango.rest.v2.exception.InvalidRQLRestException) ASTNode(net.jazdw.rql.parser.ASTNode) ApiOperation(com.wordnik.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

InvalidRQLRestException (com.infiniteautomation.mango.rest.v2.exception.InvalidRQLRestException)16 RestProcessResult (com.serotonin.m2m2.web.mvc.rest.v1.message.RestProcessResult)16 ApiOperation (com.wordnik.swagger.annotations.ApiOperation)16 ASTNode (net.jazdw.rql.parser.ASTNode)16 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)16 User (com.serotonin.m2m2.vo.User)13 QueryDataPageStream (com.serotonin.m2m2.web.mvc.rest.v1.model.QueryDataPageStream)8 FilteredPageQueryStream (com.serotonin.m2m2.web.mvc.rest.v1.model.FilteredPageQueryStream)3 DataPointVO (com.serotonin.m2m2.vo.DataPointVO)2 ApiResponses (com.wordnik.swagger.annotations.ApiResponses)2 AuditEventDao (com.serotonin.m2m2.db.dao.AuditEventDao)1 DataPointDao (com.serotonin.m2m2.db.dao.DataPointDao)1 EventHandlerDao (com.serotonin.m2m2.db.dao.EventHandlerDao)1 TranslatableMessage (com.serotonin.m2m2.i18n.TranslatableMessage)1 UserCommentVO (com.serotonin.m2m2.vo.comment.UserCommentVO)1 DataSourceVO (com.serotonin.m2m2.vo.dataSource.DataSourceVO)1 AbstractEventHandlerVO (com.serotonin.m2m2.vo.event.AbstractEventHandlerVO)1 EventInstanceVO (com.serotonin.m2m2.vo.event.EventInstanceVO)1 AuditEventInstanceVO (com.serotonin.m2m2.vo.event.audit.AuditEventInstanceVO)1 WatchListDao (com.serotonin.m2m2.watchlist.WatchListDao)1