use of org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValueAudit in project dhis2-core by dhis2.
the class AuditController method getTrackedEntityAttributeValueAudit.
@RequestMapping(value = "trackedEntityAttributeValue", method = RequestMethod.GET)
@ResponseBody
public RootNode getTrackedEntityAttributeValueAudit(@RequestParam(required = false, defaultValue = "") List<String> tea, @RequestParam(required = false, defaultValue = "") List<String> tei, @RequestParam(required = false) AuditType auditType, @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"));
List<TrackedEntityAttribute> trackedEntityAttributes = getTrackedEntityAttributes(tea);
List<TrackedEntityInstance> trackedEntityInstances = getTrackedEntityInstances(tei);
List<TrackedEntityAttributeValueAudit> attributeValueAudits;
Pager pager = null;
if (skipPaging) {
attributeValueAudits = trackedEntityAttributeValueAuditService.getTrackedEntityAttributeValueAudits(trackedEntityAttributes, trackedEntityInstances, auditType);
} else {
int total = trackedEntityAttributeValueAuditService.countTrackedEntityAttributeValueAudits(trackedEntityAttributes, trackedEntityInstances, auditType);
pager = new Pager(page, total, pageSize);
attributeValueAudits = trackedEntityAttributeValueAuditService.getTrackedEntityAttributeValueAudits(trackedEntityAttributes, trackedEntityInstances, auditType, pager.getOffset(), pager.getPageSize());
}
RootNode rootNode = NodeUtils.createMetadata();
if (pager != null) {
rootNode.addChild(NodeUtils.createPager(pager));
}
CollectionNode trackedEntityAttributeValueAudits = rootNode.addChild(new CollectionNode("trackedEntityAttributeValueAudits", true));
trackedEntityAttributeValueAudits.addChildren(fieldFilterService.filter(TrackedEntityAttributeValueAudit.class, attributeValueAudits, fields).getChildren());
return rootNode;
}
Aggregations