use of org.motechproject.email.domain.EmailRecords in project motech by motech.
the class EmailController method getEmails.
@RequestMapping(value = "/emails", method = RequestMethod.GET)
@PreAuthorize(EmailRolesConstants.HAS_ANY_EMAIL_ROLE)
@ResponseBody
public EmailRecords<? extends BasicEmailRecordDto> getEmails(GridSettings filter, HttpServletRequest request) {
EmailRecordSearchCriteria criteria = prepareCriteria(filter);
List<EmailRecord> filtered = auditService.findEmailRecords(criteria);
List<? extends BasicEmailRecordDto> rows = hideColumns(filtered, filter);
long total = auditService.countEmailRecords(criteria);
if (filter.getRows() == null) {
int defaultRowsAmount = 10;
filter.setRows(defaultRowsAmount);
}
if (filter.getPage() == null) {
int defaultPage = 1;
filter.setPage(defaultPage);
}
int totalPages = (int) Math.ceil((double) total / filter.getRows());
String username = getUsername(request);
if (username != null) {
lastFilter.put(username, filter);
}
return new EmailRecords<>((int) total, filter.getPage(), totalPages, rows);
}
Aggregations