use of org.hisp.dhis.trackedentitydatavalue.TrackedEntityDataValueAudit in project dhis2-core by dhis2.
the class TrackedEntityDataValueAuditStoreTest method testGetTrackedEntityDataValueAudits.
@Test
void testGetTrackedEntityDataValueAudits() {
TrackedEntityDataValueAudit dataValueAudit = new TrackedEntityDataValueAudit(dataElementA, stageInstance, dataValueA.getAuditValue(), "userA", dataValueA.getProvidedElsewhere(), AuditType.UPDATE);
auditStore.addTrackedEntityDataValueAudit(dataValueAudit);
Assertions.assertEquals(1, auditStore.getTrackedEntityDataValueAudits(Lists.newArrayList(dataElementA), Lists.newArrayList(stageInstance), AuditType.UPDATE).size());
Assertions.assertEquals(1, auditStore.countTrackedEntityDataValueAudits(Lists.newArrayList(dataElementA, dataElementB), Lists.newArrayList(stageInstance), AuditType.UPDATE));
}
use of org.hisp.dhis.trackedentitydatavalue.TrackedEntityDataValueAudit in project dhis2-core by dhis2.
the class DefaultProgramStageInstanceService method createAndAddAudit.
private void createAndAddAudit(EventDataValue dataValue, DataElement dataElement, ProgramStageInstance programStageInstance, AuditType auditType) {
if (!config.isEnabled(CHANGELOG_TRACKER) || dataElement == null) {
return;
}
TrackedEntityDataValueAudit dataValueAudit = new TrackedEntityDataValueAudit(dataElement, programStageInstance, dataValue.getValue(), dataValue.getStoredBy(), dataValue.getProvidedElsewhere(), auditType);
dataValueAuditService.addTrackedEntityDataValueAudit(dataValueAudit);
}
use of org.hisp.dhis.trackedentitydatavalue.TrackedEntityDataValueAudit in project dhis2-core by dhis2.
the class AuditController method getTrackedEntityDataValueAudit.
@GetMapping("trackedEntityDataValue")
@ResponseBody
public RootNode getTrackedEntityDataValueAudit(@RequestParam(required = false, defaultValue = "") List<String> de, @RequestParam(required = false, defaultValue = "") List<String> psi, @RequestParam(required = false) AuditType auditType, @RequestParam(required = false) Boolean skipPaging, @RequestParam(required = false) Boolean paging, @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());
}
List<DataElement> dataElements = getDataElements(de);
List<ProgramStageInstance> programStageInstances = getProgramStageInstances(psi);
List<TrackedEntityDataValueAudit> dataValueAudits;
Pager pager = null;
if (PagerUtils.isSkipPaging(skipPaging, paging)) {
dataValueAudits = trackedEntityDataValueAuditService.getTrackedEntityDataValueAudits(dataElements, programStageInstances, auditType);
} else {
int total = trackedEntityDataValueAuditService.countTrackedEntityDataValueAudits(dataElements, programStageInstances, auditType);
pager = new Pager(page, total, pageSize);
dataValueAudits = trackedEntityDataValueAuditService.getTrackedEntityDataValueAudits(dataElements, programStageInstances, auditType, pager.getOffset(), pager.getPageSize());
}
RootNode rootNode = NodeUtils.createMetadata();
if (pager != null) {
rootNode.addChild(NodeUtils.createPager(pager));
}
CollectionNode trackedEntityAttributeValueAudits = rootNode.addChild(new CollectionNode("trackedEntityDataValueAudits", true));
trackedEntityAttributeValueAudits.addChildren(fieldFilterService.toCollectionNode(TrackedEntityDataValueAudit.class, new FieldFilterParams(dataValueAudits, fields)).getChildren());
return rootNode;
}
Aggregations