Skip to content

Commit

Permalink
chore: remove unnecessary interface
Browse files Browse the repository at this point in the history
  • Loading branch information
teleivo committed Jan 17, 2025
1 parent 8eb324d commit 486ac52
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import lombok.RequiredArgsConstructor;
import org.hisp.dhis.audit.AuditOperationType;
import org.hisp.dhis.common.IdentifiableObjectManager;
import org.hisp.dhis.common.collection.CollectionUtils;
import org.hisp.dhis.trackedentity.TrackedEntity;
import org.hisp.dhis.trackedentity.TrackedEntityAudit;
import org.hisp.dhis.trackedentity.TrackedEntityAuditQueryParams;
Expand Down Expand Up @@ -81,7 +80,7 @@ public void addTrackedEntityAudit(
.map(te -> new TrackedEntityAudit(te.getUid(), username, type))
.toList();

if (CollectionUtils.isEmpty(audits)) {
if (audits.isEmpty()) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ public List<TrackedEntity> getTrackedEntities(

return getTrackedEntities(ids, operationParams, queryParams, user);
}

@Override
public @Nonnull Page<TrackedEntity> getTrackedEntities(
@Nonnull TrackedEntityOperationParams operationParams, @Nonnull PageParams pageParams)
Expand All @@ -365,12 +366,18 @@ public List<TrackedEntity> getTrackedEntities(
}

// TODO can I only pass in query params?
private List<TrackedEntity> getTrackedEntities(List<Long> ids, TrackedEntityOperationParams operationParams,
TrackedEntityQueryParams queryParams, UserDetails user) throws NotFoundException {
private List<TrackedEntity> getTrackedEntities(
List<Long> ids,
TrackedEntityOperationParams operationParams,
TrackedEntityQueryParams queryParams,
UserDetails user)
throws NotFoundException {

List<TrackedEntity> trackedEntities =
this.trackedEntityAggregate.find(ids,
operationParams.getTrackedEntityParams(), queryParams,
this.trackedEntityAggregate.find(
ids,
operationParams.getTrackedEntityParams(),
queryParams,
queryParams.getOrgUnitMode());
setRelationshipItems(
trackedEntities,
Expand All @@ -388,7 +395,6 @@ private List<TrackedEntity> getTrackedEntities(List<Long> ids, TrackedEntityOper
return trackedEntities;
}


/**
* We need to return the full models for relationship items (i.e. trackedEntity, enrollment and
* event) in our API. The aggregate stores currently do not support that, so we need to fetch the
Expand Down Expand Up @@ -571,7 +577,7 @@ private RelationshipItem getTrackedEntityInRelationshipItem(String uid) throws N
}

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

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@
/**
* @author Luciano Fiandesio
*/
interface Aggregate {
class AsyncUtils {
AsyncUtils() {
throw new IllegalStateException("Utility class");
}

/**
* Executes the Supplier asynchronously using the thread pool from the provided {@see Executor}
*
Expand All @@ -48,7 +52,7 @@ interface Aggregate {
* @param executor an Executor instance
* @return A CompletableFuture with the result of the Supplier
*/
default <T> CompletableFuture<Multimap<String, T>> conditionalAsyncFetch(
static <T> CompletableFuture<Multimap<String, T>> conditionalAsyncFetch(
boolean condition, Supplier<Multimap<String, T>> supplier, Executor executor) {
return (condition
? supplyAsync(supplier, executor)
Expand All @@ -61,7 +65,7 @@ default <T> CompletableFuture<Multimap<String, T>> conditionalAsyncFetch(
* @param supplier The Supplier to execute
* @return A CompletableFuture with the result of the Supplier
*/
default <T> CompletableFuture<Multimap<String, T>> asyncFetch(
static <T> CompletableFuture<Multimap<String, T>> asyncFetch(
Supplier<Multimap<String, T>> supplier, Executor executor) {
return supplyAsync(supplier, executor);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
package org.hisp.dhis.tracker.export.trackedentity.aggregates;

import static java.util.concurrent.CompletableFuture.allOf;
import static org.hisp.dhis.tracker.export.trackedentity.aggregates.AsyncUtils.asyncFetch;
import static org.hisp.dhis.tracker.export.trackedentity.aggregates.AsyncUtils.conditionalAsyncFetch;
import static org.hisp.dhis.tracker.export.trackedentity.aggregates.ThreadPoolManager.getPool;

import com.google.common.collect.Multimap;
Expand All @@ -51,7 +53,7 @@
*/
@Component("org.hisp.dhis.tracker.trackedentity.aggregates.EnrollmentAggregate")
@RequiredArgsConstructor
public class EnrollmentAggregate implements Aggregate {
public class EnrollmentAggregate {
@Qualifier("org.hisp.dhis.tracker.trackedentity.aggregates.EnrollmentStore")
@Nonnull
private final EnrollmentStore enrollmentStore;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

import static java.util.concurrent.CompletableFuture.allOf;
import static java.util.concurrent.CompletableFuture.supplyAsync;
import static org.hisp.dhis.tracker.export.trackedentity.aggregates.AsyncUtils.asyncFetch;
import static org.hisp.dhis.tracker.export.trackedentity.aggregates.AsyncUtils.conditionalAsyncFetch;
import static org.hisp.dhis.tracker.export.trackedentity.aggregates.ThreadPoolManager.getPool;

import com.google.common.collect.Multimap;
Expand All @@ -51,7 +53,7 @@
*/
@Component("org.hisp.dhis.tracker.trackedentity.aggregates.EventAggregate")
@RequiredArgsConstructor
public class EventAggregate implements Aggregate {
public class EventAggregate {
@Qualifier("org.hisp.dhis.tracker.trackedentity.aggregates.EventStore")
@Nonnull
private final EventStore eventStore;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import static java.util.concurrent.CompletableFuture.allOf;
import static java.util.concurrent.CompletableFuture.supplyAsync;
import static org.hisp.dhis.common.OrganisationUnitSelectionMode.ALL;
import static org.hisp.dhis.tracker.export.trackedentity.aggregates.AsyncUtils.conditionalAsyncFetch;
import static org.hisp.dhis.tracker.export.trackedentity.aggregates.ThreadPoolManager.getPool;

import com.google.common.collect.Lists;
Expand Down Expand Up @@ -74,7 +75,7 @@
*/
@Component
@RequiredArgsConstructor
public class TrackedEntityAggregate implements Aggregate {
public class TrackedEntityAggregate {
@Nonnull private final TrackedEntityStore trackedEntityStore;

@Qualifier("org.hisp.dhis.tracker.trackedentity.aggregates.EnrollmentAggregate")
Expand Down

0 comments on commit 486ac52

Please sign in to comment.