Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Use correct get single TE for deduplication feature [DHIS2-18541] #20124

Merged
merged 6 commits into from
Feb 28, 2025

Conversation

enricocolasante
Copy link
Contributor

@enricocolasante enricocolasante commented Feb 28, 2025

Moving getTrackedEntity() to use the same code as multiple entities has a big impact in a lot of places in the system and it is going to be done in small steps, changing it feature by feature.

Changes in this PR

  • Use getNewTrackedEntity method in DeduplicationController. We are using the TrackedEntityService only to validate the tracked entity, then we use the manager to get a managed object that is needed for the deduplication operations.
  • Remove now unused getTrackedEntity(UID) method.

Challenges in tests
TrackedEntityAggregate is loading data in new threads so they have their own transaction and not committed data are not visible in those threads, that is why we cannot use @Transactional annotation when we are importing data and reading in one one transaction.

Common misconfigurations in tests

  • Create tracked entity and enrollment but do not create an ownership.
  • Create a tracker program without a tracked entity type

Next Steps

  • Move new methods in tracked entity controller
  • Move new methods in all remaining places
  • Remove old getTrackedEntity() methods and rename new ones
  • Add Optional<T> find(UID) to our services

@enricocolasante enricocolasante force-pushed the DHIS2-18541-deduplication branch from 9be412d to 2eb8818 Compare February 28, 2025 12:24
@enricocolasante enricocolasante marked this pull request as ready for review February 28, 2025 12:56
@enricocolasante enricocolasante requested a review from a team as a code owner February 28, 2025 12:56
@enricocolasante enricocolasante enabled auto-merge (squash) February 28, 2025 13:13
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
1 New issue
1 New Code Smells (required ≤ 0)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

DeduplicationMergeParams params =
DeduplicationMergeParams.builder()
.potentialDuplicate(potentialDuplicate)
.mergeObject(mergeObject)
.original(original)
.duplicate(duplicate)
.original(hibernateOriginal)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this a temporary fix only?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, in this case we should completely refactor deduplication service and use the importer instead of custom stores. And then, we wouldn't need to get the tracked entities using the manager.

@enricocolasante enricocolasante merged commit c0de1e4 into master Feb 28, 2025
16 of 17 checks passed
@enricocolasante enricocolasante deleted the DHIS2-18541-deduplication branch February 28, 2025 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants