use of org.hisp.dhis.dataapproval.DataApprovalAudit in project dhis2-core by dhis2.
the class AuditController method getDataApprovalAudit.
@RequestMapping(value = "dataApproval", method = RequestMethod.GET)
@ResponseBody
public RootNode getDataApprovalAudit(@RequestParam(required = false, defaultValue = "") List<String> dal, @RequestParam(required = false, defaultValue = "") List<String> wf, @RequestParam(required = false, defaultValue = "") List<String> ou, @RequestParam(required = false, defaultValue = "") List<String> aoc, @RequestParam(required = false) Date startDate, @RequestParam(required = false) Date endDate, @RequestParam(required = false) boolean skipPaging, @RequestParam(required = false, defaultValue = "50") int pageSize, @RequestParam(required = false, defaultValue = "1") int page) throws WebMessageException {
List<String> fields = Lists.newArrayList(contextService.getParameterValues("fields"));
if (fields.isEmpty()) {
fields.addAll(Preset.ALL.getFields());
}
DataApprovalAuditQueryParams params = new DataApprovalAuditQueryParams();
params.setLevels(new HashSet<>(getDataApprovalLevel(dal)));
params.setWorkflows(new HashSet<>(getDataApprovalWorkflow(wf)));
params.setOrganisationUnits(new HashSet<>(getOrganisationUnit(ou)));
params.setAttributeOptionCombos(new HashSet<>(getCategoryOptionCombo(aoc)));
params.setStartDate(startDate);
params.setEndDate(endDate);
List<DataApprovalAudit> audits = dataApprovalAuditService.getDataApprovalAudits(params);
Pager pager = null;
RootNode rootNode = NodeUtils.createMetadata();
if (!skipPaging) {
pager = new Pager(page, audits.size(), pageSize);
audits = audits.subList(pager.getOffset(), pager.getOffset() + pager.getPageSize() < audits.size() ? pager.getOffset() + pager.getPageSize() : audits.size());
rootNode.addChild(NodeUtils.createPager(pager));
}
CollectionNode dataApprovalAudits = rootNode.addChild(new CollectionNode("dataApprovalAudits", true));
dataApprovalAudits.addChildren(fieldFilterService.filter(DataApprovalAudit.class, audits, fields).getChildren());
return rootNode;
}
Aggregations