Skip to content

Commit

Permalink
Move domain specific code from service to Norm object
Browse files Browse the repository at this point in the history
RISDEV-0000
  • Loading branch information
SebastianRossa committed Jan 14, 2025
1 parent 7d2848b commit d8f2d6a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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}
*/
Expand Down

0 comments on commit d8f2d6a

Please sign in to comment.