Search in sources :

Example 1 with EventDetectors

use of com.infiniteautomation.mango.db.tables.EventDetectors in project ma-modules-public by infiniteautomation.

the class EventDetectorsRestController method exportQuery.

@ApiOperation(value = "Export formatted for Configuration Import by supplying an RQL query", notes = "User must have read permission")
@RequestMapping(method = RequestMethod.GET, value = "/export", produces = MediaTypes.SEROTONIN_JSON_VALUE)
public Map<String, JsonStreamedArray> exportQuery(HttpServletRequest request, @AuthenticationPrincipal PermissionHolder user) {
    ASTNode rql = RQLUtils.parseRQLtoAST(request.getQueryString());
    Map<String, JsonStreamedArray> export = new HashMap<>();
    if (permissionService.hasAdminRole(user)) {
        export.put("eventDetectors", new StreamedSeroJsonVORqlQuery<>(service, rql, null, fieldMap, null));
    } else {
        export.put("eventDetectors", new StreamedSeroJsonVORqlQuery<>(service, rql, null, fieldMap, null, vo -> service.hasReadPermission(user, vo)));
    }
    return export;
}
Also used : BadRequestException(com.infiniteautomation.mango.rest.latest.exception.BadRequestException) PathVariable(org.springframework.web.bind.annotation.PathVariable) UriComponentsBuilder(org.springframework.web.util.UriComponentsBuilder) RequestParam(org.springframework.web.bind.annotation.RequestParam) BiFunction(java.util.function.BiFunction) StreamedVORqlQueryWithTotal(com.infiniteautomation.mango.rest.latest.model.StreamedVORqlQueryWithTotal) Autowired(org.springframework.beans.factory.annotation.Autowired) ApiParam(io.swagger.annotations.ApiParam) Translations(com.serotonin.m2m2.i18n.Translations) PermissionHolder(com.serotonin.m2m2.vo.permission.PermissionHolder) RestModelMapper(com.infiniteautomation.mango.rest.latest.model.RestModelMapper) PatchVORequestBody(com.infiniteautomation.mango.rest.latest.patch.PatchVORequestBody) ActionAndModel(com.infiniteautomation.mango.rest.latest.model.ActionAndModel) ApiOperation(io.swagger.annotations.ApiOperation) TranslatableIllegalStateException(com.infiniteautomation.mango.util.exception.TranslatableIllegalStateException) Map(java.util.Map) URI(java.net.URI) PointEventDetectorRT(com.serotonin.m2m2.rt.event.detectors.PointEventDetectorRT) TemporaryResourceStatusUpdate(com.infiniteautomation.mango.rest.latest.temporaryResource.TemporaryResourceStatusUpdate) HttpHeaders(org.springframework.http.HttpHeaders) RQLUtils(com.infiniteautomation.mango.util.RQLUtils) RequestMethod(org.springframework.web.bind.annotation.RequestMethod) TranslatableMessage(com.serotonin.m2m2.i18n.TranslatableMessage) Field(org.jooq.Field) Collectors(java.util.stream.Collectors) RestController(org.springframework.web.bind.annotation.RestController) JsonStreamedArray(com.serotonin.json.type.JsonStreamedArray) List(java.util.List) StreamedSeroJsonVORqlQuery(com.infiniteautomation.mango.rest.latest.model.StreamedSeroJsonVORqlQuery) ASTNode(net.jazdw.rql.parser.ASTNode) Environment(org.springframework.core.env.Environment) EventDetectors(com.infiniteautomation.mango.db.tables.EventDetectors) PermissionService(com.infiniteautomation.mango.spring.service.PermissionService) AbstractEventDetectorRTModel(com.infiniteautomation.mango.rest.latest.model.event.detectors.rt.AbstractEventDetectorRTModel) FilteredStreamWithTotal(com.infiniteautomation.mango.rest.latest.model.FilteredStreamWithTotal) VoAction(com.infiniteautomation.mango.rest.latest.bulk.VoAction) NotFoundRestException(com.infiniteautomation.mango.rest.latest.exception.NotFoundRestException) EventHandlerService(com.infiniteautomation.mango.spring.service.EventHandlerService) TemporaryResourceStatus(com.infiniteautomation.mango.rest.latest.temporaryResource.TemporaryResource.TemporaryResourceStatus) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) HashMap(java.util.HashMap) DataPointRT(com.serotonin.m2m2.rt.dataImage.DataPointRT) Function(java.util.function.Function) RequestBody(org.springframework.web.bind.annotation.RequestBody) EventDetectorsService(com.infiniteautomation.mango.spring.service.EventDetectorsService) HttpServletRequest(javax.servlet.http.HttpServletRequest) MappingJacksonValue(org.springframework.http.converter.json.MappingJacksonValue) StreamedArrayWithTotal(com.infiniteautomation.mango.rest.latest.model.StreamedArrayWithTotal) AbstractEventDetectorModel(com.infiniteautomation.mango.rest.latest.model.event.detectors.AbstractEventDetectorModel) Api(io.swagger.annotations.Api) TemporaryResourceWebSocketHandler(com.infiniteautomation.mango.rest.latest.temporaryResource.TemporaryResourceWebSocketHandler) AbstractEventDetectorVO(com.serotonin.m2m2.vo.event.detector.AbstractEventDetectorVO) TemporaryResource(com.infiniteautomation.mango.rest.latest.temporaryResource.TemporaryResource) MangoTaskTemporaryResourceManager(com.infiniteautomation.mango.rest.latest.temporaryResource.MangoTaskTemporaryResourceManager) Common(com.serotonin.m2m2.Common) BulkResponse(com.infiniteautomation.mango.rest.latest.bulk.BulkResponse) BulkRequest(com.infiniteautomation.mango.rest.latest.bulk.BulkRequest) HttpStatus(org.springframework.http.HttpStatus) VoIndividualRequest(com.infiniteautomation.mango.rest.latest.bulk.VoIndividualRequest) AuthenticationPrincipal(org.springframework.security.core.annotation.AuthenticationPrincipal) MediaTypes(com.serotonin.m2m2.web.MediaTypes) ResponseEntity(org.springframework.http.ResponseEntity) AbstractRestException(com.infiniteautomation.mango.rest.latest.exception.AbstractRestException) TemporaryResourceManager(com.infiniteautomation.mango.rest.latest.temporaryResource.TemporaryResourceManager) VoIndividualResponse(com.infiniteautomation.mango.rest.latest.bulk.VoIndividualResponse) HashMap(java.util.HashMap) ASTNode(net.jazdw.rql.parser.ASTNode) JsonStreamedArray(com.serotonin.json.type.JsonStreamedArray) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

