use of com.serotonin.m2m2.vo.permission.PermissionHolder in project ma-modules-public by infiniteautomation.
the class WatchListModelMapping method unmap.
@Override
public WatchListVO unmap(Object from, PermissionHolder user, RestModelMapper mapper) throws ValidationException {
WatchListModel model = (WatchListModel) from;
WatchListVO vo = model.toVO();
vo.setReadPermission(model.getReadPermission() != null ? model.getReadPermission().getPermission() : new MangoPermission());
vo.setEditPermission(model.getEditPermission() != null ? model.getEditPermission().getPermission() : new MangoPermission());
if (vo.getType() == WatchListType.STATIC && model.getPoints() != null) {
vo.setPointList(model.getPoints().stream().map(m -> {
DataPointSummary summary = new DataPointSummary();
summary.setXid(m.getXid());
return summary;
}).collect(Collectors.toList()));
}
return vo;
}
use of com.serotonin.m2m2.vo.permission.PermissionHolder in project ma-modules-public by infiniteautomation.
the class WatchListSummaryModelMapping method map.
@Override
public WatchListSummaryModel map(Object from, PermissionHolder user, RestModelMapper mapper) {
WatchListVO vo = (WatchListVO) from;
WatchListSummaryModel model = new WatchListSummaryModel(vo);
model.setReadPermission(new MangoPermissionModel(vo.getReadPermission()));
model.setEditPermission(new MangoPermissionModel(vo.getEditPermission()));
return model;
}
use of com.serotonin.m2m2.vo.permission.PermissionHolder in project ma-modules-public by infiniteautomation.
the class WatchListRestController method create.
@ApiOperation(value = "Create New WatchList")
@ResponseStatus(HttpStatus.CREATED)
@RequestMapping(method = RequestMethod.POST)
public ResponseEntity<WatchListModel> create(@RequestBody WatchListModel model, @AuthenticationPrincipal PermissionHolder user, UriComponentsBuilder builder) {
WatchListVO vo = service.insert(mapping.unmap(model, user, mapper));
URI location = builder.path("/watch-lists/{xid}").buildAndExpand(vo.getXid()).toUri();
HttpHeaders headers = new HttpHeaders();
headers.setLocation(location);
return new ResponseEntity<>(mapping.map(vo, user, mapper), headers, HttpStatus.CREATED);
}
use of com.serotonin.m2m2.vo.permission.PermissionHolder in project ma-modules-public by infiniteautomation.
the class WatchListRestController method update.
@ApiOperation(value = "Update a WatchList", notes = "Requires edit permission")
@RequestMapping(method = RequestMethod.PUT, value = "/{xid}")
public ResponseEntity<WatchListModel> update(@ApiParam(value = "XID of WatchList to update", required = true, allowMultiple = false) @PathVariable String xid, @ApiParam(value = "WatchList of update", required = true, allowMultiple = false) @RequestBody WatchListModel model, @AuthenticationPrincipal PermissionHolder user, UriComponentsBuilder builder) {
WatchListVO vo = service.update(xid, mapping.unmap(model, user, mapper));
URI location = builder.path("/watch-lists/{xid}").buildAndExpand(vo.getXid()).toUri();
HttpHeaders headers = new HttpHeaders();
headers.setLocation(location);
return new ResponseEntity<>(mapping.map(vo, user, mapper), headers, HttpStatus.OK);
}
use of com.serotonin.m2m2.vo.permission.PermissionHolder in project ma-modules-public by infiniteautomation.
the class WatchListRestController method partialUpdate.
@ApiOperation(value = "Partially update a WatchList", notes = "Requires edit permission")
@RequestMapping(method = RequestMethod.PATCH, value = "/{xid}")
public ResponseEntity<WatchListModel> partialUpdate(@PathVariable String xid, @ApiParam(value = "Updated WatchList", required = true) @PatchVORequestBody(service = WatchListService.class, modelClass = WatchListModel.class) WatchListModel model, @AuthenticationPrincipal PermissionHolder user, UriComponentsBuilder builder) {
WatchListVO vo = service.update(xid, mapping.unmap(model, user, mapper));
URI location = builder.path("/watch-lists/{xid}").buildAndExpand(vo.getXid()).toUri();
HttpHeaders headers = new HttpHeaders();
headers.setLocation(location);
return new ResponseEntity<>(mapping.map(vo, user, mapper), headers, HttpStatus.OK);
}
Aggregations