From ff2fd96d8191760769c523b71ca4095a1d8b8770 Mon Sep 17 00:00:00 2001 From: Hanna Prinz Date: Tue, 26 Nov 2024 11:59:16 +0100 Subject: [PATCH] Fix sonar issues RISDEV-0000 --- .../jpa/PostgresLegalPeriodicalEditionRepositoryImpl.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/backend/src/main/java/de/bund/digitalservice/ris/caselaw/adapter/database/jpa/PostgresLegalPeriodicalEditionRepositoryImpl.java b/backend/src/main/java/de/bund/digitalservice/ris/caselaw/adapter/database/jpa/PostgresLegalPeriodicalEditionRepositoryImpl.java index 2f2a722ad2..405e744c22 100644 --- a/backend/src/main/java/de/bund/digitalservice/ris/caselaw/adapter/database/jpa/PostgresLegalPeriodicalEditionRepositoryImpl.java +++ b/backend/src/main/java/de/bund/digitalservice/ris/caselaw/adapter/database/jpa/PostgresLegalPeriodicalEditionRepositoryImpl.java @@ -106,11 +106,12 @@ private void deleteDocUnitLinksForDeletedReferences(LegalPeriodicalEdition updat for (UUID reference : oldEdition.get().getReferences()) { // skip all existing and null references var referenceDTO = referenceRepository.findById(reference); - if (updatedEdition.references().stream() - .anyMatch( - newReference -> newReference.id().equals(reference) || referenceDTO.isEmpty())) { + if (referenceDTO.isEmpty() + || updatedEdition.references().stream() + .anyMatch(newReference -> newReference.id().equals(reference))) { continue; } + // delete all deleted references and possible source reference documentationUnitRepository .findById(referenceDTO.get().getDocumentationUnit().getId())