Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move domain specific code from service to Norm object #886

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -137,6 +137,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() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public List<ExpressionEli> targetLawElis() {
public List<ExpressionEli> getTargetLawElis() {

return getNodesFromExpression("//body//article[not(ancestor-or-self::mod)]", document)
.stream()
.map(Article::new)
Comment on lines +146 to +148
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return getNodesFromExpression("//body//article[not(ancestor-or-self::mod)]", document)
.stream()
.map(Article::new)
return getArticles()

.filter(article ->
article.getRefersTo().isPresent() &&
!article.getRefersTo().get().equals("geltungszeitregel")
Comment on lines +150 to +151
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could also have this logic in the Article class eg. Article::isAmendingArticle or not(Article::isGeltungszeitregel) or something similar

)
.map(Article::getMandatoryAffectedDocumentEli)
.toList();
}

/**
* Extracts a list of {@link Mod}s from the document.
*
Expand Down Expand Up @@ -229,7 +246,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
Loading