use of com.serotonin.m2m2.web.mvc.rest.v1.model.pointValue.PointValueTimeModel in project ma-modules-public by infiniteautomation.
the class PointValueRestController method putPointsValues.
@ApiOperation(value = "Update one or many data point's current value", notes = "Each data point must exist and be enabled")
@RequestMapping(method = RequestMethod.PUT, produces = { "application/json" }, consumes = { "application/json" })
public ResponseEntity<List<XidPointValueTimeModel>> putPointsValues(HttpServletRequest request, @RequestBody(required = true) List<XidPointValueTimeModel> models, @ApiParam(value = "Return converted value using displayed unit", required = false, defaultValue = "false", allowMultiple = false) @RequestParam(required = false, defaultValue = "false") boolean unitConversion) throws RestValidationFailedException {
RestProcessResult<List<XidPointValueTimeModel>> result = new RestProcessResult<List<XidPointValueTimeModel>>(HttpStatus.OK);
List<XidPointValueTimeModel> setValues = new ArrayList<XidPointValueTimeModel>();
User user = this.checkUser(request, result);
if (result.isOk()) {
for (XidPointValueTimeModel model : models) {
RestProcessResult<PointValueTimeModel> pointResult = setPointValue(user, model.getXid(), model, unitConversion, ServletUriComponentsBuilder.fromContextPath(request));
if (pointResult.getHighestStatus().value() == HttpStatus.CREATED.value()) {
// Save the model for later
setValues.add(model);
}
for (RestMessage message : pointResult.getRestMessages()) {
result.addRestMessage(message);
}
}
if (setValues.size() > 0)
return result.createResponseEntity(setValues);
}
return result.createResponseEntity();
}
Aggregations