Search in sources :

Example 1 with PointValueImportResult

use of com.infiniteautomation.mango.rest.latest.model.pointValue.PointValueImportResult in project ma-modules-public by infiniteautomation.

the class PointValueRestController method savePointsValues.

@ApiOperation(value = "Import Point Values for one or many Data Points, this is deprecated and it is recommended to use the /point-value-modification endpoints", notes = "Data Point must exist and user must have write access")
@RequestMapping(method = RequestMethod.POST)
public ResponseEntity<Collection<PointValueImportResult>> savePointsValues(@ApiParam(value = "Shall data point listeners be notifified, default is NEVER") @RequestParam(defaultValue = "NEVER") FireEvents fireEvents, @RequestBody() List<LegacyXidPointValueTimeModel> models, @AuthenticationPrincipal User user) {
    // Map of XIDs to results
    Map<String, PointValueImportResult> results = new HashMap<>();
    for (LegacyXidPointValueTimeModel model : models) {
        PointValueImportResult result = results.get(model.getXid());
        if (result == null) {
            result = new PointValueImportResult(model.getXid(), dao, dataPointService, fireEvents, user);
            results.put(model.getXid(), result);
        }
        // Attempt to save it
        result.saveValue(model);
    }
    return ResponseEntity.ok(results.values());
}
Also used : HashMap(java.util.HashMap) PointValueImportResult(com.infiniteautomation.mango.rest.latest.model.pointValue.PointValueImportResult) LegacyXidPointValueTimeModel(com.infiniteautomation.mango.rest.latest.model.pointValue.LegacyXidPointValueTimeModel) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

LegacyXidPointValueTimeModel (com.infiniteautomation.mango.rest.latest.model.pointValue.LegacyXidPointValueTimeModel)1 PointValueImportResult (com.infiniteautomation.mango.rest.latest.model.pointValue.PointValueImportResult)1 ApiOperation (io.swagger.annotations.ApiOperation)1 HashMap (java.util.HashMap)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1