use of com.serotonin.m2m2.web.mvc.rest.v1.model.QueryArrayStream in project ma-modules-public by infiniteautomation.
the class DataPointRestController method getAllDataPoints.
@ApiOperation(value = "Get all data points", notes = "Only returns points available to logged in user")
@RequestMapping(method = RequestMethod.GET, produces = { "application/json" }, value = "/list")
public ResponseEntity<QueryArrayStream<DataPointVO>> getAllDataPoints(HttpServletRequest request, @ApiParam(value = "Limit the number of results", required = false) @RequestParam(value = "limit", required = false, defaultValue = "100") int limit) {
RestProcessResult<QueryArrayStream<DataPointVO>> result = new RestProcessResult<QueryArrayStream<DataPointVO>>(HttpStatus.OK);
User user = this.checkUser(request, result);
if (result.isOk()) {
ASTNode root = new ASTNode("limit", limit);
if (user.isAdmin()) {
// Admin Users Don't need to filter the results
return result.createResponseEntity(getStream(root));
} else {
// We are going to filter the results, so we need to strip out the limit(limit,offset) or limit(limit) clause.
DataPointStreamCallback callback = new DataPointStreamCallback(this, user);
FilteredQueryStream<DataPointVO, DataPointModel, DataPointDao> stream = new FilteredQueryStream<DataPointVO, DataPointModel, DataPointDao>(DataPointDao.instance, this, root, callback);
stream.setupQuery();
return result.createResponseEntity(stream);
}
}
return result.createResponseEntity();
}
use of com.serotonin.m2m2.web.mvc.rest.v1.model.QueryArrayStream in project ma-modules-public by infiniteautomation.
the class EventsRestController method getAll.
@ApiOperation(value = "Get all events", notes = "", response = EventInstanceModel.class, responseContainer = "Array")
@RequestMapping(method = RequestMethod.GET, produces = { "application/json" }, value = "/list")
public ResponseEntity<QueryArrayStream<EventInstanceVO>> getAll(HttpServletRequest request, @RequestParam(value = "limit", required = false, defaultValue = "100") Integer limit) {
RestProcessResult<QueryArrayStream<EventInstanceVO>> result = new RestProcessResult<QueryArrayStream<EventInstanceVO>>(HttpStatus.OK);
User user = this.checkUser(request, result);
if (result.isOk()) {
ASTNode root = new ASTNode("and", new ASTNode("eq", "userId", user.getId()), new ASTNode("limit", limit));
return result.createResponseEntity(getPageStream(root));
}
return result.createResponseEntity();
}
use of com.serotonin.m2m2.web.mvc.rest.v1.model.QueryArrayStream in project ma-core-public by infiniteautomation.
the class CsvQueryArrayStreamMessageConverter method writeInternal.
/* (non-Javadoc)
* @see org.springframework.http.converter.AbstractHttpMessageConverter#writeInternal(java.lang.Object, org.springframework.http.HttpOutputMessage)
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
protected void writeInternal(QueryArrayStream stream, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException {
CSVPojoWriter out = new CSVPojoWriter(new CSVWriter(new OutputStreamWriter(outputMessage.getBody(), Common.UTF8_CS), separator, quote));
stream.streamData(out);
out.close();
}
Aggregations