use of com.serotonin.m2m2.vo.publish.PublishedPointVO in project ma-modules-public by infiniteautomation.
the class PublishedPointsRestController method partialUpdate.
@ApiOperation(value = "Partially update a published point", notes = "Requires edit permission")
@RequestMapping(method = RequestMethod.PATCH, value = "/{xid}")
public ResponseEntity<AbstractPublishedPointModel<?>> partialUpdate(@PathVariable String xid, @ApiParam(value = "Updated published point", required = true) @PatchVORequestBody(service = PublishedPointService.class, modelClass = AbstractPublishedPointModel.class) AbstractPublishedPointModel<?> model, @AuthenticationPrincipal PermissionHolder user, UriComponentsBuilder builder) {
PublishedPointVO vo = service.update(xid, unmap.apply(model, user));
URI location = builder.path("/published-points/{xid}").buildAndExpand(vo.getXid()).toUri();
HttpHeaders headers = new HttpHeaders();
headers.setLocation(location);
return new ResponseEntity<>(map.apply(vo, user), headers, HttpStatus.OK);
}
use of com.serotonin.m2m2.vo.publish.PublishedPointVO in project ma-core-public by infiniteautomation.
the class PublishedPointServiceTest method testNonAdminDelete.
@Test(expected = PermissionException.class)
public void testNonAdminDelete() {
PublishedPointVO vo = insertNewVO(readUser);
PublishedPointVO fromDb = service.get(vo.getId());
assertVoEqual(vo, fromDb);
runAs.runAs(readUser, () -> {
service.delete(vo);
});
}
use of com.serotonin.m2m2.vo.publish.PublishedPointVO in project ma-core-public by infiniteautomation.
the class PublishedPointService method delete.
@Override
protected PublishedPointVO delete(PublishedPointVO vo) throws PermissionException, NotFoundException {
PermissionHolder user = Common.getUser();
ensureDeletePermission(user, vo);
getRuntimeManager().stopPublishedPoint(vo.getId());
dao.delete(vo);
return vo;
}
use of com.serotonin.m2m2.vo.publish.PublishedPointVO in project ma-core-public by infiniteautomation.
the class PublishedPointService method update.
@Override
protected PublishedPointVO update(PublishedPointVO existing, PublishedPointVO vo) throws PermissionException, ValidationException {
PermissionHolder user = Common.getUser();
ensureEditPermission(user, existing);
vo.setId(existing.getId());
ensureValid(existing, vo);
getRuntimeManager().stopPublishedPoint(vo.getId());
dao.update(existing, vo);
if (vo.isEnabled()) {
getRuntimeManager().startPublishedPoint(vo);
}
return vo;
}
use of com.serotonin.m2m2.vo.publish.PublishedPointVO in project ma-core-public by infiniteautomation.
the class PublisherDefinition method createPublishedPointVO.
/**
* Create a new published point vo with all base field initialized
*/
@NonNull
public <T extends PublishedPointVO> T createPublishedPointVO(PUB publisher, IDataPoint dataPoint) {
T vo = newPublishedPointVO();
vo.setPublisherId(publisher.getId());
vo.setPublisherXid(publisher.getXid());
vo.setDataPointId(dataPoint.getId());
vo.setDataPointXid(dataPoint.getXid());
vo.setPublisherTypeName(getPublisherTypeName());
return vo;
}
Aggregations