Search in sources :

Example 1 with TimezoneModel

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

the class ServerRestController method queryTimezone.

@ApiOperation(value = "Query Timezones", notes = "", response = TimezoneModel.class, responseContainer = "Array")
@RequestMapping(method = RequestMethod.GET, produces = { "application/json" }, value = "/timezones")
public ResponseEntity<PageQueryResultModel<TimezoneModel>> queryTimezone(HttpServletRequest request) {
    RestProcessResult<PageQueryResultModel<TimezoneModel>> result = new RestProcessResult<PageQueryResultModel<TimezoneModel>>(HttpStatus.OK);
    this.checkUser(request, result);
    if (result.isOk()) {
        try {
            // Parse the RQL Query
            ASTNode root = parseRQLtoAST(request.getQueryString());
            List<TimezoneModel> list = root.accept(new RQLToObjectListQuery<TimezoneModel>(), allTimezones);
            PageQueryResultModel<TimezoneModel> model = new PageQueryResultModel<TimezoneModel>(list, allTimezones.size() + 1);
            return result.createResponseEntity(model);
        } 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) InvalidRQLRestException(com.infiniteautomation.mango.rest.v2.exception.InvalidRQLRestException) ASTNode(net.jazdw.rql.parser.ASTNode) TimezoneModel(com.serotonin.m2m2.web.mvc.rest.v1.model.system.TimezoneModel) PageQueryResultModel(com.serotonin.m2m2.web.mvc.rest.v1.model.PageQueryResultModel) ApiOperation(com.wordnik.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with TimezoneModel

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

the class ServerRestV2Controller method queryTimezone.

@ApiOperation(value = "Query Timezones", notes = "", response = TimezoneModel.class, responseContainer = "Array")
@RequestMapping(method = RequestMethod.GET, value = "/timezones")
public ResponseEntity<PageQueryResultModel<TimezoneModel>> queryTimezone(HttpServletRequest request) {
    ASTNode root = parseRQLtoAST(request.getQueryString());
    List<TimezoneModel> list = root.accept(new RQLToObjectListQuery<TimezoneModel>(), allTimezones);
    PageQueryResultModel<TimezoneModel> model = new PageQueryResultModel<TimezoneModel>(list, allTimezones.size() + 1);
    return new ResponseEntity<PageQueryResultModel<TimezoneModel>>(model, HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) ASTNode(net.jazdw.rql.parser.ASTNode) TimezoneModel(com.serotonin.m2m2.web.mvc.rest.v1.model.system.TimezoneModel) PageQueryResultModel(com.serotonin.m2m2.web.mvc.rest.v1.model.PageQueryResultModel) ApiOperation(com.wordnik.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

PageQueryResultModel (com.serotonin.m2m2.web.mvc.rest.v1.model.PageQueryResultModel)2 TimezoneModel (com.serotonin.m2m2.web.mvc.rest.v1.model.system.TimezoneModel)2 ApiOperation (com.wordnik.swagger.annotations.ApiOperation)2 ASTNode (net.jazdw.rql.parser.ASTNode)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 InvalidRQLRestException (com.infiniteautomation.mango.rest.v2.exception.InvalidRQLRestException)1 RestProcessResult (com.serotonin.m2m2.web.mvc.rest.v1.message.RestProcessResult)1 ResponseEntity (org.springframework.http.ResponseEntity)1