use of com.infiniteautomation.mango.rest.latest.model.pointValue.emport.PointValueTimeImportResult in project ma-modules-public by infiniteautomation.
the class PointValueModificationRestController method importPointValues.
@ApiOperation(value = "Import Point Values for one or many Data Points", notes = "Data Point must exist and user must have write access")
@RequestMapping(method = RequestMethod.POST, value = "/import")
@Async
public CompletableFuture<List<PointValueTimeImportResult>> importPointValues(@ApiParam(value = "Shall data point listeners be notified, default is NEVER") @RequestParam(defaultValue = "NEVER") FireEvents fireEvents, @RequestBody Stream<XidPointValueTimeModel> stream, @AuthenticationPrincipal PermissionHolder user) {
return CompletableFuture.supplyAsync(() -> {
try {
Map<String, PointValueTimeImport> results = new LinkedHashMap<>();
stream.forEachOrdered((pvt) -> {
var entry = results.computeIfAbsent(pvt.getXid(), (xidKey) -> new PointValueTimeImport(pvt.getXid(), fireEvents, user));
entry.saveValue(pvt.getValue(), pvt.getTimestamp(), pvt.getAnnotation());
});
return results.values().stream().map(v -> new PointValueTimeImportResult(v.xid, v.totalProcessed, v.totalSkipped, v.result)).collect(Collectors.toList());
} catch (Exception e) {
throw new CompletionException(e);
}
}, executorService);
}
Aggregations