Skip to content

Commit

Permalink
#10622 - All Visits of Contacts of the same Person are deleted when p…
Browse files Browse the repository at this point in the history
…ermanent deletion is triggered for one of the Contacts, if there's a distance of >30 days between their Report Dates - update case visits delete permanent test - review changes
  • Loading branch information
sergiupacurariu committed Oct 14, 2022
1 parent 90c6365 commit 8b10254
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public void syncInfraWithCentral() {
centralInfraSyncFacade.syncAll();
}

@Schedule(hour = "*", minute = "*/2", persistent = false)
@Schedule(hour = "1", minute = "55", persistent = false)
public void deleteExpiredEntities() {
coreEntityDeletionService.executeAutomaticDeletion();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1529,28 +1529,6 @@ public void deletePermanent(Contact contact) {
super.deletePermanent(contact);
}

private Subquery<Long> countVisitsContactSubqueryForDelete(CriteriaBuilder cb, CriteriaDelete<Visit> cd, Root<Visit> visitRoot, Contact contact) {
Subquery<Long> contactVisitsSubquery = cd.subquery(Long.class);
Root<Visit> subqueryRoot = contactVisitsSubquery.from(Visit.class);
Join<Visit, Contact> visitContactJoin = subqueryRoot.join(Visit.CONTACTS, JoinType.INNER);
contactVisitsSubquery.where(
cb.and(cb.equal(subqueryRoot.get(Visit.ID), visitRoot.get(Visit.ID)), cb.equal(visitContactJoin.get(Contact.ID), contact.getId())));

contactVisitsSubquery.select(cb.count(visitContactJoin.get(Contact.ID)));

return contactVisitsSubquery;
}

private Subquery<Visit> getVisitsContactSubqueryForDelete(CriteriaBuilder cb, CriteriaDelete<Visit> cd, Contact contact) {
Subquery<Visit> contactVisitsSubquery = cd.subquery(Visit.class);
Root<Visit> subqueryRoot = contactVisitsSubquery.from(Visit.class);
contactVisitsSubquery.where(cb.equal(subqueryRoot.join(Visit.CONTACTS).get(Contact.ID), contact.getId()));

contactVisitsSubquery.select(subqueryRoot);

return contactVisitsSubquery;
}

private void deleteContactLinks(Contact contact) {
// Remove the contact from any sample that is also connected to other entities
contact.getSamples().stream().filter(s -> s.getAssociatedCase() != null || s.getAssociatedEventParticipant() != null).forEach(s -> {
Expand Down

0 comments on commit 8b10254

Please sign in to comment.