use of com.serotonin.m2m2.vo.event.EventInstanceVO 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.vo.event.EventInstanceVO in project ma-modules-public by infiniteautomation.
the class EventsRestController method queryRQL.
@ApiOperation(value = "Query Events", notes = "Query via rql in url", response = EventInstanceModel.class, responseContainer = "Array")
@RequestMapping(method = RequestMethod.GET, produces = { "application/json" })
public ResponseEntity<QueryDataPageStream<EventInstanceVO>> queryRQL(HttpServletRequest request) {
RestProcessResult<QueryDataPageStream<EventInstanceVO>> result = new RestProcessResult<QueryDataPageStream<EventInstanceVO>>(HttpStatus.OK);
User user = this.checkUser(request, result);
if (result.isOk()) {
try {
// Parse the RQL Query
ASTNode query = parseRQLtoAST(request.getQueryString());
query = addAndRestriction(query, new ASTNode("eq", "userId", user.getId()));
return result.createResponseEntity(getPageStream(query));
} catch (InvalidRQLRestException e) {
LOG.error(e.getMessage(), e);
result.addRestMessage(getInternalServerErrorMessage(e.getMessage()));
return result.createResponseEntity();
}
}
return result.createResponseEntity();
}
use of com.serotonin.m2m2.vo.event.EventInstanceVO in project ma-core-public by infiniteautomation.
the class EventExportServlet method exportExcel.
/**
* @param response
* @param def
* @param user
* @throws IOException
*/
private void exportExcel(HttpServletResponse response, User user) throws IOException {
// Stream the content.
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
final EventInstanceEmporter sheetEmporter = new EventInstanceEmporter();
final SpreadsheetEmporter emporter = new SpreadsheetEmporter(FileType.XLSX);
BufferedOutputStream bos = new BufferedOutputStream(response.getOutputStream());
emporter.prepareExport(bos);
emporter.prepareSheetExport(sheetEmporter);
QueryDefinition queryData = (QueryDefinition) user.getAttribute("eventInstanceExportDefinition");
DojoQueryCallback<EventInstanceVO> callback = new DojoQueryCallback<EventInstanceVO>(false) {
@Override
public void row(EventInstanceVO vo, int rowIndex) {
sheetEmporter.exportRow(vo);
}
};
EventInstanceDao.instance.exportQuery(queryData.getQuery(), queryData.getSort(), null, null, queryData.isOr(), callback);
emporter.finishExport();
}
Aggregations