use of com.serotonin.m2m2.rt.event.detectors.PointEventDetectorRT in project ma-modules-public by infiniteautomation.
the class EventDetectorsRestController method getState.
@ApiOperation(value = "Get Event Detector's internal state", notes = "User must have read permission for the data point", response = AbstractEventDetectorRTModel.class)
@RequestMapping(method = RequestMethod.GET, value = "/runtime/{xid}")
public AbstractEventDetectorRTModel<?> getState(@ApiParam(value = "ID of Event detector", required = true, allowMultiple = false) @PathVariable String xid, @AuthenticationPrincipal PermissionHolder user, UriComponentsBuilder builder) {
AbstractEventDetectorVO vo = service.get(xid);
// For now all detectors are data point type
DataPointRT rt = Common.runtimeManager.getDataPoint(vo.getSourceId());
if (rt == null) {
throw new TranslatableIllegalStateException(new TranslatableMessage("rest.error.pointNotEnabled", xid));
}
for (PointEventDetectorRT<?> edrt : rt.getEventDetectors()) {
if (edrt.getVO().getId() == vo.getId()) {
return modelMapper.map(edrt, AbstractEventDetectorRTModel.class, user);
}
}
throw new NotFoundRestException();
}
use of com.serotonin.m2m2.rt.event.detectors.PointEventDetectorRT in project ma-core-public by infiniteautomation.
the class DataPointChangeDefinitionTest method addDetectorsOnInsert.
@Test
public void addDetectorsOnInsert() {
MockDataSourceVO ds = createMockDataSource(true);
DataPointVO point = createMockDataPoint(ds, dp -> dp.setEnabled(true));
DataPointRT rt = Common.runtimeManager.getDataPoint(point.getId());
Assert.assertNotNull(rt);
List<PointEventDetectorRT<?>> runningDetectors = rt.getEventDetectors();
Assert.assertEquals(1, runningDetectors.size());
}
Aggregations