use of com.infiniteautomation.mango.rest.latest.model.pointValue.emport.PointValueTimeDeleteResult in project ma-modules-public by infiniteautomation.
the class PointValueModificationRestController method deletePointValues.
@ApiOperation(value = "Delete Point Values for one or many Data Points", notes = "Data Point must exist and user must have write access")
@RequestMapping(method = RequestMethod.DELETE, value = "/delete")
@Async
public CompletableFuture<List<PointValueTimeDeleteResult>> deletePointValues(@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, PointValueTimeDelete> results = new HashMap<>();
stream.forEachOrdered((pvt) -> {
var entry = results.computeIfAbsent(pvt.getXid(), (xidKey) -> new PointValueTimeDelete(pvt.getXid(), fireEvents, user));
entry.deleteValue(pvt.getTimestamp());
});
return results.values().stream().map(v -> new PointValueTimeDeleteResult(v.xid, v.totalProcessed, v.totalSkipped, v.result)).collect(Collectors.toList());
} catch (Exception e) {
throw new CompletionException(e);
}
}, executorService);
}
use of com.infiniteautomation.mango.rest.latest.model.pointValue.emport.PointValueTimeDeleteResult in project ma-modules-public by infiniteautomation.
the class PointValueModificationRestController method deletePointValues.
@ApiOperation(value = "Delete Point Values for one or many Data Points", notes = "Data Point must exist and user must have write access")
@RequestMapping(method = RequestMethod.DELETE, value = "/delete")
@Async
public CompletableFuture<List<PointValueTimeDeleteResult>> deletePointValues(@RequestBody Stream<XidPointValueTimeModel> stream, @AuthenticationPrincipal PermissionHolder user) {
return CompletableFuture.supplyAsync(() -> {
try {
PointValueDao pointValueDao = Common.getBean(PointValueDao.class);
Map<String, PointValueTimeDelete> results = new HashMap<>();
stream.forEach((pvt) -> {
results.compute(pvt.getXid(), (xidKey, entry) -> {
if (entry == null) {
entry = new PointValueTimeDelete(pvt.getXid(), pointValueDao, dataPointDao, user);
}
entry.deleteValue(pvt.getTimestamp());
return entry;
});
});
return results.values().stream().map((v) -> {
return new PointValueTimeDeleteResult(v.xid, v.totalProcessed, v.totalSkipped, v.result);
}).collect(Collectors.toList());
} catch (Exception e) {
throw new CompletionException(e);
}
});
}
Aggregations