use of org.hisp.dhis.dataapproval.DataApprovalAuditQueryParams 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;
}
use of org.hisp.dhis.dataapproval.DataApprovalAuditQueryParams in project dhis2-core by dhis2.
the class AuditController method getDataApprovalAudit.
@GetMapping("dataApproval")
@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) Boolean paging, @RequestParam(required = false, defaultValue = "50") int pageSize, @RequestParam(required = false, defaultValue = "1") int page) {
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;
RootNode rootNode = NodeUtils.createMetadata();
if (!PagerUtils.isSkipPaging(skipPaging, paging)) {
pager = new Pager(page, audits.size(), pageSize);
audits = audits.subList(pager.getOffset(), Math.min(pager.getOffset() + pager.getPageSize(), audits.size()));
rootNode.addChild(NodeUtils.createPager(pager));
}
CollectionNode dataApprovalAudits = rootNode.addChild(new CollectionNode("dataApprovalAudits", true));
dataApprovalAudits.addChildren(fieldFilterService.toCollectionNode(DataApprovalAudit.class, new FieldFilterParams(audits, fields)).getChildren());
return rootNode;
}
Aggregations