Skip to content

Commit

Permalink
report clearLink
Browse files Browse the repository at this point in the history
  • Loading branch information
cmangeat committed Jul 10, 2024
1 parent 9fb663a commit 2838e0a
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion core/src/main/java/org/fao/geonet/kernel/url/UrlAnalyzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,24 @@ public void purgeMetataLink(Link link) {
.findAll(metadatalinksTargetting(link))
.stream()
.filter(metadatalink -> isReferencingAnUnknownMetadata((MetadataLink)metadatalink))
.forEach(metadataLinkRepository::delete);
.forEach(this::clearLink);
entityManager.flush();
}

public void deleteLink(Integer id) {
Link link = linkRepository.findById(id).get();
if (metadataLinkRepository.findAll(metadatalinksTargetting(link)).size() > 0) {
return;
}
linkRepository.delete(link);
entityManager.flush();
}

private void clearLink(MetadataLink metadataLink) {
metadataLink.getLink().getRecords().remove(metadataLink);
metadataLinkRepository.delete(metadataLink);
}

public void deleteAll() {
metadataLinkRepository.deleteAllInBatch();
linkStatusRepository.deleteAllInBatch();
Expand Down

0 comments on commit 2838e0a

Please sign in to comment.