diff --git a/backend/src/main/java/de/bund/digitalservice/ris/norms/application/service/AnnouncementService.java b/backend/src/main/java/de/bund/digitalservice/ris/norms/application/service/AnnouncementService.java index dc23ea73d..98240852e 100644 --- a/backend/src/main/java/de/bund/digitalservice/ris/norms/application/service/AnnouncementService.java +++ b/backend/src/main/java/de/bund/digitalservice/ris/norms/application/service/AnnouncementService.java @@ -101,18 +101,12 @@ public List<Norm> loadTargetNormsAffectedByAnnouncement( .orElseThrow(() -> new NormNotFoundException(query.eli().toString())); return amendingNorm - .getArticles() + .targetLawElis() .stream() - .filter(article -> - article.getRefersTo().isPresent() && - !article.getRefersTo().get().equals("geltungszeitregel") - ) - .map(article -> + .map(eli -> loadNormPort - .loadNorm(new LoadNormPort.Command(article.getMandatoryAffectedDocumentEli())) - .orElseThrow(() -> - new NormNotFoundException(article.getMandatoryAffectedDocumentEli().toString()) - ) + .loadNorm(new LoadNormPort.Command(eli)) + .orElseThrow(() -> new NormNotFoundException(eli.toString())) ) .toList(); } diff --git a/backend/src/main/java/de/bund/digitalservice/ris/norms/domain/entity/Norm.java b/backend/src/main/java/de/bund/digitalservice/ris/norms/domain/entity/Norm.java index b8fbe74f5..e6b63b0f4 100644 --- a/backend/src/main/java/de/bund/digitalservice/ris/norms/domain/entity/Norm.java +++ b/backend/src/main/java/de/bund/digitalservice/ris/norms/domain/entity/Norm.java @@ -136,6 +136,23 @@ public List<Article> getArticles() { .toList(); } + /** + * Returns a {@link List} of all target norms {@link ExpressionEli}s of an amending {@link Norm}. + * + * @return The list of target norm elis + */ + public List<ExpressionEli> targetLawElis() { + return getNodesFromExpression("//body//article[not(ancestor-or-self::mod)]", document) + .stream() + .map(Article::new) + .filter(article -> + article.getRefersTo().isPresent() && + !article.getRefersTo().get().equals("geltungszeitregel") + ) + .map(Article::getMandatoryAffectedDocumentEli) + .toList(); + } + /** * Extracts a list of {@link Mod}s from the document. * @@ -228,7 +245,7 @@ public Optional<String> getStartDateForEventRef(String eId) { * The temporalData node will get a new temporalGroup node as child, which will have a new * timeInterval node as child. * - * @param date the {@link LocalDate} for the new time boundary. + * @param date the {@link LocalDate} for the new time boundary. * @param eventRefType the {@link EventRefType} for the new time boundary. * @return the newly created {@link TemporalGroup} */