use of com.infiniteautomation.mango.db.query.ConditionSortLimit in project ma-core-public by infiniteautomation.
the class AbstractBasicDao method rqlQuery.
public void rqlQuery(ASTNode rql, MappedRowCallback<T> callback) {
ConditionSortLimit result = this.rqlToCondition(rql);
this.customizedQuery(result, callback);
}
use of com.infiniteautomation.mango.db.query.ConditionSortLimit in project ma-modules-public by infiniteautomation.
the class EventsRestController method acknowledgeManyEvents.
@ApiOperation(value = "Acknowledge many existing events")
@RequestMapping(method = RequestMethod.POST, value = "/acknowledge")
@Async
public CompletableFuture<Integer> acknowledgeManyEvents(@RequestBody(required = false) TranslatableMessageModel message, ASTNode rql) {
TranslatableMessage tlm;
if (message != null) {
tlm = new TranslatableMessage(message.getKey(), message.getArgs().toArray());
} else {
tlm = null;
}
// Ensure we supply the mappings when converting the RQL
ConditionSortLimit conditions = service.rqlToCondition(rql, null, fieldMap, valueConverters);
int count = service.acknowledgeMany(conditions, tlm);
return CompletableFuture.completedFuture(count);
}
use of com.infiniteautomation.mango.db.query.ConditionSortLimit in project ma-modules-public by infiniteautomation.
the class EventsRestController method eventCounts.
@ApiOperation("Query for event counts using RQL")
@RequestMapping(method = RequestMethod.POST, path = "/counts")
public List<PeriodCounts> eventCounts(@AuthenticationPrincipal PermissionHolder user, @RequestBody List<Date> periodBoundaries, ASTNode rql) {
// TODO Clean up, add model, move restrictions to service
Assert.isTrue(periodBoundaries.size() >= 2, "periodBoundaries must have at least 2 elements");
List<Date> sorted = new ArrayList<>(periodBoundaries);
Collections.sort(sorted);
Date from = sorted.get(0);
Date to = sorted.get(periodBoundaries.size() - 1);
rql = RQLUtils.addAndRestriction(rql, new ASTNode("ge", "activeTs", from));
rql = RQLUtils.addAndRestriction(rql, new ASTNode("lt", "activeTs", to));
ConditionSortLimit conditions = service.rqlToCondition(rql, Collections.emptyMap(), fieldMap, valueConverters);
return service.countQuery(conditions, sorted);
}
use of com.infiniteautomation.mango.db.query.ConditionSortLimit in project ma-modules-public by infiniteautomation.
the class JsonDataRestController method list.
@ApiOperation(value = "List all available xids", notes = "Shows any xids that you have read permissions for")
@RequestMapping(method = RequestMethod.GET)
public List<String> list() {
List<String> xids = new ArrayList<>();
service.customizedQuery(new ConditionSortLimit(null, null, null, null), (item) -> {
xids.add(item.getXid());
});
return xids;
}
use of com.infiniteautomation.mango.db.query.ConditionSortLimit in project ma-modules-public by infiniteautomation.
the class WatchListService method getDataPoints.
/**
* Get the full data points for a list (TAG_TYPE not supported)
*/
public void getDataPoints(WatchListVO vo, Consumer<DataPointVO> callback) {
PermissionHolder user = Common.getUser();
switch(vo.getType()) {
case STATIC:
this.dao.getPoints(vo.getId(), (dp) -> {
if (dataPointService.hasReadPermission(user, dp)) {
callback.accept(dp);
}
});
break;
case QUERY:
if (vo.getParams().size() > 0)
throw new ServerErrorException(new TranslatableMessage("watchList.queryParametersNotSupported"));
ASTNode rql = RQLUtils.parseRQLtoAST(vo.getQuery());
ConditionSortLimit conditions = dataPointService.rqlToCondition(rql, null, null, null);
dataPointService.customizedQuery(conditions, callback);
break;
case TAGS:
throw new ServerErrorException(new TranslatableMessage("watchList.queryParametersNotSupported"));
default:
throw new ServerErrorException(new TranslatableMessage("common.default", "unknown watchlist type: " + vo.getType()));
}
}
Aggregations