Skip to content

Commit

Permalink
test: finally
Browse files Browse the repository at this point in the history
  • Loading branch information
teleivo committed Jan 15, 2025
1 parent 871d518 commit 3c5db77
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -297,10 +297,10 @@ private TrackedEntity getTrackedEntity(
result.setCreatedByUserInfo(trackedEntity.getCreatedByUserInfo());
result.setLastUpdatedByUserInfo(trackedEntity.getLastUpdatedByUserInfo());
result.setGeometry(trackedEntity.getGeometry());
setRelationshipItems(result, trackedEntity, params, includeDeleted);
if (params.isIncludeEnrollments()) {
result.setEnrollments(getEnrollments(trackedEntity, user, includeDeleted, program));
}
setRelationshipItems(result, trackedEntity, params, includeDeleted);
if (params.isIncludeProgramOwners()) {
result.setProgramOwners(getTrackedEntityProgramOwners(trackedEntity, program));
}
Expand Down Expand Up @@ -437,34 +437,33 @@ private void setRelationshipItems(
}

private void setRelationshipItems(
TrackedEntity target,
TrackedEntity source,
TrackedEntity targetTrackedEntity,
TrackedEntity sourceTrackedEntity,
TrackedEntityParams params,
boolean includeDeleted)
throws NotFoundException {
if (params.isIncludeRelationships()) {
target.setRelationshipItems(getRelationshipItems(source, includeDeleted));
targetTrackedEntity.setRelationshipItems(
getRelationshipItems(sourceTrackedEntity, includeDeleted));
}
if (params.getEnrollmentParams().isIncludeRelationships()) {
for (Enrollment enrollment : source.getEnrollments()) {
enrollment.setRelationshipItems(getRelationshipItems(enrollment, source, includeDeleted));
}
}
if (params.getEventParams().isIncludeRelationships()) {
for (Enrollment enrollment : source.getEnrollments()) {
for (Event event : enrollment.getEvents()) {
Set<RelationshipItem> relationshipItems =
getRelationshipItems(event, source, includeDeleted);
// target.getEnrollments().stream()
// .filter(e -> e.getUid().equals(enrollment.getUid()))
// .findFirst()
// .orElseThrow(() -> new NotFoundException(Enrollment.class,
// enrollment.getUid()))
// .getEvents().stream()
// .filter(ev->ev.getUid().equals(event.getUid()))
// .findFirst().orElseThrow(() -> new NotFoundException(Enrollment.class,
// enrollment.getUid()));
event.setRelationshipItems(relationshipItems);
for (Enrollment sourceEnrollment : sourceTrackedEntity.getEnrollments()) {
for (Enrollment targetEnrollment : targetTrackedEntity.getEnrollments()) {
if (sourceEnrollment.getUid().equals(targetEnrollment.getUid())) {
targetEnrollment.setRelationshipItems(
getRelationshipItems(sourceEnrollment, sourceTrackedEntity, includeDeleted));

if (params.getEventParams().isIncludeRelationships()) {
for (Event sourceEvent : sourceEnrollment.getEvents()) {
for (Event targetEvent : targetEnrollment.getEvents()) {
if (targetEvent.getUid().equals(sourceEvent.getUid())) {
targetEvent.setRelationshipItems(
getRelationshipItems(sourceEvent, sourceTrackedEntity, includeDeleted));
}
}
}
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1686,8 +1686,6 @@ void shouldReturnTrackedEntityRelationshipsWithTe2Event()
.trackedEntityParams(params)
.build();

System.out.println(trackedEntityA.getUid());
System.out.println(eventA.getUid());
List<TrackedEntity> trackedEntities = trackedEntityService.getTrackedEntities(operationParams);

TrackedEntity trackedEntity = trackedEntities.get(0);
Expand Down

0 comments on commit 3c5db77

Please sign in to comment.