Skip to content

Commit

Permalink
task: Address PR comments [DHIS2-18477]
Browse files Browse the repository at this point in the history
  • Loading branch information
muilpp committed Dec 2, 2024
1 parent dd014fb commit 1354339
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,6 @@ public void addPropertyChangeLog(
"geometry", Event::getGeometry, this::formatGeometry, currentEvent, event, username);
}

@Override
@Transactional(readOnly = true)
public int countTrackedEntityDataValueChangeLogs(
TrackedEntityDataValueChangeLogQueryParams params) {
return trackedEntityDataValueChangeLogStore.countTrackedEntityDataValueChangeLogs(params);
}

@Override
@Transactional
public void deleteTrackedEntityDataValueChangeLog(Event event) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@ void addDataValueChangeLog(
void addPropertyChangeLog(
@Nonnull Event currentEvent, @Nonnull Event event, @Nonnull String userName);

@Deprecated(since = "2.42")
int countTrackedEntityDataValueChangeLogs(TrackedEntityDataValueChangeLogQueryParams params);

void deleteTrackedEntityDataValueChangeLog(Event event);

void deleteEventChangeLog(Event event);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2555,9 +2555,8 @@ void dataValueAuditMergeDeleteTest() throws ConflictException {
// --------------------------------------
@Test
@DisplayName(
"TrackedEntityChangeLogs with references to source DataElements are not changed or deleted when sources not deleted")
void trackedEntityChangeLogMergeTest()
throws ConflictException, ForbiddenException, NotFoundException {
"EventChangeLogs with references to source DataElements are not changed or deleted when sources not deleted")
void eventChangeLogMergeTest() throws ConflictException, ForbiddenException, NotFoundException {
// given
TrackedEntity trackedEntity = createTrackedEntity(ou1);
identifiableObjectManager.save(trackedEntity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ public RootNode getDataApprovalAudit(
*/
@Deprecated(since = "2.41")
@GetMapping("trackedEntityInstance")
public RootNode getTrackedEntityInstanceChangeLog(
public RootNode getTrackedEntityInstanceAudit(
@Deprecated(since = "2.41")
@OpenApi.Param({UID[].class, TrackedEntity.class})
@RequestParam(required = false, defaultValue = "")
Expand Down Expand Up @@ -415,17 +415,17 @@ public RootNode getTrackedEntityInstanceChangeLog(
.setStartDate(startDate)
.setEndDate(endDate);

List<TrackedEntityAudit> teChangeLogs;
List<TrackedEntityAudit> teAudits;
Pager pager = null;

if (PagerUtils.isSkipPaging(skipPaging, paging)) {
int total = trackedEntityAuditService.getTrackedEntityAuditsCount(params);

pager = new Pager(page, total, pageSize);

teChangeLogs = trackedEntityAuditService.getTrackedEntityAudits(params);
teAudits = trackedEntityAuditService.getTrackedEntityAudits(params);
} else {
teChangeLogs = trackedEntityAuditService.getTrackedEntityAudits(params.setPager(pager));
teAudits = trackedEntityAuditService.getTrackedEntityAudits(params.setPager(pager));
}

RootNode rootNode = NodeUtils.createMetadata();
Expand All @@ -434,11 +434,11 @@ public RootNode getTrackedEntityInstanceChangeLog(
rootNode.addChild(NodeUtils.createPager(pager));
}

CollectionNode changeLogs =
CollectionNode audits =
rootNode.addChild(new CollectionNode("trackedEntityInstanceAudits", true));
changeLogs.addChildren(
audits.addChildren(
fieldFilterService
.toCollectionNode(TrackedEntityAudit.class, new FieldFilterParams(teChangeLogs, fields))
.toCollectionNode(TrackedEntityAudit.class, new FieldFilterParams(teAudits, fields))
.getChildren());

return rootNode;
Expand Down Expand Up @@ -473,17 +473,17 @@ public RootNode getTrackedEntityAudit(
.setStartDate(startDate)
.setEndDate(endDate);

List<TrackedEntityAudit> teChangeLogs;
List<TrackedEntityAudit> teAudits;
Pager pager = null;

if (PagerUtils.isSkipPaging(skipPaging, paging)) {
int total = trackedEntityAuditService.getTrackedEntityAuditsCount(params);

pager = new Pager(page, total, pageSize);

teChangeLogs = trackedEntityAuditService.getTrackedEntityAudits(params);
teAudits = trackedEntityAuditService.getTrackedEntityAudits(params);
} else {
teChangeLogs = trackedEntityAuditService.getTrackedEntityAudits(params.setPager(pager));
teAudits = trackedEntityAuditService.getTrackedEntityAudits(params.setPager(pager));
}

RootNode rootNode = NodeUtils.createMetadata();
Expand All @@ -492,10 +492,10 @@ public RootNode getTrackedEntityAudit(
rootNode.addChild(NodeUtils.createPager(pager));
}

CollectionNode changeLogs = rootNode.addChild(new CollectionNode("trackedEntityAudits", true));
changeLogs.addChildren(
CollectionNode audits = rootNode.addChild(new CollectionNode("trackedEntityAudits", true));
audits.addChildren(
fieldFilterService
.toCollectionNode(TrackedEntityAudit.class, new FieldFilterParams(teChangeLogs, fields))
.toCollectionNode(TrackedEntityAudit.class, new FieldFilterParams(teAudits, fields))
.getChildren());

return rootNode;
Expand Down

0 comments on commit 1354339

Please sign in to comment.