EventDetectors (com.infiniteautomation.mango.db.tables.EventDetectors)1 BulkRequest (com.infiniteautomation.mango.rest.latest.bulk.BulkRequest)1 BulkResponse (com.infiniteautomation.mango.rest.latest.bulk.BulkResponse)1 VoAction (com.infiniteautomation.mango.rest.latest.bulk.VoAction)1 VoIndividualRequest (com.infiniteautomation.mango.rest.latest.bulk.VoIndividualRequest)1 VoIndividualResponse (com.infiniteautomation.mango.rest.latest.bulk.VoIndividualResponse)1 AbstractRestException (com.infiniteautomation.mango.rest.latest.exception.AbstractRestException)1 BadRequestException (com.infiniteautomation.mango.rest.latest.exception.BadRequestException)1 NotFoundRestException (com.infiniteautomation.mango.rest.latest.exception.NotFoundRestException)1 ActionAndModel (com.infiniteautomation.mango.rest.latest.model.ActionAndModel)1 FilteredStreamWithTotal (com.infiniteautomation.mango.rest.latest.model.FilteredStreamWithTotal)1 RestModelMapper (com.infiniteautomation.mango.rest.latest.model.RestModelMapper)1 StreamedArrayWithTotal (com.infiniteautomation.mango.rest.latest.model.StreamedArrayWithTotal)1 StreamedSeroJsonVORqlQuery (com.infiniteautomation.mango.rest.latest.model.StreamedSeroJsonVORqlQuery)1 StreamedVORqlQueryWithTotal (com.infiniteautomation.mango.rest.latest.model.StreamedVORqlQueryWithTotal)1 AbstractEventDetectorModel (com.infiniteautomation.mango.rest.latest.model.event.detectors.AbstractEventDetectorModel)1 AbstractEventDetectorRTModel (com.infiniteautomation.mango.rest.latest.model.event.detectors.rt.AbstractEventDetectorRTModel)1 PatchVORequestBody (com.infiniteautomation.mango.rest.latest.patch.PatchVORequestBody)1 MangoTaskTemporaryResourceManager (com.infiniteautomation.mango.rest.latest.temporaryResource.MangoTaskTemporaryResourceManager)1 TemporaryResource (com.infiniteautomation.mango.rest.latest.temporaryResource.TemporaryResource)1