use of com.infiniteautomation.mango.rest.latest.model.MaintenanceEventModel in project ma-modules-public by infiniteautomation.
the class MaintenanceEventsRestController method update.
@ApiOperation(value = "Update an existing maintenance event")
@RequestMapping(method = RequestMethod.PUT, value = "/{xid}")
public ResponseEntity<MaintenanceEventModel> update(@PathVariable String xid, @ApiParam(value = "Updated maintenance event", required = true) @RequestBody(required = true) MaintenanceEventModel model, @AuthenticationPrincipal PermissionHolder user, UriComponentsBuilder builder) {
MaintenanceEventVO vo = service.update(xid, model.toVO());
URI location = builder.path("/maintenance-events/{xid}").buildAndExpand(vo.getXid()).toUri();
HttpHeaders headers = new HttpHeaders();
headers.setLocation(location);
return new ResponseEntity<>(new MaintenanceEventModel(vo), headers, HttpStatus.OK);
}
use of com.infiniteautomation.mango.rest.latest.model.MaintenanceEventModel in project ma-modules-public by infiniteautomation.
the class MaintenanceEventsRestController method create.
@ApiOperation(value = "Create new maintenance event", notes = "User must have global data source permission")
@RequestMapping(method = RequestMethod.POST)
public ResponseEntity<MaintenanceEventModel> create(@ApiParam(value = "Updated maintenance event", required = true) @RequestBody(required = true) MaintenanceEventModel model, @AuthenticationPrincipal PermissionHolder user, UriComponentsBuilder builder) {
MaintenanceEventVO vo = service.insert(model.toVO());
URI location = builder.path("/maintenance-events/{xid}").buildAndExpand(vo.getXid()).toUri();
HttpHeaders headers = new HttpHeaders();
headers.setLocation(location);
return new ResponseEntity<>(new MaintenanceEventModel(vo), headers, HttpStatus.OK);
}
use of com.infiniteautomation.mango.rest.latest.model.MaintenanceEventModel in project ma-modules-public by infiniteautomation.
the class MaintenanceEventsRestController method getForPointsByIds.
@ApiOperation(value = "Find Maintenance Events linked to data points by point IDs", notes = "Returns a map of point ids to a list of events that have this data point in their list OR the its data source in the list", response = Map.class, responseContainer = "List")
@RequestMapping(method = RequestMethod.GET, value = "/query/get-for-points-by-ids/{pointIds}")
public Map<Integer, List<MaintenanceEventModel>> getForPointsByIds(@PathVariable(required = true) List<Integer> pointIds, HttpServletRequest request, @AuthenticationPrincipal PermissionHolder user) {
Map<Integer, List<MaintenanceEventModel>> map = new HashMap<>();
for (Integer id : pointIds) {
List<MaintenanceEventModel> models = new ArrayList<>();
map.put(id, models);
dao.getForDataPoint(id, new Consumer<MaintenanceEventVO>() {
@Override
public void accept(MaintenanceEventVO vo) {
MaintenanceEventModel model = new MaintenanceEventModel(vo);
fillDataPoints(model);
fillDataSources(model);
models.add(model);
}
});
}
return map;
}
use of com.infiniteautomation.mango.rest.latest.model.MaintenanceEventModel in project ma-modules-public by infiniteautomation.
the class MaintenanceEventsRestController method getForPointsByXid.
@ApiOperation(value = "Find Maintenance Events linked to data points by point XIDs", notes = "Returns a map of point xids to a list of events that have this data point in their list OR the its data source in the list", response = Map.class, responseContainer = "List")
@RequestMapping(method = RequestMethod.GET, value = "/query/get-for-points-by-xids/{pointXids}")
public Map<String, List<MaintenanceEventModel>> getForPointsByXid(@PathVariable(required = true) List<String> pointXids, HttpServletRequest request, @AuthenticationPrincipal PermissionHolder user) {
Map<String, List<MaintenanceEventModel>> map = new HashMap<>();
for (String xid : pointXids) {
List<MaintenanceEventModel> models = new ArrayList<>();
map.put(xid, models);
dao.getForDataPoint(xid, new Consumer<MaintenanceEventVO>() {
@Override
public void accept(MaintenanceEventVO vo) {
MaintenanceEventModel model = new MaintenanceEventModel(vo);
fillDataPoints(model);
fillDataSources(model);
models.add(model);
}
});
}
return map;
}
use of com.infiniteautomation.mango.rest.latest.model.MaintenanceEventModel in project ma-modules-public by infiniteautomation.
the class MaintenanceEventsRestController method partialUpdate.
@ApiOperation(value = "Partially update an existing maintenance event")
@RequestMapping(method = RequestMethod.PATCH, value = "/{xid}")
public ResponseEntity<MaintenanceEventModel> partialUpdate(@PathVariable String xid, @ApiParam(value = "Updated maintenance event", required = true) @PatchVORequestBody(service = MaintenanceEventsService.class, modelClass = MaintenanceEventModel.class) MaintenanceEventModel model, @AuthenticationPrincipal PermissionHolder user, UriComponentsBuilder builder) {
MaintenanceEventVO vo = service.update(xid, model.toVO());
URI location = builder.path("/maintenance-events/{xid}").buildAndExpand(vo.getXid()).toUri();
HttpHeaders headers = new HttpHeaders();
headers.setLocation(location);
return new ResponseEntity<>(new MaintenanceEventModel(vo), headers, HttpStatus.OK);
}
Aggregations