use of org.craftercms.studio.model.rest.dashboard.AuditDashboardItem in project studio by craftercms.
the class DashboardController method getAuditDashboard.
@GetMapping(value = AUDIT_DASHBOARD, produces = APPLICATION_JSON_VALUE)
public ResponseBody getAuditDashboard(@Valid AuditDashboardRequestParameters requestParameters) {
String user = null;
List<String> operations = null;
ZonedDateTime dateFrom = null;
ZonedDateTime dateTo = null;
String target = null;
if (requestParameters.getFilters() != null) {
user = requestParameters.getFilters().getActor();
operations = requestParameters.getFilters().getOperations();
dateFrom = requestParameters.getFilters().getOperationTimestampFrom();
dateTo = requestParameters.getFilters().getOperationTimestampTo();
target = requestParameters.getFilters().getTarget();
}
int total = dashboardService.getAuditDashboardTotal(requestParameters.getSiteId(), user, operations, dateFrom, dateTo, target);
List<AuditLog> auditLog = dashboardService.getAuditDashboard(requestParameters.getSiteId(), requestParameters.getOffset(), requestParameters.getLimit(), user, operations, dateFrom, dateTo, target, requestParameters.getSortBy(), requestParameters.getOrder());
ResponseBody responseBody = new ResponseBody();
PaginatedResultList<AuditDashboardItem> result = new PaginatedResultList<AuditDashboardItem>();
result.setTotal(total);
result.setLimit(CollectionUtils.isEmpty(auditLog) ? 0 : auditLog.size());
result.setOffset(requestParameters.getOffset());
result.setEntities(RESULT_KEY_ITEMS, prepareAuditResult(auditLog));
result.setResponse(OK);
responseBody.setResult(result);
return responseBody;
}
use of org.craftercms.studio.model.rest.dashboard.AuditDashboardItem in project studio by craftercms.
the class DashboardController method prepareAuditResult.
private List<AuditDashboardItem> prepareAuditResult(List<AuditLog> auditLogs) {
List<AuditDashboardItem> resultItems = new ArrayList<AuditDashboardItem>();
for (AuditLog auditLog : auditLogs) {
AuditDashboardItem item = new AuditDashboardItem();
item.setSiteId(auditLog.getSiteName());
item.setActor(auditLog.getActorId());
item.setOperation(auditLog.getOperation());
item.setOperationTimestamp(auditLog.getOperationTimestamp());
item.setTarget(auditLog.getPrimaryTargetValue());
resultItems.add(item);
}
return resultItems;
}
Aggregations