Skip to content

Commit

Permalink
chore: adapt signature
Browse files Browse the repository at this point in the history
  • Loading branch information
teleivo committed Jan 17, 2025
1 parent e3e71b6 commit ea91da7
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class DefaultTrackedEntityAuditService implements TrackedEntityAuditServi
@Async
@Transactional
public void addTrackedEntityAudit(
TrackedEntity trackedEntity, String username, AuditOperationType type) {
AuditOperationType type, String username, TrackedEntity trackedEntity) {
if (username != null
&& trackedEntity != null
&& trackedEntity.getTrackedEntityType() != null
Expand All @@ -73,7 +73,7 @@ public void addTrackedEntityAudit(
@Async
@Transactional
public void addTrackedEntityAudit(
@Nonnull List<TrackedEntity> trackedEntities, String username, AuditOperationType type) {
AuditOperationType type, String username, @Nonnull List<TrackedEntity> trackedEntities) {
List<TrackedEntityAudit> audits =
trackedEntities.stream()
.filter(te -> te.getTrackedEntityType().isAllowAuditLog())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ public interface TrackedEntityAuditService {

String ID = TrackedEntityAuditService.class.getName();

void addTrackedEntityAudit(TrackedEntity trackedEntity, String username, AuditOperationType type);
void addTrackedEntityAudit(AuditOperationType type, String username, TrackedEntity trackedEntity);

/** Adds multiple tracked entity audit */
void addTrackedEntityAudit(
@Nonnull List<TrackedEntity> trackedEntity, String username, AuditOperationType type);
AuditOperationType type, String username, @Nonnull List<TrackedEntity> trackedEntity);

/**
* Returns tracked entity audits matching query params
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public TrackedEntity validateTrackedEntity(UID uid, UserDetails user)
if (trackedEntity == null) {
throw new BadRequestException("Tracked entity is specified but does not exist: " + uid);
}
trackedEntityAuditService.addTrackedEntityAudit(trackedEntity, user.getUsername(), READ);
trackedEntityAuditService.addTrackedEntityAudit(READ, user.getUsername(), trackedEntity);

if (trackedEntity.getTrackedEntityType() != null
&& !aclService.canDataRead(user, trackedEntity.getTrackedEntityType())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ private TrackedEntity getTrackedEntity(
throw new NotFoundException(TrackedEntity.class, uid);
}

trackedEntityAuditService.addTrackedEntityAudit(trackedEntity, user.getUsername(), READ);
trackedEntityAuditService.addTrackedEntityAudit(READ, user.getUsername(), trackedEntity);

if (program != null) {
List<String> errors =
Expand Down Expand Up @@ -365,7 +365,6 @@ public List<TrackedEntity> getTrackedEntities(
return ids.withItems(trackedEntities);
}

// TODO can I only pass in query params?
private List<TrackedEntity> getTrackedEntities(
List<Long> ids,
TrackedEntityOperationParams operationParams,
Expand All @@ -391,7 +390,7 @@ private List<TrackedEntity> getTrackedEntities(
trackedEntity.setTrackedEntityAttributeValues(
getTrackedEntityAttributeValues(trackedEntity, queryParams.getProgram()));
}
addSearchAudit(trackedEntities, user);
trackedEntityAuditService.addTrackedEntityAudit(SEARCH, user.getUsername(), trackedEntities);
return trackedEntities;
}

Expand Down Expand Up @@ -570,16 +569,12 @@ private RelationshipItem getTrackedEntityInRelationshipItem(String uid) throws N
return null;
}

trackedEntityAuditService.addTrackedEntityAudit(trackedEntity, user.getUsername(), SEARCH);
trackedEntityAuditService.addTrackedEntityAudit(SEARCH, user.getUsername(), trackedEntity);

relationshipItem.setTrackedEntity(trackedEntity);
return relationshipItem;
}

private void addSearchAudit(List<TrackedEntity> trackedEntities, UserDetails user) {
trackedEntityAuditService.addTrackedEntityAudit(trackedEntities, user.getUsername(), SEARCH);
}

@Override
public Set<String> getOrderableFields() {
return trackedEntityStore.getOrderableFields();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public TrackerTypeReport deleteTrackedEntities(List<UID> trackedEntities)
if (entity == null) {
throw new NotFoundException(TrackedEntity.class, uid);
}
trackedEntityAuditService.addTrackedEntityAudit(entity, getCurrentUsername(), DELETE);
trackedEntityAuditService.addTrackedEntityAudit(DELETE, getCurrentUsername(), entity);

entity.setLastUpdatedByUserInfo(userInfoSnapshot);

Expand Down

0 comments on commit ea91da7

Please sign in to comment.